{"record":{"id":"9f25f6e3dea7b44a","repo":"sgl-project/sglang","slug":"kv-cache-quant-config-must-be-qvgkvquantargs-or-a","errorCode":null,"errorMessage":"kv_cache_quant_config must be QVGKVQuantArgs or a dict","messagePattern":"kv_cache_quant_config must be QVGKVQuantArgs or a dict","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/server_args/server_args.py","lineNumber":3116,"sourceCode":"            if attr == \"_explicit_arg_names\":\n                continue\n            elif attr == \"pipeline_config\":\n                pipeline_config = PipelineConfig.from_kwargs(kwargs)\n                logger.debug(f\"Using PipelineConfig: {type(pipeline_config)}\")\n                server_args_kwargs[\"pipeline_config\"] = pipeline_config\n            elif attr == \"nunchaku_config\":\n                nunchaku_config = NunchakuSVDQuantArgs.from_dict(kwargs)\n                server_args_kwargs[\"nunchaku_config\"] = nunchaku_config\n            elif attr == \"kv_cache_quant_config\":\n                kv_quant_config = kwargs.get(\"kv_cache_quant_config\")\n                if kv_quant_config is None:\n                    kv_quant_config = QVGKVQuantArgs.from_dict(kwargs)\n                elif isinstance(kv_quant_config, dict):\n                    kv_quant_config = QVGKVQuantArgs(**kv_quant_config).validate()\n                elif isinstance(kv_quant_config, QVGKVQuantArgs):\n                    kv_quant_config.validate()\n                else:\n                    raise TypeError(\n                        \"kv_cache_quant_config must be QVGKVQuantArgs or a dict\"\n                    )\n                server_args_kwargs[\"kv_cache_quant_config\"] = kv_quant_config\n            elif attr in kwargs:\n                server_args_kwargs[attr] = kwargs[attr]\n\n        return cls(**server_args_kwargs)\n\n    @staticmethod\n    def _reject_retired_args(kwargs: dict[str, Any]) -> None:\n        retired_args = {\n            \"decoder_tp\": \"decoder_sp for decoder/VAE parallel decode\",\n            \"warmup\": \"warmup_mode=request or warmup_mode=off\",\n            \"server_warmup\": \"warmup_mode=server or warmup_mode=off\",\n        }\n        removed = [name for name in retired_args if name in kwargs]\n        if removed:\n            replacements = \"; \".join(","sourceCodeStart":3098,"sourceCodeEnd":3134,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/server_args/server_args.py#L3098-L3134","documentation":"TypeError from ServerArgs.from_dict when the kv_cache_quant_config field is present but is neither a QVGKVQuantArgs instance nor a dict. The constructor accepts an object, a dict of kwargs, or the internal path via QVGKVQuantArgs.from_dict; anything else (string, list, None-with-flag, etc.) is rejected.","triggerScenarios":"Passing kv_cache_quant_config as a JSON string from a config file, a list of settings, or an already-validated object of the wrong type; also passing a nested dict under the wrong key so it lands as a foreign type.","commonSituations":"YAML/JSON config files where quantization settings were written as a string or list; programmatic ServerArgs(**kwargs) built by generic config loaders that keep raw JSON types; version changes that switched the field from string id to structured args.","solutions":["Pass a plain dict of QVGKVQuantArgs fields and let from_dict construct/validate it.","If you have the structured object already, ensure it is actually QVGKVQuantArgs (not a look-alike dataclass from another module version).","If the value comes from JSON as a string, json.loads it first or restructure the config as a mapping."],"exampleFix":"# before\n{\"kv_cache_quant_config\": \"{\\\"method\\\": \\\"awq\\\"}\"}\n# after\n{\"kv_cache_quant_config\": {\"method\": \"awq\"}}","handlingStrategy":"type-guard","validationCode":"from sglang.multimodal_gen.runtime.server_args.server_args import QVGKVQuantArgs\ncfg = raw.get(\"kv_cache_quant_config\")\nassert cfg is None or isinstance(cfg, (dict, QVGKVQuantArgs)), type(cfg)","typeGuard":"def is_kv_quant_config(v) -> bool:\n    from sglang.multimodal_gen.runtime.server_args.server_args import QVGKVQuantArgs\n    return v is None or isinstance(v, (dict, QVGKVQuantArgs))","tryCatchPattern":"try:\n    args = ServerArgs.from_dict(d)\nexcept TypeError as e:\n    if \"kv_cache_quant_config\" in str(e):\n        d[\"kv_cache_quant_config\"] = dict(d[\"kv_cache_quant_config\"])\n        args = ServerArgs.from_dict(d)\n    else:\n        raise","preventionTips":["Keep quant config as a plain dict in files.","Validate loaded JSON types before passing to from_dict.","json.loads strings before nesting them."],"tags":["configuration","type-validation","quantization","kv-cache"],"backgroundTag":"config-type-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}