Skip to content

[MPS] Fix dlpack exports/imports for sliced tensors#169272

Closed
malfet wants to merge 2 commits intogh/malfet/612/basefrom
gh/malfet/612/head
Closed

[MPS] Fix dlpack exports/imports for sliced tensors#169272
malfet wants to merge 2 commits intogh/malfet/612/basefrom
gh/malfet/612/head

Conversation

@malfet
Copy link
Contributor

@malfet malfet commented Dec 1, 2025

Stack from ghstack (oldest at bottom):

For MPS tensor, one must pass both id<MTL_Buffer> (which is t.storage().data() and t.storage_offset())

Luckily, DLTensor already has byte_offset field, which feels natural to use as product of storage_offset and element_size.

Partially extends #168193, but instead of writing a completely new test, fix both export and import paths of sliced tensor and unskip test_from_dlpack_noncontinguous for MPS

Error out if one is attempting to create tensor with non-zero byte_offsets and no strides, as there are no at::from_blob variant that could be used

Fixes #168177

For MPS tensor, one must pass both `id<MTL_Buffer>` (which is `t.storage().data()` and `t.storage_offset()`)

Luckily, DLTensor already has `byte_offset` field, which feels natural to use as product of `storage_offset` and element_size

Partially extends #168193, but instead of writing a completely new test, fix both export and import paths of sliced tensor and unskip test_from_dlpack_noncontinguous for MPS

Fixes #168177

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Dec 1, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure, 7 Unrelated Failures

As of commit b1bbb85 with merge base a1ab3a0 (image):

NEW FAILURE - The following job has failed:

UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:

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

malfet added a commit that referenced this pull request Dec 1, 2025
For MPS tensor, one must pass both `id<MTL_Buffer>` (which is `t.storage().data()` and `t.storage_offset()`)

Luckily, DLTensor already has `byte_offset` field, which feels natural to use as product of `storage_offset` and element_size

Partially extends #168193, but instead of writing a completely new test, fix both export and import paths of sliced tensor and unskip test_from_dlpack_noncontinguous for MPS

Fixes #168177

ghstack-source-id: 61a32f2
Pull Request resolved: #169272
@malfet malfet added ciflow/trunk Trigger trunk jobs on your pull request topic: bug fixes topic category release notes: mps Release notes category ciflow/mps Run MPS tests (subset of trunk) labels Dec 1, 2025
malfet added a commit that referenced this pull request Dec 1, 2025
For MPS tensor, one must pass both `id<MTL_Buffer>` (which is `t.storage().data()` and `t.storage_offset()`)

Luckily, DLTensor already has `byte_offset` field, which feels natural to use as product of `storage_offset` and element_size

Partially extends #168193, but instead of writing a completely new test, fix both export and import paths of sliced tensor and unskip test_from_dlpack_noncontinguous for MPS

Fixes #168177

ghstack-source-id: 61a32f2
Pull Request resolved: #169272
[ghstack-poisoned]
malfet added a commit that referenced this pull request Dec 1, 2025
For MPS tensor, one must pass both `id<MTL_Buffer>` (which is `t.storage().data()` and `t.storage_offset()`)

Luckily, DLTensor already has `byte_offset` field, which feels natural to use as product of `storage_offset` and element_size

Partially extends #168193, but instead of writing a completely new test, fix both export and import paths of sliced tensor and unskip test_from_dlpack_noncontinguous for MPS

Fixes #168177

ghstack-source-id: 702dda8
Pull Request resolved: #169272
@malfet
Copy link
Contributor Author

malfet commented Dec 2, 2025

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@huydhn
Copy link
Contributor

huydhn commented Dec 3, 2025

@pytorchbot revert -m 'I am seeing some ROCm failures in trunk after this lands' -c nosignals

test/inductor/test_aot_inductor.py::AOTInductorTestABICompatibleGpu::test_non_tensor_input_cuda GH job link HUD commit link

test/inductor/test_torchinductor.py::GPUTests::test_aoti_eager_override_registration_cuda GH job link HUD commit link

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 3, 2025

❌ 🤖 pytorchbot command failed:

@pytorchbot revert: error: argument -c/--classification: invalid choice: 'nosignals' (choose from 'nosignal', 'ignoredsignal', 'landrace', 'weird', 'ghfirst', 'autorevert')

usage: @pytorchbot revert -m MESSAGE -c
                          {nosignal,ignoredsignal,landrace,weird,ghfirst,autorevert}

Try @pytorchbot --help for more info.

@huydhn
Copy link
Contributor

huydhn commented Dec 3, 2025

@pytorchbot revert -m 'I am seeing some ROCm failures in trunk after this lands' -c nosignal

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

pytorchmergebot added a commit that referenced this pull request Dec 3, 2025
This reverts commit 7741edd.

Reverted #169272 on behalf of https://github.com/huydhn due to I am seeing some ROCm failures in trunk after this lands ([comment](#169272 (comment)))
@pytorchmergebot
Copy link
Collaborator

@malfet your PR has been successfully reverted.

@pytorchmergebot pytorchmergebot added Reverted ci-no-td Do not run TD on this PR labels Dec 3, 2025
@huydhn
Copy link
Contributor

huydhn commented Dec 3, 2025

@pytorchbot merge -i

Reland this as I don't think the revert helps

JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
For MPS tensor, one must pass both `id<MTL_Buffer>` (which is `t.storage().data()` and `t.storage_offset()`)

Luckily, DLTensor already has `byte_offset` field, which feels natural to use as product of `storage_offset` and element_size.

Partially extends #168193, but instead of writing a completely new test, fix both export and import paths of sliced tensor and unskip test_from_dlpack_noncontinguous for MPS

Error out if one is attempting to create tensor with non-zero `byte_offsets` and no strides, as there are no `at::from_blob` variant that could be used

Fixes #168177
Pull Request resolved: #169272
Approved by: https://github.com/ngimel
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
This reverts commit 7741edd.

Reverted #169272 on behalf of https://github.com/huydhn due to I am seeing some ROCm failures in trunk after this lands ([comment](#169272 (comment)))
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
For MPS tensor, one must pass both `id<MTL_Buffer>` (which is `t.storage().data()` and `t.storage_offset()`)

Luckily, DLTensor already has `byte_offset` field, which feels natural to use as product of `storage_offset` and element_size.

Partially extends #168193, but instead of writing a completely new test, fix both export and import paths of sliced tensor and unskip test_from_dlpack_noncontinguous for MPS

Error out if one is attempting to create tensor with non-zero `byte_offsets` and no strides, as there are no `at::from_blob` variant that could be used

Fixes #168177
Pull Request resolved: #169272
Approved by: https://github.com/ngimel
@github-actions github-actions bot deleted the gh/malfet/612/head branch January 3, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/mps Run MPS tests (subset of trunk) ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: mps Release notes category Reverted topic: bug fixes topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants