{"record":{"id":"6bb2139e169b8c93","repo":"sgl-project/sglang","slug":"max-seqlen-must-be-positive-got-max-seqlen","errorCode":null,"errorMessage":"max_seqlen must be positive, got {max_seqlen}","messagePattern":"max_seqlen must be positive, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/kimi_k3_vit_cuda_graph_runner.py","lineNumber":50,"sourceCode":"    outputs: Tuple[torch.Tensor, ...]\n    metadata: KimiK3VisionForwardMetadata\n\n\nclass KimiK3ViTCudaGraphRunner:\n    def __init__(\n        self,\n        tower: KimiK3VisionTower,\n        *,\n        capacity: int,\n        min_hits: int,\n        max_seqlen: int | None = None,\n    ) -> None:\n        if capacity <= 0:\n            raise ValueError(f\"capacity must be positive, got {capacity}\")\n        if min_hits <= 0:\n            raise ValueError(f\"min_hits must be positive, got {min_hits}\")\n        if max_seqlen is not None and max_seqlen <= 0:\n            raise ValueError(f\"max_seqlen must be positive, got {max_seqlen}\")\n        self.tower = tower\n        self.capacity = capacity\n        self.min_hits = min_hits\n        self.max_seqlen = max_seqlen\n        self.graphs: dict[Hashable, _CapturedVisionGraph] = {}\n        self.seen: OrderedDict[Hashable, int] = OrderedDict()\n        self.failed_keys: set[Hashable] = set()\n        self._graph_memory_pool: Any = None\n        self._capacity_logged = False\n        self._max_seqlen_logged = False\n        logger.info(\n            \"Kimi-K3 ViT CUDA graph: capacity=%d min_hits=%d max_seqlen=%s\",\n            capacity,\n            min_hits,\n            max_seqlen,\n        )\n\n    @staticmethod","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/kimi_k3_vit_cuda_graph_runner.py#L32-L68","documentation":"When max_seqlen is provided to the Kimi-K3 ViT CUDA graph runner it must be positive; None disables the bound, but an explicit value <= 0 is rejected because it would exclude every sequence.","triggerScenarios":"Passing max_seqlen=0 or negative while intending 'no limit' — the API uses None for unlimited, not 0.","commonSituations":"Config schemas defaulting unset ints to 0; passing max_model_len-1 style computed values that underflow to 0 for tiny test configs.","solutions":["Pass max_seqlen=None when unlimited","Otherwise pass a positive bound, e.g. the model's max vision sequence length","Sanitize: max_seqlen = max_seqlen if max_seqlen and max_seqlen > 0 else None"],"exampleFix":"// before\nrunner = KimiK3VitCudaGraphRunner(tower=t, capacity=8, min_hits=2, max_seqlen=cfg.max_len or 0)\n// after\nrunner = KimiK3VitCudaGraphRunner(tower=t, capacity=8, min_hits=2, max_seqlen=cfg.max_len or None)","handlingStrategy":"validation","validationCode":"if max_seqlen is not None and max_seqlen <= 0:\n    max_seqlen = None  # or raise in strict mode","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use None for 'unlimited', never 0","Validate derived max_seqlen (e.g. max_model_len-based) in test configs where it can underflow"],"tags":["cuda-graph","kimi-k3","config-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}