sgl-project/sglang · error · ValueError
recycle_interval must be positive
Error message
recycle_interval must be positive
What it means
SharedMemoryPool (multimodal transport memory pool) validates its constructor arguments; recycle_interval controls how often the background recycler thread wakes to reclaim completed leases. A non-positive interval would make the recycler spin or fail to wait, so it is rejected upfront with ValueError.
Source
Thrown at python/sglang/srt/multimodal/transport/memory_pool.py:178
self,
*,
memory_size: int,
byte_tensor: torch.Tensor,
base_address: int,
device_id: int,
consumer_count: int,
recycle_interval: float,
transport_name: str,
max_inflight_slices: int = DEFAULT_MAX_INFLIGHT_SLICES,
) -> None:
if memory_size <= 0:
raise ValueError("memory_size must be positive")
if consumer_count <= 0:
raise ValueError("consumer_count must be positive")
if max_inflight_slices <= 0:
raise ValueError("max_inflight_slices must be positive")
if recycle_interval <= 0:
raise ValueError("recycle_interval must be positive")
if (
not byte_tensor.is_cuda
or byte_tensor.device.index != device_id
or byte_tensor.dtype != torch.uint8
or not byte_tensor.is_contiguous()
or byte_tensor.numel() < memory_size
):
raise ValueError(
"byte_tensor must be a sufficiently large contiguous uint8 tensor "
f"on cuda:{device_id}"
)
self.memory_size = memory_size
self.byte_tensor = byte_tensor
self.base_address = base_address
self.device_id = device_id
self.consumer_count = consumer_count
self.control_words_per_slot = 1 + consumer_countView on GitHub (pinned to 0132848349)
Solutions
- Set recycle_interval to a positive number of seconds (e.g. 0.1–1.0)
- Check the config path feeding this constructor for a missing/zeroed recycle_interval field
- If a shorter/longer cadence is desired, tune the positive value rather than zeroing it
Example fix
// before pool = SharedMemoryPool(..., recycle_interval=0) // after pool = SharedMemoryPool(..., recycle_interval=0.5)
Defensive patterns
Strategy: validation
Validate before calling
assert isinstance(recycle_interval, (int, float)) and recycle_interval > 0, 'recycle_interval must be > 0'
Prevention
- Validate pool config values centrally before constructing SharedMemoryPool
- Fail fast in config loading when optional numeric fields are absent instead of defaulting to 0
When it happens
Trigger: Constructing SharedMemoryPool (directly or via a transport factory) with recycle_interval=0 or negative, e.g. passing a config value that was never set and defaulted to 0.
Common situations: YAML/JSON config missing the recycle interval key so it defaults to 0; unit tests constructing pools with placeholder integers; copy-paste of another pool's kwargs.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Replicated Q, K, and V must be provided together.
- LTX2DurationHead requires at least one of video_tokens / aud
- byte_tensor must be a sufficiently large contiguous uint8 te
- {transport_name} pool is too small after control metadata: p
- {self.transport_name} pool slot generation exhausted
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/dd47f33b864be2fd.
Report an issue: GitHub.