sgl-project/sglang · error · ValueError

consumer_count must be positive

Error message

consumer_count must be positive

What it means

Constructor guard: consumer_count must be > 0. The pool needs at least one consumer to reserve/publish for; zero means the config is nonsensical.

Source

Thrown at python/sglang/srt/utils/cuda_vmm_transport_utils.py:184

        return get_parallel().tp_size // get_parallel().dp_size
    return get_parallel().tp_size


class CudaVmmMemoryPool:
    """Bounded CUDA VMM pool shared through FABRIC or a local POSIX FD."""

    def __init__(
        self,
        memory_size: int,
        recycle_interval: float,
        base_gpu_id: int,
        consumer_count: int,
        allow_posix_fallback: bool = False,
    ) -> None:
        if memory_size <= 0:
            raise ValueError("memory_size must be positive")
        if consumer_count <= 0:
            raise ValueError("consumer_count must be positive")
        if recycle_interval <= 0:
            raise ValueError("recycle_interval must be positive")

        self.device_index = int(base_gpu_id)
        self.consumer_count = int(consumer_count)
        self._recycle_interval = float(recycle_interval)
        self._lock = threading.Lock()
        self._publisher_condition = threading.Condition(self._lock)
        self._shutdown_lock = threading.Lock()
        self._active_publishers = 0
        self._closing = False
        self._pool_full_warned = False
        self._stop_recycler = threading.Event()
        self._pool_error: BaseException | None = None
        self._closed = False

        self._allocation: VmmReservation | None = None
        self.allocation_size = 0

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass the true number of consumer ranks/processes
  2. Skip pool creation entirely when there are no consumers
  3. Validate config at parse time, not deep in the constructor

Example fix

# before
pool = CudaVmmTransportPool(..., consumer_count=len(consumers))  # empty list
# after
if consumers:
    pool = CudaVmmTransportPool(..., consumer_count=len(consumers))
Defensive patterns

Strategy: validation

Validate before calling

assert isinstance(consumer_count, int) and consumer_count > 0

Prevention

When it happens

Trigger: Passing consumer_count=0 (e.g. derived from an empty consumer list such as zero DP ranks using the transport).

Common situations: Degenerate parallelism configs (dp=1, no consumers registered) or a race where the pool is built before consumers register.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/995eb94b2c0605e8. Report an issue: GitHub.