mmq config for Q4_K/Q5_K/Q6_K - #3
Conversation
b39391d to
a03ff66
Compare
|
OK I ran tests and short summary:
|
| // | ||
| // Q4_K/Q5_K/Q6_K: measured on MI50. I=64 halves the accumulator array and the X | ||
| // LDS tile, cutting VGPR/scratch and improving Q5_K/Q6_K throughput ~15-35%. | ||
| // Q4_K stays at I=128 (I=64 makes it ~53% slower). J=64 only. |
There was a problem hiding this comment.
"cutting VGPR/scratch" does not hold on a stock build - J=64 comes out 85 VGPRs against 84 with ScratchSize 0 in both, Q5_K and Q6_K alike. Only occupancy moves from 2 to 3.
| } | ||
| CASE(GGML_TYPE_Q4_K, 256, 2, 128, 64, GGML_CUDA_MMQ_SRAM_LAYOUT_Q8_1, MMQ_ITER_K, false, true); | ||
| CASE(GGML_TYPE_Q4_K, 256, 2, 128, 64, GGML_CUDA_MMQ_SRAM_LAYOUT_Q8_1, MMQ_ITER_K, false, false); | ||
|
|
There was a problem hiding this comment.
These are probably not needed as rdna2 already returns the same nine parameters for Q4_K?
| CASE(GGML_TYPE_Q4_K, 256, 2, 128, 64, GGML_CUDA_MMQ_SRAM_LAYOUT_Q8_1, MMQ_ITER_K, false, false); | ||
|
|
||
| CASE(GGML_TYPE_Q5_K, 256, 2, 64, 64, GGML_CUDA_MMQ_SRAM_LAYOUT_Q8_1, MMQ_ITER_K, false, true); | ||
| CASE(GGML_TYPE_Q5_K, 256, 2, 64, 64, GGML_CUDA_MMQ_SRAM_LAYOUT_Q8_1, MMQ_ITER_K, false, false); |
There was a problem hiding this comment.
These cost -9.6% on current base build, kernel 8002 -> 8461 us, but gain +3.1% under max-ilp.
Would nthreads be the knob instead here? 512 at the inherited I=128 gives 956.5 vs 610.9 for I=64 here, still not bit exact.
CASE(GGML_TYPE_Q5_K, 512, 2, 128, 64, GGML_CUDA_MMQ_SRAM_LAYOUT_Q8_1, MMQ_ITER_K, false, true);
CASE(GGML_TYPE_Q5_K, 512, 2, 128, 64, GGML_CUDA_MMQ_SRAM_LAYOUT_Q8_1, MMQ_ITER_K, false, false);
|
Hi. Sorry for the long reply, I've been busy. I'm (and ai) can try to look for something else and prepare better, but it’s possible that the same crap will happen again. |
I personally builded, double-checked, and confirmed that the numbers are true and that the AI made no errors in the research. I am ready to provide all the raw data.
The data in this spreadsheet https://docs.google.com/spreadsheets/d/1gUs7c80ErwtZPrry1sAHvgsGcHsWLk3eHZkZ8hvokjA/edit?gid=373998456#gid=373998456 was collected by me personally, without the involvement of an AI.
Prebuilt images:
q6k-rocprof files:
Overview
Add per-format MMQ tile configurations for the K-quant types on gfx906
(Vega20 / MI50, wave64) in
ggml/src/ggml-cuda/mmq-config-gfx906.cuh.The mx-llama.cpp gfx906 config already handles Q8_0 (512 threads, J up to 128)
and MXFP4 (512 threads). This change adds the missing K-quant tuning measured
on MI50 with ROCm 7.14 and
-mllvm -amdgpu-sched-strategy=max-ilp.Additional information
Change
In
ggml/src/ggml-cuda/mmq-config-gfx906.cuh, before the rdna2 fallback:Same thread count, occupancy, J, K and stream-k as the rdna2 table. Only I
changes: I=128 -> I=64 for Q5_K and Q6_K. Q4_K stays at I=128.
Motivation / measured effect
Direct A/B on the mx-llama.cpp tree (
751b611), same compiler flag, one MI50,--n-prompt 2048 --ubatch-size 2048 --batch-size 2048 --n-gen 256,--n-depth 0 --split-mode layer --flash-attn on.End-to-end (tokens per second)
First the production GGUFs, then a full per-type matrix.
Qwen PP is dominated by Q8_0 and is therefore unchanged. Gemma PP, which is
dominated by Q4_K/Q5_K/Q6_K, improves by 4.6%. TG is unchanged within noise.
Full per-type matrix (PP, same bench settings; models quantized from the same
F16 source with the mxxm
llama-quantize):Non-K types are untouched, as expected. The K-quant gains reproduce on both a
9B dense model and a 26B MoE, and scale with model size.
Kernel totals (Gemma PP, fallback=false)
I=64 halves the accumulator array (32 -> 16 floats per thread) and roughly
halves the X tile in LDS. On gfx906 this removes register pressure/scratch for
Q5_K and Q6_K without hurting their tile reuse. Q4_K was measured to lose ~53%
at I=64, so it keeps I=128.
Verification
MUL_MAT: 1186/1186 passed.MUL_MAT_ID: 865/865 passed (MoE expert boundaries).accumulation math; all backend comparisons pass.
Requirements