Skip to content

[Perf] deepseek-v4.1: Run encoder SWA bounded replay in the breakable prefill graph - #44930

Merged
hnyls2002 merged 3 commits into
mainfrom
lsyin/dsv41-encoder-replay-bcg
Oct 18, 2026
Merged

hnyls2002 merged 3 commits into
mainfrom
lsyin/dsv41-encoder-replay-bcg

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator
  • --enable-encoder-swa-bounded-replay now accepts --cuda-graph-backend-prefill breakable; other prefill graph backends stay rejected, and so does any prefill graph on ROCm, which replays hits in a forward of their own
  • The static batch carries the fold's encoder_swa_replay, encoder_swa_row_floor and encoder_swa_compress_rows, so capture and replay build the same window floors and compressor slots as an eager prefill
  • Under the graph the request-window layout covers the live rows and pads to the bucket: padding rows get no window, write past the live rows and commit nowhere (window_layout(padded_rows=...), WindowLayout.leading_rows); the window groups are fixed at one per request slot, at most one per row
  • refresh_for_breakable_cuda_graph_replay_ copies the request-window layout in place, and capture and replay activate it
  • Graph metadata keeps its compressor slots in its own buffer (_compressor_out_loc(own_buffer=True)), so the in-place refresh before a replay leaves the static out_cache_loc as the runner filled it
  • With DP attention, the prefill graph vote counts the folded replay rows, which an extend replay runs, so the vote agrees with the runner's own check
  • The request-window workspace also covers the largest breakable prefill graph bucket, which can exceed a DP rank's share of the chunk
  • Add tests for the padded layout, the slot buffer, the startup check and the workspace size; all five fail on main
  • Checked on GB300, TP4/EP4, DeepSeek-V4.1-Flash, encoder and decoder replay on:
    • The replay rows' cached c1/c2 bytes, compared before and after each prefix-hit prefill: 0 rows changed over 8 graph and 8 eager hits
    • GSM8K, all 1,319 questions behind a shared 8-shot prefix (903 replay prefills, 909 of 910 prefills in the graph): 97.04%; with the same settings on the previous day's main, eager prefill with replay scored 97.50% and the graph without replay 97.27%
    • TTFT of 417 new tokens after a 13,312-token cached prefix: 81.2 ms; eager prefill with replay took 231.6 ms on the previous day's main; contexts above 16K still run eager
  • Checked on GB300 with DP attention 2 / EP 2 and MegaMoE, encoder and decoder replay on: GSM8K, all 1,319 questions behind the same prefix at 64 concurrent requests, 97.27% with the graph and 97.35% eager
  • Known issue on main, not changed here: with DP attention and MegaMoE, the breakable prefill graph hangs when one DP rank prefills while another is idle, because decoder replay's late-layer row-count gather runs only in the idle rank's eager forward

Supersedes #43010.

No behavior change unless encoder replay runs with the breakable prefill graph, which used to be rejected at startup; in every breakable prefill graph the captured compressor slots are now a copy refreshed before each replay instead of the static out_cache_loc itself.


CI States

Latest PR Test (Base): ❌ Run #39080782541
Latest PR Test (Extra): ❌ Run #39080782521
Latest PR Test (AMD ROCm 10): ❌ Run #39080782546

…for prefill graph buckets; set encoder replay state in one place; tidy tests and comments
@hnyls2002

hnyls2002 commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_encoder_swa_replay.py test_dsv4_compressed_pools.py
(2 tries)

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🚀 ubuntu-latest (6 tests): ✅ View workflow run

cd test/ && python3 registered/unit/model_executor/test_encoder_swa_replay.py
cd test/ && python3 registered/unit/mem_cache/test_dsv4_compressed_pools.py
cd test/ && python3 registered/unit/layers/test_dsv41_late_layer_tail_readers.py
cd test/ && python3 registered/unit/model_executor/test_prefill_cuda_graph_runner.py
cd test/ && python3 registered/unit/managers/scheduler_components/test_dp_attn.py
cd test/ && python3 registered/unit/model_executor/runner/test_prefill_cuda_graph_padding.py

🚀 1-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_dsv41_request_window_copy.py

🚀 4-gpu-gb300 (1 test): ✅ View workflow run

cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_tp4ep4.py

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🚀 ubuntu-latest (2 tests): ✅ View workflow run

cd test/ && python3 registered/unit/model_executor/test_encoder_swa_replay.py
cd test/ && python3 registered/unit/mem_cache/test_dsv4_compressed_pools.py

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 18, 2026
@hnyls2002
hnyls2002 merged commit ff73d63 into main Oct 18, 2026
245 of 290 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/dsv41-encoder-replay-bcg branch October 18, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek memory-pool run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant