Fix handling of JAX tensor types without TVM FFI and leading dim deduction for all-1-size tensors - #3583
Open
dextero wants to merge 2 commits into
Open
Fix handling of JAX tensor types without TVM FFI and leading dim deduction for all-1-size tensors#3583dextero wants to merge 2 commits into
dextero wants to merge 2 commits into
Conversation
added 2 commits
September 4, 2026 13:19
… <= 1 When leading_dim is None in _Tensor.mark_layout_dynamic(), the underlying C++ DLPack wrapper attempts to deduce the leading dimension by finding the stride-1 dimension. For tensors where all dimensions in shape are <= 1 (e.g., unit or 1D single-element tensors like shape (1,)), the deduction fails or becomes ambiguous. Fallback to selecting the innermost stride-1 dimension (or the last dimension if no stride is 1) when all shape dimensions are <= 1, and pass the explicit leading dimension to the wrapper. Signed-off-by: Marcin Radomski <dextero@google.com>
While numpy.ndarray and torch.Tensor are lazily registered with TensorAdapter in JitArgAdapterRegistry, JAX array types were missing. Consequently, passing JAX arrays into CuTeDSL JIT functions failed when looking up the argument adapter. Register the common JAX array implementation class qualified names (jaxlib._jax.ArrayImpl, jax.jaxlib._jax.ArrayImpl, jaxlib.xla_extension.ArrayImpl, jax._src.array.ArrayImpl) lazily so that JAX arrays are automatically adapted to TensorAdapter without incurring an import overhead for JAX. Signed-off-by: Marcin Radomski <dextero@google.com>
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.
Fix leading dimension deduction for tensors with dimensions <= 1
When leading_dim is None in _Tensor.mark_layout_dynamic(), the
underlying C++ DLPack wrapper attempts to deduce the leading dimension
by finding the stride-1 dimension. For tensors where all dimensions in
shape are <= 1 (e.g., unit or 1D single-element tensors like shape (1,)),
the deduction fails or becomes ambiguous.
While numpy.ndarray and torch.Tensor are lazily registered with
TensorAdapter in JitArgAdapterRegistry, JAX array types were missing.
Consequently, passing JAX arrays into CuTeDSL JIT functions failed
when looking up the argument adapter.