sgl-project/sglang · error · ValueError
--mamba-max-states-per-path must be -1 (unlimited) or a posi
Error message
--mamba-max-states-per-path must be -1 (unlimited) or a positive integer, got {cfg.mamba_max_states_per_path}. What it means
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.
Source
Thrown at python/sglang/srt/server_args.py:6752
if cfg.pre_warm_nccl and not (is_cuda() or is_hip() or is_npu()):
logger.warning(
"pre_warm_nccl is only applicable for CUDA or HIP hardware or NPU hardware. "
"Ignoring pre_warm_nccl setting on current hardware."
)
self._declare("_handle_nccl_pre_warm", pre_warm_nccl=False)
def _handle_grammar_backend(self):
cfg = resolving_view(self)
if cfg.grammar_backend is None:
self._declare("_handle_grammar_backend", grammar_backend="xgrammar")
def _handle_mamba_backend(self):
cfg = resolving_view(self)
if cfg.mamba_cache_philox_rounds < 0:
raise ValueError("--mamba-cache-philox-rounds must be non-negative.")
if cfg.mamba_max_states_per_path == 0 or cfg.mamba_max_states_per_path < -1:
raise ValueError(
"--mamba-max-states-per-path must be -1 (unlimited) or a positive "
f"integer, got {cfg.mamba_max_states_per_path}."
)
if cfg.enable_mamba_cache_stochastic_rounding:
if cfg.mamba_ssm_dtype != "float16":
raise ValueError(
"Stochastic rounding for the Mamba SSM cache requires "
f"--mamba-ssm-dtype float16, got {cfg.mamba_ssm_dtype!r}. "
"Run with --mamba-ssm-dtype float16 or disable "
"--enable-mamba-cache-stochastic-rounding."
)
if not is_cuda():
raise ValueError(
"Stochastic rounding for the Mamba SSM cache is only "
"supported on NVIDIA CUDA platforms. Disable "
"--enable-mamba-cache-stochastic-rounding on this platform."
)View on GitHub (pinned to 0132848349)
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
Example fix
# before python -m sglang.launch_server --mamba-max-states-per-path 0 # after python -m sglang.launch_server --mamba-max-states-per-path -1
Defensive patterns
Strategy: validation
Validate before calling
v = args.mamba_max_states_per_path
assert v == -1 or v > 0, f"mamba_max_states_per_path must be -1 or positive, got {v}" Type guard
null
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Decode context parallel size (--dcp-size / --decode-context-
- Stochastic rounding for the Mamba SSM cache requires --mamba
- Stochastic rounding for the Mamba SSM cache is only supporte
- --enable-int8-mamba-checkpoint is not supported together wit
- --enable-int8-mamba-checkpoint only supports the built-in ma
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/add59746e337dcf9.
Report an issue: GitHub.