-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Nested Tensor] view: basic support for ragged_idx != 1 and _unsafe_view #118317
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
[Nested Tensor] view: basic support for ragged_idx != 1 and _unsafe_view #118317
Conversation
…view Uses case: `_unsafe_view` is used in aot_autograd to create a view that doesn't register as a view: https://github.com/pytorch/pytorch/blob/eebe7e1d37f1baa995c694d540cc2fc98884fa18/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py#L470-L476 If a transposed nested tensor (i.e. NT with ragged_idx != 1) encounters this code path, it previously would fail for two reasons: 1) because `_unsafe_view` isn't registered, and 2) because ragged_idx != 1 is not supported. This PR adds support for `_unsafe_view` (completely reusing the implementation of `view`; this just registers `_unsafe_view` as another op using the same implementation). It also adds support for ragged_idx != 1, but only for trivial cases where inp._size == size (the use case used by aot_autograd). Tests: verify that the result of `_unsafe_view` doesn't have a `_base`, and that simple views on transposed NTs work. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/118317
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 8428891 with merge base 3cdd4e2 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@davidberard98 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
…nd _unsafe_view" Uses case: `_unsafe_view` is used in aot_autograd to create a view that doesn't register as a view: https://github.com/pytorch/pytorch/blob/eebe7e1d37f1baa995c694d540cc2fc98884fa18/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py#L470-L476 If a transposed nested tensor (i.e. NT with ragged_idx != 1) encounters this code path, it previously would fail for two reasons: 1) because `_unsafe_view` isn't registered, and 2) because ragged_idx != 1 is not supported. This PR adds support for `_unsafe_view` (completely reusing the implementation of `view`; this just registers `_unsafe_view` as another op using the same implementation). It also adds support for ragged_idx != 1, but only for trivial cases where inp._size == size (the use case used by aot_autograd). Tests: verify that the result of `_unsafe_view` doesn't have a `_base`, and that simple views on transposed NTs work. Differential Revision: [D53096814](https://our.internmc.facebook.com/intern/diff/D53096814) [ghstack-poisoned]
…view Uses case: `_unsafe_view` is used in aot_autograd to create a view that doesn't register as a view: https://github.com/pytorch/pytorch/blob/eebe7e1d37f1baa995c694d540cc2fc98884fa18/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py#L470-L476 If a transposed nested tensor (i.e. NT with ragged_idx != 1) encounters this code path, it previously would fail for two reasons: 1) because `_unsafe_view` isn't registered, and 2) because ragged_idx != 1 is not supported. This PR adds support for `_unsafe_view` (completely reusing the implementation of `view`; this just registers `_unsafe_view` as another op using the same implementation). It also adds support for ragged_idx != 1, but only for trivial cases where inp._size == size (the use case used by aot_autograd). Tests: verify that the result of `_unsafe_view` doesn't have a `_base`, and that simple views on transposed NTs work. ghstack-source-id: 7c15f5b Pull Request resolved: #118317
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.
SGTM
@pytorchbot merge -r |
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
…d _unsafe_view" Uses case: `_unsafe_view` is used in aot_autograd to create a view that doesn't register as a view: https://github.com/pytorch/pytorch/blob/eebe7e1d37f1baa995c694d540cc2fc98884fa18/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py#L470-L476 If a transposed nested tensor (i.e. NT with ragged_idx != 1) encounters this code path, it previously would fail for two reasons: 1) because `_unsafe_view` isn't registered, and 2) because ragged_idx != 1 is not supported. This PR adds support for `_unsafe_view` (completely reusing the implementation of `view`; this just registers `_unsafe_view` as another op using the same implementation). It also adds support for ragged_idx != 1, but only for trivial cases where inp._size == size (the use case used by aot_autograd). Tests: verify that the result of `_unsafe_view` doesn't have a `_base`, and that simple views on transposed NTs work. Differential Revision: [D53096814](https://our.internmc.facebook.com/intern/diff/D53096814) [ghstack-poisoned]
Successfully rebased |
…view Uses case: `_unsafe_view` is used in aot_autograd to create a view that doesn't register as a view: https://github.com/pytorch/pytorch/blob/eebe7e1d37f1baa995c694d540cc2fc98884fa18/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py#L470-L476 If a transposed nested tensor (i.e. NT with ragged_idx != 1) encounters this code path, it previously would fail for two reasons: 1) because `_unsafe_view` isn't registered, and 2) because ragged_idx != 1 is not supported. This PR adds support for `_unsafe_view` (completely reusing the implementation of `view`; this just registers `_unsafe_view` as another op using the same implementation). It also adds support for ragged_idx != 1, but only for trivial cases where inp._size == size (the use case used by aot_autograd). Tests: verify that the result of `_unsafe_view` doesn't have a `_base`, and that simple views on transposed NTs work. ghstack-source-id: 1e0b057 Pull Request resolved: #118317
Merge failedReason: This PR has internal changes and must be landed via Phabricator Details for Dev Infra teamRaised by workflow job |
@davidberard98 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@pytorchbot merge |
Merge failedReason: This PR has internal changes and must be landed via Phabricator 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 |
…iew (pytorch#118317) Uses case: `_unsafe_view` is used in aot_autograd to create a view that doesn't register as a view: https://github.com/pytorch/pytorch/blob/eebe7e1d37f1baa995c694d540cc2fc98884fa18/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py#L470-L476 If a transposed nested tensor (i.e. NT with ragged_idx != 1) encounters this code path, it previously would fail for two reasons: 1) because `_unsafe_view` isn't registered, and 2) because ragged_idx != 1 is not supported. This PR adds support for `_unsafe_view` (completely reusing the implementation of `view`; this just registers `_unsafe_view` as another op using the same implementation). It also adds support for ragged_idx != 1, but only for trivial cases where inp._size == size (the use case used by aot_autograd). Tests: verify that the result of `_unsafe_view` doesn't have a `_base`, and that simple views on transposed NTs work. Differential Revision: [D53096814](https://our.internmc.facebook.com/intern/diff/D53096814) Pull Request resolved: pytorch#118317 Approved by: https://github.com/soulitzer
Stack from ghstack (oldest at bottom):
Uses case:
_unsafe_view
is used in aot_autograd to create a view that doesn't register as a view:pytorch/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py
Lines 470 to 476 in eebe7e1
If a transposed nested tensor (i.e. NT with ragged_idx != 1) encounters this code path, it previously would fail for two reasons: 1) because
_unsafe_view
isn't registered, and 2) because ragged_idx != 1 is not supported. This PR adds support for_unsafe_view
(completely reusing the implementation ofview
; this just registers_unsafe_view
as another op using the same implementation). It also adds support for ragged_idx != 1, but only for trivial cases where inp._size == size (the use case used by aot_autograd).Tests: verify that the result of
_unsafe_view
doesn't have a_base
, and that simple views on transposed NTs work.Differential Revision: D53096814