{"record":{"id":"4f47c0fbe7404b19","repo":"jax-ml/jax","slug":"explicitly-requested-dtype-is-not-available","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/dtypes.py","lineNumber":972,"sourceCode":"    raise TypeError(f\"Dtype {dtype} is not a valid JAX array \"\n                    \"type. Only arrays of numeric types are supported by JAX.\")\n\ndef _maybe_canonicalize_explicit_dtype(dtype: DType, fun_name: str) -> DType:\n  \"Canonicalizes explicitly requested dtypes, per explicit_x64_dtypes.\"\n  allow = config.explicit_x64_dtypes.value\n  if allow == config.ExplicitX64Mode.ALLOW or config.enable_x64.value:\n    return dtype\n  canonical_dtype = canonicalize_dtype(dtype)\n  if canonical_dtype == dtype:\n    return dtype\n  fun_name = f\" requested in {fun_name}\" if fun_name else \"\"\n  if allow == config.ExplicitX64Mode.ERROR:\n    msg = (\"Explicitly requested dtype {}{} is not available. To enable more \"\n           \"dtypes, set the jax_enable_x64 or allow_explicit_x64_dtypes \"\n           \"configuration options.\"\n          \"See https://github.com/jax-ml/jax#current-gotchas for more.\")\n    msg = msg.format(dtype, fun_name, canonical_dtype.name)\n    raise ValueError(msg)\n  else:  # WARN\n    msg = (\"Explicitly requested dtype {}{} is not available, \"\n          \"and will be truncated to dtype {}. To enable more dtypes, set the \"\n          \"jax_enable_x64 configuration option or the JAX_ENABLE_X64 shell \"\n          \"environment variable. \"\n          \"See https://github.com/jax-ml/jax#current-gotchas for more.\")\n    msg = msg.format(dtype, fun_name, canonical_dtype.name)\n    warnings.warn(msg, stacklevel=4)\n    return canonical_dtype\n\n\n_types_whose_dtype_should_not_be_canonicalized: tuple[type, ...] = (\n    Array,\n)\n\ndef register_type_whose_dtype_should_not_be_canonicalized(typ: type):\n  global _types_whose_dtype_should_not_be_canonicalized\n  _types_whose_dtype_should_not_be_canonicalized += (typ,)","sourceCodeStart":954,"sourceCodeEnd":990,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/dtypes.py#L954-L990","documentation":"A 64-bit dtype (e.g. np.float64/int64/uint64, or a non-canonical variant) was explicitly requested, but JAX runs with x64 disabled (the default), so the dtype is unavailable. With jax_numpy_dtype_promotion / allow_explicit_x64_dtypes in ERROR mode this raises instead of silently truncating to 32 bits.","triggerScenarios":"Calling jnp.zeros(n, dtype=np.float64) or passing dtype=jnp.int64 when jax_enable_x64=False and explicit-x64 policy is set to 'error' (e.g. via JAX_NUMPY_DTYPE_PROMOTION or allow_explicit_x64_dtypes='error'). Common entry points: jax.numpy.dtype, check_and_canonicalize_user_dtype (dtype= args to lax ops, searchsorted, conv_general_dilated).","commonSituations":"Porting NumPy code that uses float64/int64; running on TPU where 64-bit is undesired; library code that must guarantee no silent truncation setting the ERROR policy; env var JAX_ENABLE_X64 unset on a fresh install.","solutions":["Enable 64-bit: jax.config.update('jax_enable_x64', True) at startup (or set JAX_ENABLE_X64=true before importing JAX)","Or allow explicit 64-bit dtypes only: jax.config.update('allow_explicit_x64_dtypes', 'allow')","Or change the requested dtype to a 32-bit equivalent (np.float32/int32) if 64-bit precision is not required"],"exampleFix":"# before\nimport jax.numpy as jnp\nx = jnp.zeros(10, dtype=jnp.float64)\n\n# after\nimport jax\njax.config.update('jax_enable_x64', True)\nimport jax.numpy as jnp\nx = jnp.zeros(10, dtype=jnp.float64)","handlingStrategy":"validation","validationCode":"import jax\nif not jax.config.jax_enable_x64 and np.dtype(requested).itemsize == 8 and np.dtype(requested).kind in 'iuf':\n    requested = np.dtype(f'{np.dtype(requested).kind}4')  # or enable x64","typeGuard":"def is_x64_dtype(dt) -> bool:\n    import numpy as np\n    return np.dtype(dt).itemsize == 8","tryCatchPattern":"try:\n    arr = jnp.zeros(n, dtype=dt)\nexcept ValueError:\n    jax.config.update('jax_enable_x64', True)\n    arr = jnp.zeros(n, dtype=dt)","preventionTips":["Set jax_enable_x64 once at program start if 64-bit is needed","Standardize on float32/int32 unless precision demands 64-bit","Pin JAX config in a single bootstrap module imported before all others"],"tags":["jax","x64","dtype","configuration"],"backgroundTag":"precision-disabled-by-config","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}