jax-ml/jax · warning
Explicitly requested dtype {}{} is not available, and will b
Error message
Explicitly requested dtype {}{} is not available, and will be truncated to dtype {}. To enable more dtypes, set the jax_enable_x64 configuration option or the JAX_ENABLE_X64 shell environment variable. See https://github.com/jax-ml/jax#current-gotchas for more. What it means
You explicitly requested a 64-bit dtype (e.g. float64/int64/complex128) but JAX's x64 mode is disabled (the default), so the dtype is truncated to its 32-bit canonical equivalent (float32/int32/complex64). JAX warns so silent precision loss doesn't go unnoticed.
Source
Thrown at jax/_src/dtypes.py:980
canonical_dtype = canonicalize_dtype(dtype)
if canonical_dtype == dtype:
return dtype
fun_name = f" requested in {fun_name}" if fun_name else ""
if allow == config.ExplicitX64Mode.ERROR:
msg = ("Explicitly requested dtype {}{} is not available. To enable more "
"dtypes, set the jax_enable_x64 or allow_explicit_x64_dtypes "
"configuration options."
"See https://github.com/jax-ml/jax#current-gotchas for more.")
msg = msg.format(dtype, fun_name, canonical_dtype.name)
raise ValueError(msg)
else: # WARN
msg = ("Explicitly requested dtype {}{} is not available, "
"and will be truncated to dtype {}. To enable more dtypes, set the "
"jax_enable_x64 configuration option or the JAX_ENABLE_X64 shell "
"environment variable. "
"See https://github.com/jax-ml/jax#current-gotchas for more.")
msg = msg.format(dtype, fun_name, canonical_dtype.name)
warnings.warn(msg, stacklevel=4)
return canonical_dtype
_types_whose_dtype_should_not_be_canonicalized: tuple[type, ...] = (
Array,
)
def register_type_whose_dtype_should_not_be_canonicalized(typ: type):
global _types_whose_dtype_should_not_be_canonicalized
_types_whose_dtype_should_not_be_canonicalized += (typ,)
def dtype(x: Any) -> DType:
"""Return the dtype object for a value or type.
Python scalars, Python scalar types, NumPy scalar type, NumPy dtypes, and
non-JAX arrays will have their dtypes canonicalized.
Note: this is not the same function as jax.numpy.dtype, which simply aliasesView on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Enable 64-bit mode at startup: jax.config.update('jax_enable_x64', True) (or export JAX_ENABLE_X64=true) before any JAX arrays are created.
- If 32-bit is acceptable, change the requested dtype to float32/int32/complex64 to silence the warning.
- Note x64 must be enabled before arrays/tracers are created; changing it late has no effect on existing arrays.
Example fix
# before
import jax.numpy as jnp
x = jnp.array([1.5, 2.5], dtype=jnp.float64) # truncated to float32
# after
import jax
jax.config.update('jax_enable_x64', True)
import jax.numpy as jnp
x = jnp.array([1.5, 2.5], dtype=jnp.float64) # true float64 Defensive patterns
Strategy: validation
Validate before calling
import jax
assert jax.config.jax_enable_x64 or not any(str(d).endswith('64') and 'complex' not in str(d) or str(d)=='complex128' for d in []), 'x64 off'
# simpler: check before using 64-bit dtypes
if not jax.config.jax_enable_x64:
raise SystemExit('enable x64 before using float64/int64') Type guard
import jax.numpy as jnp
def is_64bit_available(dtype) -> bool:
import jax
return jax.config.jax_enable_x64 or jnp.zeros((), dtype=dtype).dtype == dtype Try / catch
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
x = jnp.array(vals, dtype=jnp.float64)
if any('truncated to dtype' in str(i.message) for i in w):
# precision silently lost — enable x64 and rebuild arrays Prevention
- Call jax.config.update('jax_enable_x64', True) at program start, before any arrays.
- Set JAX_ENABLE_X64=true in the environment for the whole job.
- Assert on this warning in numerical-precision-sensitive tests.
When it happens
Trigger: Passing dtype=jnp.float64 (or int64/uint64/complex128) to jnp.array, jnp.zeros, jax.random functions, searchsorted, etc., without jax_enable_x64=True; every explicit 64-bit request goes through _maybe_canonicalize_explicit_dtype and warns.
Common situations: Porting NumPy code that assumes int64 indices/default float64; scientific computing needing double precision; ML pipelines where silent downcast breaks numerics.
Related errors
- Explicitly requested dtype {}{} is not available. To enable
- 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/608c3c82a23d8d00.
Report an issue: GitHub.