Repository navigation
[Fix] deepseek-v4.1: Keep the DSpark draft SWA out of the radix tree - #44673
Merged
Merged
Conversation
hnyls2002
requested review from
BBuf,
DarkSharpness,
Fridge003,
HaiShaw,
HydraQYH,
Qiaolin-Yu,
Ying1123,
alphabetc1,
celve,
hanming-lu,
hebiao064,
huangtingwei9988,
hzh0425,
ispobock,
merrymercy,
xiezhq-hermann,
yizhang2077 and
yuan-luo
as code owners
October 16, 2026 05:17
Collaborator
Author
|
/rerun-test test_dsv4_compressed_pools.py test_pool_configurator.py test_encoder_swa_replay.py test_dspark_draft_block.py test_dsv4_c4_state_lifecycle.py test_dspark_kernel_parity.py test_deepseek_v41_flash_gb300.py test_unified_radix_cache_kl_dsv4.py |
Collaborator
Author
|
/tag-and-rerun-ci |
Contributor
|
🚀 🚀 🚀 🚀 |
17 of 56 tasks
4 of 5 tasks
This was referenced Oct 16, 2026
4 of 5 tasks
This was referenced Nov 17, 2026
JamesBrianD
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 18, 2026
Under --enable-encoder-swa-bounded-replay the TPU DSpark draft kept paged SWA through the target's full-to-SWA mapping, so the target kept its paged SWA allocator, the radix tree kept tracking SWA, and a partial prefix hit whose SWA was freed matched 0 tokens. The draft now keeps its SWA in a per-request ring, as core DSparkWorkerV2 since sgl-project/sglang#44673, and TPU stops forcing uses_draft_swa_ring() off. - Pool: the draft SWA pool takes the request window's ring layout (4 x 64-token pages per slot after the reserved pages) and keeps swa_req_ring_valid_from on the host for the attention backend. - Writes: TpuBlockSpecWorker computes ring rows from (req slot, position) for extend (last 256 positions of each request) and verify commit instead of the full-to-SWA map; a newly placed or retracted request restarts its ring at its cached prefix (encoder_swa_reset), since replayed rows never reach the draft. - Reads: the draft backend's SWA table maps every logical page to the slot's ring and floors visibility at valid_from. - Sizing: the TPU request-window price includes the draft ring pages; the 0-token SWA floor skip also applies to the draft worker.
JamesBrianD
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 18, 2026
Under --enable-encoder-swa-bounded-replay the TPU DSpark draft kept paged SWA through the target's full-to-SWA mapping, so the target kept its paged SWA allocator, the radix tree kept tracking SWA, and a partial prefix hit whose SWA was freed matched 0 tokens. The draft now keeps its SWA in a per-request ring, as core DSparkWorkerV2 since sgl-project/sglang#44673, and TPU stops forcing uses_draft_swa_ring() off. - Pool: the draft SWA pool takes the request window's ring layout (4 x 64-token pages per slot after the reserved pages) and keeps swa_req_ring_valid_from on the host for the attention backend. - Writes: TpuBlockSpecWorker computes ring rows from (req slot, position) for extend (last 256 positions of each request) and verify commit instead of the full-to-SWA map; a newly placed or retracted request restarts its ring at its cached prefix (encoder_swa_reset), since replayed rows never reach the draft. - Reads: the draft backend's SWA table maps every logical page to the slot's ring and floors visibility at valid_from. - Sizing: the TPU request-window price includes the draft ring pages; the 0-token SWA floor skip also applies to the draft worker.
JamesBrianD
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 18, 2026
Under --enable-encoder-swa-bounded-replay the TPU DSpark draft kept paged SWA through the target's full-to-SWA mapping, so the target kept its paged SWA allocator, the radix tree kept tracking SWA, and a partial prefix hit whose SWA was freed matched 0 tokens. The draft now keeps its SWA in a per-request ring, as core DSparkWorkerV2 since sgl-project/sglang#44673, and TPU stops forcing uses_draft_swa_ring() off. - Pool: the draft SWA pool takes the request window's ring layout (4 x 64-token pages per slot after the reserved pages) and keeps swa_req_ring_valid_from on the host for the attention backend. - Writes: TpuBlockSpecWorker computes ring rows from (req slot, position) for extend (last 256 positions of each request) and verify commit instead of the full-to-SWA map; a newly placed or retracted request restarts its ring at its cached prefix (encoder_swa_reset), since replayed rows never reach the draft. - Reads: the draft backend's SWA table maps every logical page to the slot's ring and floors visibility at valid_from. - Sizing: the TPU request-window price includes the draft ring pages; the 0-token SWA floor skip also applies to the draft worker.
JamesBrianD
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 19, 2026
Under --enable-encoder-swa-bounded-replay the TPU DSpark draft kept paged SWA through the target's full-to-SWA mapping, so the target kept its paged SWA allocator, the radix tree kept tracking SWA, and a partial prefix hit whose SWA was freed matched 0 tokens. The draft now keeps its SWA in a per-request ring, as core DSparkWorkerV2 since sgl-project/sglang#44673, and TPU stops forcing uses_draft_swa_ring() off. - Pool: the draft SWA pool takes the request window's ring layout (4 x 64-token pages per slot after the reserved pages) and keeps swa_req_ring_valid_from on the host for the attention backend. - Writes: TpuBlockSpecWorker computes ring rows from (req slot, position) for extend (last 256 positions of each request) and verify commit instead of the full-to-SWA map; a newly placed or retracted request restarts its ring at its cached prefix (encoder_swa_reset), since replayed rows never reach the draft. - Reads: the draft backend's SWA table maps every logical page to the slot's ring and floors visibility at valid_from. - Sizing: the TPU request-window price includes the draft ring pages; the 0-token SWA floor skip also applies to the draft worker.
JamesBrianD
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 19, 2026
Under --enable-encoder-swa-bounded-replay the TPU DSpark draft kept paged SWA through the target's full-to-SWA mapping, so the target kept its paged SWA allocator, the radix tree kept tracking SWA, and a partial prefix hit whose SWA was freed matched 0 tokens. The draft now keeps its SWA in a per-request ring, as core DSparkWorkerV2 since sgl-project/sglang#44673, and TPU stops forcing uses_draft_swa_ring() off. - Pool: the draft SWA pool takes the request window's ring layout (4 x 64-token pages per slot after the reserved pages) and keeps swa_req_ring_valid_from on the host for the attention backend. - Writes: TpuBlockSpecWorker computes ring rows from (req slot, position) for extend (last 256 positions of each request) and verify commit instead of the full-to-SWA map; a newly placed or retracted request restarts its ring at its cached prefix (encoder_swa_reset), since replayed rows never reach the draft. - Reads: the draft backend's SWA table maps every logical page to the slot's ring and floors visibility at valid_from. - Sizing: the TPU request-window price includes the draft ring pages; the 0-token SWA floor skip also applies to the draft worker.
JamesBrianD
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 19, 2026
Under --enable-encoder-swa-bounded-replay the TPU DSpark draft kept paged SWA through the target's full-to-SWA mapping, so the target kept its paged SWA allocator, the radix tree kept tracking SWA, and a partial prefix hit whose SWA was freed matched 0 tokens. The draft now keeps its SWA in a per-request ring, as core DSparkWorkerV2 since sgl-project/sglang#44673, and TPU stops forcing uses_draft_swa_ring() off. - Pool: the draft SWA pool takes the request window's ring layout (4 x 64-token pages per slot after the reserved pages) and keeps swa_req_ring_valid_from on the host for the attention backend. - Writes: TpuBlockSpecWorker computes ring rows from (req slot, position) for extend (last 256 positions of each request) and verify commit instead of the full-to-SWA map; a newly placed or retracted request restarts its ring at its cached prefix (encoder_swa_reset), since replayed rows never reach the draft. - Reads: the draft backend's SWA table maps every logical page to the slot's ring and floors visibility at valid_from. - Sizing: the TPU request-window price includes the draft ring pages; the 0-token SWA floor skip also applies to the draft worker.
cjx0709
pushed a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 19, 2026
Under --enable-encoder-swa-bounded-replay the TPU DSpark draft kept paged SWA through the target's full-to-SWA mapping, so the target kept its paged SWA allocator, the radix tree kept tracking SWA, and a partial prefix hit whose SWA was freed matched 0 tokens. The draft now keeps its SWA in a per-request ring, as core DSparkWorkerV2 since sgl-project/sglang#44673, and TPU stops forcing uses_draft_swa_ring() off. - Pool: the draft SWA pool takes the request window's ring layout (4 x 64-token pages per slot after the reserved pages) and keeps swa_req_ring_valid_from on the host for the attention backend. - Writes: TpuBlockSpecWorker computes ring rows from (req slot, position) for extend (last 256 positions of each request) and verify commit instead of the full-to-SWA map; a newly placed or retracted request restarts its ring at its cached prefix (encoder_swa_reset), since replayed rows never reach the draft. - Reads: the draft backend's SWA table maps every logical page to the slot's ring and floors visibility at valid_from. - Sizing: the TPU request-window price includes the draft ring pages; the 0-token SWA floor skip also applies to the draft worker.
JamesBrianD
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 19, 2026
) * [TPU] DSV4.1 CED: keep the DSpark draft SWA in a per-request ring Under --enable-encoder-swa-bounded-replay the TPU DSpark draft kept paged SWA through the target's full-to-SWA mapping, so the target kept its paged SWA allocator, the radix tree kept tracking SWA, and a partial prefix hit whose SWA was freed matched 0 tokens. The draft now keeps its SWA in a per-request ring, as core DSparkWorkerV2 since sgl-project/sglang#44673, and TPU stops forcing uses_draft_swa_ring() off. - Pool: the draft SWA pool takes the request window's ring layout (4 x 64-token pages per slot after the reserved pages) and keeps swa_req_ring_valid_from on the host for the attention backend. - Writes: TpuBlockSpecWorker computes ring rows from (req slot, position) for extend (last 256 positions of each request) and verify commit instead of the full-to-SWA map; a newly placed or retracted request restarts its ring at its cached prefix (encoder_swa_reset), since replayed rows never reach the draft. - Reads: the draft backend's SWA table maps every logical page to the slot's ring and floors visibility at valid_from. - Sizing: the TPU request-window price includes the draft ring pages; the 0-token SWA floor skip also applies to the draft worker. * [TPU] DSV4.1 draft ring: pick verify commit rows on device The verify commit built draft ring rows from the host committed base, which trails the device seq_lens by one commit under overlap, so accepted draft KV landed one commit early (C64 accept length 4.32 -> 3.75). Map the whole [base, base + 2 * capacity) candidate window to ring rows on the host and let select_verify_rows pick the active rows on device, as the full-to-SWA path does. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [TPU] DSV4.1 draft ring: count the ring draft layers in a TPU hook, not a core edit DSV4PoolConfigurator.__init__ keeps the draft ring layer count as a local. Promoting it to an attribute was the only change this PR made under python/sglang/srt. An AROUND hook on __init__ now sets draft_ring_layers on the configurator by core's rule (and checks it against paged_draft_layers), so get_tpu_dsv41_swa_fixed_bytes can price the ring pages without the edit. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
--enable-encoder-swa-bounded-replaythe target already keeps SWA in a per-request window, but the DSpark draft still forced a paged SWA allocator, so the radix tree kept an SWA component only the draft used. Evicting the draft's SWA then cut prefix hits on Main KV the target could still reuse ([Fix] [AMD] hicache: Serve encoder-replay prefix hits with a paged DSpark draft SWA #42716 skips the same match gate).swa_ring_rows(req_pool_idx * ring + pos % ring) andget_draft_swa_ring_size(sliding window + max draft tokens) own its layout for every reader and writer. No pool needsneeds_paged_swa_allocator, so the tree holds no SWA component._ring_inject_loc, andbuild_unified_commit_inject_layoutrenamed tobuild_ring_commit_inject_layout), now keyed on the draft pool'sswa_req_ring_sizeinstead of the unified_kv gate.get_dspark_swa_page_indicesbuilds the draft window from the ring (BuildDsparkSwaRingIndices), and the draft block writes its ring rows, both eagerly and in the graph.swa_req_ring_valid_from), so the draft masks earlier positions instead of reading rows left by the slot's previous request.Only DeepSeek-V4.1 with encoder SWA bounded replay and DSpark on CUDA changes; HIP keeps the paged draft SWA, and every other configuration is unchanged. After a prefix hit, the draft attends only to rows written since the hit until its window fills again.
On DeepSeek-V4.1-Flash (4x GB300, TP4, DSpark, encoder replay), a prompt whose draft SWA was evicted by 400 other prompts re-hits 8448 of its 8565 tokens instead of 0. GSM8K stays at 98.0% with and without decoder replay, and the average accept length is 3.81 against 3.78 before.
CI States
Latest PR Test (Base): 🚫 Run #38868277003
Latest PR Test (Extra): ❌ Run #38868276936
Latest PR Test (AMD ROCm 10): 🚫 Run #38868276948