Commit fda623ac3 for llama.cpp
commit fda623ac3b302a1b92824e5abaf1974954935e7c
Author: Remiehneppo <70493913+remiehneppo@users.noreply.github.com>
Date: Sat Dec 5 21:43:26 2026 +0700
HIP: tune Vega20 MMVQ-to-MMQ batch crossover for speculative verify (#33448)
* perf(rocm): tune Vega20 MMVQ-to-MMQ batch crossover for speculative verify
Switch Vega20 (MI50 gfx906) from MMVQ to MMQ at ne11 > 4 for Q4_0/Q4_1
and ne11 > 5 for Q3_K/Q4_K/Q5_K/Q6_K/IQ4_XS/Q8_0 based on llama-bench
measurements on Qwen3.8-27B (pp8 improves +38.6% on Q4_0 from 80.99 to
112.23 t/s and +33.9% on UD-Q4_K_XL from 66.75 to 89.41 t/s).
Verified 185/185 MUL_MAT tests pass on ROCm0 via test-backend-ops.
* Apply suggestion from @JohannesGaessler
---------
Co-authored-by: tieubaoca <tieubaoca@users.noreply.github.com>
Co-authored-by: Johannes Gäßler <johannesg@5d6.de>
diff --git a/ggml/src/ggml-cuda/mmvq.cu b/ggml/src/ggml-cuda/mmvq.cu
index 5a4a6108b..3c9060a69 100644
--- a/ggml/src/ggml-cuda/mmvq.cu
+++ b/ggml/src/ggml-cuda/mmvq.cu
@@ -450,8 +450,16 @@ bool ggml_cuda_should_use_mmvq(enum ggml_type type, int cc, int64_t ne11) {
// VEGA20 devices are the only devices with dense MMQ -> ggml_cuda_should_use_mmq()
if (cc == GGML_CUDA_CC_VEGA20) {
switch (type) { // tuned on MI50 (gfx906)
+ case GGML_TYPE_Q4_0:
+ case GGML_TYPE_Q4_1:
+ return ne11 <= 4;
+ case GGML_TYPE_Q3_K:
case GGML_TYPE_Q4_K:
- return ne11 <= 7;
+ case GGML_TYPE_Q5_K:
+ case GGML_TYPE_Q6_K:
+ case GGML_TYPE_IQ4_XS:
+ case GGML_TYPE_Q8_0:
+ return ne11 <= 5;
case GGML_TYPE_NVFP4:
return ne11 <= 6;
default: