{"record":{"id":"add59746e337dcf9","repo":"sgl-project/sglang","slug":"mamba-max-states-per-path-must-be-1-unlimited","errorCode":null,"errorMessage":"--mamba-max-states-per-path must be -1 (unlimited) or a positive integer, got {cfg.mamba_max_states_per_path}.","messagePattern":"--mamba-max-states-per-path must be -1 \\(unlimited\\) or a positive integer, got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/server_args.py","lineNumber":6752,"sourceCode":"        if cfg.pre_warm_nccl and not (is_cuda() or is_hip() or is_npu()):\n            logger.warning(\n                \"pre_warm_nccl is only applicable for CUDA or HIP hardware or NPU hardware. \"\n                \"Ignoring pre_warm_nccl setting on current hardware.\"\n            )\n            self._declare(\"_handle_nccl_pre_warm\", pre_warm_nccl=False)\n\n    def _handle_grammar_backend(self):\n        cfg = resolving_view(self)\n        if cfg.grammar_backend is None:\n            self._declare(\"_handle_grammar_backend\", grammar_backend=\"xgrammar\")\n\n    def _handle_mamba_backend(self):\n        cfg = resolving_view(self)\n        if cfg.mamba_cache_philox_rounds < 0:\n            raise ValueError(\"--mamba-cache-philox-rounds must be non-negative.\")\n\n        if cfg.mamba_max_states_per_path == 0 or cfg.mamba_max_states_per_path < -1:\n            raise ValueError(\n                \"--mamba-max-states-per-path must be -1 (unlimited) or a positive \"\n                f\"integer, got {cfg.mamba_max_states_per_path}.\"\n            )\n\n        if cfg.enable_mamba_cache_stochastic_rounding:\n            if cfg.mamba_ssm_dtype != \"float16\":\n                raise ValueError(\n                    \"Stochastic rounding for the Mamba SSM cache requires \"\n                    f\"--mamba-ssm-dtype float16, got {cfg.mamba_ssm_dtype!r}. \"\n                    \"Run with --mamba-ssm-dtype float16 or disable \"\n                    \"--enable-mamba-cache-stochastic-rounding.\"\n                )\n            if not is_cuda():\n                raise ValueError(\n                    \"Stochastic rounding for the Mamba SSM cache is only \"\n                    \"supported on NVIDIA CUDA platforms. Disable \"\n                    \"--enable-mamba-cache-stochastic-rounding on this platform.\"\n                )","sourceCodeStart":6734,"sourceCodeEnd":6770,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/server_args.py#L6734-L6770","documentation":"ServerArgs validation raised in _handle_mamba_backend during the resolution pipeline. --mamba-max-states-per-path controls how many Mamba states are retained per request path; the only legal values are -1 (unlimited) or a positive integer. Any value of 0 or below -1 fails fast because it would produce a degenerate/invalid state budget.","triggerScenarios":"Launching the server with --mamba-max-states-per-path 0 or any value < -1 (e.g. -2, -5). The check runs in ServerArgs._handle_mamba_backend via _run_resolution_pipeline, so it fires at argument parsing/startup time before any model loads.","commonSituations":"Typos or scripted configs that pass 0 thinking it means 'unlimited', arithmetic that computes a negative cap, or copying a config from another tool where 0 is the unlimited sentinel.","solutions":["Set --mamba-max-states-per-path -1 for unlimited states","Set it to a positive integer (e.g. 8, 16) to cap states per path","Remove the flag entirely if the default value is acceptable"],"exampleFix":"# before\npython -m sglang.launch_server --mamba-max-states-per-path 0\n# after\npython -m sglang.launch_server --mamba-max-states-per-path -1","handlingStrategy":"validation","validationCode":"v = args.mamba_max_states_per_path\nassert v == -1 or v > 0, f\"mamba_max_states_per_path must be -1 or positive, got {v}\"","typeGuard":"null","tryCatchPattern":null,"preventionTips":["Treat -1 as the only 'unlimited' sentinel for this flag, never 0","Validate all numeric server args in your launch script before spawning the server"],"tags":["sglang","mamba","server-args","validation","startup"],"backgroundTag":"invalid-cli-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}