Skip to content

[Router] Count routing fallbacks per routing logic - #951

Open
banlor wants to merge 1 commit into
vllm-project:mainfrom
banlor:feat/routing-decisions-counter
Open

banlor wants to merge 1 commit into
vllm-project:mainfrom
banlor:feat/routing-decisions-counter

Conversation

@banlor

@banlor banlor commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

The request counter shows how many requests were routed, but not how often a routing logic left its primary policy. KV-aware routing that keeps missing the cache still routes every request, so the miss does not show up in metrics (#1062 documents how silent this is today).

This adds one counter, vllm:routing_fallbacks_total{routing_logic, reason}, incremented only when a router takes its fallback path:

routing_logic reason
session no_session_id
kvaware no_cache_hit, no_live_holder, below_threshold
loadaware lookup_failed, no_cache_hit
prefixaware below_threshold

Routing behavior does not change. Both labels take fixed values, so the counter has at most 7 series.

Tests add one case per reason, plus a primary-path hit that must not be counted, in the existing per-router test files. pytest src/tests passes (283), and pre-commit passes on the changed files.

Refs #474

@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 introduces a new Prometheus metric, routing_decisions_total, to track routing decisions across all router implementations. It adds logic to record these decisions with labels for server, model, algorithm, and outcome. Feedback suggests that the KvawareRouter should specifically record a fallback outcome upon a KV cache miss when a session ID is present, and that the test suite should be updated accordingly.

Comment thread src/tests/test_routing_metrics.py Resolved
@banlor
banlor marked this pull request as ready for review May 13, 2026 21:36
@banlor
banlor force-pushed the feat/routing-decisions-counter branch from cf970c4 to 16df357 Compare May 15, 2026 15:59

@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.

I am wondering what is the use case for this metrics? IIUC, each request will go through routing decision. So if we don't consider retry or fail, they should be the same?

@banlor
banlor force-pushed the feat/routing-decisions-counter branch from 16df357 to cfd20ea Compare June 3, 2026 12:09
@banlor

banlor commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi @ruizhang0101, good to see you again. Sorry I left this hanging for so long.

You’re right. In the simple case this mostly duplicates the request counter. The useful part is seeing where traffic goes and when routing falls back or retries. I checked current main and this PR is too stale to revive as is, so I’d rather rework it around those cases. What do you think?

@banlor
banlor force-pushed the feat/routing-decisions-counter branch from cfd20ea to 3bbe398 Compare September 3, 2026 21:38
@banlor

banlor commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Reworked this around the gap you pointed out. The counter now records bounded algorithm, decision, and reason labels for fallbacks, retries, and prefill/decode selections, which the request counter does not expose. Backend IDs and URLs are excluded so cardinality stays bounded.

@banlor

banlor commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

@ruizhang0101 any feedback on the revised routing counter? It now covers routing choices and fallbacks rather than request volume.

@banlor

banlor commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

#1079 is waiting for review too. @Shaoting-Feng could you take a look at the routing counter changes here?

@banlor

banlor commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

The routing counter changes here and the resource requests and limits in #1079 are still awaiting review. @YuhanLiu11 could you look at them?

@banlor
banlor force-pushed the feat/routing-decisions-counter branch 2 times, most recently from f70aa03 to c1c3803 Compare October 15, 2026 16:35
Add vllm:routing_fallbacks_total{routing_logic,reason}, counted when the
session, kvaware, loadaware or prefixaware router leaves its primary
policy. Every request is routed, so the request counter cannot show how
often a router fell back, e.g. KV-aware routing missing the cache.

Signed-off-by: Mikhail Basov <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@banlor
banlor force-pushed the feat/routing-decisions-counter branch from c1c3803 to 0c40288 Compare October 23, 2026 06:04
@banlor banlor changed the title [Feat][Router] Add per-algorithm routing decisions counter (Refs #474) [Router] Count routing fallbacks per routing logic Oct 23, 2026
@banlor

banlor commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@ruizhang0101 you were right that counting every routing decision mostly repeats the request counter. I cut this PR down to the part the request counter can't show: vllm:routing_fallbacks_total counts only requests where a router leaves its primary policy, such as KV-aware routing missing the cache. It is now about 25 lines of router code plus tests. I dropped the multipart change, since #1095 covers it, and the load-aware lookup change. Could you take another look?

@banlor

banlor commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@Shaoting-Feng could you take a look at this reworked fallback counter? It is now about 25 lines of router code plus tests, and CI is green.

This branch has not been deployed

No deployments
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.

2 participants