{"record":{"id":"935482d4e5c75d13","repo":"sgl-project/sglang","slug":"quanto-quantization-map-entries-must-be-named-obje","errorCode":null,"errorMessage":"Quanto quantization map entries must be named objects","messagePattern":"Quanto quantization map entries must be named objects","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/layers/quantization/configs/quanto_int8_config.py","lineNumber":108,"sourceCode":"        if metadata.get(\"quantization_format\") != \"quanto\":\n            return None\n\n        encoded_map = metadata.get(\"quantization_map_base64\")\n        if encoded_map is None:\n            raise ValueError(\"Quanto checkpoint is missing quantization_map_base64\")\n        try:\n            quantization_map = json.loads(\n                base64.b64decode(encoded_map, validate=True).decode(\"utf-8\")\n            )\n        except (ValueError, UnicodeDecodeError, json.JSONDecodeError) as error:\n            raise ValueError(\"Invalid Quanto quantization_map_base64\") from error\n        if not isinstance(quantization_map, dict) or not quantization_map:\n            raise ValueError(\"Quanto quantization map must be a non-empty object\")\n        if not all(\n            isinstance(prefix, str) and isinstance(spec, dict)\n            for prefix, spec in quantization_map.items()\n        ):\n            raise ValueError(\"Quanto quantization map entries must be named objects\")\n\n        checkpoint_keys = set(checkpoint.keys())\n        data_suffix = \".weight._data\"\n        data_prefixes = {\n            name.removesuffix(data_suffix)\n            for name in checkpoint_keys\n            if name.endswith(data_suffix)\n        }\n        map_prefixes = set(quantization_map)\n        if data_prefixes != map_prefixes:\n            missing_map = data_prefixes - map_prefixes\n            missing_data = map_prefixes - data_prefixes\n            raise ValueError(\n                \"Quanto tensor/map prefixes do not match: \"\n                f\"missing metadata={sorted(missing_map)[:5]}, \"\n                f\"missing tensors={sorted(missing_data)[:5]}\"\n            )\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/layers/quantization/configs/quanto_int8_config.py#L90-L126","documentation":"Every entry in the decoded quantization map must be a JSON object keyed by a string layer prefix with a dict value (the layer's quantization spec). Any non-string key or non-dict value (e.g. a string, list, or number) fails this check.","triggerScenarios":"A map like {\"encoder.fc1\": \"int8\"} (value is a string instead of a spec dict) or {\"0\": [\"int8\"]}; malformed maps from custom exporters that use shorthand values.","commonSituations":"Hand-written or converted maps using abbreviated layer specs; exporters that store the dtype string directly instead of a spec object like {\"weights\": \"int8\", \"activation\": null}.","solutions":["Normalize each entry to {prefix: {\"weights\": \"int8\"}} style spec dicts","Validate your map with the same check (str key + dict value) before serializing"],"exampleFix":"# before\n{\"encoder.fc1\": \"int8\"}\n\n# after\n{\"encoder.fc1\": {\"weights\": \"int8\", \"activation\": null}}","handlingStrategy":"validation","validationCode":"ok = isinstance(qmap, dict) and qmap and all(\n    isinstance(k, str) and isinstance(v, dict) for k, v in qmap.items()\n)\nif not ok:\n    raise RuntimeError(\"malformed quantization map; expected {prefix: spec_dict}\")","typeGuard":"def is_wellformed_quant_map(m: object) -> bool:\n    return isinstance(m, dict) and bool(m) and all(\n        isinstance(k, str) and isinstance(v, dict) for k, v in m.items()\n    )","tryCatchPattern":null,"preventionTips":["Use spec dicts like {\"weights\": \"int8\"}, never bare strings","Validate map schema with the same all() check before base64-encoding"],"tags":["quantization","quanto","json-validation","checkpoint-metadata"],"backgroundTag":"schema-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}