{"record":{"id":"969e19f40c367a44","repo":"sgl-project/sglang","slug":"cannot-resolve-the-transport-name-consumer-rank","errorCode":null,"errorMessage":"Cannot resolve the {transport_name} consumer rank before parallel state initialization","messagePattern":"Cannot resolve the (.+?) consumer rank before parallel state initialization","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/multimodal/transport/memory_pool.py","lineNumber":66,"sourceCode":"    )\n\n\ndef resolve_consumer_rank(\n    total_consumer_count: int,\n    consumer_rank: Optional[int] = None,\n    transport_name: str = \"GPU\",\n) -> int:\n    if total_consumer_count == 1:\n        return 0\n    if consumer_rank is None:\n        try:\n            from sglang.srt.runtime_context import get_parallel\n\n            # Use the global TP rank. An attention/DCP subgroup rank can alias\n            # another consumer's acknowledgement slot.\n            rank = int(get_parallel().tp_rank)\n        except Exception as exc:\n            raise RuntimeError(\n                f\"Cannot resolve the {transport_name} consumer rank before \"\n                \"parallel state initialization\"\n            ) from exc\n    else:\n        rank = int(consumer_rank)\n    if not 0 <= rank < total_consumer_count:\n        raise RuntimeError(\n            f\"{transport_name} consumer rank {rank} is outside \"\n            f\"[0, {total_consumer_count})\"\n        )\n    return rank\n\n\nclass StreamOrderedPoolConsumerMixin:\n    \"\"\"Ready/wait/ack protocol for stream-ordered GPU feature proxies.\"\"\"\n\n    def _init_stream_ordered_consumer(\n        self,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/transport/memory_pool.py#L48-L84","documentation":"Stream-ordered transport acknowledgement needs a consumer rank. If consumer_rank is not supplied, the code queries get_parallel().tp_rank; when the distributed/parallel runtime is not initialized, that lookup throws and is re-raised as this RuntimeError. It signals the transport was used outside a properly initialized sglang runtime.","triggerScenarios":"Calling acknowledge_consumption / _acknowledge_on_stream without an explicit consumer_rank in a standalone script or unit test where torch.distributed and sglang's parallel state were never initialized.","commonSituations":"Running transport unit tests outside the scheduler; constructing the pool in a notebook or tooling process; init order bugs where the transport outlives or precedes runtime teardown.","solutions":["Pass consumer_rank explicitly when running outside the sglang runtime","Initialize sglang's parallel state (init_distributed / RuntimeContext) before acknowledging","Restructure tests to init/destroy parallel state around the transport calls"],"exampleFix":"# before\npool.acknowledge_consumption()  # no parallel state\n# after\npool.acknowledge_consumption(consumer_rank=0)","handlingStrategy":"validation","validationCode":"try:\n    from sglang.srt.runtime_context import get_parallel\n    rank = get_parallel().tp_rank\nexcept Exception:\n    rank = None  # pass explicitly instead","typeGuard":null,"tryCatchPattern":"try:\n    pool.acknowledge_consumption()\nexcept RuntimeError as e:\n    if 'parallel state initialization' in str(e):\n        pool.acknowledge_consumption(consumer_rank=local_rank)","preventionTips":["Always pass consumer_rank explicitly outside the full runtime","In tests, init/destroy parallel state around transport usage"],"tags":["distributed","parallel-state","cuda-ipc","initialization-order"],"backgroundTag":"parallel-state-not-initialized","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}