Skip to content
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

Conversions between strided and jagged layouts for Nested Tensors #115749

Open
wants to merge 23 commits into
base: gh/ani300/4/base
Choose a base branch
from

Conversation

ani300
Copy link
Collaborator

@ani300 ani300 commented Dec 13, 2023

This PR does 3 things:

  1. Adds a copy-free strided->jagged layout conversion for NT
  2. Adds a copy-free jagged->strided layout conversion for NT
  3. Modifies and expands the .to() API to support the layout argument for the specific case of NT layout conversion.

Stack from ghstack (oldest at bottom):

cc @cpuhrsch @jbschlosser @bhosmer @drisspg @soulitzer

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Dec 13, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/115749

Note: Links to docs will display an error until the docs builds have been completed.

❌ 25 New Failures

As of commit dcfc6c0 with merge base 48a5414 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

ani300 added a commit that referenced this pull request Dec 13, 2023
ghstack-source-id: c10512f5c8c66faa6a51a3dc84c0f3fdc9af7aeb
Pull Request resolved: #115749
ani300 added a commit that referenced this pull request Dec 15, 2023
ghstack-source-id: cc51a8c36036baffa92a2cc15df68b297138d2d4
Pull Request resolved: #115749
@soulitzer
Copy link
Contributor

Add a test?

ani300 added a commit that referenced this pull request Jan 23, 2024
ghstack-source-id: 1080b577831db7b66d5351bac970f920fc409cd3
Pull Request resolved: #115749
Copy link
Contributor

@jbschlosser jbschlosser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this doesn't work today, but I think we want this sugar to work as the public API for conversion:

nt.to(layout=torch.jagged)

Today this gives:

TypeError: to() received an invalid combination of arguments - got (layout=torch.layout, ), but expected one of:
 * (torch.device device, torch.dtype dtype, bool non_blocking, bool copy, *, torch.memory_format memory_format)
 * (torch.dtype dtype, bool non_blocking, bool copy, *, torch.memory_format memory_format)
 * (Tensor tensor, bool non_blocking, bool copy, *, torch.memory_format memory_format)

I think if we support that in general then we can provide a high-level meta registration for it that is used by FakeTensor to solve the Dynamo issue you're hitting for the tests. A good place to start is in tools/autograd/templates/python_variable_methods.cpp where THPVariable_to() and dispatch_to() are defined.

test/test_nestedtensor.py Outdated Show resolved Hide resolved
test/test_nestedtensor.py Outdated Show resolved Hide resolved
test/test_nestedtensor.py Outdated Show resolved Hide resolved
test/test_nestedtensor.py Outdated Show resolved Hide resolved
test/test_nestedtensor.py Outdated Show resolved Hide resolved
ani300 added a commit that referenced this pull request Feb 20, 2024
ghstack-source-id: 56e8ca386d1636b34860515e9ff700f0b822852c
Pull Request resolved: #115749
ani300 added a commit that referenced this pull request Feb 20, 2024
ghstack-source-id: cac5a5cebb45a61757680dc914d4340c285dcfed
Pull Request resolved: #115749
ani300 added a commit that referenced this pull request Feb 21, 2024
ghstack-source-id: 0d3ddb87e909e05ebd1330596237ceb1e78b1aea
Pull Request resolved: #115749
ani300 added a commit that referenced this pull request Feb 22, 2024
ghstack-source-id: 0690da2da1d73452093783d48a900c20b09a7efb
Pull Request resolved: #115749
ani300 added a commit that referenced this pull request Feb 22, 2024
ghstack-source-id: ae00bb520f2a6faada97d86e5292439258db8c6e
Pull Request resolved: #115749
[ghstack-poisoned]
ani300 added a commit that referenced this pull request May 14, 2024
ghstack-source-id: 83751d0c4dd39fdc807d94b2b3dfeda920e1d448
Pull Request resolved: #115749
[ghstack-poisoned]
ani300 added a commit that referenced this pull request May 14, 2024
ghstack-source-id: 0f7c6b1c38615a1dc65d229fa61fad1e55c20586
Pull Request resolved: #115749
[ghstack-poisoned]
ani300 added a commit that referenced this pull request May 15, 2024
ghstack-source-id: 39edb555da2c4e9fcf86a9b24b69ca181b46df60
Pull Request resolved: #115749
[ghstack-poisoned]
@ani300 ani300 requested a review from albanD as a code owner May 16, 2024 14:02
ani300 added a commit that referenced this pull request May 16, 2024
ghstack-source-id: 763afcc1bea36813b0a33b8d802fa8e77462bf0f
Pull Request resolved: #115749
@albanD albanD removed their request for review May 16, 2024 14:08
[ghstack-poisoned]
ani300 added a commit that referenced this pull request May 16, 2024
ghstack-source-id: 9976341cee22d6233dbefb2fa2ac7dce2788b824
Pull Request resolved: #115749
@ani300 ani300 added the keep-going Don't stop on first failure, keep running tests until the end label May 16, 2024
[ghstack-poisoned]
ani300 added a commit that referenced this pull request May 17, 2024
ghstack-source-id: cc22768290c07f96b77d42d97df46dad12e6ba50
Pull Request resolved: #115749
[ghstack-poisoned]
ani300 added a commit that referenced this pull request May 17, 2024
ghstack-source-id: a8337d942551143fce99bb8d38c83e1925475a0a
Pull Request resolved: #115749
[ghstack-poisoned]
ani300 added a commit that referenced this pull request May 17, 2024
ghstack-source-id: fcad4589b439c933e16f9bdf9938e4513ec45bbb
Pull Request resolved: #115749
@ani300 ani300 changed the title Add _to_copy op for jagged NT Conversions between strided and jagged layouts for Nested Tensors May 17, 2024
[ghstack-poisoned]
ani300 added a commit that referenced this pull request May 17, 2024
ghstack-source-id: 5930cfb064f1f98e8fde058386220ae8d4535597
Pull Request resolved: #115749
[ghstack-poisoned]
ani300 added a commit that referenced this pull request May 20, 2024
ghstack-source-id: c67731de33427f75c977b2bbb1bcce7b4af81b1f
Pull Request resolved: #115749
[ghstack-poisoned]
ani300 added a commit that referenced this pull request Jun 6, 2024
ghstack-source-id: 02f83a6c339494e411228505afbb6ccc4ba0e9b5
Pull Request resolved: #115749
[ghstack-poisoned]
ani300 added a commit that referenced this pull request Jun 6, 2024
ghstack-source-id: c220d0e7655f31d07708da073fb3a7ee42be25ae
Pull Request resolved: #115749
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep-going Don't stop on first failure, keep running tests until the end module: nestedtensor NestedTensor tag see issue #25032 open source release notes: nested tensor Changes that have a direct impact on nested tensors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants