{"record":{"id":"118487f605af26bb","repo":"sgl-project/sglang","slug":"mamba-cache-philox-rounds-must-be-non-negative","errorCode":null,"errorMessage":"--mamba-cache-philox-rounds must be non-negative.","messagePattern":"--mamba-cache-philox-rounds must be non-negative\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/server_args.py","lineNumber":6749,"sourceCode":"    def _handle_nccl_pre_warm(self):\n        # pre_warm_nccl is only used with CUDA or HIP hardware or NPU hardware\n        cfg = resolving_view(self)\n        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 \"","sourceCodeStart":6731,"sourceCodeEnd":6767,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/server_args.py#L6731-L6767","documentation":"--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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\npython -m sglang.launch_server --model M --mamba-cache-philox-rounds -1\n# after\npython -m sglang.launch_server --model M --mamba-cache-philox-rounds 0","handlingStrategy":"validation","validationCode":"if getattr(args, \"mamba_cache_philox_rounds\", 0) is not None:\n    rounds = args.mamba_cache_philox_rounds or 0\n    assert rounds >= 0, \"--mamba-cache-philox-rounds must be non-negative\"","typeGuard":null,"tryCatchPattern":"try:\n    ServerArgs(**kwargs)\nexcept ValueError as e:\n    if \"philox\" in str(e):\n        kwargs[\"mamba_cache_philox_rounds\"] = 0\n        ServerArgs(**kwargs)\n    else:\n        raise","preventionTips":["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"],"tags":["sglang","mamba","argument-validation","philox","cli-args"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}