Skip to content
This repository was archived by the owner on Jul 9, 2026. It is now read-only.

perf(ggml-cuda mmq): Q4_K/Q5_K MMQ tuning for RDNA4 — +7.6% Qwen3.6-27B prefill#2

Open
DeanoC wants to merge 1 commit into
perf/luce-verify-kernelsfrom
perf/mmq-q4k-rdna4
Open

perf(ggml-cuda mmq): Q4_K/Q5_K MMQ tuning for RDNA4 — +7.6% Qwen3.6-27B prefill#2
DeanoC wants to merge 1 commit into
perf/luce-verify-kernelsfrom
perf/mmq-q4k-rdna4

Conversation

@DeanoC

@DeanoC DeanoC commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

What

Tuning of the Q4_K/Q5_K MMQ path (ggml/src/ggml-cuda/mmq.cuh) for RDNA4 / gfx1201, found autonomously by the geo-evo kernel loop over 9 iterations:

  • relax __launch_bounds__ minBlocks 2 → 1 (RDNA4 wave32 occupancy)
  • int2-vectorized y-tile flat copy in load_tiles
  • int4-vectorized x_dm LDS write in load_tiles_q4_K / load_tiles_q5_K (the biggest single win)

MMQ is the compute-bound quantized-matmul path (prefill + dflash spec-decode verify), so kernel efficiency translates here — unlike the batch-1 matvec/decode path, which is VRAM-bandwidth-bound (a parallel MMVQ experiment got +40% microbench but 0 real decode gain; not included).

Results (gfx1201 / Radeon AI PRO R9700)

  • Microbench (test-backend-ops perf, MUL_MAT q4_K m=4096 n=512 k=14336): 1139 → ~1037 µs = +9.8%
  • Real model (unsloth/Qwen3.6-27B-Q4_K_M, pinned clocks, same-session A/B): prefill pp512 583.6 → 627.7 tok/s = +7.6%; decode tg128 unchanged (MMQ doesn't touch batch-1 decode)

Notes

  • Regressed approaches were tried and reverted (documented in the loop handoff): dsB VGPR preload, stream-K (−24% on RDNA4), y-tile half2 register prefetch (−7.9%).
  • mmq.cuh is byte-identical between ac06e543 (base, perf/luce-verify-kernels) and the 30c9d7d base the change was measured on — applies cleanly.
  • Complementary to feat/rdna35-mmq-tile-override.
  • Staged on our fork; upstream to Luce-Org/lucebox-ggml when ready.

🤖 Generated with Claude Code

@DeanoC DeanoC requested a review from pramodith July 3, 2026 10:54
…7B prefill

Q4_K/Q5_K MMQ path (gfx1201 / RDNA4), found by geo-evo over 9 iterations:
- relax __launch_bounds__ minBlocks 2->1 (RDNA4 wave32 occupancy)
- int2-vectorized y-tile flat copy in load_tiles
- int4-vectorized x_dm LDS write in load_tiles_q4_K / load_tiles_q5_K

Microbench (test-backend-ops, q4_K m=4096 n=512 k=14336): 1139 -> ~1037us = +9.8%.
Real 27B (Qwen3.6-27B-Q4_K_M, pinned clocks): prefill pp512 583.6 -> 627.7 tok/s
= +7.6%; decode unaffected (MMQ is the compute-bound batch path). Regressed
approaches (dsB preload, stream-K, half2 prefetch) documented + reverted.
@DeanoC DeanoC force-pushed the perf/mmq-q4k-rdna4 branch from 168f20a to 0699be8 Compare July 3, 2026 14:48
@DeanoC DeanoC changed the title perf(ggml-cuda mmq): Q4_K MMQ tuning for RDNA4 — +6.4% Qwen3.6-27B prefill perf(ggml-cuda mmq): Q4_K/Q5_K MMQ tuning for RDNA4 — +7.6% Qwen3.6-27B prefill Jul 3, 2026
@DeanoC

DeanoC commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

Updated to the iter-9 kernel: added the int4-vectorized x_dm LDS write (load_tiles_q4_K/q5_K), improving the result from +6.4% → +7.6% real 27B prefill (microbench +7.5% → +9.8%). Same-session pinned-clock A/B: stock 583.6 → optimized 627.7 tok/s.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant