Repository navigation
[Perf] dsv41: Trim per-step DSpark decode overhead - #46176
Conversation
|
/rerun-test registered/kernels/ops/layernorm/test_mhc_stream_mean.py registered/kernels/ops/speculative/test_dspark_markov_sample.py registered/spec/dspark/test_dspark_draft_graph.py registered/unit/spec/test_dspark_deferred_commit.py registered/kernels/ops/gemm/test_dsv4_wo_a.py registered/kernels/ops/attention/test_wo_a_fused.py registered/unit/models/test_deepseek_v4_boundary.py registered/unit/models/test_deepseek_v4_platform_dispatch.py registered/unit/layers/test_dsv41_late_layer_tail_readers.py registered/unit/layer_boundary/test_aux_hidden_states.py registered/unit/model_executor/model_runner_components/test_spec_aux_hidden_state.py registered/unit/spec/test_dspark_draft_block.py registered/e2e/models/test_deepseek_v41_flash_gb300_dp2ep2.py registered/e2e/models/test_deepseek_v41_flash_gb300_tp2ep2.py |
|
/tag-and-rerun-ci |
|
🚀 🚀 🚀 🚀 🚀 |
… CUDA-graph replay and at the prefill gate Verify and draft forwards run wo_a inside CUDA graphs, and bitwise equality there also depends on cuBLAS picking the same kernel under capture. test_wo_a_strided_bmm_graph_replay_matches_einsum captures one call per shape of test_wo_a_strided_bmm_matches_einsum, replays it three times on refreshed inputs and weights, and checks token-major output equal to the einsum. Against the code before the 8-group change, its 8-group case fails on the layout assertion and its 2-group case passes. test_wo_a_strided_bmm_gate_rejects_unmeasured_prefill checks that 4095 prefill rows at 8 groups, and 4 groups at 4096 rows, keep the einsum's group-major output. Gate mutants that admit 4095 rows or 4 groups each fail exactly their own case. Only prefill bounds are checked: main (sgl-project#46176) sends every Blackwell target-verify call to the same strided bmm at any row and group count, so the 384-row verify bound is not a contract once this branch is rebased. The two case lists are shared through _strided_bmm_cases. The file takes 23-35 s on B200 (the new cases add under 0.3 s), so est_time stays at 40. Both new tests also pass with this branch's deepseek_v4.py hunks merged onto main ee2dd72. Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 2f51076c18187dd4acd392b0e3a66875994a4393)
…s per rank too At attention TP 2 a rank holds 4 of the 8 wo_a groups. The strided-bmm fast path accepted 2 and 8 groups only, so 4-group prefill calls (4096-65536 rows, Blackwell) still ran torch.einsum, whose group-major result wo_b's flatten(1) copies in every layer, and 4-group single-token decode (Blackwell, SM90) ran the einsum as well. Accept 4 groups in the CUDA shape gate. Like 8 groups, they take only the strided bmm: the 1-row gemv and the 2-8-row Triton kernels stay 2-group only. HIP is unchanged. 4-group target verify already took this bmm through sgl-project#46176's fallback branch. One call at 4 groups (32 heads per rank), CUDA-graph replay, median us per call over 3 runs, einsum + copy -> strided bmm: B200: 4096 rows 152.9 -> 102.9, 8192 rows 299.6 -> 188.6, 16384 rows 655.3 -> 358.1, 65536 rows 2192 -> 1710 B300: 4096 rows 157.0 -> 107.5, 8192 rows 321.5 -> 191.5, 16384 rows 570.9 -> 409.2, 65536 rows 2170 -> 1754 Single-token decode does not change (B200 12.11 vs 12.12 us, B300 11.91 vs 11.92 us, H100 14.39 vs 14.39 us); the einsum's 1-row output is already token-major. The eager and graph-replay strided-bmm tests also run at 4 groups (decode, target verify 1-384 rows, prefill 4096-65536 rows, contiguous and padded-head inputs) and check token-major output torch.equal to the einsum. 65536 prefill rows (the gate's upper bound) are added at every group count. Against the previous gate, both 4-group cases fail on the layout assertion at 4096 prefill rows. The 4-group gate-reject case moves from 4096 to 4095 rows. The new cases add about 0.3 s; the file takes 41 s on B200 and B300. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Small per-step DSpark decode costs on DeepSeek-V4.1, each removed without changing any output bit.
mhc_stream_mean, a Triton kernel that averages the four hc streams in torch's order (in-order fp32 sum onto +0); used for the DSpark captures and the replay tail. Unverified shapes and dtypes fall back tox.mean(dim=1).AuxHiddenStatePacker, and the mean writes straight into its slot, so the logits processor no longertorch.cats them.--enable-dp-lm-head), skip the identity vocab gather so the draft step runs one pass instead of two.einsum+ transpose copy.Without DSpark nothing changes.
Verification
test_mhc_stream_mean.pypins the kernel bitwise tox.mean(dim=1), including inf, NaN, overflow and all -0 rows.CI States
Latest PR Test (Base): 🚫 Run #40040572712
Latest PR Test (Extra): ❌ Run #40040572575
Latest PR Test (AMD ROCm 10): 🚫 Run #40040572686