sgl-project/sglang · critical · RuntimeError
Cannot resolve the {transport_name} consumer rank before par
Error message
Cannot resolve the {transport_name} consumer rank before parallel state initialization What it means
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.
Source
Thrown at python/sglang/srt/multimodal/transport/memory_pool.py:66
)
def resolve_consumer_rank(
total_consumer_count: int,
consumer_rank: Optional[int] = None,
transport_name: str = "GPU",
) -> int:
if total_consumer_count == 1:
return 0
if consumer_rank is None:
try:
from sglang.srt.runtime_context import get_parallel
# Use the global TP rank. An attention/DCP subgroup rank can alias
# another consumer's acknowledgement slot.
rank = int(get_parallel().tp_rank)
except Exception as exc:
raise RuntimeError(
f"Cannot resolve the {transport_name} consumer rank before "
"parallel state initialization"
) from exc
else:
rank = int(consumer_rank)
if not 0 <= rank < total_consumer_count:
raise RuntimeError(
f"{transport_name} consumer rank {rank} is outside "
f"[0, {total_consumer_count})"
)
return rank
class StreamOrderedPoolConsumerMixin:
"""Ready/wait/ack protocol for stream-ordered GPU feature proxies."""
def _init_stream_ordered_consumer(
self,View on GitHub (pinned to 0132848349)
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
Example fix
# before pool.acknowledge_consumption() # no parallel state # after pool.acknowledge_consumption(consumer_rank=0)
Defensive patterns
Strategy: validation
Validate before calling
try:
from sglang.srt.runtime_context import get_parallel
rank = get_parallel().tp_rank
except Exception:
rank = None # pass explicitly instead Try / catch
try:
pool.acknowledge_consumption()
except RuntimeError as e:
if 'parallel state initialization' in str(e):
pool.acknowledge_consumption(consumer_rank=local_rank) Prevention
- Always pass consumer_rank explicitly outside the full runtime
- In tests, init/destroy parallel state around transport usage
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {transport_name} consumer rank {rank} is outside [0, {total_
- --mm-feature-transport=cuda_ipc only supports a single node.
- world_size must be positive and divide global_heads
- Group {group_name} is destroyed.
- world_size ({world_size}) is less than tensor_parallel_degre
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/969e19f40c367a44.
Report an issue: GitHub.