perf(deepseek-v4): capture DSA projections and cache writes into the prefill graph - #714
Open
dongjiyingdjy wants to merge 2 commits into
Open
perf(deepseek-v4): capture DSA projections and cache writes into the prefill graph#714dongjiyingdjy wants to merge 2 commits into
dongjiyingdjy wants to merge 2 commits into
Conversation
…prefill graph Narrow the attention break to the request-dependent DSA core and move the surrounding token-shaped work into the captured prefill-graph segments: - E1: phase-1 Q/KV/QR projections and the compressor-score GEMMs run in the pre-break segment, overlapped on an aux stream. - E2: the attention output projection joins the post-break segment. - E3: the CSA indexer query packing (wq_b/weights_proj/mxfp4) runs pre-break. - E4a: per-forward memoization of compressed/state slot mappings, shared across the CSA indexer, the 30 CSA layers, and the C4 compressor. - E4b/E4c: the CSA indexer and main C4 compressor state-save + cache-insert writes are captured in the pre-break segment, fed by persistent staging buffers refreshed by prepare/finish_prefill_graph_replay model hooks, with a -1 fail-open contract and a single ctx.dsa_pregraph_writes arm flag so the eager break skips exactly what the captured segment wrote (exactly-once across capture/replay/eager/mixed/decode/MTP-draft). Structure stays 61 eager breaks / 62 graph segments / 123 callables. GSM8K 0.96 (strict/flexible) unchanged; TP8 capture smoke clean. New CPU unit tests pin the control-flow invariants (arm/disarm matrix, skip gates, hook seam, staging bind); numerical byte-equality is covered by the GPU gates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: jiyingd <87510204+dongjiyingdjy@users.noreply.github.com>
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.
Summary
Narrow the DeepSeek-V4 attention break to the request-dependent DSA core and move the surrounding token-shaped work into the captured prefill-graph segments, removing kernel launches from the eager critical path.
prepare/finish_prefill_graph_replaymodel hooks, with a -1 fail-open contract and a singlectx.dsa_pregraph_writesarm flag so the eager break skips exactly what the captured segment wrote (exactly-once across capture / replay / eager / mixed / decode / MTP-draft).Structure is unchanged: 61 eager attention breaks / 62 graph segments / 123 callables.
Verification
Verified on top of current
origin/main(rebuilt matchingtokenspeed-kernelobjs +tokenspeed-scheduler0.1.2 exposingflat_block_tables_arrays):🤖 Generated with Claude Code