Repository navigation
Eval bug: Gemma 4 crashes with MTP #25522
Copy link
Copy link
Open
Labels
Description
Name and Version
b9947
built with GNU 14.3.1 for Linux x86_64
Operating systems
Linux
GGML backends
CUDA
Hardware
Intel (AVX2, no AVX512)
2080Ti 22GB x2 (CUDA)
Models
Gemma 4 31b + MTP (Unsloth)
Problem description & steps to reproduce
Adjust the paths and run:
llama-server --model /md1200/llm/gemma4-31b/unsloth/gemma-4-31B-it-qat-UD-Q4_K_XL.gguf \
--mmproj /md1200/llm/gemma4-31b/unsloth/mmproj-F16.gguf \
--model-draft /md1200/llm/gemma4-31b/unsloth/mtp-gemma-4-31B-it.gguf \
--slots \
--parallel 8 \
--no-cache-idle-slots \
--ctx-checkpoints 128 \
--cache-ram 402653184 \
--alias "gemma4:31b" \
--api-key gemma \
--top_k 64 \
--top_p 0.95 \
--temp 1.0 \
--ctx-size 262144 \
--host 0.0.0.0 \
--port 11436 \
--no-mmap \
--flash-attn on \
--kv-unified \
--fit off \
--n-gpu-layers 61 \
--reasoning off \
--split-mode tensor \
--cache-type-k q8_0 \
--cache-type-v q5_1 \
--spec-type draft-mtp \
--spec-draft-n-max 2 \
--spec-draft-type-k q8_0 \
--spec-draft-type-v q5_1
llama-server will crash on the 2nd prompt in the session.
First Bad Commit
No response
Relevant log output
Logs
0.00.189.093 I cmn common_param: common_params_print_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
0.00.745.727 I srv load_model: loading model '/md1200/llm/gemma4-31b/unsloth/gemma-4-31B-it-qat-UD-Q4_K_XL.gguf'
0.01.443.158 W load: override 'tokenizer.ggml.add_bos_token' to 'true' for Gemma4
0.01.494.032 W load: control-looking token: 212 '</s>' was not control-type; this is probably a bug in the model. its type will be overridden
0.01.494.447 W load: control-looking token: 50 '<|tool_response>' was not control-type; this is probably a bug in the model. its type will be overridden
0.01.516.667 W load: special_eog_ids contains '<|tool_response>', removing '</s>' token from EOG list
0.19.238.842 W load: control-looking token: 212 '</s>' was not control-type; this is probably a bug in the model. its type will be overridden
0.19.239.276 W load: control-looking token: 50 '<|tool_response>' was not control-type; this is probably a bug in the model. its type will be overridden
0.19.261.158 W load: special_eog_ids contains '<|tool_response>', removing '</s>' token from EOG list
0.19.826.471 W llama_context: n_ctx_seq (262144) > n_ctx_train (131072) -- possible training context overflow
0.19.868.226 W llama_kv_cache: layer 3: sharing with layer 59. k = 0x2000000000000000, v = 0x2000000000000000
0.19.868.852 W llama_kv_cache: layer 0: sharing with layer 58. k = 0x2000000000000000, v = 0x2000000000000000
0.19.868.857 W llama_kv_cache: layer 1: sharing with layer 58. k = 0x2000000000000000, v = 0x2000000000000000
0.19.868.858 W llama_kv_cache: layer 2: sharing with layer 58. k = 0x2000000000000000, v = 0x2000000000000000
0.20.784.458 I srv load_model: loaded multimodal model, '/md1200/llm/gemma4-31b/unsloth/mmproj-F16.gguf'
0.20.867.672 I srv load_model: initializing, n_slots = 8, n_ctx_slot = 262144, kv_unified = 'true'
0.20.867.854 W set_sampler: backend sampling not supported with SPLIT_MODE_TENSOR; using CPU
0.20.867.858 W spec common_specu: backend offload failed for seq_id=0; using CPU sampler
0.20.867.860 W spec common_specu: backend offload failed for seq_id=1; using CPU sampler
0.20.867.860 W spec common_specu: backend offload failed for seq_id=2; using CPU sampler
0.20.867.861 W spec common_specu: backend offload failed for seq_id=3; using CPU sampler
0.20.867.862 W spec common_specu: backend offload failed for seq_id=4; using CPU sampler
0.20.867.864 W spec common_specu: backend offload failed for seq_id=5; using CPU sampler
0.20.867.865 W spec common_specu: backend offload failed for seq_id=6; using CPU sampler
0.20.867.866 W spec common_specu: backend offload failed for seq_id=7; using CPU sampler
0.20.944.003 I srv llama_server: model loaded
0.20.944.012 I srv llama_server: listening on http://0.0.0.0:11436
1.48.972.340 I slot get_availabl: id 7 | task -1 | selected slot by LRU, t_last = -1
1.48.972.491 I slot launch_slot_: id 7 | task 0 | processing task, is_child = 0
1.49.636.345 I slot print_timing: id 7 | task 0 | prompt eval time = 437.06 ms / 14 tokens ( 31.22 ms per token, 32.03 tokens per second)
1.49.636.351 I slot print_timing: id 7 | task 0 | eval time = 226.44 ms / 8 tokens ( 28.31 ms per token, 35.33 tokens per second)
1.49.636.352 I slot print_timing: id 7 | task 0 | total time = 663.50 ms / 22 tokens
1.49.636.354 I slot print_timing: id 7 | task 0 | graphs reused = 4
1.49.636.361 I slot print_timing: id 7 | task 0 | draft acceptance = 0.62500 ( 5 accepted / 8 generated), mean len = 2.25
1.49.636.407 I slot release: id 7 | task 0 | stop processing: n_tokens = 23, truncated = 0
1.49.667.291 I slot get_availabl: id 6 | task -1 | selected slot by LRU, t_last = -1
1.49.667.349 I slot launch_slot_: id 6 | task 8 | processing task, is_child = 0
1.50.622.647 I slot print_timing: id 6 | task 8 | prompt eval time = 605.59 ms / 315 tokens ( 1.92 ms per token, 520.16 tokens per second)
1.50.622.654 I slot print_timing: id 6 | task 8 | eval time = 349.35 ms / 15 tokens ( 23.29 ms per token, 42.94 tokens per second)
1.50.622.656 I slot print_timing: id 6 | task 8 | total time = 954.93 ms / 330 tokens
1.50.622.658 I slot print_timing: id 6 | task 8 | graphs reused = 10
1.50.622.668 I slot print_timing: id 6 | task 8 | draft acceptance = 0.57143 ( 8 accepted / 14 generated), mean len = 2.14
1.50.622.869 I slot release: id 6 | task 8 | stop processing: n_tokens = 330, truncated = 0
1.50.638.532 I slot get_availabl: id 5 | task -1 | selected slot by LRU, t_last = -1
1.50.638.583 I slot launch_slot_: id 5 | task 19 | processing task, is_child = 0
1.51.414.175 I slot print_timing: id 5 | task 19 | prompt eval time = 509.06 ms / 204 tokens ( 2.50 ms per token, 400.74 tokens per second)
1.51.414.182 I slot print_timing: id 5 | task 19 | eval time = 266.19 ms / 14 tokens ( 19.01 ms per token, 52.59 tokens per second)
1.51.414.184 I slot print_timing: id 5 | task 19 | total time = 775.25 ms / 218 tokens
1.51.414.186 I slot print_timing: id 5 | task 19 | graphs reused = 14
1.51.414.193 I slot print_timing: id 5 | task 19 | draft acceptance = 0.90000 ( 9 accepted / 10 generated), mean len = 2.80
1.51.414.302 I slot release: id 5 | task 19 | stop processing: n_tokens = 218, truncated = 0
1.56.481.598 I slot get_availabl: id 7 | task -1 | selected slot by LCP similarity, sim_best = 0.303 (> 0.100 thold), f_keep = 0.435
1.56.496.574 I slot launch_slot_: id 7 | task 28 | processing task, is_child = 0
/builddir/build/BUILD/llama-cpp-b9947/ggml/src/ggml-cuda/fattn.cu:585: fatal error
[New LWP 2453612]
[New LWP 2453611]
[New LWP 2453610]
[New LWP 2453609]
[New LWP 2453577]
[New LWP 2453576]
[New LWP 2453575]
[New LWP 2453574]
[New LWP 2453573]
[New LWP 2453455]
[New LWP 2453454]
[New LWP 2453453]
[New LWP 2453452]
[New LWP 2453451]
[New LWP 2453450]
[New LWP 2453449]
[New LWP 2453448]
[New LWP 2453447]
[New LWP 2453446]
[New LWP 2453445]
[New LWP 2453444]
[New LWP 2453443]
[New LWP 2453442]
[New LWP 2453441]
[New LWP 2453440]
[New LWP 2453439]
[New LWP 2453438]
[New LWP 2453437]
[New LWP 2453436]
[New LWP 2453435]
[New LWP 2453434]
[New LWP 2453433]
[New LWP 2453432]
[New LWP 2453431]
[New LWP 2453430]
[New LWP 2453429]
[New LWP 2453428]
[New LWP 2453427]
[New LWP 2453426]
[New LWP 2453425]
[New LWP 2453424]
[New LWP 2453423]
[New LWP 2453422]
[New LWP 2453421]
[New LWP 2453420]
[New LWP 2453419]
[New LWP 2453418]
[New LWP 2453417]
[New LWP 2453416]
[New LWP 2453415]
[New LWP 2453414]
[New LWP 2453413]
[New LWP 2453412]
[New LWP 2453411]
[New LWP 2453410]
[New LWP 2453409]
[New LWP 2453408]
[New LWP 2453407]
[New LWP 2453406]
[New LWP 2453405]
[New LWP 2453404]
[New LWP 2453403]
[New LWP 2453402]
[New LWP 2453401]
[New LWP 2453400]
[New LWP 2453399]
[New LWP 2453398]
[New LWP 2453397]
[New LWP 2453396]
[New LWP 2453395]
[New LWP 2453394]
[New LWP 2453393]
[New LWP 2453392]
[New LWP 2453391]
[New LWP 2453390]
[New LWP 2453389]
[New LWP 2453388]
[New LWP 2453387]
[New LWP 2453386]
[New LWP 2453385]
[New LWP 2453384]
[New LWP 2453383]
[New LWP 2453382]
[New LWP 2453381]
[New LWP 2453380]
[New LWP 2453379]
[New LWP 2453378]
[New LWP 2453377]
[New LWP 2453376]
[New LWP 2453375]
[New LWP 2453374]
[New LWP 2453373]
[New LWP 2453372]
[New LWP 2453371]
[New LWP 2453370]
[New LWP 2453369]
[New LWP 2453368]
[New LWP 2453367]
[New LWP 2453366]
[New LWP 2453365]
[New LWP 2453364]
[New LWP 2453363]
[New LWP 2453362]
[New LWP 2453361]
[New LWP 2453360]
[New LWP 2453359]
[New LWP 2453358]
[New LWP 2453357]
[New LWP 2453356]
[New LWP 2453355]
[New LWP 2453354]
[New LWP 2453353]
[New LWP 2453352]
[New LWP 2453351]
[New LWP 2453350]
[New LWP 2453349]
[New LWP 2453348]
[New LWP 2453347]
[New LWP 2453346]
[New LWP 2453345]
[New LWP 2453344]
[New LWP 2453343]
[New LWP 2453342]
[New LWP 2453341]
[New LWP 2453340]
[New LWP 2453339]
[New LWP 2453338]
[New LWP 2453337]
[New LWP 2453336]
[New LWP 2453335]
[New LWP 2453334]
[New LWP 2453333]
[New LWP 2453332]
[New LWP 2453331]
[New LWP 2453330]
[New LWP 2453329]
[New LWP 2453328]
[New LWP 2453327]
[New LWP 2453326]
[New LWP 2453325]
[New LWP 2453324]
[New LWP 2453323]
[New LWP 2453322]
[New LWP 2453321]
[New LWP 2453320]
[New LWP 2453319]
[New LWP 2453318]
[New LWP 2453317]
[New LWP 2453316]
[New LWP 2453315]
[New LWP 2453314]
[New LWP 2453313]
[New LWP 2453312]
[New LWP 2453311]
[New LWP 2453310]
[New LWP 2453309]
[New LWP 2453308]
[New LWP 2453307]
[New LWP 2453306]
[New LWP 2453305]
[New LWP 2453304]
[New LWP 2453303]
[New LWP 2453302]
[New LWP 2453301]
[New LWP 2453300]
[New LWP 2453299]
[New LWP 2453298]
[New LWP 2453297]
[New LWP 2453296]
[New LWP 2453295]
[New LWP 2453294]
[New LWP 2453293]
[New LWP 2453292]
[New LWP 2453291]
[New LWP 2453290]
[New LWP 2453289]
[New LWP 2453288]
[New LWP 2453287]
[New LWP 2453286]
[New LWP 2453285]
[New LWP 2453284]
[New LWP 2453283]
[New LWP 2453282]
[New LWP 2453281]
[New LWP 2453280]
[New LWP 2453279]
[New LWP 2453278]
[New LWP 2453277]
[New LWP 2453276]
[New LWP 2453275]
[New LWP 2453274]
[New LWP 2453273]
[New LWP 2453272]
[New LWP 2453271]
[New LWP 2453270]
[New LWP 2453269]
[New LWP 2453268]
[New LWP 2453267]
[New LWP 2453266]
[New LWP 2453265]
[New LWP 2453264]
[New LWP 2453261]
[New LWP 2453260]
[New LWP 2453259]
[New LWP 2453255]
[New LWP 2453254]
[New LWP 2453253]
[New LWP 2453252]
[New LWP 2453251]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
0x00007f99ada92df3 in wait4 () from /lib64/libc.so.6
#0 0x00007f99ada92df3 in wait4 () from /lib64/libc.so.6
#1 0x00007f99ad02ed59 in ggml_print_backtrace () from /lib64/libggml-base.so.0
#2 0x00007f99ad02eef0 in ggml_abort () from /lib64/libggml-base.so.0
#3 0x00007f999369ca41 in ggml_cuda_flash_attn_ext(ggml_backend_cuda_context&, ggml_tensor*) () from /lib64/libggml-cuda.so.0
#4 0x00007f99936f6041 in ?? () from /lib64/libggml-cuda.so.0
#5 0x00007f99ad0600f9 in ?? () from /lib64/libggml-base.so.0
#6 0x00007f99ad04c734 in ggml_backend_sched_graph_compute_async () from /lib64/libggml-base.so.0
#7 0x00007f99ad1b6412 in llama_context::graph_compute(ggml_cgraph*, bool) () from /lib64/libllama.so.0
#8 0x00007f99ad1b8e58 in llama_context::process_ubatch(llama_ubatch const&, llm_graph_type, llama_memory_context_i*, ggml_status&) () from /lib64/libllama.so.0
#9 0x00007f99ad1bc0e8 in llama_context::decode(llama_batch const&) () from /lib64/libllama.so.0
#10 0x00007f99ad1c6346 in llama_decode () from /lib64/libllama.so.0
#11 0x00007f99ad7cfd80 in ?? () from /lib64/libllama-common.so.0
#12 0x00007f99ad7deed3 in common_speculative_draft(common_speculative*) () from /lib64/libllama-common.so.0
#13 0x00007f99adf63ad5 in ?? () from /lib64/libllama-server-impl.so
#14 0x00007f99adf3452a in server_queue::start_loop(long) () from /lib64/libllama-server-impl.so
#15 0x00007f99adeecdcf in llama_server(common_params&, int, char**) () from /lib64/libllama-server-impl.so
#16 0x00007f99adeedffe in llama_server(int, char**) () from /lib64/libllama-server-impl.so
#17 0x00007f99ad9c85c8 in __libc_start_call_main () from /lib64/libc.so.6
#18 0x00007f99ad9c868b in __libc_start_main_impl () from /lib64/libc.so.6
#19 0x000055e219385415 in ?? ()
[Inferior 1 (process 2453249) detached]
./run-gemma4.sh: line 36: 2453249 Aborted (core dumped) llama-server --model /md1200/llm/gemma4-31b/unsloth/gemma-4-31B-it-qat-UD-Q4_K_XL.gguf --mmproj /md1200/llm/gemma4-31b/unsloth/mmproj-F16.gguf --model-draft /md1200/llm/gemma4-31b/unsloth/mtp-gemma-4-31B-it.gguf --slots --parallel 8 --no-cache-idle-slots --ctx-checkpoints 128 --cache-ram 402653184 --alias "gemma4:31b" --api-key gemma --top_k 64 --top_p 0.95 --temp 1.0 --ctx-size 262144 --host 0.0.0.0 --port 11436 --no-mmap --flash-attn on --kv-unified --fit off --n-gpu-layers 61 --reasoning off --split-mode tensor --cache-type-k q8_0 --cache-type-v q5_1 --spec-type draft-mtp --spec-draft-n-max 2 --spec-draft-type-k q8_0 --spec-draft-type-v q5_1Reactions are currently unavailable
Activity
ServeurpersoCom commentedon Jul 10, 2026
I have a very similar setup, the latest master, and it works perfectly for me. We need to find the difference that's causing the crash...
EDIT: Ah, the whole problem lies in the split for the dual GPU setup.
gordan-bobic commentedon Jul 10, 2026
Yes, it seems that there is a bug affecting MTP split across more than one GPU.
ServeurpersoCom commentedon Jul 10, 2026
Can you try --split-mode layer ?
I think --split-mode tensor can't cut a 1-head layer in half!
gordan-bobic commentedon Jul 11, 2026
That works, but that also loses me half of the prefill throughput compared to split-mode=tensor.
I tried limiting MTP to a single device with
--device-draft CUDA0, but that crashes out immediately with a different error:ServeurpersoCom commentedon Jul 11, 2026
Yeah, --device-draft won't help here: that only moves the draft model. The blocker is the main model's global layers, which have a single KV head (that's your cache_k_l58, one of the shared-KV global layers).
Tensor split partitions attention across KV heads, and a 1-head layer can't be cut, so its cache can't live in the tensor-split buffer at all.
So it's -sm layer for now. You're right that it costs you prefill throughput (layer split runs one GPU at a time on a single-stream prefill, tensor split uses both per layer). And I'm not sure yet whether it's possible to refactor the tensor-split planner to support split-mode=tensor for 1-head layers.
gordan-bobic commentedon Jul 11, 2026
If the main model only has 1 head, how is it possible to run the main model across more than one GPU? Main model alone splits across GPUs with split-mode=tensor just fine. It is only when MTP is added into the mix that it crashes llama-server..
ServeurpersoCom commentedon Jul 11, 2026
Can you try this patch?
I cheated by using ggml-rpc-server to simulate your two GPUs on a single card, which reproduces your exact crash. Dug into it with Fable 5 and GPT 5.6 Sol: there are actually two distinct problems, including a use-after-reset in the GGML tensor-split backend (the MTP draft shares KV layers with the main model, and graph rebuilds recycle shard tensors the draft still references). Whether it works or not, it will help converge on the fix.
No-rebuild alternative to test: LLAMA_GRAPH_REUSE_DISABLE=1 with your original config.
gordan-bobic commentedon Jul 11, 2026
LLAMA_GRAPH_REUSE_DISABLE=1makes it worse. Without it, llama-server crashes on the 2nd prompt. With that option it crashes on startup before any prompt can be sent.I'll try your proposed patch.
art-den commentedon Jul 26, 2026
I have the same problem with two GPUs. Is there a way around this without disabling MTP?
gordan-bobic commentedon Aug 16, 2026
Unfortunately, the proposed patch doesn't seem to work:
Caveat - I have since upgraded to 5 GPUs (from previous 2).
sssr5hsssdssqdse commentedon Aug 16, 2026
gordan-bobic commentedon Aug 16, 2026
It is same as before only 5x 22GB 2080Ti instead of 2x.
cromoteca commentedon Sep 18, 2026
Adding a data point: this is still present on current master, but it looks racy rather than "always the 2nd prompt".
Environment
llama.cpp-master542348a(2026-09-18), CUDA, sm_86unsloth/gemma-4-31B-it-qat-GGUF:gemma-4-31B-it-qat-UD-Q4_K_XL.gguf+mtp-gemma-4-31B-it.gguf(thegoogle/gemma-4-31B-it-assistantdrafter) +mmproj-BF16.ggufllama-server ... -sm tensor -ts 3/1 --device CUDA0,CUDA1 -fa on -ctk q8_0 -ctv q8_0 -c 131072 --spec-draft-model mtp-gemma-4-31B-it.gguf --spec-type draft-mtplayer 3: sharing with layer 59,layer 0/1/2: sharing with layer 58Crash — same stack as the report:
ggml/src/ggml-cuda/fattn.cu:730: fatal errorfromggml_cuda_flash_attn_ext(BEST_FATTN_KERNEL_NONE), called viacommon_speculative_impl_draft_mtp::draft. It happens on the second prompt of a session; the first prompt completes normally (graphs reused = 45). The whole server aborts.It is not deterministic here. ~20 requests in one session — sequential prompts, 4 concurrent prompts, image prompts, and varying prompt lengths (400 → 7300 tokens) — all completed. So it reads as a race on graph rebuild recycling shard tensors the draft still references, consistent with the use-after-reset analysis above, not a function of "the 2nd prompt" specifically.
-sm layeris not a usable workaround on this pair (same weights, MTP on, 131072 ctx):LLAMA_GRAPH_REUSE_DISABLE=1: on542348athis starts and serves normally (measured 56–73 t/s with it), unlike the startup assert reported earlier in the thread — so that no-rebuild alternative no longer fails immediately. I can't confirm it fixes the crash, since I can't reproduce it reliably.FWIW the single-KV-head global layers here are
cache_k_l58/cache_k_l59, matching the earlier analysis.