Skip to content

[Fix] sgl-router: Send disagg_prefill_dp_rank to decode under --dp-aware - #44072

Merged
ShangmingCai merged 3 commits into
sgl-project:mainfrom
AMD-yanfeiwang:fix/sgl-router-pd-prefill-rank-hint
Oct 15, 2026
Merged

ShangmingCai merged 3 commits into
sgl-project:mainfrom
AMD-yanfeiwang:fix/sgl-router-pd-prefill-rank-hint

Conversation

@AMD-yanfeiwang

@AMD-yanfeiwang AMD-yanfeiwang commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

With --dp-aware in PD mode, sgl-router pins the prefill DP rank but does not tell decode which rank that is. Decode needs it to set up its KV receiver. It can derive it from the bootstrap room only if prefill runs --load-balance-method follow_bootstrap_room; with any other method, decode asks prefill's bootstrap server, which learns the room only when prefill's scheduler picks the request up, so decode polls until then. Every decode handshake therefore waits on prefill's scheduler loop, and with the default --optimistic-prefill-attempts 0, prefill does not run a request until it sees decode ready. sgl-model-gateway and mini_lb already send disagg_prefill_dp_rank to decode.

Modifications

  • When --dp-aware pins the prefill rank, the decode body also carries it as disagg_prefill_dp_rank, for /generate, /v1/completions, /v1/chat/completions and /v1/messages. The prefill body is unchanged, and batch / n > 1 requests, which leave the prefill rank to the engine, send none.
  • README: DP-rank routing.

Testing

  • dp_rank_routing::pd_generate_carries_each_rank_in_its_body: decode's disagg_prefill_dp_rank equals prefill's routed_dp_rank (fails without this change). pd_fan_out_leaves_the_prefill_rank_to_the_engine: decode gets none.
  • Passing: cargo +nightly fmt --all -- --check, cargo check, cargo clippy -- -D warnings, cargo test --release --workspace -- --skip parity_matrix.

Benchmark (MI355X)

DeepSeek-V4-Pro, 1 prefill + 1 decode engine with 8 DP-attention ranks each, AgentX trace replay with AIPerf (multi-turn agentic sessions, 96% prefix-cache hit), 1 h per concurrency, prefill --optimistic-prefill-attempts 2. Router --policy sticky --routing-key-header X-SMG-Routing-Key --decode-policy power_of_two --dp-aware, decode ranks round-robin (#43511), built at 1e86143.

The runs predate this patch, so both arms use the same router binary and differ only in prefill's load-balance method:

  • before: round_robin, so decode looks every room up, as on main today;
  • after: follow_bootstrap_room, so decode computes the rank from the room. That is the information this PR sends, so decode's handshake is the same.

Handshake, mean over the hour (before → after):

conc decode handshake (ms) prefill bootstrap (ms) decode prealloc queue
192 595 → 0 1619 → 49 3.2 → 0
256 613 → 0 1642 → 56 4.3 → 0
384 682 → 0 1555 → 53 6.1 → 0
512 749 → 0 1458 → 63 6.9 → 0

The first two columns are each engine's kv_transfer_bootstrap_ms: until decode's receiver is ready, and until prefill sees it ready. The prealloc queue is decode's #prealloc-req, summed over its 8 ranks. For reference, sgl-model-gateway on the same engines, which sends the rank like this PR, measured 0 ms, 30–34 ms and 0 at every concurrency. With least-in-flight decode ranks (main's default), decode's handshake went from 587–723 ms to 0.

End to end, AIPerf (before → after):

conc output tok/s/GPU TTFT p50 (s) TTFT p90 (s) TPOT p50 (ms) TPOT p90 (ms)
192 369.5 → 369.9 3.26 → 3.38 10.68 → 10.54 14.59 → 14.61 16.31 → 16.22
256 441.6 → 438.2 3.71 → 3.76 13.70 → 13.90 16.98 → 16.93 18.53 → 18.45
384 562.6 → 561.4 7.02 → 7.59 30.01 → 31.01 19.98 → 19.80 22.85 → 22.45
512 577.0 → 599.8 19.54 → 16.84 64.17 → 57.90 21.24 → 23.13 24.47 → 25.50
  • Decode's receiver is ready when its request arrives, so prefill sees the handshake done about as fast as with the gateway, and decode's prealloc queue and bootstrap-server lookups are gone.
  • At 192–384, throughput and latency stayed within run-to-run noise (TTFT p50 at 384 ranges 8.07–9.32 s across four gateway runs that differ only in decode policy). In these runs --optimistic-prefill-attempts 2 let prefill start requests before decode was ready, which kept the late handshake off the critical path. With the default of 0, prefill holds each request until it sees decode ready, which took about 1.5 s here instead of about 50 ms; that case was not measured.
  • At 512, the arms differ in both directions because prefill ranks are pinned by a hash of the benchmark's routing keys, which are random per run. The before run had the most uneven prefill split of six c512 runs.

CI States

Latest PR Test (Base): ✅ Run #38682284072
Latest PR Test (Extra): ❌ Run #38682284058
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.

With --dp-aware in PD mode the router pins the prefill DP rank but did
not tell decode which rank that was. Unless prefill runs
--load-balance-method follow_bootstrap_room, SGLang's decode then looks
up every room on prefill's bootstrap server, which prefill has to
register first; under load that held decode KV-receiver setup at
0.6-0.75 s per request instead of ~5 ms. Name the pinned rank in the
decode body, as sgl-model-gateway does. Prefill's body is unchanged, and
a batch or n > 1 request still leaves the prefill rank to the engine.
@AMD-yanfeiwang
AMD-yanfeiwang force-pushed the fix/sgl-router-pd-prefill-rank-hint branch from c4dddff to d12b15b Compare October 14, 2026 03:55
@AMD-yanfeiwang AMD-yanfeiwang changed the title [sgl-router] Send disagg_prefill_dp_rank to decode under --dp-aware [Fix] sgl-router: Send disagg_prefill_dp_rank to decode under --dp-aware Oct 14, 2026
Since sgl-project#43511, step 3 is turn-based under --dp-rank-policy round_robin, so
"load only" no longer describes it. Match main's wording.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@ShangmingCai

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 15, 2026
@ShangmingCai
ShangmingCai merged commit a577073 into sgl-project:main Oct 15, 2026
116 of 124 checks passed
ShangmingCai added a commit that referenced this pull request Oct 16, 2026
Resolve conflicts with #42674 (squash-merged), #42818 and #44072:
- prepare() resolves OpenAI-route models with lookup_openai, so HTTP
  `model: "base:adapter"` keeps routing to the base model.
- Leg::new passes the pinned prefill rank so decode still receives
  disagg_prefill_dp_rank under --dp-aware.
- PreparedRequest::completion and ::typed set cache_namespace.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants