{"record":{"id":"c1bc73dda7d2cb86","repo":"keras-team/keras","slug":"cycle-detected-in-type-promotion-lattice-for-node","errorCode":null,"errorMessage":"cycle detected in type promotion lattice for node {n}","messagePattern":"cycle detected in type promotion lattice for node (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/common/dtypes.py","lineNumber":102,"sourceCode":"        f2: [f4],\n        f4: [f8, c64],\n        f8: [c128],\n        c64: [c128],\n        c128: [],\n    }\n    return out\n\n\ndef _make_lattice_upper_bounds():\n    lattice = _type_promotion_lattice()\n    upper_bounds = {node: {node} for node in lattice}\n    for n in lattice:\n        while True:\n            new_upper_bounds = set().union(\n                *(lattice[b] for b in upper_bounds[n])\n            )\n            if n in new_upper_bounds:\n                raise ValueError(\n                    f\"cycle detected in type promotion lattice for node {n}\"\n                )\n            if new_upper_bounds.issubset(upper_bounds[n]):\n                break\n            upper_bounds[n] |= new_upper_bounds\n    return upper_bounds\n\n\nLATTICE_UPPER_BOUNDS = _make_lattice_upper_bounds()\n\n\n@functools.lru_cache(512)\ndef _least_upper_bound(*nodes):\n    \"\"\"Compute the least upper bound of a set of nodes.\n\n    Args:\n        nodes: sequence of entries from dtypes + weak_types\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/common/dtypes.py#L84-L120","documentation":"Guard in _make_lattice_upper_bounds: while transitively closing the type-promotion lattice, a node was found among its own upper bounds, meaning the static lattice definition contains a cycle. This is an internal-configuration error in Keras's dtype machinery, not a user-input error.","triggerScenarios":"Thrown at keras/src/backend/common/dtypes.py:102 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["This indicates a bug in Keras's dtype lattice definition or a modified Keras install — report it with the traceback to the Keras maintainers.","As a workaround, reinstall/upgrade Keras to a stock release where the lattice is well-formed.","Avoid monkey-patching backend dtypes or the promotion lattice."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}