{"record":{"id":"377813c377dbe19d","repo":"sgl-project/sglang","slug":"expected-a-flat-quantization-config-dict-in-the-mo","errorCode":null,"errorMessage":"Expected a flat quantization_config dict in the ModelOpt export.","messagePattern":"Expected a flat quantization_config dict in the ModelOpt export\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/tools/build_modelopt_fp8_transformer.py","lineNumber":566,"sourceCode":"    modelopt_hf_dir: str,\n    modelopt_backbone_ckpt: str,\n    output_dir: str,\n    base_transformer_dir: str | None = None,\n    model_type: str = \"auto\",\n    keep_bf16_patterns: Sequence[str] | None = None,\n    maxbound: float = FP8_E4M3_MAXBOUND,\n    overwrite: bool = False,\n) -> dict[str, int]:\n    source_dir = _resolve_transformer_dir(modelopt_hf_dir)\n    backbone_ckpt_path = _resolve_backbone_ckpt(modelopt_backbone_ckpt)\n    base_dir = (\n        _resolve_transformer_dir(base_transformer_dir) if base_transformer_dir else None\n    )\n\n    config = _load_config(source_dir)\n    quant_config = config.get(\"quantization_config\")\n    if not isinstance(quant_config, dict):\n        raise ValueError(\n            \"Expected a flat quantization_config dict in the ModelOpt export.\"\n        )\n    if quant_config.get(\"quant_method\") != \"modelopt\":\n        raise ValueError(\n            \"This tool only supports ModelOpt diffusers FP8 exports \"\n            \"(quant_method=modelopt).\"\n        )\n\n    source_weight_map_all, index_filename = _load_weight_map(source_dir)\n    source_metadata = _load_first_shard_metadata(source_dir, source_weight_map_all)\n    is_ltx2_export = _is_ltx2_x0_export(\n        config=config,\n        source_metadata=source_metadata,\n        source_weight_map=source_weight_map_all,\n    )\n    class_name = config.get(\"_class_name\")\n    runtime_name_mapper = _get_runtime_module_name_mapper(\n        model_type=model_type, class_name=class_name","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/tools/build_modelopt_fp8_transformer.py#L548-L584","documentation":"The tool reads config.json from the source dir and requires quantization_config to be a flat dict; it is missing or not a dict (e.g. null, a list, or nested structure).","triggerScenarios":"Running the builder on an export whose config.json lacks quantization_config, or where it was written as a non-dict value.","commonSituations":"Pointing at a plain BF16 export instead of a ModelOpt FP8 export; config.json edited or generated by a tool that dropped the section.","solutions":["Confirm you are pointing at a ModelOpt-quantized export","Re-run ModelOpt quantization so config.json contains quantization_config","If hand-editing config.json, restore the quantization_config dict"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"import json\nqc = json.load(open(cfg_path)).get(\"quantization_config\")\nassert isinstance(qc, dict), \"not a ModelOpt FP8 export\"","typeGuard":"def is_modelopt_export(cfg: dict) -> bool:\n    qc = cfg.get(\"quantization_config\")\n    return isinstance(qc, dict) and qc.get(\"quant_method\") == \"modelopt\"","tryCatchPattern":null,"preventionTips":["Check config.json for quantization_config before running conversion tools","Label/artifact-tag quantized vs bf16 exports to avoid mixups"],"tags":["modelopt","fp8","config"],"backgroundTag":"missing-config-key","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}