Skip to content

Fix PD retraction checkpoint boundaries with overlap decoding - #39743

Open
chromecast56 wants to merge 2 commits into
sgl-project:mainfrom
chromecast56:codex/pd-retraction-overlap-boundary
Open

chromecast56 wants to merge 2 commits into
sgl-project:mainfrom
chromecast56:codex/pd-retraction-overlap-boundary

Conversation

@chromecast56

@chromecast56 chromecast56 commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Related PD/DCP/DFlash PRs: #40794, #39731, #39749, #40164. Each is independent and they can merge in any order.

Motivation

With overlap scheduling, PD decode can retract a request while the previous step's result is still pending. CPU offload then records output_ids at step N-1 while the GPU state it copies may already be at step N.

For pure-attention models without speculative decoding this was already correct: result processing discards the in-flight token of a retracted request, the offload covers only [:seqlen - 1], and the resumed decode step recomputes the last position. Two kinds of state break it:

  • Recurrent state (Mamba / GDN / KDA) is one in-place slot per request, so the backup can hold the state after the in-flight step. On resume the last token is fed again and the state advances twice.
  • With speculative decoding, the in-flight verify commits a whole accepted block into KV and draft state, but those tokens never reach output_ids. Resumed requests skip tokens or end early.

Upstream repro: a hybrid model such as Qwen3-Next under PD decode with overlap scheduling and SGLANG_TEST_RETRACT forcing retraction.

Modifications

  • In PD decode with overlap, when a retraction is about to happen, process the pending results first, filter finished requests, and recheck memory before retracting. pause_generation already drains the same way.
  • Normal decode steps keep overlap; only retraction steps drain the queue.

Related: #39749

Tests

test_pd_retraction_overlap_boundary.py (3 CPU tests, 8 subtests) drives the real Scheduler.update_running_batch: the pending block is settled before the offload snapshot, settlement filters completed requests and rechecks capacity, and non-retracting, non-PD, and non-overlap steps keep their pending result. Five subtests fail without the fix.

GPU check, Kimi K3 PD 1P1D on 8xB300 per role (prefill TP8, decode TP8), DFLASH full draft (block size 8), NIXL, GSM8K 5-shot, prefill DCP8 → decode DCP8 with forced decode retraction (SGLANG_TEST_RETRACT=1, interval 30, about 2,950 retractions) on the same 200 questions: main 98.5% accuracy / average accept length 5.02; a build with all five PD/DCP/DFlash PRs (#39743, #40794, #39731, #39749, #40164) 98.5% / 5.29. No accuracy regression under retraction.


CI States

Latest PR Test (Base): ❌ Run #35925575648
Latest PR Test (Extra): ❌ Run #35925575053
Latest PR Test (AMD ROCm 10): ❌ Run #35925575451

This branch has not been deployed

No deployments
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.

1 participant