{"record":{"id":"366eee760c71eb7f","repo":"sgl-project/sglang","slug":"consumer-count-must-be-1-the-attention-tp-size-o","errorCode":null,"errorMessage":"consumer_count must be 1, the attention TP size, or the full consumer count ({self.consumer_count}); got {consumer_count}","messagePattern":"consumer_count must be 1, the attention TP size, or the full consumer count \\((.+?)\\); got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/cuda_vmm_transport_utils.py","lineNumber":777,"sourceCode":"            raise ValueError(\"consumer_count must be positive\")\n        if consumer_count == self.consumer_count:\n            return 0, self.consumer_count\n\n        parallel = get_parallel()\n        group_start = parallel.attn_cp_rank * parallel.attn_tp_size\n        group_end = group_start + parallel.attn_tp_size\n        if not 0 <= group_start < group_end <= self.consumer_count:\n            raise ValueError(\n                \"attention group range \"\n                f\"[{group_start}, {group_end}) is outside \"\n                f\"consumer_count={self.consumer_count}\"\n            )\n        if consumer_count == 1:\n            slot = group_start + parallel.attn_tp_rank\n            return slot, slot + 1\n        if consumer_count == parallel.attn_tp_size:\n            return group_start, group_end\n        raise ValueError(\n            \"consumer_count must be 1, the attention TP size, or the full \"\n            f\"consumer count ({self.consumer_count}); got {consumer_count}\"\n        )\n\n    def _resolve_consumer_count(self, consumer_count: int | None) -> int:\n        return 1 if consumer_count is None else consumer_count\n\n    def _acknowledge_consumption(self, device_index: int, consumer_count: int) -> None:\n        if self._consumer_acknowledged:\n            return\n        pool = self._pool(device_index)\n        ack_start = self.control_offset\n        ack_end = ack_start + self.consumer_count * _CONTROL_WORD_BYTES\n        ack_words = pool.memory[ack_start:ack_end].view(torch.int32)\n        slot_start, slot_end = self._acknowledgement_range(consumer_count)\n        # This kernel is ordered after the remote read on the consumer stream;\n        # observing the flag therefore means the pool slice is safe to reuse.\n        ack_words[slot_start:slot_end].fill_(1)","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/cuda_vmm_transport_utils.py#L759-L795","documentation":"The acknowledgement protocol only supports three granularities: acknowledging a single consumer slot (1), the rank's whole attention TP group (attn_tp_size), or every consumer (full consumer_count). Any other consumer_count is rejected because there is no defined slot range for it.","triggerScenarios":"Calling acknowledge_consumption(consumer_count=N) where N is not 1, not attn_tp_size, and not the pool's consumer_count; e.g. acknowledging a partial subgroup or an outdated tp size.","commonSituations":"Code written for a different tp configuration reused after resizing; callers guessing a count instead of deriving it from parallel state.","solutions":["Use consumer_count=None (single slot) or pass parallel.attn_tp_size / the pool's full consumer_count","Derive the count from get_parallel() rather than hardcoding","After changing TP size, rebuild the transport so consumer_count matches"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"p = get_parallel()\nvalid = {1, p.attn_tp_size, pool.consumer_count}\nif consumer_count not in valid:\n    consumer_count = None  # or full count","typeGuard":"def is_supported_ack_count(n: int, pool, parallel) -> bool:\n    return n in (1, parallel.attn_tp_size, pool.consumer_count)","tryCatchPattern":null,"preventionTips":["Only acknowledge at 1 / tp-group / full granularity","Derive counts from live parallel state"],"tags":["cuda","vmm","validation","parallelism"],"backgroundTag":"unsupported-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}