Skip to content

Commit 549977e

Browse files
yunruisclaude
andcommitted
perf(prims-ts): run short-list H128 FP8 sparse MLA on the 2CTA schedule
_choose_fp8 only picked the H128 2CTA family for capacity >= 512. A short list (capacity 256-384, e.g. HCA at moderate context: one 128-slot SWA tile plus one or two compressed tiles) fell through to the 1CTA M64 "keep" fallback, which repeats the single KV stream for every head tile and cannot retain K. Lower the threshold to 256. On B200 (fp32 fused output, graph timing, interleaved 3 rounds): B1 Q8192 K192 (capacity 256) 1.2549 -> 0.5281 ms (2.38x) B2 Q8192 K192 2.5005 -> 1.0386 ms (2.41x) B1 Q8192 KV32768 K384 (capacity 384) 1.5452 -> 0.6297 ms (2.45x) decode B128 K192 0.0231 -> 0.0139 ms (1.66x) decode B128 K384 0.0289 -> 0.0154 ms (1.88x) decode B32 / B64 K192 (below the rows*2 >= sm_count gate): unchanged capacity 512 control: unchanged (same schedule) Tests cover capacity 256 and 384 with H128 FP8 and BF16: decode, prefill, independent source scales, and fused RoPE/quant output. The cutoffs in this policy were measured on GB300; this one was measured on B200 only and should be confirmed on GB300. AI-assisted. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> (cherry picked from commit 1e09032)
1 parent 19bfa5d commit 549977e

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎flashinfer/attention/prims_ts/kernels/mla_decode/sparse_policy.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,12 @@ def _choose_fp8(rows, heads, query_length, capacity, sm_count):
256256
scheduler="clc",
257257
paired_correction=True,
258258
)
259-
if heads == 128 and capacity >= 512 and (rows * 2 >= sm_count):
259+
if heads == 128 and capacity >= 256 and (rows * 2 >= sm_count):
260260
# The FP8 2CTA family uses its qualified static persistent scheduler;
261-
# BF16's CLC choice below is a separate measured schedule.
261+
# BF16's CLC choice below is a separate measured schedule. Short lists
262+
# (capacity 256-384, e.g. HCA at moderate context) run this schedule
263+
# too: one 2CTA tile covers H128 with a single KV stream, where the
264+
# M64 keep fallback repeats it per head tile (B200: 2.4x faster).
262265
return SparseMlaProfile(family="2cta", scheduler="static", gather_issue_warps=1)
263266
if (
264267
heads <= 16

‎tests/attention/test_prims_ts_sparse_mla.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@ def _dequant_output(output, scales, block_size):
375375
(16, 1, 128, 513, 128, "ue8m0", False, False),
376376
(5, 1, 128, 513, 32, "fp32", False, False),
377377
(5, 1, 16, 513, 128, "ue8m0", False, False),
378+
# Short lists on the H128 2CTA schedule (capacity 256), fused output.
379+
(80, 1, 128, 64, 128, "fp32", False, False),
380+
(80, 1, 128, 64, 32, "ue8m0", False, True),
381+
(1, 161, 128, 64, 128, "fp32", False, False),
378382
(1, 161, 64, 513, 32, "ue8m0", False, False),
379383
# Packed multiwave queries reuse the quantized output's shared stages.
380384
(2, 81, 128, 513, 32, "fp32", True, False),
@@ -739,6 +743,14 @@ def test_rope_quant_plan_options():
739743
),
740744
pytest.param(1, 0, 64, 513, True, False, False, True, id="multiwave-prefill"),
741745
pytest.param(0, 4, 128, 2049, True, False, False, True, id="multiwave-decode"),
746+
# Short lists (capacity 256 and 384) with enough rows for the H128 2CTA tile.
747+
pytest.param(
748+
0, 1, 128, 64, True, False, False, True, id="short-two-cta-decode"
749+
),
750+
pytest.param(
751+
1, 0, 128, 64, True, False, False, True, id="short-two-cta-prefill"
752+
),
753+
pytest.param(0, 1, 128, 256, True, False, True, True, id="short-two-cta-384"),
742754
pytest.param(
743755
1, 3, 8, 8193, True, False, False, False, id="long-split-reduction"
744756
),

0 commit comments

Comments
 (0)