-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[autograd] match 0-dim gradients device type regardless of subclassness #160165
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/160165
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Cancelled Job, 1 Unrelated FailureAs of commit 83763d7 with merge base ba37f58 ( CANCELLED JOB - The following job was cancelled. Please retry:
UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
… subclassness" Not sure if there some subclasses where the outer.dim() == 0 but you wouldn't want to move it? FIXES #160084 [ghstack-poisoned]
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.
Sounds good. A bit more testing is needed.
| if (grad.dim() == 0) { | ||
| grad = grad.to(metadata.device()); | ||
| } else { | ||
| // quick hack for: https://github.com/pytorch/pytorch/issues/65016 but |
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.
@ezyang now that we do have proper wrapper subclass, should we remove this as we don't have to use meta device for all subclasses anymore
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.
Small nit, SGTM otherwise
|
|
||
| model = RegressionModel() |
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.
| model = RegressionModel() | |
| # Keep the model on cpu as we do want to test the mixed cpu/accelerator behavior here | |
| model = RegressionModel() |
|
@pytorchbot merge -i |
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 |
|
|
||
| @staticmethod | ||
| def __new__(cls, elem, *args, **kwargs): | ||
| # Wrong device here! |
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.
@albanD This test intentionally diverges the outer tensor's device from the inner tensor's device, is this something we still want to support? Assuming it's not, the test wouldn't make sense anymore if we kept the two in sync so I just removed it
|
@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 |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10 / test (default, 1, 2, linux.rocm.gpu.2) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 2 checks: pull / linux-jammy-py3_9-clang9-xla / test (xla, 1, 1, lf.linux.12xlarge, unstable), trunk / linux-jammy-rocm-py3.10 / test (default, 1, 2, linux.rocm.gpu.2) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
|
@pytorchbot cherry-pick --onto release/2.8 -c critical |
Cherry picking #160165Command Details for Dev Infra teamRaised by workflow job |
…ss (pytorch#160165) Not sure if there some subclasses where the outer.dim() == 0 but you wouldn't want to move it? FIXES pytorch#160084 Pull Request resolved: pytorch#160165 Approved by: https://github.com/ezyang, https://github.com/albanD
…ss (pytorch#160165) Not sure if there some subclasses where the outer.dim() == 0 but you wouldn't want to move it? FIXES pytorch#160084 Pull Request resolved: pytorch#160165 Approved by: https://github.com/ezyang, https://github.com/albanD
Stack from ghstack (oldest at bottom):
Not sure if there some subclasses where the outer.dim() == 0 but you wouldn't want to move it?
FIXES #160084
cc @ezyang @albanD @gqchen @nikitaved @soulitzer @Varal7 @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames @Lucaskabela