From 9e717cae46be1a84ee0c849088f469f339316cdf Mon Sep 17 00:00:00 2001 From: Bi Xue Date: Tue, 2 Jun 2026 10:42:04 -0700 Subject: [PATCH] [sglang] Fix Mamba COW over-releasing SWA locks (cascade-evict assert crash) (#27038) --- .../unified_cache_components/mamba_component.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/sglang/srt/mem_cache/unified_cache_components/mamba_component.py b/python/sglang/srt/mem_cache/unified_cache_components/mamba_component.py index fac322005..b3e8b405b 100644 --- a/python/sglang/srt/mem_cache/unified_cache_components/mamba_component.py +++ b/python/sglang/srt/mem_cache/unified_cache_components/mamba_component.py @@ -92,10 +92,15 @@ class MambaComponent(TreeComponent): if req.mamba_pool_idx is None: dst_index = self.cache.req_to_token_pool.mamba_pool.alloc(1) if dst_index is None: - self.cache.inc_lock_ref(last_node) + # Capture the inc result and thread swa_uuid_for_lock back + # into dec. Without it, SWA's release walks past this + # request's window boundary all the way to root and + # over-decrements SWA locks held by other resident requests + # on ancestor nodes. + lock_result = self.cache.inc_lock_ref(last_node) self.cache.evict(EvictParams(num_tokens=0, mamba_num=1)) dst_index = self.cache.req_to_token_pool.mamba_pool.alloc(1) - self.cache.dec_lock_ref(last_node) + self.cache.dec_lock_ref(last_node, lock_result.to_dec_params()) assert dst_index is not None, "Can not alloc mamba cache" req.mamba_pool_idx = dst_index[0] req.mamba_cow_src_index = mamba_value