{"record":{"id":"3472ba4bee7ddab0","repo":"sgl-project/sglang","slug":"quanto-quantization-map-must-be-a-non-empty-object","errorCode":null,"errorMessage":"Quanto quantization map must be a non-empty object","messagePattern":"Quanto quantization map must be a non-empty object","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/layers/quantization/configs/quanto_int8_config.py","lineNumber":103,"sourceCode":") -> QuantoInt8Config | None:\n    \"\"\"Validate a self-describing Quanto qint8 safetensors checkpoint.\"\"\"\n\n    with safe_open(file_path, framework=\"pt\", device=\"cpu\") as checkpoint:\n        metadata = checkpoint.metadata() or {}\n        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(","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/layers/quantization/configs/quanto_int8_config.py#L85-L121","documentation":"After decoding, the quantization map must be a non-empty JSON object mapping layer prefixes to their quantization spec. An empty object, list, string, or null raises this error.","triggerScenarios":"quantization_map_base64 decodes to '[]', '\"\"', '{}', or 'null' — e.g. an empty dict was serialized when no layers were quantized, yet quantization_format was still set to 'quanto'.","commonSituations":"Exporting a model where quantization was skipped/no layers selected; a bug in the exporter serializing an uninitialized map.","solutions":["If nothing is quantized, remove the 'quantization_format': 'quanto' metadata instead of shipping an empty map","Re-export ensuring the map contains at least one entry: {prefix: {\"weights\": \"int8\", ...}}"],"exampleFix":"# before (empty map)\nmap_b64 = base64.b64encode(json.dumps({}).encode()).decode()\n\n# after\nmap_b64 = base64.b64encode(json.dumps({\"encoder.fc1\": {\"weights\": \"int8\"}}).encode()).decode()","handlingStrategy":"validation","validationCode":"qmap = json.loads(base64.b64decode(meta[\"quantization_map_base64\"]).decode())\nif not isinstance(qmap, dict) or not qmap:\n    meta.pop(\"quantization_format\", None)  # treat as unquantized\n    meta.pop(\"quantization_map_base64\", None)","typeGuard":"def is_non_empty_quant_map(m: object) -> bool:\n    return isinstance(m, dict) and len(m) > 0","tryCatchPattern":null,"preventionTips":["Skip quanto metadata entirely for unquantized exports","Assert map non-empty in the exporter before serializing"],"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"}