Skip to content

[Feat][Router] Add per-algorithm routing decisions counter (Refs #474) - #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

What this changes

The request counter shows request volume, but it cannot explain which routing path selected a backend. This redesign adds a routing-decision counter for primary choices, fallbacks, retries, and prefill/decode selections.

  • Routing methods still return URL-compatible strings. Selection metadata is carried by an immutable RoutingDecision string subtype.
  • The counter records only algorithm, decision, and reason.
  • Load-aware routing validates the current LMCache instance identity before crediting a cached prefix, including same-URL restarts and unavailable holders.
  • Multipart dispatch awaits async routing methods instead of calling them synchronously.

Cardinality

All three labels use explicit allowlists: 9 algorithms × 6 decisions × 10 reasons, for at most 540 label combinations per registry. Backend IDs, URLs, model names, and request metadata are not labels.

Tests

  • 58 focused routing-decision, KV-aware, and load-aware tests pass.
  • The full router suite reports 256 passed with the same 3 Windows-only parser expectation failures as clean main.
  • Pre-commit passes on every changed file.

Closes #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/vllm_router/routers/routing_logic.py Outdated
Comment thread src/tests/test_routing_metrics.py Outdated
@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 from 3bbe398 to f70aa03 Compare October 10, 2026 11:08
Signed-off-by: Michael Basov <124149774+banlor@users.noreply.github.com>

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.

feature: enhance observability with instance-level and routing-level metrics

2 participants