Repository navigation
[DeepSeek-V4.1] Run decoder SWA bounded replay under the breakable prefill CUDA graph - #42909
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
|
@Oasis-Git this is for the "Enable decoder bounded replay" item on #42170. It lets the cookbook V4.1 launch keep Two related things:
@harmya this also covers the stale tail state from your draft #42078. The replay path now sets or clears the tail for every batch. |
|
@Oasis-Git a gentle reminder. This still needs a first review and the |
|
I merged main into this branch (now at After the merge, GSM8K is 0.905 with the graph and 0.908 eager, and the wall time is 72.9 s against 135.5 s. Time to first token for 590 new tokens is 27.0 ms against 77.5 ms. At 14,795 new tokens the two now tie, because eager prefill on main got faster. @Oasis-Git a gentle reminder: this still needs a first review and the |
|
Closing this. #43736 has merged and covers it: decoder bounded replay now runs under the breakable prefill CUDA graph, with the tail rows in the same graph. |
Motivation
The DeepSeek-V4.1 cookbook launch uses
--enable-decoder-swa-bounded-replay. Today the server refuses to start when that flag is combined with a prefill CUDA graph, so V4.1 prefill always runs eagerly.Eager prefill costs about 85 ms per batch on 4x B300, no matter how short the prompt is. A 590-token prompt pays it, and so does every follow-up turn of a long conversation.
Roadmap #42170 lists "Enable decoder bounded replay" with no owner. The draft #42078 fixes one piece of stale state and says it does not enable the combination. This PR covers that case as well.
Modifications
With decoder bounded replay, the layers after the last KV source layer (the "late layers") only run over the last 128 tokens of each request. The number of those rows depends on how many requests are in the batch, not on how many tokens it has. A prefill CUDA graph has a fixed shape per token count, so the late layers could not be captured in it.
fullandtc_piecewisebackends, ROCm, and prefill context parallelism are still rejected at startup.Every batch now goes through the graph: any number of requests, any size up to the chunk size, any context length. Encoder bounded replay is not part of this PR.
Accuracy Tests
4x B300,
deepseek-ai/DeepSeek-V4.1-Flash, TP4 and EP4. Both columns run this branch. "Eager" is what the cookbook launch does today.Each cell is one run. Repeated runs of one configuration moved between 0.900 and 0.915 while I worked on this, so these are within noise. The DSpark accept length is 3.39 in both columns.
Speed Tests and Profiling
Time to first token, median of 5 requests sent one at a time. Prompts are sent as token ids, so tokenization is not included.
Rerun after merging main at
28621739fcmega_mhc_seam_openargument to the per-layer call. This PR had moved that call into a helper, so the helper now passes the argument too.validate_deepseek_v41_featuresand inlow_ratio_prefill_graph.Checklist
CI States
Latest PR Test (Base): ❌ Run #38269076379
Latest PR Test (Extra): ❌ Run #38269076201
Latest PR Test (AMD ROCm 10): ❌ Run #38269076416