keras-team/keras · error · ValueError

There is no implicit conversions from float8 dtypes to…

Error message

There is no implicit conversions from float8 dtypes to others. You must cast it internally. Received: {dtypes}

What it means

Guard in result_type: float8 dtypes (e.g. float8_e4m3fn) appear in the inputs to an implicit dtype-promotion decision. Keras deliberately disallows silent conversion of float8 to any other dtype because the precision loss is unsafe, so any promotion involving them must be an explicit cast.

Solutions

  1. Explicitly cast the float8 tensor to the target dtype with keras.ops.cast(x, 'float32') before mixing it with other dtypes.
  2. Keep float8 tensors in dedicated quantization-aware paths rather than generic ops that promote dtypes.
  3. Convert float8 storage to float16/bfloat16 at model boundaries if wider arithmetic is needed.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at keras/src/backend/common/dtypes.py:318 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/f9ae6b6e3d15dad2. Report an issue: GitHub.

Appendix: source

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

    "bfloat16"

    >>> x = keras.ops.ones((1,), dtype="int32")
    >>> y = keras.ops.ones((1,), dtype="float32")
    >>> keras.backend.result_type(x.dtype, y.dtype)
    "float32"

    >>> z= keras.ops.ones((1,), dtype='complex64')
    >>> keras.backend.result_type(z.dtype, int)
    "float64"

    """
    if len(dtypes) == 0:
        # If no dtypes provided, default to floatx, this matches
        # `ops.convert_to_tensor([])`
        return config.floatx()
    for dtype in dtypes:
        if dtype in FLOAT8_TYPES:
            raise ValueError(
                "There is no implicit conversions from float8 dtypes to others."
                f" You must cast it internally. Received: {dtypes}"
            )
    return _lattice_result_type(
        *(config.floatx() if arg is None else arg for arg in dtypes),
    )

View on GitHub (pinned to 7a34a03db6)