Commit afd0f6d
committed
gemm: stop accumulating the fp8 grouped GEMM in an inline-asm AGPR
Rebasing onto main moved this kernel from flydsl 0.2.4 to 0.3.x, and it started returning
numbers uncorrelated with the reference -- logits diff 0.98, i.e. not drift, wrong data --
while compiling and running clean.
The cause is the inline-asm MMA's accumulator constraint. asm mode "2" emits
v_mfma_f32_16x16x128_f8f6f4 with "=a,v,v,0": an AGPR-class output tied to srcC. On 0.2.4 that
was correct; on 0.3.x it silently miscompiles, and the shape of the damage is distinctive --
with B = I, so the output must equal A, every fourth output row comes back entirely zero and
the rest are ~25% populated. Four accumulator slots per lane map to four consecutive rows, so
that is one whole accumulator slot lost.
Isolated to the constraint: the operand types entering the asm are right (vector<8xi32>,
vector<8xi32>, vector<4xf32> against a vector<4xf32> result), dropping the
amdgpu-agpr-alloc="128,128" passthrough does not help, and the identical asm with "=v"
(mode "3") is correct. So acc_mode defaults to "vgpr" -- still the in-place asm accumulate
this kernel is built around, just in the VGPR file -- and "agpr" now asserts instead of
returning wrong numbers, since nothing about the failure is visible at compile time.
_raw -> as_ir_value on the asm operands is not the fix; it is the unwrap main moved to in
#913 when it ported the parent fp8_gemm_4wave, and it is what the passing configuration runs.
Measured on gfx950 with flydsl 0.3.2: 5 passed, and 2751 TFLOPS on 2x2048/n4096/k7168 against
2708 for the intrinsic MMA (agpr_inplace=False) -- the same within single-run noise, so the
asm path keeps its reason to exist.
Worth recording for whoever hits this next: the parent kernel does not use inline-asm MFMA at
all, so this path had no coverage in main's 0.2.4 -> 0.3.x ports. Everything else about the
kernel survived the jump.1 parent 8ebb4c9 commit afd0f6d
1 file changed
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
185 | 195 | | |
186 | 196 | | |
187 | 197 | | |
| |||
377 | 387 | | |
378 | 388 | | |
379 | 389 | | |
380 | | - | |
| 390 | + | |
381 | 391 | | |
382 | 392 | | |
383 | 393 | | |
| |||
0 commit comments