Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
… VGPR pins (#8736 @ 13b071f, head 2026-11-26T06:02:59Z) (#8743) Port of #8736's commits d9926d2 and 13b071f onto k3-455-dev; its first commit (#8181 + #7913) is already here. Conflicts: - mla_pagesize1_fp8_fp8.py: #8736's file. It carries #7913 @ 51bb7c6 (k3-455-dev had 067fee3), the only difference in that file. - mla_reduce_kernels.cuh: k3-455-dev's file (keeps #7876 and #7914) plus #8736's row-parallel reducer and its dispatch, checked first as in #8736. Co-authored-by: xiangM99 <[email protected]>
… VGPR pins (#8736 @ 13b071f, head 2026-11-26T06:02:59Z) (#8743) Port of #8736's commits d9926d2 and 13b071f onto k3-455-dev; its first commit (#8181 + #7913) is already here. Conflicts: - mla_pagesize1_fp8_fp8.py: #8736's file. It carries #7913 @ 51bb7c6 (k3-455-dev had 067fee3), the only difference in that file. - mla_reduce_kernels.cuh: k3-455-dev's file (keeps #7876 and #7914) plus #8736's row-parallel reducer and its dispatch, checked first as in #8736. Co-authored-by: xiangM99 <[email protected]> (cherry picked from commit 5b18892)
Summary
kn_mla_reduce_v1_wide(#7570) is never selected on wave32 GPUs (gfx1250). This makes its traits and dispatch follow the device wave size, so on gfx1250 the few-tile, many-split decode/verify reduces it was written for take it, as they do on gfx950. On MI455X those reduces get up to 5.5x faster (1 tile x 250 splits, 16 heads: 76.2 → 13.7 us). The size bound is tightened for wave32, wherekn_mla_reduce_v1catches up sooner.Motivation
MlaReduceWideTraits::kWaveSizeisopus::get_warp_size(), which the host compiler pass evaluates to 64 whatever the target.mla_reduce_use_widecompares it withdev_prop.warpSize, 32 on gfx1250, so the check always fails there. Taking the kernel anyway would not work either: the launch takes its block size (kNumWarps * kWaveSize) and LDS size from the host's 64, while the device code is compiled for 32.So on gfx1250, few tiles with many splits stay on
kn_mla_reduce_v1, which walks the splits of each (tile, head) with one 2-wave workgroup: a batch-1 verify with 250 splits takes 76 us. The layout cases added with the wide kernel ("8 rows, max_seqlen_q 1/4") also run onkn_mla_reduce_v1there and hit its LDS race (fixed separately in #7912).Changes
All in
csrc/include/mla_reduce_kernels.cuh:MlaReduceWideTraitstakes the wave size as a third template parameter, defaulting toopus::get_warp_size()(existing uses are unchanged).kn_mla_reduce_v1_widecompiles its body (moved tomla_reduce_v1_wide_impl) only when the device wave size matchesTraits::kWaveSize. Each target keeps one live instance; the other is an empty kernel.dispatch_mla_reduce_v1picksMlaReduceWideTraits<DV, H, 32>or<DV, H, 64>from the runtimewarpSize, so the launch's block size, LDS size and routing check all use the device's wave size.mla_reduce_use_wide: on wave32 the bound onnum_reduce_tile x heads x max_seqlen_qis 4 units per CU instead of 16. On gfx1250,kn_mla_reduce_v1is as fast or faster from about 8 units per CU (table below).wave64 targets take the same instance and route the same shapes as before.
Performance (if applicable)
MI455X (gfx1250, 256 CUs),
op_tests/test_mla_reduce.py(bf16, DV 512, one row per tile, uniform splits unless listed). "Units" = tiles x heads x rows, the routing's size measure.Forced on (
AITER_MLA_REDUCE_WIDE=1) vskn_mla_reduce_v1(=0), which sets the wave32 bound:kn_mla_reduce_v1With main's 16 units per CU (4096 here), the shapes in the last rows would take the wide kernel and run slower than today. With 4 per CU they keep
kn_mla_reduce_v1.Default routing after this change vs
kn_mla_reduce_v1, grid from the same test:kn_mla_reduce_v1)The rest of the grid keeps
kn_mla_reduce_v1and is within ±3%. That covers fewer than 8 splits per tile (1x2, 4x4, 32x2, 64x4, 256x2, 512x2) and more than 4 units per CU: 16 heads 128x8 / 256x16; 96 and 128 heads 16x32, 32x8, 64x16, 128x8, 256x16.Testing
On MI455X (gfx1250), aiter
mainat111fbd8plus this change,module_mla_reducebuilt for gfx950 + gfx1250:python3 op_tests/test_mla_reduce.py(all default dtypes, head dims and cases), withAITER_MLA_REDUCE_WIDEunset,=0and=1: everything passes except the 12-head DV-128 multi-row cases (64x[4], sometimes512x[4]).mainfails those the same way in all three settings. They never reach the wide kernel (12 heads x 64 rows); they are thekn_mla_reduce_v1LDS race fixed in [HIP] [fix] MLA reduce: LDS race between rows in kn_mla_reduce_v1's massive path #7912.main: ALL PASSED in 3 of 3 runs.MlaReduceWideTraits<DV, H, 64>) and the bound (16 units per CU) are what they were.Documentation
Routing only; the kernel and
AITER_MLA_REDUCE_WIDEbehave as documented in the code.Dependencies
Breaking Changes
None. wave64 behaviour is unchanged. On wave32 the kernel gives the same results as on wave64 (the existing correctness tests, above).
cc @yuychang (#7570)