Skip to content

[Bugfix] Forward session headers to consistent-hash routing in PD discovery mode - #243

Open
simondanielsson wants to merge 6 commits into
vllm-project:mainfrom
simondanielsson:feat/session-header-in-pd-discovery
Open

simondanielsson wants to merge 6 commits into
vllm-project:mainfrom
simondanielsson:feat/session-header-in-pd-discovery

Conversation

@simondanielsson

@simondanielsson simondanielsson commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

This preserves session affinity for both completions and chat completions when running in --vllm-pd-disaggration mode with service discovery.

Previously, the X-Session-Id header was ignored in that case.

Test Plan

CI passes.

Test Result

OK


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results

Signed-off-by: simondanielsson <[email protected]>
@simondanielsson
simondanielsson marked this pull request as ready for review September 7, 2026 15:55
@hsliuustc0106

Copy link
Copy Markdown
Collaborator

fix rust checks please

Signed-off-by: simondanielsson <[email protected]>
…-discovery-consistent-hash

Signed-off-by: simondanielsson <[email protected]>
@simondanielsson

Copy link
Copy Markdown
Contributor Author

@simondanielsson

Copy link
Copy Markdown
Contributor Author

@hsliuustc0106 Who can I contact to get a review on this PR? Thanks

Copilot AI 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.

🟡 Changes recommended

The new per-request header normalization introduces avoidable allocations and should be gated on whether the active policies actually need headers, using ASCII-only lowercasing for header names.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes session affinity in vLLM prefill/decode (PD) discovery mode by ensuring request headers (notably X-Session-Id) are forwarded into policy-based worker selection, so consistent-hash routing can remain stable across requests.

Changes:

  • Normalize incoming HTTP headers and pass them into policy-based worker selection for PD discovery routing.
  • Update discovery-mode worker selection to use the header-aware policy selection API.
  • Add tests verifying consistent-hash routing uses session headers (and that cache-aware routing ignores them).
File summaries
File Description
src/routers/http/vllm_pd_router.rs Normalizes headers for discovery-mode selection, threads headers into policy-based routing, and adds regression tests for session-affinity behavior.
Review details

Suppressed comments (1)

src/routers/http/vllm_pd_router.rs:608

  • process_vllm_request normalizes all headers into a new HashMap for every request, even when the active policies don’t consult headers. This adds avoidable per-request allocations; you can gate the normalization on needs_headers() for the prefill/decode policies and pass None otherwise.
        let request_text = serde_json::to_string(&request_json).ok();
        let request_str = request_text.as_deref();
        let request_headers = headers.map(normalize_request_headers);

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/routers/http/vllm_pd_router.rs Resolved
@hsliuustc0106 hsliuustc0106 added the bug Something isn't working label Sep 14, 2026
MohitAMD added a commit to MohitAMD/router that referenced this pull request Oct 6, 2026
… (unified via dp_utils)

In --vllm-pd-disaggregation + --vllm-discovery-address, a DP engine registers one
http_address for all ranks, so the policy saw a single worker, no X-data-parallel-rank
was emitted, and consistent_hash built a 1-entry ring (--intra-node-data-parallel-size
silently ignored). Expand each discovered prefill instance into one host:port@rank entry
per intra-node DP rank, matching direct-URL mode.

Unified via a single shared dp_utils::expand_dp_aware_url primitive (also backing
get_dp_aware_workers), so the aggregated, direct-URL PD, and service-discovery PD routers
share one DP-expansion implementation. dp_size<=1 is a no-op and already-@rank URLs are
not double-expanded; decode is left unexpanded. consistent_hash.rs unchanged.

Scope narrowed per review: session-header forwarding dropped (superseded by vllm-project#243) and
load-aware consistent_hash dropped (deferred to the hash/load/cache-aware policy RFCs).

Signed-off-by: Mohit Deopujari <[email protected]>
Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants