From 3d65944a22d873364844389836a8d96493fa0a11 Mon Sep 17 00:00:00 2001 From: leavelet Date: Wed, 27 May 2026 00:40:39 +0800 Subject: [PATCH] Remove stale layer_transfer_counter prefetch guards (port from e293d4a39 fix #3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CpSharedKVMlaPrefetcher.create and CpSharedKVIndexPrefetcher.create returned None whenever ``token_to_kv_pool.layer_transfer_counter`` was set, which permanently disables NSA indexer prefetch whenever HiCache is active — even when no H2D transfer is in progress. The guard is unnecessary: buffer getters synchronize via wait_until(), and the prefetcher's stream calls wait_stream(current_stream) before materialization. Removing it restores intended prefetch parallelism under HiCache + NSA. Only fix #3 of e293d4a39 is portable to this branch — fixes #1 (SHM timeout) and #2 (SHM exception safety) target shm_allreduce.py and the batched-CP coordination path in hiradix_cache.py, neither of which exists here. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../srt/layers/attention/nsa/cp_shared_kv_prefetch.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/python/sglang/srt/layers/attention/nsa/cp_shared_kv_prefetch.py b/python/sglang/srt/layers/attention/nsa/cp_shared_kv_prefetch.py index 3a8cf61f9..69c00c05f 100644 --- a/python/sglang/srt/layers/attention/nsa/cp_shared_kv_prefetch.py +++ b/python/sglang/srt/layers/attention/nsa/cp_shared_kv_prefetch.py @@ -178,9 +178,6 @@ class CpSharedKVMlaPrefetcher: if token_to_kv_pool is None: _prefetch_log("create_skip reason=missing_token_to_kv_pool") return None - if getattr(token_to_kv_pool, "layer_transfer_counter", None) is not None: - _prefetch_log("create_skip reason=layer_transfer_active") - return None layout = getattr(forward_batch, "cp_shared_kv_layout", None) if layout is None: @@ -705,12 +702,6 @@ class CpSharedKVIndexPrefetcher: "forward batch has no token_to_kv_pool.", ) return None - if getattr(token_to_kv_pool, "layer_transfer_counter", None) is not None: - _index_prefetch_fallback_log( - "layer_transfer_active", - "layer transfer is active.", - ) - return None layout = getattr(forward_batch, "cp_shared_kv_layout", None) if layout is None: