{"record":{"id":"7970bf92534abff8","repo":"sgl-project/sglang","slug":"scalar-type-id-scalar-type-id-doesn-t-exists","errorCode":null,"errorMessage":"scalar_type_id {scalar_type_id} doesn't exists.","messagePattern":"scalar_type_id (.+?) doesn't exists\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/aot/python/sgl_kernel/scalar_type.py","lineNumber":312,"sourceCode":"        cls, exponent: int, mantissa: int, finite_values_only: bool, nan_repr: NanRepr\n    ) -> \"ScalarType\":\n        \"\"\"\n        Create a non-standard floating point type\n        (i.e. does not follow IEEE 754 conventions).\n        \"\"\"\n        assert mantissa > 0 and exponent > 0\n        assert nan_repr != NanRepr.IEEE_754, (\n            \"use `float_IEEE754` constructor for floating point types that \"\n            \"follow IEEE 754 conventions\"\n        )\n        ret = cls(exponent, mantissa, True, 0, finite_values_only, nan_repr)\n        ret.id  # noqa B018: make sure the id is cached\n        return ret\n\n    @classmethod\n    def from_id(cls, scalar_type_id: int):\n        if scalar_type_id not in _SCALAR_TYPES_ID_MAP:\n            raise ValueError(f\"scalar_type_id {scalar_type_id} doesn't exists.\")\n        return _SCALAR_TYPES_ID_MAP[scalar_type_id]\n\n\n# naming generally follows: https://github.com/jax-ml/ml_dtypes\n# for floating point types (leading f) the scheme is:\n#  `float<size_bits>_e<exponent_bits>m<mantissa_bits>[flags]`\n#  flags:\n#  - no-flags: means it follows IEEE 754 conventions\n#  - f: means finite values only (no infinities)\n#  - n: means nans are supported (non-standard encoding)\n# for integer types the scheme is:\n#  `[u]int<size_bits>[b<bias>]`\n#  - if bias is not present it means its zero\n\n\nclass scalar_types:\n    int4 = ScalarType.int_(4, None)\n    uint4 = ScalarType.uint(4, None)","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/aot/python/sgl_kernel/scalar_type.py#L294-L330","documentation":"scalar_type.from_id looks up a compressed-integer scalar type (as used by torch.compile / inductor for quantized dtypes) in a static registry keyed by small integer IDs. If the ID is not registered, it raises, since there is no scalar type to construct.","triggerScenarios":"Calling ScalarType.from_id(n) with n not in _SCALAR_TYPES_ID_MAP — e.g. a newly introduced torch scalar type ID, a hand-invented ID, or an ID from a mismatched torch version serialized by newer code.","commonSituations":"Loading quantized torch.compile artifacts or configs produced by a different PyTorch/sgl-kernel version where new scalar types were added; deserializing ids from untrusted/stale sources.","solutions":["Upgrade sgl-kernel (and torch) so the registry knows the ID that was serialized","Regenerate/re-serialize the artifact with the current versions instead of reusing old IDs","Print sorted(_SCALAR_TYPES_ID_MAP) to confirm which IDs are supported before from_id"],"exampleFix":"# before\nt = ScalarType.from_id(some_id)\n# after\nfrom python.sgl_kernel.scalar_type import _SCALAR_TYPES_ID_MAP\nassert some_id in _SCALAR_TYPES_ID_MAP, f'unknown id {some_id}'\nt = ScalarType.from_id(some_id)","handlingStrategy":"type-guard","validationCode":"from sgl_kernel.scalar_type import _SCALAR_TYPES_ID_MAP\nif sid not in _SCALAR_TYPES_ID_MAP: raise KeyError(f'unsupported scalar_type_id {sid}')","typeGuard":"def known_scalar_id(sid): return sid in _SCALAR_TYPES_ID_MAP","tryCatchPattern":null,"preventionTips":["Regenerate serialized artifacts with current versions","Version-check torch/sgl-kernel pairs"],"tags":["scalar-type","registry","version-mismatch","quantization"],"backgroundTag":"unknown-type-id-lookup","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}