jax-ml/jax · error · TypePromotionError
Input dtypes {tuple(str(n) for n in nodes)} have no availabl
Error message
Input dtypes {tuple(str(n) for n in nodes)} have no available implicit dtype promotion path. Try explicitly casting inputs to the desired output type. What it means
The dtypes of the inputs have no common supertype on JAX's promotion lattice, so an implicit result dtype cannot be chosen. This is JAX's stricter version of NumPy promotion: e.g. mixing signed/unsigned integers of large widths, or bool with a string dtype, has no implicit path.
Source
Thrown at jax/_src/dtypes.py:871
elif any(n in _float4_dtypes for n in nodes):
msg = (
f"Input dtypes {tuple(str(n) for n in nodes)} have no available implicit dtype "
"promotion path. To avoid unintended promotion, 4-bit floats do not support "
"implicit promotion. If you'd like your inputs to be promoted to another type, "
"you can do so explicitly using e.g. x.astype('float32')")
elif any(n in _intn_dtypes for n in nodes):
msg = (
f'Input dtypes {tuple(str(n) for n in nodes)} have no available'
' implicit dtype promotion path. To avoid unintended promotion,'
' 1-bit, 2-bit and 4-bit integers do not support implicit promotion.'
" If you'd like your inputs to be promoted to another type, you can"
" do so explicitly using e.g. x.astype('int32')"
)
else:
msg = (
f"Input dtypes {tuple(str(n) for n in nodes)} have no available implicit dtype "
"promotion path. Try explicitly casting inputs to the desired output type.")
raise TypePromotionError(msg)
else:
# If we get here, it means the lattice is ill-formed.
raise TypePromotionError(
f"Internal Type Promotion error: {nodes} do not have a unique least upper bound "
f"on the specified lattice; options are {LUB}. This is an unexpected error in "
"JAX's internal logic; please report it to the JAX maintainers."
)
@set_module('jax.numpy')
def promote_types(a: DTypeLike, b: DTypeLike) -> DType:
"""Returns the type to which a binary operation should cast its arguments.
JAX implementation of :func:`numpy.promote_types`. For details of JAX's
type promotion semantics, see :ref:`type-promotion`.
Args:
a: a :class:`numpy.dtype` or a dtype specifier.
b: a :class:`numpy.dtype` or a dtype specifier.View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Explicitly cast one side to the desired output type: jnp.add(a, b.astype(a.dtype)) or cast both to a common wider type like int64
- Promote explicitly before the op: a = a.astype(jnp.int64); b = b.astype(jnp.int64)
- Check for accidental string/object arrays cast into the computation
Example fix
# before c = a_uint32 + b_int32 # after c = a_uint32.astype(jnp.int64) + b_int32.astype(jnp.int64)
Defensive patterns
Strategy: try-catch
Try / catch
from jax._src.dtypes import TypePromotionError
try:
out = a + b
except TypePromotionError:
target = jnp.result_type(a) # pick explicit target
out = a.astype(target) + b.astype(target) Prevention
- Normalize all pipeline tensors to one canonical dtype at entry
- For mixed int/uint data, cast to int64 explicitly
- Never rely on NumPy's object/float64 fallback semantics in JAX
When it happens
Trigger: Binary ops between types like jnp.uint32 and jnp.int32 (no common integer type wide enough), or operations combining extended dtypes that do not intersect; anything going through jax.lax.lattice_result_type / promote_types where CUB (common upper bounds) is empty. In non-strict numpy promotion mode the message differs; this exact text appears when no LUB exists at all.
Common situations: Loading uint32 image IDs and int32 labels and adding them; mixing indices from different pipelines; porting NumPy code where the same op silently returned float64 or object dtype.
Related errors
- {dtype=} is not a valid dtype for JAX type promotion.
- primal and tangent arguments to jax.jvp do not match; dtypes
- unexpected JAX type (e.g. shape/dtype) for gradient ref pass
- Accumulator aval mismatch: expected {aval}, got {acc.aval}
- unexpected JAX type (e.g. shape/dtype) for argument to VJP f
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/352a5b36448d902b.
Report an issue: GitHub.