{"record":{"id":"90039eb3a4590daa","repo":"sgl-project/sglang","slug":"kv-canary-req-to-token-pool-size-must-be-positive","errorCode":null,"errorMessage":"kv-canary: req_to_token_pool_size must be positive, got {req_to_token_pool_size}","messagePattern":"kv-canary: req_to_token_pool_size must be positive, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/kv_canary/capacities.py","lineNumber":53,"sourceCode":"    def __post_init__(self) -> None:\n        for name, value in (\n            (\"per_forward_verify_capacity\", self.per_forward_verify_capacity),\n            (\"per_forward_write_req_capacity\", self.per_forward_write_req_capacity),\n            (\"per_forward_write_entry_capacity\", self.per_forward_write_entry_capacity),\n        ):\n            if value <= 0:\n                raise ValueError(f\"kv-canary: {name} must be positive, got {value}\")\n\n    @classmethod\n    def from_args(\n        cls,\n        *,\n        req_to_token_pool_size: int,\n        max_seq_len_per_req: int,\n        pool_slot_count: int,\n    ) -> CanaryLaunchCapacities:\n        if req_to_token_pool_size <= 0:\n            raise ValueError(\n                \"kv-canary: req_to_token_pool_size must be positive, \"\n                f\"got {req_to_token_pool_size}\"\n            )\n        if max_seq_len_per_req <= 0:\n            raise ValueError(\n                \"kv-canary: max_seq_len_per_req must be positive, \"\n                f\"got {max_seq_len_per_req}\"\n            )\n        if pool_slot_count <= 0:\n            raise ValueError(\n                f\"kv-canary: pool_slot_count must be positive, got {pool_slot_count}\"\n            )\n\n        cuda_graph_config = get_exec().graph.cuda_graph_config\n        cuda_graph_max_bs = (\n            cuda_graph_config.decode.max_bs if cuda_graph_config is not None else 0\n        ) or 0\n        if cuda_graph_max_bs < 0:","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/kv_canary/capacities.py#L35-L71","documentation":"CanaryLaunchCapacities.from_args validates its inputs and requires req_to_token_pool_size to be strictly positive because the canary installs itself into the req-to-token pool. A non-positive pool size means there is no request pool to guard, so the constructor raises ValueError immediately.","triggerScenarios":"Calling from_args (via install_canary) with req_to_token_pool_size <= 0, typically because the server was started with --max-running-requests 0 or a req-to-token pool sized to zero by another flag.","commonSituations":"Setting --max-running-requests 0 or a pool-override flag to 0 while enabling --kv-canary log/raise; automation scripts that derive pool size arithmetically and can produce 0.","solutions":["Pass a positive req_to_token_pool_size (e.g. the server's actual req-to-token pool size)","If canary is not wanted, run with --kv-canary none instead of zeroing pool sizes","Audit scripts that compute pool sizes to guarantee a minimum of 1"],"exampleFix":"# before\n--max-running-requests 0 --kv-canary raise\n\n# after\n--max-running-requests 256 --kv-canary raise","handlingStrategy":"validation","validationCode":"if req_to_token_pool_size <= 0:\n    raise SystemExit(\"req_to_token_pool_size must be > 0; check --max-running-requests\")\ncaps = CanaryLaunchCapacities.from_args(\n    req_to_token_pool_size=req_to_token_pool_size, ...\n)","typeGuard":"def is_valid_pool_size(n: int) -> bool:\n    return isinstance(n, int) and n > 0","tryCatchPattern":null,"preventionTips":["Validate server-args-derived pool sizes before enabling --kv-canary","Don't set --max-running-requests 0 while the canary is enabled","Fail fast in launch scripts on non-positive pool sizes"],"tags":["kv-canary","validation","req-pool","value-error"],"backgroundTag":"config-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}