You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use object-based DLPack interchange and test numeric dtypes in CI - #33909
Cover all byte-aligned ORT dtypes in both directions, document and test packed dtype incompatibilities, and retain zero-copy ownership without a redundant OrtValue copy.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
No active review issues are recorded for the inference-only PyTorch DLPack interoperability changes.
No open issues 🎉
What changed in this PR
Adds inference-only PyTorch DLPack interoperability coverage following #33848, validating the existing dtype support without requiring ORT training.
Changes:
Tests bidirectional exchange for 18 byte-aligned dtypes, all float8 bit patterns, and compatibility boundaries for five packed dtypes, including zero-copy sharing and ownership.
Runs the suite in transformers-enabled Python test jobs when contrib operators are enabled.
Removes a redundant OrtValue copy, simplifies shape access, and clarifies ownership and PyTorch compatibility documentation.
File
Description
tools/ci_build/build.py
Adds mandatory DLPack suite execution to eligible test jobs.
Remove the legacy Python to_dlpack method and accept protocol objects consistently in native and public from_dlpack. Migrate callers, preserve capsule compatibility and training autograd semantics, and cover native protocol surfaces and producer errors.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Justin Chu (justinchuby)
changed the title
Test PyTorch DLPack dtype interchange in inference CI
Use object-based DLPack interchange and test numeric dtypes in CI
Nov 5, 2026
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
An existing dlpack property raising AttributeError is still masked by a generic TypeError; descriptor failures must be preserved and covered by regression tests for both importers.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve AttributeError raised by existing __dlpack__ descriptors
If an existing __dlpack__ property raises AttributeError, this branch clears the producer's exception and replaces it with the generic invalid-capsule TypeError. That still suppresses lookup failures despite the stated error-preservation contract. Distinguish an absent protocol attribute from a failing descriptor, preserve the latter exception, and add an AttributeError-raising property regression for the public and native importers.
Retain NumPy storage in native values, fence CUDA imports and exports, and make batched capsules independently owned and exception-safe. Remove unused dlpack_at and cover ownership, callback failures, vector mutation, and CUDA stream handoffs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use ORT_RETURN_IF_ERROR with CUDA_CALL because the file-local CUDA_RETURN_IF_ERROR macro is declared below the provider implementation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The DLPack bindings hold the GIL during device-wide synchronization, blocking other Python threads, and need to release it safely with exclusive capsule ownership established first for imports.
Claim capsule ownership before synchronization, retain export storage across the unlocked wait, and cover concurrent consumption and failure cleanup. Pin SentencePiece to the version compatible with the protobuf runtime used by transformer CI.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The DLPack import fails in PyTorch 2.10 when the producer tensor’s CUDA device differs from the current device, also causing the new protocol-path test to fail on multi-GPU systems.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The change fails to compile with Abseil disabled, risks exhausting memory by retaining NumPy allocations while the main thread is blocked, and lacks successful ROCm/MIGraphX handoff coverage.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Native ownership cleanup and GPU stream/device restoration require runtime validation on matching CUDA and ROCm builds, including multi-GPU and graph-capture paths, which this review environment cannot provide.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Synchronization and ownership changes remain unverified because matching CUDA/ROCm/MIGraphX hardware was unavailable to validate multi-device restoration, graph-capture safety, and cross-thread cleanup.
No open issues 🎉
Review effort: Balanced
This branch has not been deployed
No deployments
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
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.
Description
Modernize public/native
OrtValueDLPack interchange, remove obsolete export helpers, and retain legacy capsule imports.Fix NumPy ownership, CUDA/ROCm handoffs, and exception-safe batched exports. Add mandatory inference-CI coverage for dtype compatibility and lifetime/error paths.
Motivation and Context
Follow-up to #33848. Make tensor-object interchange safe for framework use, including PyTorch's packed-type limits.