Repository navigation
Conversation
…g patches Restore the two PD disaggregation R3 hunks originally introduced in THUDM#2173 that were dropped during the SGLang v0.5.15.post1 / v0.5.21 patch refreshes: 1. prefill.py: collect prompt routed experts via _maybe_collect_routed_experts on KVPoll.Success before releasing the KV cache. 2. scheduler.py: clamp req.routed_experts_start_len to len(req.origin_input_ids) under DisaggregationMode.DECODE so decode only returns [prompt_len, seqlen - 1) rather than stale/zero prompt rows. Add unit tests guarding both patch hunks across v0.5.15.post1, v0.5.21, and latest, and verifying Sample + validate_routed_experts_tensor on PD-merged routed experts across initial and continuation turns.
4 of 5 tasks
Author
|
Hi @zhuzilin, could you take a look when you have time? This restores the PD R3 SGLang patch hunks from #2173 (alongside the upstream SGLang decode fix in sgl-project/sglang#51942). Thanks! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2546.
Root Cause
R3 (
--use-rollout-routing-replay) with PD disaggregation expectssglang_routerto concatenate prefill's[routed_experts_start_len, prompt_len)rows with decode's[prompt_len, seqlen - 1)rows. Both SGLang patch hunks originally added in #2173 were dropped during thev0.5.15.post1/v0.5.21patch refreshes:prefill.pyno longer calledself.batch_result_processor._maybe_collect_routed_experts(req)onKVPoll.Success(upstream SGLang added this afterv0.5.21in [Disagg] Return prompt routed experts from the PD prefill server sgl-project/sglang#44002).scheduler.pyno longer setreq.routed_experts_start_len = len(req.origin_input_ids)underDisaggregationMode.DECODE, so decode returnedprompt_len - start_lenleading rows of zeros/stale data before the decode tokens (upstream companion fix: [Fix] disaggregation: Clamp routed_experts_start_len to prompt length on PD decode sgl-project/sglang#51942).Changes
docker/patch/v0.5.15.post1/sglang.patch,docker/patch/v0.5.21/sglang.patch, anddocker/patch/latest/sglang.patch(verified cleangit apply --checkagainst upstreamv0.5.15.post1andv0.5.21).tests/test_rollout_metrics.pyguarding both patch hunks across the three patch versions and verifyingSample.append_response_tokens+validate_routed_experts_tensoron PD-merged routed experts (initial + continuation turns).Verification
pytest tests/test_rollout_metrics.py tests/test_rollout_data_utils.py tests/test_sample.py: 45 passed.sglang_router 0.3.2+slime+ Slime R3 validator) acrossQwen3MoeForCausalLM,Qwen3_5MoeForCausalLM(21/21 exact vs non-PD baseline), andQwen/Qwen3.5-35B-A3B-FP8(4/4 passed, 0 zero rows).