-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
[autograd] Do not detach when unpacking tensors that do not require grad #127959
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/127959
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ You can merge normally! (1 Unrelated Failure)As of commit 994a888 with merge base e6d4451 (): FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
ghstack-source-id: fd728b4f37088faa03d2c44e3c416558b42045be Pull Request resolved: #127959
[ghstack-poisoned]
ghstack-source-id: e86d6b9cdee39a442829c51db19f1a444fb95067 Pull Request resolved: #127959
[ghstack-poisoned]
ghstack-source-id: a290a3d1320918b2a2bc9e502db653398bac4c93 Pull Request resolved: #127959
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
ghstack-source-id: fb514383b45a7bb292683818fca9581d60e7aa24 Pull Request resolved: #127959
test/test_nestedtensor.py
Outdated
] | ||
) | ||
|
||
def fn(values, offsets): |
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.
Do you mean def fn(values, lengths) ?
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.
Yup, good catch
…ty when tensor does not require grad" This PR ensures that if a tensor does not require grad, and it is saved for backward, (1) unpacking in general preserve the object, (2) non-reentrant checkpoint preserves the object. [ghstack-poisoned]
…ty when tensor does not require grad" This PR ensures that if a tensor does not require grad, and it is saved for backward, (1) unpacking in general preserve the object, (2) non-reentrant checkpoint preserves the object. [ghstack-poisoned]
…ty when tensor does not require grad" This PR ensures that if a tensor does not require grad, and it is saved for backward, (1) unpacking in general preserve the object, (2) non-reentrant checkpoint preserves the object. For custom autograd Function, you could directly save on ctx to work around this, but that would not work for when we switch to using custom ops. [ghstack-poisoned]
…t require grad " In this PR: - Ensure that if a tensor not requiring grad is saved for backward unpacking does not trigger a detach (unless the user installs a saved tensor pack hook that returns a tensor requiring grad). - Update non-reentrant checkpoint to also no longer detach for this case. Alternatives: - For custom autograd Function, you could directly save on ctx to work around this, but that would not work for when we switch to using custom ops. [ghstack-poisoned]
…t require grad " In this PR: - Ensure that if a tensor not requiring grad is saved for backward unpacking does not trigger a detach (unless the user installs a saved tensor pack hook that returns a tensor requiring grad). - Update non-reentrant checkpoint to also no longer detach for this case. Alternatives: - For custom autograd Function, you could directly save on ctx to work around this, but that would not work for when we switch to using custom ops. [ghstack-poisoned]
ghstack-source-id: bb06e4f94231b2af19ccb88e1b706e2c76c7161f Pull Request resolved: #127959
…t require grad " In this PR: - Ensure that if a tensor not requiring grad is saved for backward unpacking does not trigger a detach (unless the user installs a saved tensor pack hook that returns a tensor requiring grad). - Update non-reentrant checkpoint to also no longer detach for this case. Alternatives: - For custom autograd Function, you could directly save on ctx to work around this, but that would not work for when we switch to using custom ops. [ghstack-poisoned]
…t require grad " In this PR: - Ensure that if a tensor not requiring grad is saved for backward unpacking does not trigger a detach (unless the user installs a saved tensor pack hook that returns a tensor requiring grad). - Update non-reentrant checkpoint to also no longer detach for this case. Alternatives: - For custom autograd Function, you could directly save on ctx to work around this, but that would not work for when we switch to using custom ops. [ghstack-poisoned]
…t require grad " In this PR: - Ensure that if a tensor not requiring grad is saved for backward unpacking does not trigger a detach (unless the user installs a saved tensor pack hook that returns a tensor requiring grad). - Update non-reentrant checkpoint to also no longer detach for this case. Alternatives: - For custom autograd Function, you could directly save on ctx to work around this, but that would not work for when we switch to using custom ops. [ghstack-poisoned]
…t require grad " In this PR: - Ensure that if a tensor not requiring grad is saved for backward unpacking does not trigger a detach (unless the user installs a saved tensor pack hook that returns a tensor requiring grad). - Update non-reentrant checkpoint to also no longer detach for this case. Alternatives: - For custom autograd Function, you could directly save on ctx to work around this, but that would not work for when we switch to using custom ops. [ghstack-poisoned]
ghstack-source-id: 229a838975d0f4fc597745c4f867aa89b96a0d09 Pull Request resolved: #127959
…t require grad " In this PR: - Ensure that if a tensor not requiring grad is saved for backward unpacking does not trigger a detach (unless the user installs a saved tensor pack hook that returns a tensor requiring grad). - Update non-reentrant checkpoint to also no longer detach for this case. Alternatives: - For custom autograd Function, you could directly save on ctx to work around this, but that would not work for when we switch to using custom ops. [ghstack-poisoned]
ghstack-source-id: 7fca85d18ff52c390579e906378a9ccfd695fa1c Pull Request resolved: #127959
@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 |
Ready to merge again? |
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: pull / linux-focal-cuda12.1-py3.10-gcc9-sm86 / test (default, 5, 5, linux.g5.4xlarge.nvidia.gpu) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…rad (pytorch#127959) In this PR: - Ensure that if a tensor not requiring grad is saved for backward unpacking does not trigger a detach (unless the user installs a saved tensor pack hook that returns a tensor requiring grad). - Update non-reentrant checkpoint to also no longer detach for this case. Alternatives: - For custom autograd Function, you could directly save on ctx to work around this, but that would not work for when we switch to using custom ops. Pull Request resolved: pytorch#127959 Approved by: https://github.com/YuqingJ ghstack dependencies: pytorch#125795, pytorch#128545, pytorch#129262
Stack from ghstack (oldest at bottom):
In this PR:
Alternatives: