Add StridedMemoryView DLPack export and C exchange API support#1630
Open
cpcloud wants to merge 7 commits intoNVIDIA:mainfrom
Open
Add StridedMemoryView DLPack export and C exchange API support#1630cpcloud wants to merge 7 commits intoNVIDIA:mainfrom
cpcloud wants to merge 7 commits intoNVIDIA:mainfrom
Conversation
Add coverage for StridedMemoryView DLPack producer behavior and the C exchange API capsule so the implementation can be landed in follow-up commits. Co-authored-by: Cursor <cursoragent@cursor.com>
Align cuda-core's bundled DLPack header with upstream v1.3 so protocol constants and C API declarations match current spec. Co-authored-by: Cursor <cursoragent@cursor.com>
Add __dlpack__ and __dlpack_device__ support to StridedMemoryView, including owned DLManagedTensor capsule creation and lifecycle handling for shape, strides, dtype, and device metadata. Co-authored-by: Cursor <cursoragent@cursor.com>
Expose the C exchange API capsules for StridedMemoryView and align exported tensor metadata with current DLPack semantics and shared type declarations. Co-authored-by: Cursor <cursoragent@cursor.com>
Ensure nvrtc headers are present when building cuda-core in the test environment so pixi test runs do not fail on missing nvrtc.h. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Normalize test_utils import order after pre-commit autofixes so local and CI hook runs stay clean. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
/ok to test |
Clarify why setup_dl_tensor_layout always sets a non-NULL stride pointer for non-scalar exports under DLPack v1.2+ semantics. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
/ok to test |
|
leofang
reviewed
Feb 18, 2026
| kDLCUDA = _kDLCUDA | ||
| kDLCUDAHost = _kDLCUDAHost | ||
| kDLCUDAManaged = _kDLCUDAManaged | ||
| kDLTrn = _kDLTrn |
Member
There was a problem hiding this comment.
This is not an NVIDIA product, we should not expose it:
Suggested change
| kDLTrn = _kDLTrn |
leofang
reviewed
Feb 18, 2026
| setuptools-scm = ">=8" | ||
| cython = ">=3.2,<3.3" | ||
| cuda-cudart-dev = "*" | ||
| cuda-nvrtc-dev = "*" |
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.
Summary
StridedMemoryViewincuda_core/tests/test_utils.py, including NumPy/CuPy roundtrip checks, dtype-required failure behavior, and C exchange API capsule exposure.StridedMemoryViewproducer support incuda_core/cuda/core/_memoryview.pyxvia__dlpack__and__dlpack_device__, plus managed-tensor lifecycle helpers and C exchange API function-table exposure.cuda_core/cuda/core/_include/dlpack.hto DLPackv1.3and align compatibility behavior discussed in review:max_versionand emit legacy vs versioned capsules accordingly,ndim > 0(required by DLPackv1.2+) while remaining broadly compatible with consumers,__dlpack_c_exchange_api__and__c_dlpack_exchange_api__as aliases on the type.cuda-nvrtc-devtocuda_corehost dependencies (cuda_core/pixi.toml,cuda_core/pixi.lock) sonvrtc.his consistently available in pixi build/test environments.Closes #1438.
Test plan
pixi run --frozen -e cu13 --manifest-path cuda_core test tests/test_utils.py -k dlpack -q(16 passed, 10 skipped)nix run nixpkgs#gcc -- -fsyntax-only cuda_core/cuda/core/_include/dlpack.hcuda_coretest suite