[DLPack] add NumPy exchange tests.#150216
Closed
ysiraichi wants to merge 13 commits intogh/ysiraichi/84/basefrom
Closed
[DLPack] add NumPy exchange tests.#150216ysiraichi wants to merge 13 commits intogh/ysiraichi/84/basefrom
ysiraichi wants to merge 13 commits intogh/ysiraichi/84/basefrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/150216
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit be41b4a with merge base 7cc1a95 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Mar 28, 2025
msaroufim
approved these changes
May 14, 2025
Member
msaroufim
left a comment
There was a problem hiding this comment.
could be a seperate PR but I'd really love to also see some tests testing moving gpu tensors to a framework that also supports gpus
albanD
approved these changes
May 14, 2025
Collaborator
albanD
left a comment
There was a problem hiding this comment.
Small updates needed, but SGTM otherwise
Collaborator
|
Starting merge as part of PR stack under #150691 |
This PR resolves an old TODO that requested NumPy DLPack exchange tests once version 1.22 was required. [ghstack-poisoned]
This PR resolves an old TODO that requested NumPy DLPack exchange tests once version 1.22 was required. [ghstack-poisoned]
Collaborator
|
Starting merge as part of PR stack under #150691 |
pytorchmergebot
pushed a commit
that referenced
this pull request
Jul 20, 2025
This PR fixes the logic for dealing with CUDA and ROCm streams whenever we are trying to create a DLPack capsule from a tensor. In summary, this PR: - Uses the legacy default stream if `tensor.__dlpack__(stream=None)` is called for a CUDA tensor. - Errors if `tensor.__dlpack__(stream=2)` is called for a CUDA tensor: PyTorch doesn't support the per-thread default stream. - Errors if `tensor.__dlpack__(stream=stream)`, where `stream` is 1 or 2, is called for a CUDA tensor using ROCm. For more details, see [the documentation][1]. [1]: https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__dlpack__.html Pull Request resolved: #150217 Approved by: https://github.com/msaroufim, https://github.com/albanD ghstack dependencies: #150216
pytorchmergebot
pushed a commit
that referenced
this pull request
Jul 20, 2025
This PR introduces the rest of the keyword-arguments added in DLPack version 2023.12: `dl_device` and `copy`. In summary, we handle these arguments in the C++ implementation of `to_dlpack(...)` at _torch/csrc/Module.cpp_, by calling the `maybeCopyTensor` function at _aten/src/ATen/DLConvertor.cpp_. It also introduces the following changes: - Add a new Python API `torchDeviceToDLDevice()`, which is simply a refactoring of the `getDLDevice()` function at _aten/src/ATen/DLConvertor.cpp_. - Add both keyword-arguments to the `from_dlpack()` function at _torch/utils/dlpack.py_ and to the `Tensor.__dlpack__()` dunder method. Pull Request resolved: #150218 Approved by: https://github.com/albanD ghstack dependencies: #150216, #150217
pytorchmergebot
pushed a commit
that referenced
this pull request
Jul 20, 2025
This PR addresses the Array API documentation for [`__dlpack__`][1] and [`from_dlpack`][2] by making some buffer-related errors `BufferError` instead of `RuntimeError`, e.g. incompatible dtype, strides, or device. [1]: https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__dlpack__.html [2]: https://data-apis.org/array-api/latest/API_specification/generated/array_api.from_dlpack.html#from-dlpack Pull Request resolved: #150691 Approved by: https://github.com/Skylion007, https://github.com/albanD ghstack dependencies: #150216, #150217, #150218
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.
Stack from ghstack (oldest at bottom):
BufferErrorfor DLPack buffer-related errors. #150691This PR resolves an old TODO that requested NumPy DLPack exchange tests
once version 1.22 was required.