Repository navigation
[DeepSeek-V4.1] Run encoder SWA bounded replay under the breakable prefill CUDA graph - #43010
Closed
vincentzed wants to merge 7 commits into
Closed
vincentzed wants to merge 7 commits into
vincentzed wants to merge 7 commits into
Conversation
…efill CUDA graph The graph captures the late layers over each batch's tail padded to a fixed row count, and switches the attention metadata onto the tail at a graph break so a replay re-runs the switch. Graphs with equal tail rows share one tail metadata. A batch whose tail exceeds 8 windows prefills eagerly.
…under decoder bounded replay Under decoder bounded replay the low-ratio compressor and indexer run at a graph break instead of inside the graph. The break filters by candidates like eager prefill, so the 16K context cap of the captured indexer no longer applies.
… pin Graph metadata is sized by the batch's own context when no in-graph kernel reads the full width, all graphs share one padded-head query scratch, and the candidate tables are dropped once their last reader has run.
…der bounded replay The prefill graph is keyed by token count, but the late layers run over the batch's tail, whose row count does not follow it. They now have graphs keyed by tail rows that the prefill graph replays from a graph break, so a batch of any number of requests replays and its late layers run at close to its true tail.
…-replay prefill graph
…first prefill without speculation Without speculation the request windows hold every SWA row and no allocator registers a full-to-SWA mapping, so the pool never had the attribute that prefill reads on every batch.
…efill CUDA graph The graphs capture the request-window layout padded to their rows and to one window group per request slot, refresh it in place per replay, and activate it again before each replay. The pass that rebuilds a window on a prefix hit also runs through the graph.
vincentzed
requested review from
Fridge003,
HaiShaw,
JustinTong0323,
Qiaolin-Yu,
Ying1123,
alphabetc1,
hanming-lu,
hebiao064,
hnyls2002,
huangtingwei9988,
hzh0425,
ispobock,
merrymercy,
sogalin,
wisclmy0611,
xiezhq-hermann,
yizhang2077 and
zijiexia
as code owners
October 7, 2026 18:31
Contributor
Author
|
@Oasis-Git this is the encoder half for #42170 ("Enable encoder bounded replay"). It is stacked on #42909 (decoder) and #42902 (crash fix), so until those merge the diff here includes their commits. The only commit that belongs to this PR is the last one. I will rebase it as soon as the other two land. |
Contributor
Author
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.
Motivation
--enable-encoder-swa-bounded-replaykeeps each request's sliding-window state in a per-request window instead of the paged cache. Today the server refuses to start if the flag is combined with a prefill CUDA graph, so every prefill runs eagerly, and so does the extra pass that rebuilds a window when a request hits a cached prefix.Eager prefill costs about 120 ms per batch with this flag on 4x B300. A follow-up turn on a cached conversation pays it twice, once for the rebuild pass and once for the new tokens.
Roadmap #42170 lists "Enable encoder bounded replay" with no owner. This PR builds on the decoder PR #42909 and on the crash fix #42902. Until those merge, its diff includes their commits.
Modifications
Accuracy Tests
4x B300,
deepseek-ai/DeepSeek-V4.1-Flash, TP4 and EP4. Both columns run this branch.Each cell is one run. Repeated runs of one configuration moved between 0.900 and 0.915, so these are within noise. The DSpark accept length is 3.40 in both columns.
Speed Tests and Profiling
Time to first token, median of 5 requests sent one at a time, prompts sent as token ids.
Capturing all graphs takes about 11 GB per GPU with encoder replay on.
Checklist
CI States
Latest PR Test (Base): ❌ Run #37667504398
Latest PR Test (Extra): ❌ Run #37667502671
Latest PR Test (AMD ROCm 10): ❌ Run #37667505108