Skip to content

[Feat] Add priority routing - #996

Merged
ruizhang0101 merged 6 commits into
vllm-project:mainfrom
punitvara:copilot/priority-routing-squash
Aug 18, 2026
Merged

ruizhang0101 merged 6 commits into
vllm-project:mainfrom
punitvara:copilot/priority-routing-squash

Conversation

@punitvara

Copy link
Copy Markdown
Contributor

Adds a new proposal at proposals/priority-routing.md to define priority-aware routing for the vLLM Production Stack router. The document specifies how request priority is extracted, used for load-aware engine selection, and forwarded for in-engine scheduling.

  • What this PR adds

    • New proposal file: proposals/priority-routing.md
    • Full RFC-style structure: Summary, Motivation, Goals/Non-Goals, Proposal, Drawbacks, Alternatives, Timeline, References
  • Key design decisions captured

    • Introduces routing-logic=priority
    • Defines priority resolution order: header → body field → default
    • Selects Option A (binary threshold) as initial strategy for load-ranked routing
    • Specifies fallback to round-robin when load metrics are unavailable
    • Preserves vLLM pass-through semantics (priority field injection)
  • Interface/config details documented

    • Proposed router flags:
      • --priority-header
      • --priority-field
      • --priority-default
      • --priority-threshold

Example excerpt from the proposal:

Priority source resolution:
1) --priority-header (default: x-request-priority)
2) --priority-field  (default: priority)
3) --priority-default (default: 0)

Selection rule (Option A):
if priority <= priority-threshold -> least-loaded engine
else -> round-robin over remaining engines

