{"record":{"id":"73697485e803c8d0","repo":"keras-team/keras","slug":"dtype-is-not-a-valid-dtype-for-keras-type-promo","errorCode":null,"errorMessage":"{dtype=} is not a valid dtype for Keras type promotion.","messagePattern":"(.+?) is not a valid dtype for Keras type promotion\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/common/dtypes.py","lineNumber":151,"sourceCode":"    #   LUB(N) ≡ {c ∈ CUB(N) | ∀ d ∈ CUB(N), c ≤ d}\n    # The definition of an upper bound implies that\n    #   c ≤ d if and only if d ∈ UB(c),\n    # so the LUB can be expressed:\n    #   LUB(N) = {c ∈ CUB(N) | ∀ d ∈ CUB(N): d ∈ UB(c)}\n    # or, equivalently:\n    #   LUB(N) = {c ∈ CUB(N) | CUB(N) ⊆ UB(c)}\n    # By definition, LUB(N) has a cardinality of 1 for a partially ordered set.\n    # Note a potential algorithmic shortcut: from the definition of CUB(N),\n    # we have\n    #   ∀ c ∈ N: CUB(N) ⊆ UB(c)\n    # So if N ∩ CUB(N) is nonempty, if follows that LUB(N) = N ∩ CUB(N).\n    N = set(nodes)\n    UB = LATTICE_UPPER_BOUNDS\n    try:\n        bounds = [UB[n] for n in N]\n    except KeyError:\n        dtype = next(n for n in N if n not in UB)\n        raise ValueError(\n            f\"{dtype=} is not a valid dtype for Keras type promotion.\"\n        )\n    CUB = set.intersection(*bounds)\n    LUB = (CUB & N) or {c for c in CUB if CUB.issubset(UB[c])}\n    if len(LUB) == 1:\n        return LUB.pop()\n    elif len(LUB) == 0:\n        msg = (\n            f\"Input dtypes {tuple(str(n) for n in nodes)} have no available \"\n            \"implicit dtype promotion path. Try explicitly casting inputs to \"\n            \"the desired output type.\"\n        )\n        raise ValueError(msg)\n    else:\n        # If we get here, it means the lattice is ill-formed.\n        raise ValueError(\n            f\"Internal Type Promotion error: {nodes} do not have a unique \"\n            f\"least upper bound on the specified lattice; options are {LUB}. \"","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/common/dtypes.py#L133-L169","documentation":"Error \"{dtype=} is not a valid dtype for Keras type promotion.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/common/dtypes.py:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}