diff --git a/python/sglang/srt/mem_cache/hiradix_cache.py b/python/sglang/srt/mem_cache/hiradix_cache.py index 537dac798..04d60b8d5 100644 --- a/python/sglang/srt/mem_cache/hiradix_cache.py +++ b/python/sglang/srt/mem_cache/hiradix_cache.py @@ -3293,10 +3293,28 @@ class HiRadixCache(RadixCache): } self._cp_fallback_counts_last = dict(fallback_counts) + # Shared physical L2 pool report -- the REAL occupancy when l2 pooling is on. + # occ/used_tokens above are derived from _cp_counts, which the accounting + # explicitly skips for shared-L2 metadata (_cp_account_*: `not + # _is_cp_shared_l2_metadata`), so they read 0 even when the pool is full. The + # shared pool tracks its own pages_used/objects_committed/objects_evicted + + # load_hits/misses in the replicated CpSharedL2PageAllocator stats. + shared_l2_report = None + controller = getattr(self, "cache_controller", None) + if controller is not None and getattr( + controller, "cp_shared_l2_page_allocator", None + ) is not None: + report_fn = getattr(controller, "cp_shared_l2_cache_report", None) + if report_fn is not None: + try: + shared_l2_report = report_fn() + except Exception: + shared_l2_report = None + logger.info( "[CP_HICACHE_LANE_STATS] occ=%s cap_tokens=%s used_tokens=%s max=%.3f " "min=%.3f spread=%.3f imbalance=%s hot_prefix_short=%d hot_prefix_long=%d " - "skew_token_threshold=%d drops_since_last=%s drops_total=%s", + "skew_token_threshold=%d drops_since_last=%s drops_total=%s shared_l2_pool=%s", [round(x, 3) for x in occ], list(capacity), list(used), @@ -3309,6 +3327,7 @@ class HiRadixCache(RadixCache): skew_token_threshold, drops_since_last, dict(fallback_counts), + shared_l2_report, ) def _probe_existing_radix_prefix_len_no_split(self, key: RadixKey) -> int: