Misc. bug: llama : add Gemma4 MTP (#23398) kills tokens/sec
Name and Version
#23398
Operating systems
No response
Which llama.cpp modules do you know to be affected?
No response
Command line
llama-server.exe -m C:\gemma-4-12b-it-UD-Q4_K_XL.gguf --mmproj C:\mmproj-F32.gguf -ngl 999 -c 64000 -fa on -np 1 --flash-attn on --spec-type ngram-mod --spec-draft-n-max 1 --reasoning on --reasoning-budget 2048 -ctk q4_0 -ctv q4_0 -cram 256
Problem description & steps to reproduce
#23398 When I use gemma 4 12B on this new merge my tokens/sec drop to ~4 tokens/sec, previously I was getting 40+ tokens/sec.
Using CUDA on windows.
halfway through posting this I figured that because the MTP code was changed it might be interfering with n-gram mod so I disabled Ngram and instantly went back to 40 tokens/sec.
llama-server.exe -m C:\gemma-4-12b-it-UD-Q4_K_XL.gguf --mmproj C:\mmproj-F32.gguf -ngl 999 -c 64000 -fa on -np 1 --flash-attn on --spec-type ngram-mod --spec-draft-n-max 1 --reasoning on --reasoning-budget 2048 -ctk q4_0 -ctv q4_0 -cram 256
5 tokens/sec
llama-server.exe -m C:\gemma-4-12b-it-UD-Q4_K_XL.gguf --mmproj C:\mmproj-F32.gguf -ngl 999 -c 64000 -fa on -np 1 --flash-attn on --reasoning on --reasoning-budget 2048 -ctk q4_0 -ctv q4_0 -cram 256
40 tokens/sec
apologies if this bug report is badly worded, thanks to everyone for pushing so hard to increase our token generation speeds!
First Bad Commit
#23398
Relevant log output
Logs
Noticed something similar here, on an Intel Mac with Vulkan/MoltenVK backend. Speed for the 26B-A4B version tanked after I updated to b9549, but if I turn off --spec-default, it goes back up. I wasn't using MTP at all, just ngram-mod via --spec-default. @UncleMart I'd suggest reopening this issue - it seems like a pretty significant regression.
@Rhys-T Honestly, I couldnt get this new version to go above ~5 tokens/sec no matter what I did so I assumed its my system or something but reopened as I saw a couple other people on reddit say they had a massive drop too. Was SOOOOO looking forward to seeing MTP+QAT in action too ;)
Try build 9551 which contains PR #24277 .
Increasing draft threads does not increase tg/s, that is not yet solved. So keep --speec-draft-n-max at 1.
build 9551 / gemma4 26B 1k Context / MTP: 45tps / no MTP: 55tps / b9549: 45tps 20k Context / MTP: 45tps / no MTP: 45tps / b9549: 20tps
https://huggingface.co/unsloth/gemma-4-26B-A4B-it-qat-GGUF/tree/main https://huggingface.co/RachidAR/gemma-4-26B-A4B-it-qat-assistant-q4_0-gguf/tree/main
windows11
0.00.140.451 I device_info:
0.00.216.420 I - CUDA0 : NVIDIA GeForce RTX 4070 SUPER (12281 MiB, 11069 MiB free)
0.00.216.438 I - CPU : AMD Ryzen 7 8845HS w/ Radeon 780M Graphics (32085 MiB, 18368 MiB free)
0.00.216.536 I system_info: n_threads = 8 (n_threads_batch = 8) / 16 | CUDA : ARCHS = 750,800,860,890,900,1200,1210 | USE_GRAPHS = 1 | PEER_MAX_BATCH_SIZE = 128 | CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | AVX2 = 1 | F16C = 1 | FMA = 1 | BMI2 = 1 | AVX512 = 1 | AVX512_VBMI = 1 | AVX512_VNNI = 1 | AVX512_BF16 = 1 | LLAMAFILE = 1 | OPENMP = 1 | REPACK = 1 |
llama-server.exe --host 127.0.0.1 --port 5001 --no-webui --no-warmup --no-mmap --cache-ram 0 -np 1 -ngl all -ncmoe 11 -ctk q8_0 -ctv q8_0 --jinja -rea off -c 40960 -m ./models/gemma-4-26B-A4B-it-qat-UD-Q4_K_XL.gguf
-md ./models/gemma-4-26B-A4B-it-qat-MTP-Q4_0.gguf --spec-draft-n-max 2 --spec-type draft-mtp
2.07.492.246 I slot print_timing: id 0 | task 1273 | prompt eval time = 1089.57 ms / 70 tokens ( 15.57 ms per token, 64.25 tokens per second)
2.07.492.255 I slot print_timing: id 0 | task 1273 | eval time = 7315.84 ms / 359 tokens ( 20.38 ms per token, 49.07 tokens per second)
2.07.492.257 I slot print_timing: id 0 | task 1273 | total time = 8405.41 ms / 429 tokens
2.07.492.258 I slot print_timing: id 0 | task 1273 | graphs reused = 1421
2.07.492.260 I slot print_timing: id 0 | task 1273 | draft acceptance = 0.45213 ( 170 accepted / 376 generated)
2.07.492.280 I statistics draft-mtp: #calls(b,g,a) = 7 1436 1436, #gen drafts = 1436, #acc drafts = 770, #gen tokens = 2872, #acc tokens = 1113, dur(b,g,a) = 0.018, 4469.265, 1.843 ms
2.07.492.396 I slot release: id 0 | task 1273 | stop processing: n_tokens = 1264, truncated = 0
2.07.492.422 I srv update_slots: all slots are idle
llama-server.exe --host 127.0.0.1 --port 5001 --no-webui --no-warmup --no-mmap --cache-ram 0 -np 1 -ngl all -ncmoe 10 -ctk q8_0 -ctv q8_0 --jinja -rea off -c 40960 -m ./models/gemma-4-26B-A4B-it-qat-UD-Q4_K_XL.gguf
0.26.469.940 I slot print_timing: id 0 | task 391 | prompt eval time = 597.14 ms / 70 tokens ( 8.53 ms per token, 117.23 tokens per second)
0.26.469.949 I slot print_timing: id 0 | task 391 | eval time = 6200.86 ms / 385 tokens ( 16.11 ms per token, 62.09 tokens per second)
0.26.469.951 I slot print_timing: id 0 | task 391 | total time = 6798.00 ms / 455 tokens
0.26.469.952 I slot print_timing: id 0 | task 391 | graphs reused = 764
0.26.470.078 I slot release: id 0 | task 391 | stop processing: n_tokens = 1290, truncated = 0
0.26.470.108 I srv update_slots: all slots are idle
Try with --spec-draft-n-max 1. Using MTP below Q8 significantly reduces draft‑acceptance rates — Gemma is very sensitive to MTP quality.
--spec-draft-n-max 1 increased acceptance by about 0.1 Unlike before, using the same ncmoe and --spec-draft-n-max 1 seems to have boosted TPS by about 10.
With this new configuration. (MTP and no MTP)
-ncmoe 10 -t 12 -ctk q4_0 -ctv q4_0 -ctkd q4_0 -ctvd q4_0 --spec-draft-n-max 1
-t 12 MTP: 1k=68 20k=63 no MTP: 1k=63 20k=56
without -t 12 MTP: 1k=64 20k=60 no MTP: 1k=61 20k=55
https://www.reddit.com/r/LocalLLaMA/comments/1t53dhp/quality_comparison_between_qwen_36_27b/ This is a case of a kind of code work.
eval time = 20397.76 ms / 1598 tokens ( 12.76 ms per token, 78.34 tokens per second)
draft acceptance = 0.91717 ( 764 accepted / 833 generated)
Try with
--spec-draft-n-max 1. Using MTP below Q8 significantly reduces draft‑acceptance rates — Gemma is very sensitive to MTP quality.
That is true behavior is changed after latest gemma MTP update. Even for Qwen 3.6 now --spec-draft-n-max 1 is faster than --spec-draft-n-max 2. Previously for me --spec-draft-n-max 2 was fastest.
But for me Q4 MTP (IQ4_NL-q4emb) is faster than Q8 MTP and draft acceptance rate is not lower. Before using QAT gemma 4 and MTP my decode was 9.x tps now with QAT and MTP at my decode speed is 18.17 t/s.
My setup is ubuntu, Vega 8 with vulkan backend.
Before QAT and MTP:
After QAT and MTP:
My configuration.
[Gemma-4-26B-A4B]
model = /home/tipu/AI/models/unsloth/gemma-4-26B-A4B/gemma-4-26B-A4B-it-qat-UD-Q4_K_XL.gguf
mmproj = /home/tipu/AI/models/unsloth/gemma-4-26B-A4B/gemma-4-26B-A4B-it-qat-mmproj-F16.gguf
n-predict = -1
keep = -1
no-repack = on
cache-ram = -1
n-gpu-layers = 99
flash-attn = on
sampling-seq = kpt
temp = 1.0
top-p = 0.95
top-k = 64
ctx-size = 65536
ubatch-size = 1088
batch-size = 2176
ctx-checkpoints = 64
offline = on
parallel = 2
kv-unified = on
prio-batch = 2
prio = 2
no-mmap = on
mlock = on
fit = off
backend-sampling = on
spec-draft-prio = 2
spec-draft-prio-batch = 2
spec-type = draft-mtp
spec-draft-ngl = 99
spec-draft-model = /home/tipu/AI/models/unsloth/gemma-4-26B-A4B/gemma-4-26b-A4B-it-assistant-IQ4_NL-q4emb.gguf
spec-draft-n-max = 1
spec-draft-p-min = 0.05
MTP GGUF used from https://huggingface.co/RachidAR/gemma-4-26B-A4B-it-qat-assistant-q4_0-gguf
I ran benchmark tests and can confirm that passing the file as a prompt (using curl) to llama-server gave me about 2 to 8 tokens/s more than using a web browser. Nonetheless, it was still faster than llama-cli - by 1 to 4 tokens, so this is acceptable, more runs shows that delta is near 0. I’ll verify this again while generating a more complex story.