Skip to content

hicache: restore per-tier (L1/L2/L3) KV cache hit metrics - #31883

Open
TianDi101 wants to merge 2 commits into
sgl-project:mainfrom
TianDi101:feat/hicache-per-tier-hit-metrics
Open

TianDi101 wants to merge 2 commits into
sgl-project:mainfrom
TianDi101:feat/hicache-per-tier-hit-metrics

Conversation

@TianDi101

@TianDi101 TianDi101 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Split out of #31879 (general per-tier hit counters only, no UMBP-specific or eviction/load-back changes).

Re-adds the per-tier cache hit breakdown that was previously reverted in feat/umbp-pr (001e9ce) and never carried forward: PrefillAdder tracks L1 (GPU device), L2 (host DRAM), and L3 (storage) hit tokens plus cache misses, reported via SchedulerStats and exported as sglang:cache_hit_tokens_l{1,2,3}_total / cache_miss_tokens_total Prometheus counters. Adapted to current code: uses req.storage_hit_length directly (no getattr) and req.extend_range instead of the since-removed req.extend_input_len.

Backend-agnostic — req.storage_hit_length is set generically by scheduler.pop_prefetch_loaded_tokens() regardless of which L3 storage backend (mooncake, hf3fs, file, UMBP, ...) served the prefetch.

Also restores the corresponding Grafana panels: "Cache Hit Rate (Per-Tier)" (new metric, percentage view split by tier) and "Cached Tokens Rate (hit tokens/s)" (existing sglang:cached_tokens_total counter, restored alongside it as a natural companion). Uses "datasource": {"default": true} rather than a hardcoded UID so it works on any fresh Grafana instance.

Test plan

  • Existing scheduler/metrics unit tests pass
  • Manual: run with --enable-metrics --enable-hierarchical-cache and confirm sglang:cache_hit_tokens_l1/l2/l3_total and cache_miss_tokens_total populate correctly, and the two Grafana panels render

CI States

Latest PR Test (Base): ❌ Run #29801015638
Latest PR Test (Extra): ❌ Run #29801015521

TianDi101 and others added 2 commits July 21, 2026 04:13
Re-adds the per-tier cache hit breakdown that was previously reverted
in feat/umbp-pr (commit 001e9ce): PrefillAdder tracks L1 (GPU device),
L2 (host DRAM), and L3 (storage) hit tokens plus cache misses, reported
via SchedulerStats and exported as sglang:cache_hit_tokens_l{1,2,3}_total
/ cache_miss_tokens_total Prometheus counters. Adapted to current code:
uses req.storage_hit_length directly (no getattr) and req.extend_range
instead of the since-removed req.extend_input_len.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Visualizes the L1/L2/L3 per-tier cache hit metrics from the previous
commit: 'Cache Hit Rate (Per-Tier)' (percentage view split by tier)
and 'Cached Tokens Rate (hit tokens/s)' (existing sglang:cached_tokens_total
counter, restored alongside it as a natural companion).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant