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

[Bugfix] Forward session headers to consistent-hash routing in PD discovery mode#243
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 <simon.danielsson99@hotmail.com>
@simondanielsson
simondanielsson marked this pull request as ready for review September 7, 2026 15:55
Signed-off-by: simondanielsson <simon.danielsson99@hotmail.com>
Signed-off-by: simondanielsson <simon.danielsson99@hotmail.com>
@hsliuustc0106

Copy link
Copy Markdown
Collaborator

fix rust checks please

Signed-off-by: simondanielsson <simon.danielsson99@hotmail.com>
…-discovery-consistent-hash

Signed-off-by: simondanielsson <simon.danielsson99@hotmail.com>
@simondanielsson

Copy link
Copy Markdown
Contributor Author

Environment issue in NV PD tests causing CI to fail: https://buildkite.com/vllm/router/builds/786/canvas?sid=01a0812d-1087-4bb6-92ac-2546f27be662&tab=output

@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
Signed-off-by: simondanielsson <simon.danielsson99@hotmail.com>
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.

3 participants