Repository navigation
Conversation
|
Thanks, JoursBleu. Can confirm this resolves the issue, also appears to be a slight improvement. original was 40.2 TPS now 41.14. |
|
According to the llama.cpp AI usage policy:
Your posts very much read like they are machine-generated. Please clarify the extent to which language models were used. |
No, i didn't use AI to write the post. But I do write it in Chinese, and use Claude Opus to translate it to English. |
|
Thank you for clarifying. The problem from our end as maintainers is that we get a lot of spam and the only feasible way for us to sift through it is to ban the use of language models altogether (since it is much easier to determine whether language models were used at all vs. whether someone carefully checked the language model outputs). |
23bae61 to
afb6b78
Compare
|
Hi @IMbackK @JohannesGaessler, would please review when you have time, thanks! |
|
I have not forgotten about this PR but there happen to be other, concurrent PRs that tough the same code. One of them in particular is relevant for getting good scaling with tensor parallelism so I'm prioritizing it over this PR. |
|
Can you rebase on top of master? I'll then review this PR so that it van be merged. |
afb6b78 to
71a7fb1
Compare
|
@JohannesGaessler rebased |
JohannesGaessler
left a comment
There was a problem hiding this comment.
Please change the name of the function to calc_max_nwarps to better reflect how it is being used. The PR seems to be correct based on static code analysis but I will need to check it for regressions.
8cd2a84 to
40dc8a1
Compare
|
Can confirm the updated version still works, without this 36.66 TPS vs 41.22. |
|
hi @JohannesGaessler,
|
|
When I tested the performance: Details
I am still seeing performance regressions for hardware that would be supposedly unaffected. And for RDNA4 the speedup is not consistent. So this PR should not be merged. |
Actually, it seems that someone else was using the machine simultaneously so that was probably the reason. Still, I don't think the additional complexity is worthwhile if the speedup is inconsistent. |
|
Probably need to narrow the results to RDNA3/4 which are not in the benchmarks results, I would suspect Radeon 8060S (RDNA 3.5) may not be an ideal candidate for validation being an integrated shared memory platform. I'll try with the Gemma 4 32b MOE today just for isolation, I'll also test without the RDNA restriction on RTX 3090 to determine if there is regression or not. |
|
Apologies for the delay, here are the results of for when the RDNA4/3 fixes are not contained (which has been done) Not sure if anything can be done to improve the logic so that it could actually be used with Nvidia CUDA and not restricted, of which I can understand is not ideal. ---- SUMMARY ---- llama.cpp MMVQ patch benchmark sweep
Primary signal: llama.cpp-full-cuda — OLMoE-1B-7B-Q5_K_M
llama.cpp-full-cuda — Llama-3.1-8B-Q4_K_M
llama.cpp-full-cuda — Qwen3.5-9B-Q4_0
llama.cpp-full-cuda — Qwen3-30B-A3B-Q4_K_XL
llama.cpp-full-cuda — Gemma-4-E2B-Q6_K_XL
llama-cpp-base-latest — OLMoE-1B-7B-Q5_K_M
llama-cpp-base-latest — Llama-3.1-8B-Q4_K_M
llama-cpp-base-latest — Qwen3.5-9B-Q4_0
llama-cpp-base-latest — Qwen3-30B-A3B-Q4_K_XL
llama-cpp-base-latest — Gemma-4-E2B-Q6_K_XL
llama-cpp-test-latest — OLMoE-1B-7B-Q5_K_M
llama-cpp-test-latest — Llama-3.1-8B-Q4_K_M
llama-cpp-test-latest — Qwen3.5-9B-Q4_0
llama-cpp-test-latest — Qwen3-30B-A3B-Q4_K_XL
llama-cpp-test-latest — Gemma-4-E2B-Q6_K_XL
|
|
on the 12‑CU gfx1103 iGPU, clamping to The mechanism might be the same, though, the low CU contention -> more warps than the 12 CU can use so optimum is 1. Testing conditions: h255 ubuntu 24.04 2x16GB 5600 RAM current master, gemma‑4‑26B‑A4B (MoE), all on current master / gfx1103 / gemma‑4 26B A4B MoE / tg128 decode:
To bench #20831 on current master I rebased it — one trivial conflict, the Patch is easy and straight forward. used copy/paste with little changes: 1 file to change:
enum mmvq_parameter_table_id {
....
MMVQ_PARAMETERS_RDNA3_0,
+ MMVQ_PARAMETERS_RDNA3_0_GFX1103, // adding it here
....
}
static constexpr __device__ mmvq_parameter_table_id get_device_table_id() {
#if defined(RDNA4)
return MMVQ_PARAMETERS_RDNA4;
+#elif defined(__gfx1103__)
+ return MMVQ_PARAMETERS_RDNA3_0_GFX1103; // select before RDNA3_0: gfx1103 would otherwise fall into that table.
#elif defined(RDNA3_0)
return MMVQ_PARAMETERS_RDNA3_0;
.....
#else
return MMVQ_PARAMETERS_GENERIC;
#endif
}
static __host__ mmvq_parameter_table_id get_device_table_id(int cc) {
if (GGML_CUDA_CC_IS_RDNA4(cc)) {
return MMVQ_PARAMETERS_RDNA4;
}
+ if (cc == GGML_CUDA_CC_OFFSET_AMD + 0x1103) {
+ return MMVQ_PARAMETERS_RDNA3_0_GFX1103;
+ }
if (GGML_CUDA_CC_IS_RDNA3_0(cc)) {
return MMVQ_PARAMETERS_RDNA3_0;
}
....
return MMVQ_PARAMETERS_GENERIC;
}
if (table_id == MMVQ_PARAMETERS_RDNA3_0_GFX1103) {
// gfx1103 (Phoenix iGPU): at ncols_dst == 1 these mul_mat_vec_q launches
// otherwise split a 64 thread workgroup into two 32 lane waves
// one wave per workgroup avoids the gfx1103-specific decode regression
// on this path.
if (ncols_dst == 1) {
switch (type) {
case GGML_TYPE_Q4_K:
case GGML_TYPE_Q5_0:
case GGML_TYPE_Q5_K:
case GGML_TYPE_Q6_K:
case GGML_TYPE_Q8_0:
return 1;
default:
break;
}
}
return calc_nwarps(type, ncols_dst, MMVQ_PARAMETERS_RDNA3_0);
}Just extending RDNA3 for THIS specific iGPU without touching or changing anything else. Reasoning is I am overriding only the specific case I measured and tested for stability (24h runs for Q8_0 and Q6_K in the table on Gemma4 26B). In summary - my edit means gfx1103 inherits RDNA3_0 unchanged and only overrides nwarps for those quants where I measured a regression (Q5_0/Q5_K included by the same dispatch path, not separately benchmarked). Prefill and other metrics are same as today. Since this PR is under review and saw another one about my same iGPU but closed, I saw no reason to open a new one until this is one is resolved. Besides, it is a 5 minutes edit by an existing contributor/maintainer with self explanatory logic and nothing really new, so no reason for another PR to fight for attention if this comment could be enough. Regarding AI usage - used opus and codex to check my understanding, speed up repetitive work and automate drudgery (monitor the dmsg for errors and notify me of fails when they happen and to double check for errors). |
|
Why we are not pushing it further? |
40dc8a1 to
34def05
Compare
|
Tested on 2x RX 7900 XTX (gfx1100), ROCm 10.0. Dense Qwen3.8-27B,
pp2048 moved slightly down in both (1576.56 -> 1571.12 and 1643.13 -> 1636.17). Null on dense, which is expected rather than a problem with the patch, and your own dense The reason it does not engage is the shapes: this targets 512-2048 column matrices, i.e. MoE Your gfx1100 MoE rows are where the value is — #19478 costs 1.7% to 8.7% there and this PR The separate two-card scaling loss I measured is unrelated to this patch and is written up |
22de1c3 to
5d0f165
Compare
Fix MMVQ TG regression on MoE models from #19478.
#19478 increased
nwarpsto 8 on RDNA3/RDNA4 to better utilize memory bandwidth for bs=1 decode. However,nwarps=8assumes wide weight matrices. MoE expert FFN layers are narrow (512–2048 cols), so most warps have no work but still pay__syncthreads()and shared-memory reduction overhead, causing a net TG regression. This patch dynamically clampsnwarpsbased on the actual matrix width to avoid this.R9700 (gfx1201, RDNA4), ROCm 7.2
MoE (regression fixed):
Dense (no regression):
Full whitelist sweep — llama-2-7b, 1x R9700, tg512, r=5:
W7900 (gfx1100, RDNA3), ROCm 7.1
MoE (regression fixed):
Full whitelist sweep — llama-2-7b, 1x W7900, tg512, r=5:
Note: PR description translated with AI assistance.