Gate the idle-loop tree-cache sanity check behind a default-off env (#36205)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: hzh0425 <hzh0425@apache.org>
This commit is contained in:
Sam Shleifer
2026-08-30 00:10:28 +08:00
committed by GitHub
co-authored by Claude Fable 5 hzh0425
parent 000c636342
commit 6afb5e1771
3 changed files with 99 additions and 0 deletions
+8
View File
@@ -37,6 +37,11 @@ def _default_cache_subdir(name: str) -> str:
return os.path.join(os.path.expanduser(envs.SGLANG_CACHE_DIR.get()), name)
def _default_tree_cache_sanity_check() -> bool:
"""Enable the expensive tree-cache sanity check by default in CI."""
return envs.SGLANG_IS_IN_CI.get()
class EnvField:
_allow_set_name = True
@@ -464,6 +469,9 @@ class Envs:
SGLANG_ENABLE_TP_MEMORY_INBALANCE_CHECK = EnvBool(True)
SGLANG_ENABLE_STRICT_MEM_CHECK_DURING_BUSY = EnvInt(0)
SGLANG_ENABLE_STRICT_MEM_CHECK_DURING_IDLE = EnvBool(True)
# The explicit environment variable still takes precedence over this CI
# default, so production remains opt-in and CI remains opt-out if needed.
SGLANG_ENABLE_TREE_CACHE_SANITY_CHECK = EnvBool(_default_tree_cache_sanity_check)
# Physical KV-page checks: committed<=allocated + no page alias.
SGLANG_CHECK_KV_PAGE_INVARIANTS = EnvBool(False)
SGLANG_TBO_DEBUG = EnvBool(False)
@@ -462,6 +462,8 @@ class SchedulerInvariantChecker:
return has_leak, messages
def _check_tree_cache(self):
if not envs.SGLANG_ENABLE_TREE_CACHE_SANITY_CHECK.get():
return
if (
self.tree_cache.is_tree_cache()
and (self.is_hybrid_swa and self.tree_cache.supports_swa())