You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HIP: the prompt GEMM pays a group-32 scale and bias fold every K stage #1600
On AMD Ryzen AI MAX+ 395, Radeon 8060S gfx1151 (40 CUs, 128 GB unified memory, measured 225.6 GB/s read), Ubuntu 26.04, archive HIP 7.1 (clang 21), TensorFold 7c068895, TensorFold/Qwen3.8-Flash-Next-MLX-4bit-MTP.
With the WMMA sparse attention above, a 7.9K-token prompt spends 60% of its time (8.2 s) in affine_wmma_gemm<4> (zig/kernels/hip/tiles/matrix_gemm.hpp) at about 14 TFLOP/s, a quarter of the chip's fp16 WMMA rate. With MLX group 32 equal to the tile's K step (per == 1), every 32-wide stage zeroes a second accumulator set, runs two WMMAs, then folds the group's scale and bias and the activation row sums into the main accumulator.
Proposal
For group sizes equal to the K step, stage dequantized weights (code x scale + bias) as the bf16 B operand so WMMA accumulates straight into the output tile, dropping the per-stage fold, the row sums and the second accumulator set (freeing registers for a second resident block). This changes the sums (the dequantized weight is rounded to bf16 before the product), so it needs the agreed arithmetic gate; the existing path stays selectable.
Gate to agree
FP64 reference per projection class, worst-column error no worse than today's path, teacher-forced top-token differences, kernel contract and limits, cold prefill at 8K/32K before and after.
Thanks @gilby. Rounding the dequantized weight to bf16 changes tokens, so this lands as an opt-in only, and it stays
opt-in; today's path remains the default. Your gate is the one CONTRIBUTING sets, and it stands:
an FP64 reference per projection class, with worst-column error no worse than today's path;
teacher-forced top-token differences with margins;
the kernel contract and limits for every served chip;
cold prefill at 8k and 32k before and after.
Please also show decode is untouched: tokens equal to main with the switch off, and decode speed level. A change like
this can do well against FP64 on average and badly on one column, so the worst-column row matters most here.
Closing with #1650: with #1663 in 1.2.0 (the matrix tile no longer spills), the default group-32 prompt GEMM is as fast as the dequantizing tile on Flash Next, and it keeps the folding tile's fp64 accuracy. Thanks @gilby for the measurements.
Activity
ashhart commentedon Oct 30, 2026
Thanks @gilby. Rounding the dequantized weight to bf16 changes tokens, so this lands as an opt-in only, and it stays
opt-in; today's path remains the default. Your gate is the one CONTRIBUTING sets, and it stands:
Please also show decode is untouched: tokens equal to main with the switch off, and decode speed level. A change like
this can do well against FP64 on average and badly on one column, so the worst-column row matters most here.
ashhart commentedon Nov 1, 2026
Closing with #1650: with #1663 in 1.2.0 (the matrix tile no longer spills), the default group-32 prompt GEMM is as fast as the dequantizing tile on Flash Next, and it keeps the folding tile's fp64 accuracy. Thanks @gilby for the measurements.