From b34e7cb932db5324071ed54296042271580312cd Mon Sep 17 00:00:00 2001 From: leavelet Date: Wed, 17 Jun 2026 16:29:31 +0000 Subject: [PATCH] Add SGLANG_CP_TRANSFER_LOG: decouple CP shared-KV transfer-partition dumps from debug flag SGLANG_DEBUG_CP_SHARED_KV also disables tai IPC materialize -> NSA index fail-fast at warmup (unusable in this config). Add a logging-only flag that emits the sender/worker transfer-partition dumps (main-KV pages/positions vs NSA-state pages/positions) without that side effect, and lift the 64-log cap, so we can diff the state-vs-main-KV partition for a cache-hit vs cache-miss. Co-Authored-By: Claude Opus 4.8 (1M context) --- python/sglang/srt/disaggregation/mooncake/conn.py | 10 +++++----- python/sglang/srt/environ.py | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/python/sglang/srt/disaggregation/mooncake/conn.py b/python/sglang/srt/disaggregation/mooncake/conn.py index 3dd6f05fd..95cfe75f1 100644 --- a/python/sglang/srt/disaggregation/mooncake/conn.py +++ b/python/sglang/srt/disaggregation/mooncake/conn.py @@ -43,8 +43,8 @@ logger = logging.getLogger(__name__) _CP_SHARED_DEBUG_COUNTS: dict[str, int] = {} -def _cp_shared_debug_log(key: str, message: str, *args, limit: int = 64) -> None: - if not envs.SGLANG_DEBUG_CP_SHARED_KV.get(): +def _cp_shared_debug_log(key: str, message: str, *args, limit: int = 1_000_000) -> None: + if not (envs.SGLANG_DEBUG_CP_SHARED_KV.get() or envs.SGLANG_CP_TRANSFER_LOG.get()): return count = _CP_SHARED_DEBUG_COUNTS.get(key, 0) if count >= limit: @@ -1241,7 +1241,7 @@ class MooncakeKVManager(CommonKVManager): _np_summary(chunked_dst_kv_indice), kv_chunk.is_last_chunk, ) - if envs.SGLANG_DEBUG_CP_SHARED_KV.get(): + if envs.SGLANG_DEBUG_CP_SHARED_KV.get() or envs.SGLANG_CP_TRANSFER_LOG.get(): _cp_shared_debug_log( "transfer_worker_kv", "transfer worker cp_rank=%s room=%s prefill_pages=%s " @@ -1350,7 +1350,7 @@ class MooncakeKVManager(CommonKVManager): req.dst_state_indices, kv_chunk.state_logical_page_positions, ) - if envs.SGLANG_DEBUG_CP_SHARED_KV.get(): + if envs.SGLANG_DEBUG_CP_SHARED_KV.get() or envs.SGLANG_CP_TRANSFER_LOG.get(): _cp_shared_debug_log( "transfer_worker_state", "transfer worker state cp_rank=%s room=%s prefill_state_pages=%s " @@ -1731,7 +1731,7 @@ class MooncakeKVSender(CommonKVSender): ) ) index_slice = None - if envs.SGLANG_DEBUG_CP_SHARED_KV.get(): + if envs.SGLANG_DEBUG_CP_SHARED_KV.get() or envs.SGLANG_CP_TRANSFER_LOG.get(): _cp_shared_debug_log( "sender_filter", "sender filter cp_rank=%s room=%s page_start=%s orig_kv_pages=%s " diff --git a/python/sglang/srt/environ.py b/python/sglang/srt/environ.py index c178e1c57..d0f3c82a1 100644 --- a/python/sglang/srt/environ.py +++ b/python/sglang/srt/environ.py @@ -274,6 +274,10 @@ class Envs: # CP HiCache round-trip KV-corruption tracing. 0=off, 1=structural lifecycle # (rid_map/backup/split/evict/reload), 2=+compose/free/ack timing. SGLANG_CP_HICACHE_KV_TRACE = EnvInt(0) + # Logging-only: emit the CP shared-KV sender/worker transfer-partition dumps + # (main-KV pages/positions vs NSA-state pages/positions) WITHOUT the side effects + # of SGLANG_DEBUG_CP_SHARED_KV (which disables tai materialize -> fail-fast). + SGLANG_CP_TRANSFER_LOG = EnvBool(False) # Dir to torch.save per-stage attention tensors for L1-hit vs L2-reload diff. # Empty=off. Only requests whose rid starts with "dump-" are dumped. SGLANG_NSA_DUMP_DIR = EnvStr("")