Skip to content

perf(hip): bit-identical 32-row w4a16 GEMM twin for M<=32 verify (+17-20% Ripple DFlash2 decode) - #354

Merged
AzeezIsh merged 1 commit into
mainfrom
perf/hip-w4a16-m32-verify
Nov 13, 2026
Merged

AzeezIsh merged 1 commit into
mainfrom
perf/hip-w4a16-m32-verify

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

What

A 32-row twin of w4a16_gemm_t_m128_f16a (gfx1151, strix-hip) used for small-M GEMMs (M ≤ 32: DFlash/MTP verify widths). At Ripple's M=17 verify, the 128-row CTA spends 6 of its 8 WMMA row tiles on empty rows. The twin keeps the same LDS staging, the same exact NVFP4→f16 dequant and the same K order, but each CTA covers 32 rows and the warps split N. Every 16×16 output tile sees the same WMMA operands in the same order, so the result is bit-identical.

The NT=128 variant is used for N > 8192 and NT=64 for narrower N. ATLAS_W4A16_M32=0 turns it off. M > 32 is unchanged.

Evidence (DevLab Strix runner, gfx1151)

  • kbench 43302086666 + wide-range 43321417618: 0 differing outputs at every shape. The wide-range run covers the full e4m3 scale range with sign, |A| scaled by 2^±12, M in 16–19, and N up to 100278.
    • Ripple M=17 gate/up: 1589 → 686 µs
    • q|gate: 797 → 324 µs
    • down: 1563 → 1231 µs
    • o: 395 → 317 µs
    • lm_head-shaped (N=100278): 3271 → 1617 µs
  • AR on/off (43321435955 / 43321442468): probe outputs are byte-identical to each other and to main's AR.
  • DFlash2 @0.93 decode: on 4.8/4.8/4.6 tok/s vs off 4.1/4.1/4.0. With kernels serialized (HIP_LAUNCH_BLOCKING=1 AMD_SERIALIZE_KERNEL=3, 43342612809 / 43342616857), on and off produce byte-identical probes, and on is still faster (4.8 vs 4.0 steady).

Note: pre-existing DFlash timing sensitivity on main (not caused by this PR)

Unserialized, the sky probe under DFlash2 lands at 64 or 69 tokens depending on launch timing. Main alone flips between the two depending on the serialization env var (43357178780 → 69, 43357182991 → 64). Each configuration is deterministic, but the result depends on timing, so there is a race somewhere in the DFlash verify/draft path. This is tracked separately.

Gates

  • kbench bit-identical + faster
  • e2e A/B: faster, with identical output under serialization; AR byte-identical to main
  • post-merge build + serve on framework (framework is currently unreachable)

🤖 Generated with Claude Code

…<= 32 verify GEMMs

At Ripple's DFlash2 verify width (M = 17) m128_f16a multiplies six zero-row
WMMA tiles for every two useful ones; on the runner it is 64% of DFlash2
decode GPU time (rocprof 43291803106). w4a16_gemm_t_m32_f16a_n{128,64} keeps
the same A staging, exact NVFP4 -> f16 dequant and K loop for a 32-row CTA,
with the 4 warps splitting N, so every output tile sees the same WMMA operands
in the same order: bit-identical (kbench 43302086666, 0 differing outputs at
every shape), and 2.3x (gate/up), 2.45x (q|gate), 1.27x (down, NT 64), 1.25x
(o, NT 64) faster.

w4a16_gemm_n128_m128 swaps it in when the launch is the f16a twin and M <= 32;
the twins are resolved beside m128_f16a, so targets without them (and CUDA)
are unchanged. ATLAS_W4A16_M32=0 keeps m128_f16a for A/B.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Race follow-up (DevLab runner, Ripple [email protected], sky probe), all on main with no m32 involved: default → 64 tok (43365660707), ATLAS_DEBUG_NO_GRAPH=1 → 69 (43365657638), AMD_SERIALIZE_KERNEL=3 → 69 (43357178780), HIP_LAUNCH_BLOCKING=1 → 64 (43357182991). Every configuration is deterministic, but the result depends on timing. This predates #354: with kernels serialized, m32 on and off give byte-identical probes (43342612809 / 43342616857). Next: 27B C8 MTP A/B (NUM_DRAFTS 0/1/3) to see whether the twin also helps the 27B verify widths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant