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) <noreply@anthropic.com>
This commit is contained in:
@@ -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 "
|
||||
|
||||
@@ -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("")
|
||||
|
||||
Reference in New Issue
Block a user