Repository navigation
[Feat] Add priority routing - #996
Conversation
There was a problem hiding this comment.
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.
| - <a>Summary</a> | ||
| - <a>Motivation</a> | ||
| - <a>Proposal</a> | ||
| - <a>Drawbacks</a> | ||
| - <a>Alternatives</a> | ||
| - [Implementation Timeline / Phases](#implementation-timeline — phases) | ||
| - <a>References</a> |
There was a problem hiding this comment.
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.
| - <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) |
| ┌────────────────┐ | ||
| │ vLLM engine │ priority scheduler | ||
| Become a Medium member | ||
| │ (preempts) │ serves P first | ||
| └────────────────┘ |
There was a problem hiding this comment.
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.
| ┌────────────────┐ | |
| │ vLLM engine │ priority scheduler | |
| Become a Medium member | |
| │ (preempts) │ serves P first | |
| └────────────────┘ | |
| ┌────────────────┐ | |
| │ vLLM engine │ priority scheduler | |
| │ (preempts) │ serves P first | |
| └────────────────┘ |
| - **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. |
There was a problem hiding this comment.
| **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`. |
There was a problem hiding this comment.
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.
| **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`. |
| - **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. |
There was a problem hiding this comment.
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.
| - **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. |
973b85e to
e43f9c6
Compare
ruizhang0101
left a comment
There was a problem hiding this comment.
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 | |
There was a problem hiding this comment.
Does default 0 mean all the requests have the highest priority? Is this intentional?
There was a problem hiding this comment.
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.
| └────────────────┘ | ||
| ``` | ||
| 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`). |
There was a problem hiding this comment.
The enginestats might have delay since it is scraped based. Would be better to use the router side inflight requests metrics.
There was a problem hiding this comment.
Agreed. updated for the same.
| high priority ──────────────────┼────────▶ least-loaded engine | ||
| normal priority ────────────────┼────────▶ round-robin remainder | ||
| │ | ||
| │ inject “priority”: P into body |
There was a problem hiding this comment.
vllm might not be able to take priority if the scheduling is not priority, consider adding a safe fallback and a warning?
There was a problem hiding this comment.
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
| 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. |
There was a problem hiding this comment.
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.
e43f9c6 to
158b7fa
Compare
|
Should I raise separate PR draft for code ? Or should I keep commit with this PR ? |
158b7fa to
260ce9d
Compare
|
@ruizhang0101 I updated Proposal and also added code. Can you please review it ? |
|
Do you want me to update anything @ruizhang0101 ? |
260ce9d to
8502705
Compare
|
ok done @ruizhang0101 Do we need to get any other approval or is it good to merge ? |
ref: vllm-project#855 Signed-off-by: Punit Vara <[email protected]>
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]>
Head branch was pushed to by a user without write access
767a1cf to
2130298
Compare
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]>
2130298 to
c4148ba
Compare
|
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. |
|
@ruizhang0101 Can I focus on any other issue if nothing else is required in this one ? |
|
I think there is some issue with checks. This wont auto merge @ruizhang0101 Can you check that part ? |
Adds a new proposal at
proposals/priority-routing.mdto 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
proposals/priority-routing.mdKey design decisions captured
routing-logic=prioritypriorityfield injection)Interface/config details documented
--priority-header--priority-field--priority-default--priority-thresholdExample excerpt from the proposal:
Signed-off-by: Punit Vara [email protected]