keras-team/keras · error · ValueError

cycle detected in type promotion lattice for node {n}

Error message

cycle detected in type promotion lattice for node {n}

What it means

Error "cycle detected in type promotion lattice for node {n}" thrown in keras-team/keras.

Source

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

        f2: [f4],
        f4: [f8, c64],
        f8: [c128],
        c64: [c128],
        c128: [],
    }
    return out


def _make_lattice_upper_bounds():
    lattice = _type_promotion_lattice()
    upper_bounds = {node: {node} for node in lattice}
    for n in lattice:
        while True:
            new_upper_bounds = set().union(
                *(lattice[b] for b in upper_bounds[n])
            )
            if n in new_upper_bounds:
                raise ValueError(
                    f"cycle detected in type promotion lattice for node {n}"
                )
            if new_upper_bounds.issubset(upper_bounds[n]):
                break
            upper_bounds[n] |= new_upper_bounds
    return upper_bounds


LATTICE_UPPER_BOUNDS = _make_lattice_upper_bounds()


@functools.lru_cache(512)
def _least_upper_bound(*nodes):
    """Compute the least upper bound of a set of nodes.

    Args:
        nodes: sequence of entries from dtypes + weak_types

View on GitHub (pinned to 7a34a03db6)

When it happens

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