Signed-off-by: Punit Vara [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 introduces a new design proposal for priority-based routing in the vLLM Production Stack router. The feedback focuses on correcting formatting issues in the proposal document, including fixing broken HTML anchor tags in the Table of Contents, removing a copy-paste artifact ('Become a Medium member') from an ASCII diagram, and replacing spaced em-dashes with standard double hyphens for CLI arguments.

Comment thread proposals/priority-routing.md Outdated
Comment on lines +2 to +8
- <a>Summary</a>
- <a>Motivation</a>
- <a>Proposal</a>
- <a>Drawbacks</a>
- <a>Alternatives</a>
- [Implementation Timeline / Phases](#implementation-timeline — phases)
- <a>References</a>

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.

medium

The Table of Contents contains broken HTML anchor tags (<a>) without href attributes, and the link for 'Implementation Timeline / Phases' uses an em-dash instead of a standard hyphen structure. They should be updated to standard Markdown relative links.

Suggested change
- <a>Summary</a>
- <a>Motivation</a>
- <a>Proposal</a>
- <a>Drawbacks</a>
- <a>Alternatives</a>
- [Implementation Timeline / Phases](#implementation-timeline — phases)
- <a>References</a>
- [Summary](#summary)
- [Motivation](#motivation)
- [Proposal](#proposal)
- [Drawbacks](#drawbacks)
- [Alternatives](#alternatives)
- [Implementation Timeline / Phases](#implementation-timeline--phases)
- [References](#references)

Comment thread proposals/priority-routing.md Outdated
Comment on lines +46 to +50
┌────────────────┐
│ vLLM engine │ priority scheduler
Become a Medium member
│ (preempts) │ serves P first
└────────────────┘

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.

medium

There is a copy-paste artifact ('Become a Medium member') inside the ASCII diagram on line 48, which also breaks the alignment of the box. This should be removed and the box borders properly aligned.

Suggested change
┌────────────────┐
│ vLLM engine │ priority scheduler
Become a Medium member
│ (preempts) │ serves P first
└────────────────┘
┌────────────────┐
│ vLLM engine │ priority scheduler
│ (preempts) │ serves P first
└────────────────┘

Comment thread proposals/priority-routing.md Outdated
- **What use cases does it address?** Tiered service levels (premium vs. free), prioritizing interactive over batch traffic, keeping health/readiness probes responsive under load, and de-prioritizing best-effort background jobs.
- **What current limitations does it alleviate?** The router cannot differentiate traffic by importance, and vLLM’s own priority scheduler is unreachable because no routing logic propagates a priority field to the engine.
### Goals
- Add `priority` as a new ` — routing-logic` option.

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.

medium

The CLI argument uses a spaced em-dash (—) instead of double hyphens (--). This is likely a formatting artifact and should be corrected to ensure accurate documentation.

Suggested change
- Add `priority` as a new ` — routing-logic` option.
- Add `priority` as a new `--routing-logic` option.

Comment thread proposals/priority-routing.md Outdated
Comment on lines +29 to +33
**Priority semantics.** We adopt vLLM’s convention so pass-through is lossless: `priority` is an integer where **lower means higher priority** (served earlier). The default is configurable (` — priority-default`, default `0`).
**Priority source.** Resolved in this order:
1. Request header named by ` — priority-header` (default `x-request-priority`).
2. Request body field named by ` — priority-field` (default `priority`).
3. ` — priority-default`.

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.

medium

Several CLI arguments in this section use spaced em-dashes (—) instead of double hyphens (--). They should be corrected to standard double-hyphen CLI argument syntax.

Suggested change
**Priority semantics.** We adopt vLLM’s convention so pass-through is lossless: `priority` is an integer where **lower means higher priority** (served earlier). The default is configurable (` — priority-default`, default `0`).
**Priority source.** Resolved in this order:
1. Request header named by ` — priority-header` (default `x-request-priority`).
2. Request body field named by ` — priority-field` (default `priority`).
3. ` — priority-default`.
**Priority semantics.** We adopt vLLM’s convention so pass-through is lossless: `priority` is an integer where **lower means higher priority** (served earlier). The default is configurable (`--priority-default`, default `0`).
**Priority source.** Resolved in this order:
1. Request header named by `--priority-header` (default `x-request-priority`).
2. Request body field named by `--priority-field` (default `priority`).
3. `--priority-default`.

Comment thread proposals/priority-routing.md Outdated
Comment on lines +58 to +60
- **Option A — binary threshold (proposed default).** Requests whose priority is at least as important as a configurable threshold (`priority <= — priority-threshold`, default equal to ` — priority-default`) are routed to the least-loaded engine; all others round-robin across the remaining engines. Simple to reason about, deterministic, and easy to unit-test. Selected as the default.
- **Option B — proportional rank mapping.** The priority value is mapped onto the load-ranked engine list so that the most important requests get the least-loaded engine and progressively lower-priority requests get progressively more-loaded engines. More granular, but the mapping is fuzzier, harder to test deterministically, and sensitive to how sparse or clustered the priority values are.
Both are compatible with the same router interface; the strategy could be exposed later via a ` — priority-selection={binary,proportional}` flag if Option B proves useful. This proposal implements Option A first.

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.

medium

The CLI arguments in this section use spaced em-dashes (—) instead of double hyphens (--). They should be corrected to standard double-hyphen CLI argument syntax.

Suggested change
- **Option A — binary threshold (proposed default).** Requests whose priority is at least as important as a configurable threshold (`priority <= — priority-threshold`, default equal to ` — priority-default`) are routed to the least-loaded engine; all others round-robin across the remaining engines. Simple to reason about, deterministic, and easy to unit-test. Selected as the default.
- **Option B — proportional rank mapping.** The priority value is mapped onto the load-ranked engine list so that the most important requests get the least-loaded engine and progressively lower-priority requests get progressively more-loaded engines. More granular, but the mapping is fuzzier, harder to test deterministically, and sensitive to how sparse or clustered the priority values are.
Both are compatible with the same router interface; the strategy could be exposed later via a ` — priority-selection={binary,proportional}` flag if Option B proves useful. This proposal implements Option A first.
- **Option A — binary threshold (proposed default).** Requests whose priority is at least as important as a configurable threshold (`priority <= --priority-threshold`, default equal to `--priority-default`) are routed to the least-loaded engine; all others round-robin across the remaining engines. Simple to reason about, deterministic, and easy to unit-test. Selected as the default.
- **Option B — proportional rank mapping.** The priority value is mapped onto the load-ranked engine list so that the most important requests get the least-loaded engine and progressively lower-priority requests get progressively more-loaded engines. More granular, but the mapping is fuzzier, harder to test deterministically, and sensitive to how sparse or clustered the priority values are.
Both are compatible with the same router interface; the strategy could be exposed later via a `--priority-selection={binary,proportional}` flag if Option B proves useful. This proposal implements Option A first.

@punitvara
punitvara force-pushed the copilot/priority-routing-squash branch from 973b85e to e43f9c6 Compare July 14, 2026 08: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.

Thanks for the proposal, I think it is solid overall with some minor suggestions.

| `--routing-logic=priority` | — | Enable priority routing |
| `--priority-header` | `x-request-priority` | Header carrying the request priority |
| `--priority-field` | `priority` | Body field carrying the request priority |
| `--priority-default` | `0` | Priority used when none is provided |

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.

Does default 0 mean all the requests have the highest priority? Is this intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — that was unintentional. Fixed by tightening the comparison to a strict priority < threshold. Now default-priority (untagged) traffic never auto-qualifies as high-priority — only requests explicitly marked below the threshold do. --priority-threshold still defaults to --priority-default so the mental model stays simple, but the boundary is now exclusive.

Comment thread proposals/priority-routing.md Outdated
└────────────────┘
```
1. Client sends a request with a priority (header or body).
2. Router extracts the priority and ranks candidate engines by live load (`num_running_requests + num_queuing_requests` from `EngineStats`).

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.

The enginestats might have delay since it is scraped based. Would be better to use the router side inflight requests metrics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. updated for the same.

high priority ──────────────────┼────────▶ least-loaded engine
normal priority ────────────────┼────────▶ round-robin remainder
│
│ inject “priority”: P into body

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.

vllm might not be able to take priority if the scheduling is not priority, consider adding a safe fallback and a warning?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a fallback + warning. if the engine wasn't started with --scheduling-policy priority, vLLM just ignores the injected priority field with no adverse effect (safe no-op), and the router logs a one-time startup warning reminding operators to verify their engines are configured for priority scheduling when routing-logic=priority is on. happy to discuss if we want a stronger guard

Comment thread proposals/priority-routing.md Outdated
4. Router injects `priority` into the forwarded body so vLLM’s priority scheduler can preempt within the engine.
5. Response streams back normally.
**Engine selection strategy.** Two strategies were considered for mapping a priority value onto the load-ranked engine list:
- **Option A — binary threshold (proposed default).** Requests whose priority is at least as important as a configurable threshold (`priority <= --priority-threshold`, default equal to `--priority-default`) are routed to the least-loaded engine; all others round-robin across the remaining engines. Simple to reason about, deterministic, and easy to unit-test. Selected as the default.

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.

If all the requests are low priority, the least loaded engine will never be used. Consider roundrobin across all the engines instead of remaining engines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

@punitvara
punitvara force-pushed the copilot/priority-routing-squash branch from e43f9c6 to 158b7fa Compare July 23, 2026 17:31
@punitvara

Copy link
Copy Markdown
Contributor Author

Should I raise separate PR draft for code ? Or should I keep commit with this PR ?

@punitvara
punitvara force-pushed the copilot/priority-routing-squash branch from 158b7fa to 260ce9d Compare July 28, 2026 17:03
@punitvara

Copy link
Copy Markdown
Contributor Author

@ruizhang0101 I updated Proposal and also added code. Can you please review it ?

@punitvara

Copy link
Copy Markdown
Contributor Author

Do you want me to update anything @ruizhang0101 ?

ruizhang0101
ruizhang0101 previously approved these changes Aug 3, 2026

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

Could you add some user-facing doc/tutorial? Otherwise LGTM.

@punitvara
punitvara force-pushed the copilot/priority-routing-squash branch from 260ce9d to 8502705 Compare August 4, 2026 01:55
@punitvara punitvara changed the title [Doc] Add priority routing proposal draft [Feat] Add priority routing proposal draft Aug 4, 2026
@punitvara punitvara changed the title [Feat] Add priority routing proposal draft [Feat] Add priority routing Aug 4, 2026
@punitvara

Copy link
Copy Markdown
Contributor Author

ok done @ruizhang0101 Do we need to get any other approval or is it good to merge ?

ruizhang0101
ruizhang0101 previously approved these changes Aug 4, 2026

@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 enabled auto-merge (squash) August 4, 2026 20:24
Introduce a new "priority" routing-logic mode that resolves a
per-request priority (header > body field > default), steering
higher-priority requests to the least-loaded engine while all other
requests round-robin across every healthy engine. The resolved
priority is also injected back into the forwarded request body so
vLLM's own priority scheduler can preempt within the engine.

- Add PriorityRouter to routing_logic.py and wire it into
  initialize/get/cleanup routing logic helpers
- Add --priority-header, --priority-field, --priority-default, and
  --priority-threshold CLI args
- Thread priority config through DynamicRouterConfig and app
  initialization for dynamic reconfiguration
- Recompute Content-Length after injecting priority into the request
  body in request_service/request.py
- Add unit tests for PriorityRouter in test_priority_router.py

Signed-off-by: Punit Vara <[email protected]>
Addresses review feedback requesting user-facing docs for the priority
routing feature.

Signed-off-by: Punit Vara <[email protected]>
auto-merge was automatically disabled August 5, 2026 04:16

Head branch was pushed to by a user without write access

@punitvara
punitvara force-pushed the copilot/priority-routing-squash branch from 767a1cf to 2130298 Compare August 5, 2026 04:16
Reformat test_priority_router.py with black and fix markdownlint
violations in priority-routing.md (missing blank lines around
headings/lists/fences, missing top-level H1).

Signed-off-by: Punit Vara <[email protected]>
@punitvara
punitvara force-pushed the copilot/priority-routing-squash branch from 2130298 to c4148ba Compare August 5, 2026 04:42
@punitvara

punitvara commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Can you restart worfklows @ruizhang0101 ? Not sure why they are getting timed out. I have rebased and had force push, auto merge was automatically disabled.

@punitvara

Copy link
Copy Markdown
Contributor Author

@ruizhang0101 Can I focus on any other issue if nothing else is required in this one ?

@ruizhang0101
ruizhang0101 enabled auto-merge (squash) August 10, 2026 18:11
@punitvara

Copy link
Copy Markdown
Contributor Author

I think there is some issue with checks. This wont auto merge @ruizhang0101 Can you check that part ?

@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 58a0935 into vllm-project:main Aug 18, 2026
25 of 31 checks passed
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