{"record":{"id":"7fa2168d0d034082","repo":"sgl-project/sglang","slug":"expert-pack-stats-flush-interval-cannot-be-negativ","errorCode":null,"errorMessage":"expert-pack stats flush interval cannot be negative","messagePattern":"expert-pack stats flush interval cannot be negative","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/moe/expert_pack.py","lineNumber":188,"sourceCode":") -> None:\n    store.cache_vram_mib = int(cache_vram_mib)\n    store.cache_vram_reserve_mib = int(cache_vram_reserve_mib)\n    store.kernel_backend = \"custom\"\n    store.stage_slot_count = int(stage_slots)\n    store.read_splits = int(read_splits)\n    store.direct_io = bool(direct_io)\n    store.stats_flush_interval = int(stats_flush_interval)\n    if (\n        store.cache_vram_mib <= 0\n        or store.cache_vram_reserve_mib <= 0\n        or store.stage_slot_count <= 0\n        or store.read_splits <= 0\n    ):\n        raise ValueError(\n            \"expert cache and staging budgets, and read splits, must be positive\"\n        )\n    if store.stats_flush_interval < 0:\n        raise ValueError(\"expert-pack stats flush interval cannot be negative\")\n    if store.direct_io and not hasattr(os, \"O_DIRECT\"):\n        raise ValueError(\"expert-pack direct I/O is unavailable on this platform\")\n    open_flags = os.O_RDONLY | (os.O_DIRECT if store.direct_io else 0)\n    store._fd = os.open(store.path, open_flags)\n    store._lock = threading.RLock()\n    store._cache = None\n    store._cache_slots = []\n    store._key_to_slot = {}\n    store._key_frequency = {}\n    store._lru = OrderedDict()\n    store._staging = []\n    store._stage_events = []\n    store._stage_cursor = 0\n    store._transfer_stream = None\n    store._read_executor = None\n    store._active_keys = set()\n    store._route_calls_by_layer = [0] * store.header.num_layers\n    store._route_tokens_by_layer = [0] * store.header.num_layers","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/moe/expert_pack.py#L170-L206","documentation":"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.","triggerScenarios":"Constructing ExpertPackStore with stats_flush_interval=-1 or a computed negative value, e.g. from subtracting overheads or parsing a signed CLI/env value.","commonSituations":"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.","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"],"exampleFix":"# before\nstore = ExpertPackStore(p, stats_flush_interval=-1)  # tried to disable\n\n# after\nstore = ExpertPackStore(p, stats_flush_interval=0)  # disabled","handlingStrategy":"validation","validationCode":"stats_flush_interval = max(0.0, float(stats_flush_interval))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 0 to disable stats flushing, not -1","Clamp config-derived intervals at 0 before passing them in"],"tags":["moe","expert-pack","configuration","interval","argument-validation"],"backgroundTag":"invalid-configuration-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}