Repository navigation
Preserve full DFlash draft KV during PD CPU retraction - #39749
Open
chromecast56 wants to merge 2 commits into
Open
chromecast56 wants to merge 2 commits into
chromecast56 wants to merge 2 commits into
Conversation
chromecast56
marked this pull request as ready for review
September 21, 2026 20:44
chromecast56
requested review from
Qiaolin-Yu,
Ying1123,
alphabetc1,
hanming-lu,
hnyls2002,
huangtingwei9988,
hzh0425,
ispobock,
merrymercy,
xiezhq-hermann and
yizhang2077
as code owners
September 21, 2026 20:44
chromecast56
force-pushed
the
codex/pd-full-draft-retraction
branch
from
September 22, 2026 21:23
3c18f83 to
2f2660c
Compare
chromecast56
requested review from
ByronHsu,
Duyi-Wang,
Fridge003,
HaiShaw,
ShangmingCai and
sogalin
as code owners
September 22, 2026 21:23
This was referenced Sep 22, 2026
chromecast56
force-pushed
the
codex/pd-full-draft-retraction
branch
from
September 22, 2026 23:10
2f2660c to
5224443
Compare
chromecast56
requested review from
JustinTong0323,
wisclmy0611 and
zijiexia
as code owners
September 22, 2026 23:10
chromecast56
force-pushed
the
codex/pd-full-draft-retraction
branch
2 times, most recently
from
September 23, 2026 00:54
6a1cd3a to
31bec99
Compare
Replace the externally assigned cpu_retraction_draft_pool with DFlashWorkerV2.full_draft_kv_pool, which accepts only a non-compact MHATokenToKVPool (MLA pools localize token ids to DCP rows), and BaseTokenToKVPoolAllocator.register_full_draft_kv_pool. Trim the round-trip matrix to the DCP1 and DCP8 cases that fail without the fix and use the 3.10-safe enter_scope helper. Co-Authored-By: Claude Opus 5.5 <[email protected]>
chromecast56
force-pushed
the
codex/pd-full-draft-retraction
branch
from
September 23, 2026 21:57
31bec99 to
9d448cc
Compare
kpham-sgl
reviewed
Sep 29, 2026
|
|
||
| class BaseTokenToKVPoolAllocator(abc.ABC): | ||
| # Class-level: SWA and HiSparse allocators do not call this __init__. | ||
| full_draft_kv_pool: KVCache | None = None |
Collaborator
There was a problem hiding this comment.
Could we pass the existing draft pool explicitly into Req.offload_kv_cache() / load_kv_cache() instead of registering it on the allocator? Add a keyword-only draft_kv_pool=None argument and use it directly:
# offload_kv_cache: RetractionBackup field
draft_cpu=(
draft_kv_pool.get_cpu_copy(
token_indices, req_pool_index=self.kv.req_pool_idx
)
if draft_kv_pool is not None
else None
),# load_kv_cache
draft_cpu = self.kv.retraction_backup.draft_cpu
if draft_cpu is not None:
assert draft_kv_pool is not None
draft_kv_pool.load_cpu_copy(
draft_cpu, token_indices, req_pool_index=self.kv.req_pool_idx
)Thread the eligible existing draft-pool reference through both call paths from the scheduler. This keeps draft_cpu and removes the allocator registration and new DFlash property.
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.
Related PD/DCP/DFlash PRs: #39743, #40794, #39731, #40164. Each is independent and they can merge in any order.
Motivation
PD CPU retraction (
--disaggregation-decode-retraction-backup cpu_tensor) saves the target KV but not the full DFlash draft KV. The draft pool has its own tensors indexed by the target allocator's token ids, so once the retracted request's slots are reused, its draft history is overwritten before it resumes. The target still verifies every drafted token, so outputs stay correct; the resumed request drafts against another request's KV and its acceptance rate drops.Modifications
DFlashWorkerV2.full_draft_kv_poolis the one declaration of a full draft pool: a non-compactMHATokenToKVPool. MLA pools localize token ids to this DCP rank's rows, so their rows are not logical. The worker registers it withBaseTokenToKVPoolAllocator.register_full_draft_kv_pool.__init__.host_poolbackend already carries draft KV as aDRAFTsidecar pool.cpu_tensor(acceptance only). They are not registered here: DeepSeek-style MTP draft pools are MLA, and multi-layer EAGLE has one pool per runner.Related: #39743
Tests
test_pd_full_draft_cpu_retraction.py(3 CPU tests, 5 subtests):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 (+5%). That matches the draft KV now surviving CPU retraction. One run per build on a 200-question subset.CI States
Latest PR Test (Base): ⏳ Run #35925582614
Latest PR Test (Extra): ⏳ Run #35925582290
Latest PR Test (AMD ROCm 10): ⏳ Run #35925582583