sgl-project/sglang · error · ValueError
expert-pack stats flush interval cannot be negative
Error message
expert-pack stats flush interval cannot be negative
What it means
ExpertPackStore._initialize_runtime_state rejects stats_flush_interval < 0. The interval controls how often cache statistics are flushed; negative intervals are meaningless (and would be treated as truthy/always by some code paths), so they are rejected at construction.
Source
Thrown at python/sglang/srt/layers/moe/expert_pack.py:188
) -> None:
store.cache_vram_mib = int(cache_vram_mib)
store.cache_vram_reserve_mib = int(cache_vram_reserve_mib)
store.kernel_backend = "custom"
store.stage_slot_count = int(stage_slots)
store.read_splits = int(read_splits)
store.direct_io = bool(direct_io)
store.stats_flush_interval = int(stats_flush_interval)
if (
store.cache_vram_mib <= 0
or store.cache_vram_reserve_mib <= 0
or store.stage_slot_count <= 0
or store.read_splits <= 0
):
raise ValueError(
"expert cache and staging budgets, and read splits, must be positive"
)
if store.stats_flush_interval < 0:
raise ValueError("expert-pack stats flush interval cannot be negative")
if store.direct_io and not hasattr(os, "O_DIRECT"):
raise ValueError("expert-pack direct I/O is unavailable on this platform")
open_flags = os.O_RDONLY | (os.O_DIRECT if store.direct_io else 0)
store._fd = os.open(store.path, open_flags)
store._lock = threading.RLock()
store._cache = None
store._cache_slots = []
store._key_to_slot = {}
store._key_frequency = {}
store._lru = OrderedDict()
store._staging = []
store._stage_events = []
store._stage_cursor = 0
store._transfer_stream = None
store._read_executor = None
store._active_keys = set()
store._route_calls_by_layer = [0] * store.header.num_layers
store._route_tokens_by_layer = [0] * store.header.num_layersView on GitHub (pinned to 0132848349)
Solutions
- Use 0 to disable periodic stats flushing instead of a negative value
- Set a positive interval such as 5.0 seconds if stats are wanted
- Audit config arithmetic that produces the interval and clamp at 0
Example fix
# before store = ExpertPackStore(p, stats_flush_interval=-1) # tried to disable # after store = ExpertPackStore(p, stats_flush_interval=0) # disabled
Defensive patterns
Strategy: validation
Validate before calling
stats_flush_interval = max(0.0, float(stats_flush_interval))
Prevention
- Use 0 to disable stats flushing, not -1
- Clamp config-derived intervals at 0 before passing them in
When it happens
Trigger: Constructing ExpertPackStore with stats_flush_interval=-1 or a computed negative value, e.g. from subtracting overheads or parsing a signed CLI/env value.
Common situations: Using -1 as an 'unlimited/disabled' sentinel (0 is the correct value for disabled here); arithmetic that computes a negative interval from timing config; misparsed config files.
Related errors
- expert cache and staging budgets, and read splits, must be p
- expert-pack direct I/O is unavailable on this platform
- Removed server argument(s): {replacements}
- expert-pack header coverage is inconsistent
- expert-pack is not identity triplet layout
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/7fa2168d0d034082.
Report an issue: GitHub.