Commit 6c5dd25
Enable the XCD head-slow remap on the bf16 dense attention path
The DUALWAVE_SWP dense kernel launches
grid=(NUM_HEADS_Q, num_q_blocks, grid_z), which is head-fast: one head's
q-blocks scatter across all 8 XCDs and every XCD re-streams that head's
K/V from HBM. With 256 CUs at one workgroup/CU the number of concurrent
distinct K/V streams is the head count, so at H=32/64 the working set
outgrows L2 and throughput decays as S grows.
Measured on MI355X, bf16, D=128, non-causal, B=2 H=32: the L2 hit rate
falls from 86% at S=27k to 37% at S=180k, where the kernel reads 1182 GB
from HBM against a compulsory 8.9 GB -- 133x -- while aiter holds 87% and
28x over the same range.
The fix already existed. _init_dualwave_thread_mapping re-derives
(head, q_block) with head as the slow axis, and _make_dualwave_swp_traits
already accepted xcd_swizzle; only the fp8 builder ever passed it, gated
on dtype_str == "fp8". This plumbs the flag through the bf16 builder and
reuses the fp8 dispatch condition (non-causal, H % NUM_XCD_GFX950 == 0,
num_q_blocks >= MIN_Q_BLOCKS_XCD_SWIZZLE, no split-K).
With the remap on, FlyDSL's memory profile lands on aiter's: 89.2% hit
and 28.1x re-stream at S=180k, against aiter's 87.1% and 28.2x.
Throughput goes flat at 1264-1272 TFLOP/s (84.5% of this box's 1497
TFLOP/s bf16 GEMM ceiling) across S=27k..240k, 2.7-3.1% above aiter at
every point. Best case is +8.5% at S=239,580 H=64.
The remap is bijective, so the output is bit-identical to the unpatched
kernel -- pinned by a new test. H=8 and H=16 already fit L2 and show no
decay; the remap measures as a no-op there (0.999-1.000x), so the
dispatch does not gate on head count.
dualwave_swp_xcd_swizzle joins the existing dualwave_swp_* build options:
None auto-selects, True/False force it, which is what lets the test drive
both paths through the public API.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: John Qin <yanyuan.qin@amd.com>1 parent ac227c3 commit 6c5dd25
3 files changed
Lines changed: 75 additions & 1 deletion
File tree
- kernels/attention
- tests/kernels
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| 122 | + | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
133 | 137 | | |
134 | 138 | | |
135 | 139 | | |
| 140 | + | |
136 | 141 | | |
137 | 142 | | |
138 | 143 | | |
| |||
151 | 156 | | |
152 | 157 | | |
153 | 158 | | |
| 159 | + | |
154 | 160 | | |
155 | 161 | | |
156 | 162 | | |
| |||
625 | 631 | | |
626 | 632 | | |
627 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
628 | 638 | | |
629 | 639 | | |
630 | 640 | | |
| |||
873 | 883 | | |
874 | 884 | | |
875 | 885 | | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
876 | 900 | | |
877 | 901 | | |
878 | 902 | | |
| |||
887 | 911 | | |
888 | 912 | | |
889 | 913 | | |
| 914 | + | |
890 | 915 | | |
891 | 916 | | |
892 | 917 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3471 | 3471 | | |
3472 | 3472 | | |
3473 | 3473 | | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
3474 | 3521 | | |
3475 | 3522 | | |
0 commit comments