[MemCache] Fix the strict busy check on prefill-aware SWA and tidy small leftovers (#43474)

This commit is contained in:
Liangsheng Yin
2026-10-09 20:27:27 -07:00
committed by GitHub
parent f2e9a2bed1
commit 7d44269907
5 changed files with 41 additions and 18 deletions
-1
View File
@@ -2750,7 +2750,6 @@ class Scheduler(
def _maybe_namespace_elastic_radix_cache(self, req: Req) -> None:
if (
get_exec().moe.elastic_ep_backend is None
or self.disable_radix_cache
or not self.tree_cache.supports_prefix_sharing()
):
return
@@ -484,9 +484,8 @@ class SchedulerInvariantChecker:
def _check_tree_cache(self):
if not envs.SGLANG_ENABLE_TREE_CACHE_SANITY_CHECK.get():
return
if (
self.tree_cache.supports_prefix_sharing()
and (self.is_hybrid_swa and self.tree_cache.supports_swa())
if self.tree_cache.supports_prefix_sharing() and (
(self.is_hybrid_swa and self.tree_cache.supports_swa())
or (self.is_hybrid_ssm and self.tree_cache.supports_mamba())
):
self.tree_cache.sanity_check()
@@ -33,10 +33,13 @@ def kv_private_tokens(kv: ReqKvInfo, page_size: int) -> int:
def kv_private_swa_tokens(kv: ReqKvInfo, page_size: int) -> int:
# Window eviction frees only [swa_dead_lo, evicted); [protected, swa_dead_lo)
# stays held until the request finishes, even after the cursor jumps past it.
allocated = ceil_align(kv.kv_allocated_len, page_size)
return allocated - max(
kv.cache_protected_len, kv.get_evicted_seqlen(ComponentType.SWA)
window_freed = max(
0, kv.get_evicted_seqlen(ComponentType.SWA) - kv.swa_dead_lo(page_size)
)
return allocated - kv.cache_protected_len - window_freed
def kv_mamba_slots(kv: ReqKvInfo) -> int: