Skip to content

[Perf] dsv4: Gather V4.1 index-K slots once per prefill graph replay - #45741

Merged
hnyls2002 merged 4 commits into
mainfrom
lsyin/dsv41-graph-kslot-snapshot
Oct 22, 2026
Merged

hnyls2002 merged 4 commits into
mainfrom
lsyin/dsv41-graph-kslot-snapshot

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator
  • Prefill graph replays take the same index-K slot snapshot as eager extend ([Perf] dsv4: Gather V4.1 index-K slots once per forward and cache the prefill index plan #45577): prepare_forward_metadata_for_breakable_cuda_graph_replay calls _snapshot_low_ratio_k_slots after refreshing the full and tail metadata, so the full top-k and low-ratio source breaks read low_ratio_k_slots and one PrefillIndexPlan per ratio instead of gathering from req_to_token and rebuilding the plan in every layer. The snapshot's condition moves into the helper, so both callers make the same one-line call; only the capture pass still gathers per layer.
  • The late-layer tail that leaves the prefill graph for its row-bucket graphs builds fresh metadata for the live rows; _share_low_ratio_k_slots hands it the same snapshot with its own plan cache, as _snapshot_low_ratio_k_slots already does for the tail metadata of an eager extend.
  • The replay-context test stubs the snapshot like the other backend collaborators.

No behavior change: the snapshot holds the same slots and plans the per-layer path builds, which assertions confirmed on every layer, tail included, of 639 prefill graph replays of DeepSeek-V4.1-Flash (DEP4 with MegaMoE on GB300, 4,096 and 8,192 tokens per rank). At 4,096 tokens per rank the scheduler thread spends about 3.4 ms less per step (sampled), with the index-K gather down from 4.0 to 0.9 ms.


CI States

Latest PR Test (Base): 🚫 Run #39734244451
Latest PR Test (Extra): ❌ Run #39734244329
Latest PR Test (AMD ROCm 10): 🚫 Run #39734244523

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_dsv41_late_layer_tail_readers.py test_dsv41_candidate_blocks.py test_dsv4_nonpaged_indexer.py test_encoder_swa_replay.py test_deepseek_v4.py test_dsv41_prefill_sparse_indexer.py test_dense_prefill_indexer.py test_deepseek_v41_flash_gb300_encoder_bcg.py test_deepseek_v41_flash_gb300_trtllm_bounded_bcg.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 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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

cd test/ && python3 registered/unit/layers/test_dsv41_late_layer_tail_readers.py
cd test/ && python3 registered/unit/layers/test_dsv41_candidate_blocks.py
cd test/ && python3 registered/unit/layers/test_dsv4_nonpaged_indexer.py
cd test/ && python3 registered/unit/model_executor/test_encoder_swa_replay.py

🚀 4-gpu-b200 (3 tests): ✅ View workflow run

cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py
cd test/ && python3 registered/kernels/ops/attention/test_dsv41_prefill_sparse_indexer.py
cd test/ && python3 registered/kernels/ops/attention/test_dense_prefill_indexer.py

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

cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py

🚀 2-gpu-gb300 (2 tests): ✅ View workflow run

cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_encoder_bcg.py
cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_trtllm_bounded_bcg.py

@hnyls2002
hnyls2002 merged commit 82f7249 into main Oct 22, 2026
77 of 108 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/dsv41-graph-kslot-snapshot branch October 22, 2026 06:34
chaohu2000 added a commit to flytiger-eco/sglang-for-sail that referenced this pull request Oct 27, 2026
…gl-project#45741)

(cherry picked from commit 7d43eeb75cd0aa4e99ac5c383e3531e3afb62895)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek 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