keras-team/keras · error · ValueError

Input dtypes have no available implicit dtype promotion…

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

Raised by the type-promotion resolver when the common upper bounds of the input dtypes have no least element — the dtypes sit on lattice branches with no shared implicit promotion target. Typical case: mixing floats/ints with complex or bool in ways numpy-style promotion forbids; the fix is an explicit cast.

Solutions

  1. Explicitly cast one input to the desired output dtype with keras.ops.cast before the operation.
  2. Avoid mixing incompatible kinds (e.g. complex with non-complex, or bool with numeric) and rely on implicit promotion.
  3. Standardize tensor dtypes at model input time (e.g. cast both to float32).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at keras/src/backend/common/dtypes.py:164 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/d0d62fa320f06736. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/backend/common/dtypes.py:164

    UB = LATTICE_UPPER_BOUNDS
    try:
        bounds = [UB[n] for n in N]
    except KeyError:
        dtype = next(n for n in N if n not in UB)
        raise ValueError(
            f"{dtype=} is not a valid dtype for Keras type promotion."
        )
    CUB = set.intersection(*bounds)
    LUB = (CUB & N) or {c for c in CUB if CUB.issubset(UB[c])}
    if len(LUB) == 1:
        return LUB.pop()
    elif len(LUB) == 0:
        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 ValueError(msg)
    else:
        # If we get here, it means the lattice is ill-formed.
        raise ValueError(
            f"Internal Type Promotion error: {nodes} do not have a unique "
            f"least upper bound on the specified lattice; options are {LUB}. "
            "This is an unexpected error in Keras's internal logic; "
            "please report it to the maintainers."
        )


def _dtype_and_weaktype(value):
    """Return a (dtype, weak_type) tuple for the given input."""
    is_weak_type = False
    if value is int or value is float:
        # Note that we can't use `value in [int, float]` because the dtype
        # might be equal to python scalar types.
        # e.g, tf.float32 == float is True
        is_weak_type = True

View on GitHub (pinned to 7a34a03db6)