Commit 4ae435e
authored
Expand Triton autotune configs for MoE FP8 kernels to improve AMD GPU performance (#3952)
* Expand Triton autotune configs for MoE FP8 rowwise and jagged scales kernels
The existing autotune configs for the MoE training FP8 kernels use a
single configuration each (e.g., num_warps=4, num_stages=4, one block
size), which prevents Triton's autotuner from finding better configs
for different hardware targets.
Expand the search space to cover:
- Multiple num_warps values (4, 8) to better saturate both NVIDIA
(warp size 32) and AMD (wavefront size 64) GPU compute units
- Multiple num_stages values for software pipelining flexibility
across different cache hierarchies
- Multiple block sizes to adapt to varying matrix dimensions
This is complementary to PR #3945 (relaxed atomics on AMDGPU) and
targets the same kernels.
* Gate expanded autotune configs to AMD only, preserve original NVIDIA configs
H100 benchmarks showed ~18% regression on the atomic kernel with the
expanded search space. The autotuner appears to pick suboptimal configs
from the larger candidate set on NVIDIA. Gate the expanded configs
behind torch.version.hip so AMD gets the broader search (4-7% faster
on MI250X) while NVIDIA keeps the original tuned configs.
* Widen autotune search space and add N_GROUPS to scales kernel autotuning key
Two improvements based on MI300X (gfx942) benchmarking:
1. float8_rowwise.py: Widen block size search space for AMD GPUs.
- Atomic configs: add BLOCK_SIZE_N=256 and BLOCK_SIZE_K=64
- Reduction configs: add BLOCK_SIZE_N=128, BLOCK_SIZE_K=64, and num_stages=2,4
- Yields 1.5-2.2x speedup on MI300X for the atomic kernel and
1.05-1.25x for the reduction kernel across Llama4 MoE shapes.
2. jagged_float8_scales.py: Add N_GROUPS to autotuning key for both
rowwise and colwise scales kernels. The previous key (M or K only)
caused the autotuner to cache a single config across all n_groups
values, but optimal tile sizes differ significantly by n_groups.
This eliminates cross-n_groups interference and allows each n_groups
value to independently find its best config.1 parent 9960da8 commit 4ae435e
2 files changed
Lines changed: 66 additions & 49 deletions
Lines changed: 40 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
| |||
283 | 288 | | |
284 | 289 | | |
285 | 290 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
303 | 311 | | |
304 | 312 | | |
305 | 313 | | |
| |||
Lines changed: 26 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
| |||
108 | 113 | | |
109 | 114 | | |
110 | 115 | | |
| 116 | + | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| |||
147 | 153 | | |
148 | 154 | | |
149 | 155 | | |
150 | | - | |
| 156 | + | |
151 | 157 | | |
152 | 158 | | |
153 | 159 | | |
| |||
156 | 162 | | |
157 | 163 | | |
158 | 164 | | |
| 165 | + | |
159 | 166 | | |
160 | 167 | | |
161 | 168 | | |
| |||
299 | 306 | | |
300 | 307 | | |
301 | 308 | | |
| 309 | + | |
302 | 310 | | |
303 | 311 | | |
304 | 312 | | |
| |||
336 | 344 | | |
337 | 345 | | |
338 | 346 | | |
339 | | - | |
| 347 | + | |
340 | 348 | | |
341 | 349 | | |
342 | 350 | | |
| |||
345 | 353 | | |
346 | 354 | | |
347 | 355 | | |
| 356 | + | |
348 | 357 | | |
349 | 358 | | |
350 | 359 | | |
| |||
0 commit comments