ggml-cuda: add dequant-float matvec (mmvdq) for Q4_K/Q5_K/Q6_K on RDN…#61
ggml-cuda: add dequant-float matvec (mmvdq) for Q4_K/Q5_K/Q6_K on RDN…#61Annieren wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Correct me if my understanding is wrong. We go from:
fp32
|
v
quant q_weights
| /
v v
gemmv (int8 compute)
To:
fp32 q_weights
| /
v v
gemmv (fp32 compute)
Right?
Getting rid of one kernel dispatch in decode is usually good idea. The same applies to the fusion you are proposing. Usually the activation quantization kernels hit caches since activations are fairly small. I am wondering what roofline you are seeing for quant+gemmv prior to these changes. Are they at their peak and this is the only way to make it faster, or are the kernels poorly implemented/optimized?
|
Suggestions for Improvement. non blocking
Overall this is a clean, well-organized kernel addition with a conservative default (RDNA3.5-only, env-overridable) and a solid perf story. The two |
MMVDQ change summary
What it adds: a dequantize-to-float matvec path (mmvdq) for K-quant weights
during decode (n=1), as an alternative to the existing mul_mat_vec_q (mmvq)
path.
Why: mmvq quantizes the activation vector to q8_1 first (a quantize_q8_1
pass) so it can do int8 dot products. On RDNA3.5 (gfx1151) these matvecs
are DRAM-bandwidth-bound on the weights, so the q8_1 quantize pass is
pure overhead. mmvdq dequantizes the weight blocks straight to float and
does the dot in float, skipping the quantize pass entirely.
Kernel design (mmvdq.cu): one warp per output block, 16 threads process one
super-block, activations loaded once (as float4/float2) and reused across the
block. Covers Q4_K, Q5_K, Q6_K. Includes a fused gate+up SwiGLU variant
(mul_mat_vec_dq_glu) that computes silu(gate)*up in one dispatch sharing the
activation load.
Routing / gating (ggml-cuda.cu):
Q4_K/Q5_K (or Q6_K if enabled), all tensors contiguous, ne02/03/12/13==1, and
ne[0] % QK_K == 0.
GGML_GLU_OP_SWIGLU, matching gate/up shapes+type, single row.
Enablement (env overrides):
= force off, non-zero = force on
~neutral vs mmvq)
Default is on only for RDNA3.5; every other arch keeps mmvq.
Full decode comparison (38 models)
Mean +3.09%, median +2.78% (n=38). * = controlled DQ-toggle run (DQ-off/mmvq
vs DQ-on/mmvdq) substituted for the three thermally-throttled full-suite
rows.