Propagate CreationMeta when chaining views#51061
Closed
jbschlosser wants to merge 3 commits intopytorch:masterfrom
Closed
Propagate CreationMeta when chaining views#51061jbschlosser wants to merge 3 commits intopytorch:masterfrom
jbschlosser wants to merge 3 commits intopytorch:masterfrom
Conversation
Contributor
💊 CI failures summary and remediationsAs of commit 895554f (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
Codecov Report
@@ Coverage Diff @@
## master #51061 +/- ##
==========================================
- Coverage 80.99% 80.99% -0.01%
==========================================
Files 1916 1916
Lines 209552 209558 +6
==========================================
- Hits 169736 169729 -7
- Misses 39816 39829 +13 |
albanD
reviewed
Jan 26, 2021
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
@jbschlosser has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Contributor
|
@jbschlosser merged this pull request in 0b5303e. |
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
Summary: Fixes pytorch#49824 ## Background When creating a view of a view, there was a possibility that the new view would be less restrictive than the previous view, incorrectly sidestepping the error that should be thrown when using in-place operations on the new view. The fix addresses this by propagating `CreationMeta` from the previous view to the new view. Currently, the old view's `creation_meta` is only propagated when the new view's `creation_meta == CreationMeta::DEFAULT`. This ensures that the new view is not less restrictive than the previous view wrt. allowing in-place operations. Pull Request resolved: pytorch#51061 Test Plan: ``` python test/test_autograd.py TestAutogradDeviceTypeCPU.test_inplace_view_of_multiple_output_view_cpu python test/test_autograd.py TestAutogradDeviceTypeCUDA.test_inplace_view_of_multiple_output_view_cuda python test/test_autograd.py TestAutogradDeviceTypeCPU.test_inplace_multiple_output_view_of_view_cpu python test/test_autograd.py TestAutogradDeviceTypeCUDA.test_inplace_multiple_output_view_of_view_cuda ``` Reviewed By: heitorschueroff Differential Revision: D26076434 Pulled By: jbschlosser fbshipit-source-id: c47f0ddcef9b8449427b671aff9ad08edca70fcd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #49824
Background
When creating a view of a view, there was a possibility that the new view would be less restrictive than the previous view, incorrectly sidestepping the error that should be thrown when using in-place operations on the new view.
The fix addresses this by propagating
CreationMetafrom the previous view to the new view. Currently, the old view'screation_metais only propagated when the new view'screation_meta == CreationMeta::DEFAULT. This ensures that the new view is not less restrictive than the previous view wrt. allowing in-place operations.Test Plan
BC-Breaking Note
After this fix, an error will properly be thrown to avoid wrong gradients when an in-place operation is performed on a view of a view, where the second view has
creation_meta == CreationMeta::DEFAULT(e.g. a standard single output view) while the first view hascreation_meta != CreationMeta::DEFAULT(e.g. a multiple output or other restricted view).Since previous behavior allowed such in-place operations without an error, this change is BC-breaking.