Skip to content

[Fix] scheduler: Tell a step's middle chunk from the batch's chunked request, not a per-request counter - #43906

Merged
hnyls2002 merged 4 commits into
mainfrom
lsyin/sched-pr12
Nov 3, 2026
Merged

hnyls2002 merged 4 commits into
mainfrom
lsyin/sched-pr12

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Facts about work in flight now come from what each step recorded when it was built or launched, instead of a per-request counter or a batch snapshot. This fixes a miscount of chunked prefill on main.

The fix

Req.inflight_middle_chunks was raised whenever a chunked request existed after an admission pass that admitted something, even when the chunked request got no chunk in that pass. Under the hybrid-SWA joint prefill budget, a chunk whose remaining prompt does not fit with its new-token headroom is parked, while a smaller waiting request can still be admitted in the same pass. The counter then never came back down, and the request's final chunk was processed as a middle chunk: its first token was not committed (PD prefill: it was requeued as if it had yielded).

The same state made contains_last_prefill_chunk False for a batch whose only row ran a final prefill, so pipeline parallelism with SGLANG_PP_SKIP_PURE_CHUNKED_OUTPUT_COMM skipped its output exchange.

A pause that retracts under pipeline parallelism reset the counter while other micro-batches still carried the request, so their results could be labelled wrongly too; each step's own record labels it by itself.

Changes

  • Result processing (prefill, embedding, PD prefill, the pipeline-parallel output check, the grammar skip) asks whether a row is its batch's chunked_req, which the batch already records at build: the request that runs a chunk in this batch and is still chunked after it. A parked request is named there too but is not a row, so it is never asked about. copy() now carries chunked_req, since overlap processes the copy. The counter, its resets and the never-read dLLM increments are removed.
  • contains_last_prefill_chunk counts the chunked request only when it is admitted in this pass.
  • A PD optimistic request that yields the chunked slot is requeued once no step of it is in flight (Req.inflight_steps): at once at the yield, otherwise when its last step in flight is processed. This replaces the overlap flag and the extend_end inference; both rules agree wherever the yield can happen (optimistic prefill is off with pipeline parallelism, and a request otherwise has at most one step in flight).
  • _reqs_finishing_inflight finds running requests whose queued result finishes them by inflight_steps > 0 instead of reading the queued batch copy, and drops the one-batch assert. Same result: only the overlap loop enables it, and there the queued step is the only step in flight.

Behavior changes: only the parked-chunk and pipeline-parallel retract states above.

Test plan

  • test_chunked_prefill_does_not_yield_for_decode_admission covers a yield with and without a step in flight.
  • The unit tests under test/registered/unit/managers/, test/registered/unit/disaggregation/ and test/registered/unit/dllm/ pass locally with SGLANG_IS_IN_CI=1, apart from failures main has too.

CI States

Latest PR Test (Base): 🚫 Run #41560652630
Latest PR Test (Extra): ❌ Run #41560652511
Latest PR Test (AMD ROCm 10): 🚫 Run #41560652473

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

@github-actions github-actions Bot added the Multi-modal multi-modal language model label Oct 12, 2026
@hnyls2002
hnyls2002 marked this pull request as draft October 13, 2026 02:01
@hnyls2002
hnyls2002 force-pushed the lsyin/sched-pr11 branch 3 times, most recently from df458f8 to 1eeb89a Compare November 2, 2026 22:28
@hnyls2002 hnyls2002 changed the title [Scheduler] Join prefills at launch and drop finished rows at commit [Refactor] scheduler: Requeue a yielded optimistic prefill when no step of it is in flight Nov 2, 2026
Base automatically changed from lsyin/sched-pr11 to main November 3, 2026 00:25
…st counter; read in-flight work from inflight_steps
@hnyls2002 hnyls2002 changed the title [Refactor] scheduler: Requeue a yielded optimistic prefill when no step of it is in flight [Fix] scheduler: Record a step's middle-chunk rows instead of counting them per request Nov 3, 2026
@hnyls2002
hnyls2002 marked this pull request as ready for review November 3, 2026 00:30

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@hnyls2002 hnyls2002 changed the title [Fix] scheduler: Record a step's middle-chunk rows instead of counting them per request [Fix] scheduler: Tell a step's middle chunk from the batch's chunked request, not a per-request counter Nov 3, 2026
@hnyls2002 hnyls2002 added bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) parallel-stages CI: stages dispatch together instead of waiting on each other labels Nov 3, 2026
@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Nov 3, 2026
@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_disaggregation_optimistic_prefill.py test_prefill_complete_allocation.py test_scripted_swa_1gpu.py test_scripted_core_1gpu.py test_pp_single_node_extra.py registered/disaggregation/test_disaggregation_pp.py test_retract_decode.py test_dp_spec_prefill_coordination_mixed.py test_disaggregation_hisparse.py test_disaggregation_unified_memory.py

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🚀 2-gpu-h100 (3 tests): ✅ View workflow run

cd test/ && python3 registered/disaggregation/test_disaggregation_optimistic_prefill.py
cd test/ && python3 registered/e2e/disaggregation/test_prefill_complete_allocation.py
cd test/ && python3 registered/disaggregation/test_disaggregation_unified_memory.py

🚀 1-gpu-h100 (1 test): ❌ View workflow run

cd test/ && python3 registered/chunked_prefill/test_scripted_swa_1gpu.py

🚀 1-gpu-5090 (2 tests): ✅ View workflow run

cd test/ && python3 registered/chunked_prefill/test_scripted_core_1gpu.py
cd test/ && python3 registered/scheduler/test_retract_decode.py

🚀 4-gpu-h100 (2 tests): ✅ View workflow run

cd test/ && python3 registered/pp/test_pp_single_node_extra.py
cd test/ && python3 registered/spec/eagle/test_dp_spec_prefill_coordination_mixed.py

🚀 8-gpu-h20 (1 test): ✅ View workflow run

cd test/ && python3 registered/disaggregation/test_disaggregation_pp.py

🚀 8-gpu-h200 (1 test): ✅ View workflow run

cd test/ && python3 registered/disaggregation/test_disaggregation_hisparse.py

@hnyls2002
hnyls2002 merged commit dbeecc9 into main Nov 3, 2026
277 of 330 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/sched-pr12 branch November 3, 2026 02:33
AgainstEntropy added a commit to erikwijmans/sglang that referenced this pull request Nov 5, 2026
…t-free-pool

Resolve test conflicts and adapt held-row test to sgl-project#43906 (inflight_middle_chunks removed) and IndexedReqList waiting_queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Yuxingwang-intel pushed a commit to Yuxingwang-intel/sglang that referenced this pull request Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apple-silicon bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) Multi-modal multi-modal language model parallel-stages CI: stages dispatch together instead of waiting on each other run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant