{"record":{"id":"fcda2ee5a638df8c","repo":"sgl-project/sglang","slug":"transport-name-pool-is-too-small-after-control-m","errorCode":null,"errorMessage":"{transport_name} pool is too small after control metadata: pool={memory_size}, control={self.data_start}","messagePattern":"(.+?) pool is too small after control metadata: pool=(.+?), control=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/transport/memory_pool.py","lineNumber":204,"sourceCode":"            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\n        self.consumer_count = consumer_count\n        self.control_words_per_slot = 1 + consumer_count\n        self.max_inflight_slices = max_inflight_slices\n        self.transport_name = transport_name\n        control_bytes = (\n            max_inflight_slices * self.control_words_per_slot * CONTROL_WORD_BYTES\n        )\n        self.data_start = align_up(control_bytes, DATA_ALIGNMENT)\n        if memory_size <= self.data_start:\n            raise ValueError(\n                f\"{transport_name} pool is too small after control metadata: \"\n                f\"pool={memory_size}, control={self.data_start}\"\n            )\n\n        control_word_count = max_inflight_slices * self.control_words_per_slot\n        self._control_words = (\n            byte_tensor[: control_word_count * CONTROL_WORD_BYTES]\n            .view(torch.int32)\n            .view(max_inflight_slices, self.control_words_per_slot)\n        )\n        self._control_words.zero_()\n        torch.cuda.synchronize(device_id)\n\n        self._available_ranges = [(self.data_start, memory_size)]\n        self._available_slots = list(reversed(range(max_inflight_slices)))\n        self._slot_generations = [0] * max_inflight_slices\n        self._occupied: dict[int, PoolLease] = {}\n        self._lock = threading.Lock()","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/transport/memory_pool.py#L186-L222","documentation":"The pool reserves its leading bytes for per-slice control metadata (max_inflight_slices slots of control words, aligned up to DATA_ALIGNMENT) before payload data. If memory_size is not larger than this control region, no usable payload space remains and construction aborts.","triggerScenarios":"Small memory_size combined with large max_inflight_slices; e.g. memory_size=1MB with max_inflight_slices=64 can be fully consumed by control words plus alignment padding.","commonSituations":"Sizing the pool with a rough 'a few MB' guess; raising max_inflight_slices without growing the pool; shrinking memory_size for tests.","solutions":["Increase memory_size well beyond data_start (e.g. 2-4x the largest expected inflight payload total)","Reduce max_inflight_slices if high slice concurrency is not needed","Compute control_bytes = max_inflight_slices * control_words_per_slot * CONTROL_WORD_BYTES plus alignment and assert headroom before constructing"],"exampleFix":"# before\npool = SharedMemoryPool(memory_size=1<<20, max_inflight_slices=64, ...)\n# after\npool = SharedMemoryPool(memory_size=64<<20, max_inflight_slices=64, ...)","handlingStrategy":"validation","validationCode":"control = align_up(max_inflight_slices * control_words_per_slot * CONTROL_WORD_BYTES, DATA_ALIGNMENT)\nassert memory_size > control * 4, 'pool too small for control metadata + payload'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Size pools from measured payload totals, not round guesses","When raising max_inflight_slices, scale memory_size proportionally"],"tags":["multimodal","memory-pool","capacity-planning"],"backgroundTag":"buffer-too-small","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}