{"record":{"id":"3b2d1092b98bb461","repo":"sgl-project/sglang","slug":"cuda-graph-config-phase-backend-backend-r-n","errorCode":null,"errorMessage":"--cuda-graph-config[{phase}].backend={backend!r} not allowed; allowed: {ALLOWED_BACKENDS_PER_PHASE[phase]}","messagePattern":"--cuda-graph-config\\[(.+?)\\]\\.backend=(.+?) not allowed; allowed: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/server_args.py","lineNumber":5220,"sourceCode":"            \"FlashAttention fallback that regresses prefill). Set the prefill cuda graph \"\n            \"backend explicitly (e.g. --cuda-graph-backend-prefill tc_piecewise) to override.\",\n            cfg.cuda_graph_config.prefill.backend,\n        )\n        self._declare(\n            \"_disable_prefill_cuda_graph_for_deepseek_trtllm_mla\",\n            cuda_graph_config=with_phase(\n                cfg.cuda_graph_config, Phase.PREFILL, backend=Backend.DISABLED\n            ),\n        )\n\n    def _validate_cuda_graph_config(self):\n        cfg = resolving_view(self)\n        if cfg.cuda_graph_config is None:\n            return\n        for phase in Phase.ALL:\n            backend = getattr(cfg.cuda_graph_config, phase).backend\n            if backend not in ALLOWED_BACKENDS_PER_PHASE[phase]:\n                raise ValueError(\n                    f\"--cuda-graph-config[{phase}].backend={backend!r} not allowed; \"\n                    f\"allowed: {ALLOWED_BACKENDS_PER_PHASE[phase]}\"\n                )\n\n    def _handle_multi_item_scoring(self):\n        \"\"\"Setup and validate multi-item scoring constraints.\n\n        Auto-disables settings incompatible with MIS mechanics (CUDA graph,\n        radix cache, chunked prefill). Asserts on attention backend since\n        changing it silently could surprise users who intentionally picked\n        a non-flashinfer backend.\n        \"\"\"\n        cfg = resolving_view(self)\n        if not cfg.enable_mis:\n            return\n\n        if cfg.cuda_graph_config.decode.backend != Backend.DISABLED:\n            logger.warning(\"CUDA graph is disabled because --enable-mis is set.\")","sourceCodeStart":5202,"sourceCodeEnd":5238,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/server_args.py#L5202-L5238","documentation":"Each CUDA graph phase (e.g. prefill/decode) in --cuda-graph-config only permits a fixed set of graph backends (ALLOWED_BACKENDS_PER_PHASE). Passing a backend name not in that phase's allowlist raises this error during config validation.","triggerScenarios":"Setting --cuda-graph-config with a backend (e.g. 'piecewise' or 'full') that is not allowed for the given phase, or misspelling a backend name.","commonSituations":"Copy-pasting a decode-phase config into the prefill phase, version upgrades that renamed/removed backends, or typos in the JSON/YAML config.","solutions":["Check ALLOWED_BACKENDS_PER_PHASE[phase] in python/sglang/srt/server_args.py and use one of those exact names","Use the default backend per phase by omitting the backend field","Re-check config examples for your SGLang version after upgrading"],"exampleFix":"# before\n--cuda-graph-config '{\"prefill\": {\"backend\": \"full\"}}'\n# after\n--cuda-graph-config '{\"prefill\": {\"backend\": \"<allowed prefill backend>\"}}'","handlingStrategy":"validation","validationCode":"from sglang.srt.server_args import ALLOWED_BACKENDS_PER_PHASE\nfor phase in Phase.ALL:\n    backend = cfg[phase][\"backend\"]\n    assert backend in ALLOWED_BACKENDS_PER_PHASE[phase], f\"{phase}: {backend} not allowed\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit the backend field to take the per-phase default instead of hardcoding a name","Re-validate cuda-graph configs after upgrading SGLang since allowlists change"],"tags":["cuda-graph","config-validation","backend-selection"],"backgroundTag":"invalid-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}