Skip to content

[Feat][Router] Add per-algorithm routing decisions counter (Refs #474)#951

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

[Feat][Router] Add per-algorithm routing decisions counter (Refs #474)#951
banlor wants to merge 2 commits into
vllm-project:mainfrom
banlor:feat/routing-decisions-counter

Conversation

@banlor
Copy link
Copy Markdown
Contributor

@banlor banlor commented May 13, 2026

Routing decision counter for #474. Counter vllm:routing_decisions_total{server, model, algorithm, outcome}, incremented once per routing decision. outcome is success for the algorithm's primary path, fallback when an algorithm degrades (session router without session id falls back to QPS, kv-aware below match threshold falls back to session/QPS).

Orchestrated disaggregated routing is instrumented inside select_prefill_endpoint / select_decode_endpoint rather than route_request, because route_orchestrated_disaggregated_request bypasses route_request. Two decisions per request, prefill and decode.

DisaggregatedPrefillRouter (non-orchestrated) is not instrumented: prefill_client and decode_client are bound to fixed URLs at startup, no per-request routing.

Out of scope: retry outcome. No retry loop exists on the routing path today (max_instance_failover_reroute_attempts is parsed but unused). Will follow up if retry lands.

Tests in src/tests/test_routing_metrics.py cover round-robin, session (both branches), kv-aware fallback, orchestrated disaggregated, and the None-label defensive path.

Refs #474


  • Make sure the code changes pass the pre-commit checks.
  • Sign-off your commit by using -s when doing git commit
  • Try to classify PRs for easy understanding of the type of changes, such as [Bugfix], [Feat], and [CI].
Detailed Checklist (Click to Expand)

Thank you for your contribution to production-stack! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.

PR Title and Classification

Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:

  • [Bugfix] for bug fixes.
  • [CI/Build] for build or continuous integration improvements.
  • [Doc] for documentation fixes and improvements.
  • [Feat] for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).
  • [Router] for changes to the vllm_router (e.g., routing algorithm, router observability, etc.).
  • [Misc] for PRs that do not fit the above categories. Please use this sparingly.

Note: If the PR spans more than one category, please include all relevant prefixes.

Code Quality

The PR need to meet the following code quality standards:

  • Pass all linter checks. Please use pre-commit to format your code. See README.md for installation.
  • The code need to be well-documented to ensure future contributors can easily understand the code.
  • Please include sufficient tests to ensure the change is stay correct and robust. This includes both unit tests and integration tests.

DCO and Signed-off-by

When contributing changes to this project, you must agree to the DCO. Commits must include a Signed-off-by: header which certifies agreement with the terms of the DCO.

Using -s with git commit will automatically add this header.

What to Expect for the Reviews

We aim to address all PRs in a timely manner. If no one reviews your PR within 5 days, please @-mention one of YuhanLiu11
, Shaoting-Feng or ApostaC.

Copy link
Copy Markdown
Contributor

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

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 added 2 commits May 15, 2026 20:59
…-project#474)

Adds Prometheus counter `vllm:routing_decisions_total{server, model,
algorithm, outcome}` recording every routing decision. Outcome
distinguishes the algorithm's primary path from internal fallbacks
(session router with no session id, kv-aware below match threshold).

Orchestrated disaggregated routing is instrumented at
`select_prefill_endpoint` / `select_decode_endpoint` since the
production flow bypasses `route_request`.

Signed-off-by: Mikhail Basov <Michael.S.Sinclair@protonmail.com>
The whole KV-cache miss branch is a degradation from kv-aware's
primary path (cache lookup), so both session-id hash-ring and QPS
sub-branches record outcome=fallback. Previously only the QPS path
was marked fallback, which understated KV-aware misses in the metric.

Signed-off-by: Mikhail Basov <Michael.S.Sinclair@protonmail.com>
@banlor banlor force-pushed the feat/routing-decisions-counter branch from cf970c4 to 16df357 Compare May 15, 2026 15:59
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