{"record":{"id":"417647aaf91035c0","repo":"sgl-project/sglang","slug":"could-not-parse-attention-backend-config-config","errorCode":null,"errorMessage":"Could not parse attention backend config: {config_str}","messagePattern":"Could not parse attention backend config: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/server_args/server_args.py","lineNumber":1724,"sourceCode":"\n        # 3. treat as k=v pairs (simple implementation). e.g., \"sparsity=0.5,enable_x=true\"\n        try:\n            config = {}\n            pairs = config_str.split(\",\")\n            for pair in pairs:\n                k, v = pair.split(\"=\", 1)\n                k = k.strip()\n                v = v.strip()\n                if v.lower() == \"true\":\n                    v = True\n                elif v.lower() == \"false\":\n                    v = False\n                elif v.replace(\".\", \"\", 1).isdigit():\n                    v = float(v) if \".\" in v else int(v)\n                config[k] = v\n            return config\n        except Exception:\n            raise ValueError(f\"Could not parse attention backend config: {config_str}\")\n\n    def __post_init__(self):\n        # configure logger before use\n        configure_logger(server_args=self)\n\n        component_paths: dict[str, str] = {}\n        component_weights_paths = dict(self.component_weights_paths)\n        for component, path in self.component_paths.items():\n            supports_weight_file_override = (\n                is_dit_component_name(component)\n                or is_text_encoder_component_name(component)\n                or is_image_encoder_component_name(component)\n                or is_vae_component_name(component)\n            )\n            if (\n                not supports_weight_file_override\n                or not is_explicit_weight_file_reference(path)\n            ):","sourceCodeStart":1706,"sourceCodeEnd":1742,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/server_args/server_args.py#L1706-L1742","documentation":"The attention-backend config string (e.g. --attention-backend flash:kv_cache_dtype=fp8,...) is parsed key-by-key into bool/int/float/str. If any part of parsing or value coercion throws, the generic 'Could not parse attention backend config' error wraps it, discarding the underlying cause.","triggerScenarios":"Passing malformed syntax like 'flash:kv_cache_dtype=' or 'flash:flag==true', or an unterminated JSON-ish fragment; any non-numeric, non-bool, non-str token that breaks the coercion ladder.","commonSituations":"Hand-writing backend override strings; shell quoting mangling colons/commas; version changes in the accepted config grammar.","solutions":["Simplify the config string to confirm the backend name alone parses, then add one key=value at a time to find the bad token","Match the documented 'name:key=value,key=value' grammar exactly, quoting the whole flag in shell","Check for stray characters from shell expansion (unquoted colons/commas)"],"exampleFix":"# before\n--attention-backend 'flash:kv_cache_dtype==fp8'\n# after\n--attention-backend 'flash:kv_cache_dtype=fp8'","handlingStrategy":"try-catch","validationCode":"def validate_backend_config(s: str) -> bool:\n    try:\n        name, _, rest = s.partition(':')\n        return bool(name) and all('=' in kv for kv in rest.split(',') if kv)\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    parsed = ServerArgs._parse_attention_backend_config(cfg)\nexcept ValueError:\n    logger.warning('bad attention backend config %r; using default', cfg)\n    parsed = {}","preventionTips":["Quote the whole flag in shell","Build config strings programmatically","Add one option at a time when debugging"],"tags":["config","attention-backend","parsing"],"backgroundTag":"config-parse-error","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}