Skip to content

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
NVIDIA:mainfrom
dextero:main
Open

Fix handling of JAX tensor types without TVM FFI and leading dim deduction for all-1-size tensors#3583
dextero wants to merge 2 commits into
NVIDIA:mainfrom
dextero:main

Conversation

@dextero

@dextero dextero commented Sep 4, 2026

Copy link
Copy Markdown

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.

Marcin Radomski 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant