{"record":{"id":"84eb42077f77a564","repo":"sgl-project/sglang","slug":"kv-canary-pool-slot-count-must-be-positive-got","errorCode":null,"errorMessage":"kv-canary: pool_slot_count must be positive, got {pool_slot_count}","messagePattern":"kv-canary: pool_slot_count must be positive, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/kv_canary/capacities.py","lineNumber":63,"sourceCode":"    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:\n            raise ValueError(\n                f\"kv-canary: cuda_graph_max_bs must be non-negative, got {cuda_graph_max_bs}\"\n            )\n\n        spec_num_draft_tokens = get_spec().speculative_num_draft_tokens\n        if spec_num_draft_tokens is None:\n            spec_num_draft_tokens = 0\n        if spec_num_draft_tokens < 0:\n            raise ValueError(\n                \"kv-canary: speculative_num_draft_tokens must be non-negative, \"","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/kv_canary/capacities.py#L45-L81","documentation":"from_args requires pool_slot_count > 0: the KV pool must have at least one slot for the canary to write/verify against. Zero or negative slots indicate a degenerate or misconfigured KV cache pool, and the canary refuses to install.","triggerScenarios":"Calling install_canary/from_args with pool_slot_count <= 0, e.g. when the KV cache pool sizing computed zero tokens/slots from --max-total-tokens 0, --kv-cache-dtype issues, or gpu-memory-utilization so low no cache fits.","commonSituations":"Starting with --max-total-tokens 0 or an extremely low --mem-fraction-static/--gpu-memory-utilization so the token pool is empty; overriding pool size in test harnesses with 0.","solutions":["Give the KV pool a positive size: raise --mem-fraction-static / remove --max-total-tokens 0","Check server startup logs that the KV pool actually allocated slots","Run with --kv-canary none if canary monitoring is not needed"],"exampleFix":"# before\n--max-total-tokens 0 --kv-canary raise\n\n# after\n--max-total-tokens 16384 --kv-canary raise","handlingStrategy":"validation","validationCode":"if pool_slot_count <= 0:\n    raise SystemExit(\"KV pool has no slots; raise --mem-fraction-static or unset --max-total-tokens\")\ncaps = CanaryLaunchCapacities.from_args(pool_slot_count=pool_slot_count, ...)","typeGuard":"def has_kv_slots(n: int) -> bool:\n    return isinstance(n, int) and n > 0","tryCatchPattern":null,"preventionTips":["Never pass --max-total-tokens 0 with --kv-canary enabled","Check startup logs for a non-zero allocated KV pool before enabling the canary","Use --kv-canary none in memory-constrained experiments"],"tags":["kv-canary","validation","kv-cache-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"}