{"record":{"id":"cf885d1d9e3327ea","repo":"sgl-project/sglang","slug":"max-inflight-slices-must-be-positive","errorCode":null,"errorMessage":"max_inflight_slices must be positive","messagePattern":"max_inflight_slices must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/transport/memory_pool.py","lineNumber":176,"sourceCode":"\n    def __init__(\n        self,\n        *,\n        memory_size: int,\n        byte_tensor: torch.Tensor,\n        base_address: int,\n        device_id: int,\n        consumer_count: int,\n        recycle_interval: float,\n        transport_name: str,\n        max_inflight_slices: int = DEFAULT_MAX_INFLIGHT_SLICES,\n    ) -> None:\n        if memory_size <= 0:\n            raise ValueError(\"memory_size must be positive\")\n        if consumer_count <= 0:\n            raise ValueError(\"consumer_count must be positive\")\n        if max_inflight_slices <= 0:\n            raise ValueError(\"max_inflight_slices must be positive\")\n        if recycle_interval <= 0:\n            raise ValueError(\"recycle_interval must be positive\")\n        if (\n            not byte_tensor.is_cuda\n            or byte_tensor.device.index != device_id\n            or byte_tensor.dtype != torch.uint8\n            or not byte_tensor.is_contiguous()\n            or byte_tensor.numel() < memory_size\n        ):\n            raise ValueError(\n                \"byte_tensor must be a sufficiently large contiguous uint8 tensor \"\n                f\"on cuda:{device_id}\"\n            )\n\n        self.memory_size = memory_size\n        self.byte_tensor = byte_tensor\n        self.base_address = base_address\n        self.device_id = device_id","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/transport/memory_pool.py#L158-L194","documentation":"The pool caps concurrent in-flight slices (DEFAULT_MAX_INFLIGHT_SLICES) to bound ready/ack generation bookkeeping; max_inflight_slices must be >= 1. Zero or negative values would deadlock recycling since no slice could ever be in flight.","triggerScenarios":"Constructing the transport pool with max_inflight_slices <= 0 — explicit override with 0 or a computed concurrency value that rounded down to 0.","commonSituations":"Tuning flags for low memory by setting inflight slices to 0 instead of 1; deriving the value from batch size / concurrency math that can produce 0; copy-pasted configs.","solutions":["Set max_inflight_slices to at least 1","If limiting memory, lower slice size instead of slice count","Validate computed values before passing them in"],"exampleFix":"# before\nMemoryPoolTransport(..., max_inflight_slices=0, ...)\n# after\nMemoryPoolTransport(..., max_inflight_slices=1, ...)","handlingStrategy":"validation","validationCode":"if max_inflight_slices is not None:\n    assert int(max_inflight_slices) >= 1, 'max_inflight_slices must be >= 1'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 1 as the minimum when tuning for low memory, never 0","Validate concurrency-derived config values before startup"],"tags":["memory-pool","config-validation","cuda-ipc","multimodal-transport"],"backgroundTag":"invalid-resource-size","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}