{"record":{"id":"352a5b36448d902b","repo":"jax-ml/jax","slug":"input-dtypes-tuple-str-n-for-n-in-nodes-have-n","errorCode":null,"errorMessage":"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.","messagePattern":"Input dtypes (.+?) have no available implicit dtype promotion path\\. Try explicitly casting inputs to the desired output type\\.","errorType":"validation","errorClass":"TypePromotionError","httpStatus":null,"severity":"error","filePath":"jax/_src/dtypes.py","lineNumber":871,"sourceCode":"    elif any(n in _float4_dtypes for n in nodes):\n      msg = (\n        f\"Input dtypes {tuple(str(n) for n in nodes)} have no available implicit dtype \"\n        \"promotion path. To avoid unintended promotion, 4-bit floats do not support \"\n        \"implicit promotion. If you'd like your inputs to be promoted to another type, \"\n        \"you can do so explicitly using e.g. x.astype('float32')\")\n    elif any(n in _intn_dtypes for n in nodes):\n      msg = (\n          f'Input dtypes {tuple(str(n) for n in nodes)} have no available'\n          ' implicit dtype promotion path. To avoid unintended promotion,'\n          ' 1-bit, 2-bit and 4-bit integers do not support implicit promotion.'\n          \" If you'd like your inputs to be promoted to another type, you can\"\n          \" do so explicitly using e.g. x.astype('int32')\"\n      )\n    else:\n      msg = (\n        f\"Input dtypes {tuple(str(n) for n in nodes)} have no available implicit dtype \"\n        \"promotion path. Try explicitly casting inputs to the desired output type.\")\n    raise TypePromotionError(msg)\n  else:\n    # If we get here, it means the lattice is ill-formed.\n    raise TypePromotionError(\n      f\"Internal Type Promotion error: {nodes} do not have a unique least upper bound \"\n      f\"on the specified lattice; options are {LUB}. This is an unexpected error in \"\n      \"JAX's internal logic; please report it to the JAX maintainers.\"\n    )\n\n@set_module('jax.numpy')\ndef promote_types(a: DTypeLike, b: DTypeLike) -> DType:\n  \"\"\"Returns the type to which a binary operation should cast its arguments.\n\n  JAX implementation of :func:`numpy.promote_types`. For details of JAX's\n  type promotion semantics, see :ref:`type-promotion`.\n\n  Args:\n    a: a :class:`numpy.dtype` or a dtype specifier.\n    b: a :class:`numpy.dtype` or a dtype specifier.","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/dtypes.py#L853-L889","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nc = a_uint32 + b_int32\n\n# after\nc = a_uint32.astype(jnp.int64) + b_int32.astype(jnp.int64)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from jax._src.dtypes import TypePromotionError\ntry:\n    out = a + b\nexcept TypePromotionError:\n    target = jnp.result_type(a)  # pick explicit target\n    out = a.astype(target) + b.astype(target)","preventionTips":["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"],"tags":["jax","type-promotion","casting","dtype"],"backgroundTag":"dtype-promotion-failure","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}