-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix aten.copy device mismatch bug in FakeTensor #102664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/102664
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 6187fbc: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Fixes `pytest ./generated/test_yizhou_wang_RODNet.py -k test_000` failure in #92670. FakeTensor would raise an error upon trying to run `aten.copy` with inputs with different devices, although this is allowed behavior. [ghstack-poisoned]
Fixes `pytest ./generated/test_yizhou_wang_RODNet.py -k test_000` failure in #92670. FakeTensor would raise an error upon trying to run `aten.copy` with inputs with different devices, although this is allowed behavior. [ghstack-poisoned]
Can you coordinate with @davidberard98 to add other ops that support different devices? Thanks! |
Fixes `pytest ./generated/test_yizhou_wang_RODNet.py -k test_000` failure in #92670. FakeTensor would raise an error upon trying to run `aten.copy` with inputs with different devices, although this is allowed behavior. [ghstack-poisoned]
@pytorchbot merge |
Merge failedReason: This PR needs a If not, please add the To add a label, you can comment to pytorchbot, for example For more information, see Details for Dev Infra teamRaised by workflow job |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
j1 = torch.tensor([2], device="cuda") | ||
j2 = torch.tensor([2], device="cpu") | ||
r3 = torch.ops.aten.index_put.default(x1, j1, y1) | ||
r4 = torch.ops.aten.index_put.default(x2, j2, y2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code doesn't actually pass on eager though?
(/home/ezyang/local/b/pytorch-env) [ezyang@devgpu005.nha1 ~/local/b/pytorch (fc2aa23c)]$ python test.py
Traceback (most recent call last):
File "/data/users/ezyang/b/pytorch/test.py", line 7, in <module>
r1 = torch.ops.aten.index(x1, i1)
File "/data/users/ezyang/b/pytorch/torch/_ops.py", line 1018, in __call__
return self_._op(*args, **(kwargs or {}))
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)
(/home/ezyang/local/b/pytorch-env) [ezyang@devgpu005.nha1 ~/local/b/pytorch (fc2aa23c)]$ cat test.py
import torch
x1 = torch.rand(4, 4, device="cpu")
x2 = torch.rand(4, 4, device="cuda")
i1 = torch.tensor([0, 1], device="cuda")
i2 = torch.tensor([0, 1], device="cpu")
r1 = torch.ops.aten.index(x1, i1)
r2 = torch.ops.aten.index(x2, i2)
y1 = torch.rand(4, device="cpu")
y2 = torch.rand(4, device="cuda")
j1 = torch.tensor([2], device="cuda")
j2 = torch.tensor([2], device="cpu")
r3 = torch.ops.aten.index_put.default(x1, j1, y1)
r4 = torch.ops.aten.index_put.default(x2, j2, y2)
Stack from ghstack (oldest at bottom):
Fixes
pytest ./generated/test_yizhou_wang_RODNet.py -k test_000
failure in #92670.FakeTensor would raise an error upon trying to run
aten.copy
with inputs with different devices, although this is allowed behavior.Also fix
aten.slice_scatter
, since it also takes args with different devices.