Skip to content

[Bugfix][Router] Read vllm:kv_cache_usage_perc for KV cache usage - #1118

Merged
ruizhang0101 merged 4 commits into
vllm-project:mainfrom
ibrahimnd2000:fix-kv-cache-usage-metric
Oct 14, 2026
Merged

ruizhang0101 merged 4 commits into
vllm-project:mainfrom
ibrahimnd2000:fix-kv-cache-usage-metric

Conversation

@ibrahimnd2000

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

vLLM renamed vllm:gpu_cache_usage_perc to vllm:kv_cache_usage_perc, and newer releases (e.g. v0.31) only export the new name. EngineStats.from_vllm_scrape only reads the old name, so every engine reports 0 KV cache usage to the router — any routing or dashboard logic that looks at KV usage silently sees idle engines. This is one concrete case of #1074.

The fix accepts both metric names into the existing gpu_cache_usage_perc field (no API change).

Test: new src/tests/test_engine_stats_kv_usage.py (new name read, legacy name still read); it fails on main. Full router test suite: 184 passed.

Part of #1074.

vLLM renamed vllm:gpu_cache_usage_perc to vllm:kv_cache_usage_perc and newer
releases (e.g. v0.31) only export the new name, so EngineStats reported 0 KV
usage for every engine. Accept both names. Part of vllm-project#1074.

Signed-off-by: Muhammad Ibrahim <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the EngineStats.from_vllm_scrape method to support both the legacy vllm:gpu_cache_usage_perc and the new vllm:kv_cache_usage_perc metric names, ensuring compatibility with newer vLLM releases. It also adds corresponding unit tests to verify that both metric names are correctly parsed. There are no review comments, so I have no feedback to provide.

@qaisermehdi3-coder

Copy link
Copy Markdown

Nice fix. The prefix cache counters were renamed too: vLLM 0.27.1 registers vllm:prefix_cache_queries and vllm:prefix_cache_hits (exposed with _total), but engine_stats.py still matches vllm:gpu_prefix_cache_queries_total / _hits_total, and there is no gpu_prefix_cache_hit_rate gauge in v1 anymore. So those router stats would stay 0 on current vLLM too. Might be worth covering in this PR. (From reading the code, I have not run the router.) Qaiser

@ruizhang0101 ruizhang0101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ruizhang0101
ruizhang0101 merged commit 031f54e into vllm-project:main Oct 14, 2026
16 checks passed
ibrahimnd2000 pushed a commit to ibrahimnd2000/production-stack that referenced this pull request Oct 14, 2026
Resolve the conflict with vllm-project#1118 in engine_stats.py: keep the per-engine
aggregation, and read both vllm:gpu_cache_usage_perc and the renamed
vllm:kv_cache_usage_perc into the per-engine KV cache usage.

Signed-off-by: Muhammad Ibrahim <[email protected]>
ibrahimnd2000 added a commit to ibrahimnd2000/production-stack that referenced this pull request Oct 22, 2026
Resolve the conflict with vllm-project#1118 in engine_stats.py: keep the per-engine
aggregation, and read both vllm:gpu_cache_usage_perc and the renamed
vllm:kv_cache_usage_perc into the per-engine KV cache usage.

Signed-off-by: Muhammad Ibrahim <[email protected]>
bcdonadio added a commit to powerhome/vllm-production-stack that referenced this pull request Nov 12, 2026
* [Bugfix][Router] Read vllm:kv_cache_usage_perc for KV cache usage (vllm-project#1118)

Signed-off-by: Muhammad Ibrahim <[email protected]>

* [Doc] Add Simplified Chinese translation (README.zh.md) (vllm-project#1136)

Signed-off-by: YE <[email protected]>

* [CI/Build] Run helm unittest in CI and fix two broken tests (vllm-project#1131)

Signed-off-by: zjjkee <[email protected]>

* [Bugfix][Router] Key request stats by dispatch, not by X-Request-Id (vllm-project#1115)

Signed-off-by: David-Wu1119 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Rui Zhang <[email protected]>

* [Bugfix][Router] Use least-inflight for PrefixAware below-threshold fallback (vllm-project#1089)

Signed-off-by: Dundy Pasupuleti <[email protected]>

* [Bugfix][Router] Keep P/D model labels when dynamic config reloads the router (vllm-project#1129)

Signed-off-by: MinJun Choi <[email protected]>

* [Bugfix] Match KEDA scalers to enabled model deployments (vllm-project#1142)

Signed-off-by: bojiang-li <[email protected]>

* [Router] added pooling route (vllm-project#1112)

Signed-off-by: [email protected] <[email protected]>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Rui Zhang <[email protected]>

* [CI] Drop host docker prune from runner-cleanup workflow (vllm-project#1174)

Signed-off-by: Rui Zhang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

* [Feat][Router] Add /v1/systemone and /v1/decisions routes (vllm-project#1173)

Signed-off-by: Shern Shiou Tan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

* [CI/Build] Stop k8s routing tests when the engine pods never become ready (vllm-project#1134)

Signed-off-by: MinJun Choi <[email protected]>

* [Bugfix][Router] Upgrade aiohttp and vllm (0.33.0) to resolve router image CVEs (vllm-project#1185)

Signed-off-by: Shern Shiou Tan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

* Bump chart version to 0.1.14 (vllm-project#1190)

Signed-off-by: Rui Zhang <[email protected]>

---------

Signed-off-by: Muhammad Ibrahim <[email protected]>
Signed-off-by: YE <[email protected]>
Signed-off-by: zjjkee <[email protected]>
Signed-off-by: David-Wu1119 <[email protected]>
Signed-off-by: Dundy Pasupuleti <[email protected]>
Signed-off-by: MinJun Choi <[email protected]>
Signed-off-by: bojiang-li <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: Rui Zhang <[email protected]>
Signed-off-by: Shern Shiou Tan <[email protected]>
Signed-off-by: MinJun Choi <[email protected]>
Signed-off-by: Rui Zhang <[email protected]>
Signed-off-by: Bernardo Donadio <[email protected]>
Co-authored-by: Muhammad Ibrahim <[email protected]>
Co-authored-by: YE <[email protected]>
Co-authored-by: Jingke zou <[email protected]>
Co-authored-by: Yanze (David) Wu <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Rui Zhang <[email protected]>
Co-authored-by: Dundy Pasupuleti <[email protected]>
Co-authored-by: MinJun Choi <[email protected]>
Co-authored-by: Bojiang Li <[email protected]>
Co-authored-by: MaelvanDijk <[email protected]>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Shern Shiou Tan <[email protected]>
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.

3 participants