Skip to content

[Fix] disaggregation: Keep output ids during a PD rebootstrap instead of popping and replaying the last one - #47366

Merged
hnyls2002 merged 4 commits into
mainfrom
lsyin/pd-rebootstrap-keep-output
Oct 30, 2026
Merged

hnyls2002 merged 4 commits into
mainfrom
lsyin/pd-rebootstrap-keep-output

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

A PD decode rebootstrap (a retracted request whose prefix KV the prefill worker recomputes, e.g. DeepSeek-V4 retraction or pause_generation(mode="retract")) popped the last output id before the recompute and appended it back at the transfer commit, overriding the token the prefill sampled. While it was popped, output_ids was one shorter than what the client had already received, so an output row emitted in that window (overlap scheduling) reported a shrunken completion_tokens, and the replayed id and its logprob row were then streamed to the client a second time.

The last output id now stays in output_ids:

  • The prefill payload sends origin_input_ids + output_ids[:-1], the same tokens as before; the prefill's sampled token is still ignored, so the next token is sampled on the decode side with its grammar, penalties and logprob state.
  • _pre_alloc_fill_len is one formula, len(origin_input_ids) + max(len(output_ids) - 1, 0), and every decode prealloc length uses it (admission, capacity check, KV preallocation); KV sizes are unchanged.
  • At commit, a rebootstrap that already emitted output appends nothing and commits no logprob, sampling mask or reasoning count; one with no output yet takes the normal path as before.
  • pd_rebootstrap_forced_output_id, both pops and the commit-time override are gone. pd_rebootstrap_in_progress and _rebootstrap_prefill_len are gone too: the flag only told that helper to use the fill length instead of the prompt length, and the two now agree for every request in the prealloc queue (new requests have no output, rebootstrap requests had the flag set). The only other caller is the capacity check, where an offload-retracted request now sees its fill length (prompt + output - 1) instead of its prompt length; the check's ceiling_fits branch already used this length, and the request's KV fit the pool before the retract, so the check gives the same result.

Verification

  • CPU unit tests covering pause/retract, prealloc priority, the transfer commit, the rebootstrap payload, and the mem-cache paths that size rebootstrap requests. A new test checks that the payload length equals the decode-side fill length for 0, 1 and 2 output ids and that output_ids is untouched; the commit test checks the emitted ids and their mask rows survive and the prefill's token is dropped.
  • GPU coverage runs in CI: test_disaggregation_dsv4.py, test_disaggregation_basic.py, test_prefill_complete_allocation.py, and the PD pause/retract tests.

CI States

Latest PR Test (Base): 🚫 Run #40993962760
Latest PR Test (Extra): ❌ Run #40993963404
Latest PR Test (AMD ROCm 10): 🚫 Run #40993963214

…t ids except the last; drop the commit-time replay of the popped token

@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

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_scheduler_pause_generation.py test_priority_scheduling_disaggregation.py test_prefill_complete_integration.py test_disaggregation_wire.py test_admission_abort_not_enqueued.py test_batch_result_processor_spec_grammar.py test_hisparse_max_token_pool_size.py test_decode_radix_lock_ref.py test_mamba_capacity.py test_disaggregation_dsv4.py registered/disaggregation/test_disaggregation_basic.py test_prefill_complete_allocation.py test_scheduler_control.py test_update_weights_from_tensor.py test_weight_version_spans.py

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🚀 ubuntu-latest (9 tests): ✅ View workflow run

cd test/ && python3 registered/unit/managers/test_scheduler_pause_generation.py
cd test/ && python3 registered/unit/managers/test_priority_scheduling_disaggregation.py
cd test/ && python3 registered/unit/disaggregation/test_prefill_complete_integration.py
cd test/ && python3 registered/unit/disaggregation/test_disaggregation_wire.py
cd test/ && python3 registered/unit/disaggregation/test_admission_abort_not_enqueued.py
cd test/ && python3 registered/unit/managers/test_batch_result_processor_spec_grammar.py
cd test/ && python3 registered/unit/mem_cache/test_hisparse_max_token_pool_size.py
cd test/ && python3 registered/unit/mem_cache/test_decode_radix_lock_ref.py
cd test/ && python3 registered/unit/mem_cache/test_mamba_capacity.py

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

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

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

cd test/ && python3 registered/disaggregation/test_disaggregation_basic.py
cd test/ && python3 registered/e2e/disaggregation/test_prefill_complete_allocation.py
cd test/ && python3 registered/rl/test_weight_version_spans.py

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

cd test/ && python3 registered/scheduler/test_scheduler_control.py
cd test/ && python3 registered/rl/test_update_weights_from_tensor.py

…p the rebootstrap prefill length helper and the pd rebootstrap in-progress flag
@hnyls2002 hnyls2002 added the run-ci CI: run the baseline test suite on this PR label Oct 30, 2026
@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_disaggregation_dsv4.py registered/disaggregation/test_disaggregation_basic.py test_prefill_complete_allocation.py test_disaggregation_optimistic_prefill.py

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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

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

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

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

@hnyls2002
hnyls2002 merged commit 03aba9e into main Oct 30, 2026
139 of 180 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/pd-rebootstrap-keep-output branch October 30, 2026 03:15
ShangmingCai added a commit to nvjullin/sglang that referenced this pull request Oct 30, 2026
Resolve the decode.py conflict with sgl-project#47366: carry main's origin_input_len ->
fill_len rename into the moved _publish_destination and _PendingPublish.

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

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