{"record":{"id":"eaed652f006d25e8","repo":"sgl-project/sglang","slug":"memory-size-must-be-positive","errorCode":null,"errorMessage":"memory_size must be positive","messagePattern":"memory_size must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/transport/memory_pool.py","lineNumber":172,"sourceCode":"\n\nclass StreamOrderedMmFeaturePool:\n    \"\"\"Bounded GPU pool with generation-safe producer/consumer leases.\"\"\"\n\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","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/transport/memory_pool.py#L154-L190","documentation":"The transport memory pool's constructor validates that memory_size (the pooled byte budget) is positive before allocating the backing CUDA byte tensor. Zero or negative sizes indicate a misconfigured pool budget and are rejected immediately.","triggerScenarios":"Constructing the multimodal transport memory pool with memory_size <= 0 — e.g. budget flag parsed as 0 bytes or a size computation underflowing to a negative value.","commonSituations":"Budget flags set to 0 or omitted with broken defaults; unit confusion (MB vs bytes) truncating to 0; arithmetic that subtracts reserved sizes below zero.","solutions":["Set a positive memory_size (bytes) for the pool","Verify unit parsing of the memory budget flag","Check that reserved-size subtractions can't push the final size below 1"],"exampleFix":"# before\nMemoryPoolTransport(memory_size=0, ...)\n# after\nMemoryPoolTransport(memory_size=512 * 1024 * 1024, ...)","handlingStrategy":"validation","validationCode":"if memory_size is None or int(memory_size) <= 0:\n    raise ValueError('memory_size must be positive bytes')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize size parsing (MB/GB -> bytes) in one helper","Unit-test config edge cases (0, negative) at 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"}