sgl-project/sglang · error · ValueError
--mamba-cache-philox-rounds must be non-negative.
Error message
--mamba-cache-philox-rounds must be non-negative.
What it means
--mamba-cache-philox-rounds controls Philox RNG rounds used when initializing/dropping Mamba (hybrid linear-attention) cache states; negative values are meaningless and rejected outright by the _handle_mamba_backend resolution step (0 is allowed, only < 0 raises).
Source
Thrown at python/sglang/srt/server_args.py:6749
def _handle_nccl_pre_warm(self):
# pre_warm_nccl is only used with CUDA or HIP hardware or NPU hardware
cfg = resolving_view(self)
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 "View on GitHub (pinned to 0132848349)
Solutions
- Set --mamba-cache-philox-rounds to 0 (default/off) or a positive round count
- Audit launch scripts/env templates that coerce unset values to -1
- If you meant unlimited states, use --mamba-max-states-per-path, not philox-rounds
Example fix
# before python -m sglang.launch_server --model M --mamba-cache-philox-rounds -1 # after python -m sglang.launch_server --model M --mamba-cache-philox-rounds 0
Defensive patterns
Strategy: validation
Validate before calling
if getattr(args, "mamba_cache_philox_rounds", 0) is not None:
rounds = args.mamba_cache_philox_rounds or 0
assert rounds >= 0, "--mamba-cache-philox-rounds must be non-negative" Try / catch
try:
ServerArgs(**kwargs)
except ValueError as e:
if "philox" in str(e):
kwargs["mamba_cache_philox_rounds"] = 0
ServerArgs(**kwargs)
else:
raise Prevention
- Don't use -1 as an 'unset' sentinel for numeric CLI flags; use None/omit
- Remember only --mamba-max-states-per-path accepts -1; philox-rounds accepts 0+
- Validate Mamba-related ints in a shared config sanitizer before launch
When it happens
Trigger: Passing a negative integer to --mamba-cache-philox-rounds (e.g. --mamba-cache-philox-rounds -1) so that cfg.mamba_cache_philox_rounds < 0 when the mamba backend handler runs.
Common situations: Typos or env-var templating producing -1; users assuming -1 means 'unlimited/default' like the sibling flag --mamba-max-states-per-path which does accept -1; scripts defaulting unset numeric flags to -1.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- --speculative-draft-window-size must be positive, got {}.
- Quantization method specified in the model config ({quant_me
- routed_dp_rank={routed_dp_rank} out of range [0, {dp_size})
- Invalid forward mode: {forward_batch.forward_mode=}
- Mamba2AttnBackend's forward is called directly instead of th
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/118487f605af26bb.
Report an issue: GitHub.