Incorrect device index in `StorageView`
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 536
- Avg merge
- 12h 12m
- Merged PRs (30d)
- 4
Description
import torch
import ctranslate2
x0 = torch.ones((2, 4), dtype=torch.int32, device="cuda:0")
y0 = ctranslate2.StorageView.from_array(x0)
print(f"Original tensor is on {x0.device} and StorageView is on {y0.device}:{y0.device_index}")
x1 = torch.ones((2, 4), dtype=torch.int32, device="cuda:1")
y1 = ctranslate2.StorageView.from_array(x1)
print(f"Original tensor is on {x1.device} and StorageView is on {y1.device}:{y1.device_index}")
The output I get is
Original tensor is on cuda:0 and StorageView is on cuda:0
Original tensor is on cuda:1 and StorageView is on cuda:0
The actual data is still on cuda:0 for y0 and on cuda:1 for y1.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Python StorageView.from_array example with tensors on cuda:0 and cuda:1, then trace how device and device_index are reported. Compare the reported index with the actual data placement; done means StorageView.device_index matches the source tensor for both devices without changing the data location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100