Eval bug: gemma4 infinite output
Name and Version
llama.cpp-b8645# ./build/bin/llama-cli --version ggml_cuda_init: found 1 CUDA devices (Total VRAM: 81155 MiB): Device 0: NVIDIA A800-SXM4-80GB, compute capability 8.0, VMM: yes, VRAM: 81155 MiB version: 8645 (57ace0d61) built with GNU 11.4.0 for Linux x86_64
Operating systems
Linux
GGML backends
CUDA
Hardware
NVIDIA A800/A100
Models
unsloth/gemma-4-31B-it-UD-Q4_K_XL.gguf
Problem description & steps to reproduce
serve and inference
*I also tried same param with llama-cli, it work's but llama-server break down.*
./build/bin/llama-server \
--model /data/base/models/gguf/gemma-4-31B-it-UD-Q4_K_XL.gguf \
--mmproj /data/base/models/gguf/mmproj-BF16.gguf \
--temp 1.0 \
--top-p 0.95 \
--top-k 64
curl http://localhost:8080/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer no-key" \
-N \
-d '{
"model": "Gemma4-31B",
"prompt": "测试",
"stream": true
}'
output
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
First Bad Commit
No response
Relevant log output
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
data: {"choices":[{"text":"額","index":0,"logprobs":null,"finish_reason":null}],"created":1775210403,"model":"gemma-4-31B-it-UD-Q4_K_XL.gguf","system_fingerprint":"b8645-57ace0d61","object":"text_completion","id":"chatcmpl-mjzsIiGL6XOEDUgge7xz7zQ3QdFhNthe"}
Can confirm that I have the same problem with a few different gemma 4 GGUFs, both 26B A4B and 31B, from both unsloth and ggml-org (just using CPU on Alpine Linux). As far as I have tested, they give sensible output with llama-cli, but just nonsensical repetition with llama-completion or llama-server.
Please retest on newer build, at least 8647.
Using 8650 causes immediate segfault with the gemma 4 models on both llama-server and llama-cli (cli worked with 8641).
Where's the segfault? :O
It seems to be related to the length of the prompt and context, so perhaps a separate issue. But the original problem with llama-server giving repetitive output for a prompt working with llama-cli remains.
Using 8650 causes immediate segfault with the gemma 4 models on both llama-server and llama-cli (cli worked with 8641).
I am also experiencing segfaults with llama.cpp version b8645 on gemma 4 26b a4b model.
started llama like this (turned ngl to zero because i suspected vulkan bug from last crash) to start to understand if this is related to vulkan
./llama-server -hf bartowski/google_gemma-4-26B-A4B-it-GGUF:IQ4_NL --port 8080 -ngl 0 -c 16000 --temp 0.5 --jinja --alias gemma
short prompt : yes it works
big prompt with 8000+ tokens:
srv update_slots: all slots are idle
srv params_from_: Chat format: peg-gemma4
slot get_availabl: id 2 | task -1 | selected slot by LRU, t_last = -1
slot launch_slot_: id 2 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> top-p -> min-p -> ?xtc -> temp-ext -> dist
slot launch_slot_: id 2 | task 136 | processing task, is_child = 0
slot update_slots: id 2 | task 136 | new prompt, n_ctx_slot = 16128, n_keep = 0, task.n_tokens = 8591
slot update_slots: id 2 | task 136 | n_tokens = 0, memory_seq_rm [0, end)
slot update_slots: id 2 | task 136 | prompt processing progress, n_tokens = 2048, batch.n_tokens = 2048, progress = 0.238389
srv log_server_r: done request: POST /v1/chat/completions 127.0.0.1 200
double free or corruption (out)
Aborted (core dumped)
I am running the latest commit (built myself) with 7900XTX on Vulkan, not seeing any segfault but I do see the infinite output. It is intermittent, sometimes I can only do a few tool calls and other times I can do many before it happens.
@NickM-27 - do you also get infinite output from cpu only ? by turning ngl to zero
I don't have time to test this moment, but given that OP is using CUDA backend it appears this is backend agnostic
I always see these reasoning budget logs whenever the infinite output occurs, despite the fact that I have reasoning set to off
[50689] srv get_availabl: prompt cache update took 877.71 ms
[50689] slot launch_slot_: id 0 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> top-p -> min-p -> ?xtc -> ?temp-ext -> dist
[50689] slot launch_slot_: id 0 | task 241 | processing task, is_child = 0
[50689] slot update_slots: id 0 | task 241 | new prompt, n_ctx_slot = 20224, n_keep = 0, task.n_tokens = 8075
[50689] slot update_slots: id 0 | task 241 | n_past = 1195, slot.prompt.tokens.size() = 7853, seq_id = 0, pos_min = 5361, n_swa = 1024
[50689] slot update_slots: id 0 | task 241 | Checking checkpoint with [5361, 7836] against 171...
[50689] slot update_slots: id 0 | task 241 | Checking checkpoint with [5361, 7720] against 171...
[50689] slot update_slots: id 0 | task 241 | Checking checkpoint with [5361, 7413] against 171...
[50689] slot update_slots: id 0 | task 241 | Checking checkpoint with [2389, 5460] against 171...
[50689] slot update_slots: id 0 | task 241 | Checking checkpoint with [1024, 4095] against 171...
[50689] slot update_slots: id 0 | task 241 | Checking checkpoint with [0, 2047] against 171...
[50689] slot update_slots: id 0 | task 241 | restored context checkpoint (pos_min = 0, pos_max = 2047, n_tokens = 2048, n_past = 1195, size = 212.524 MiB)
[50689] slot update_slots: id 0 | task 241 | erased invalidated context checkpoint (pos_min = 0, pos_max = 2047, n_tokens = 2048, n_swa = 1024, pos_next = 1195, size = 212.524 MiB)
[50689] slot update_slots: id 0 | task 241 | erased invalidated context checkpoint (pos_min = 1024, pos_max = 4095, n_tokens = 4096, n_swa = 1024, pos_next = 1195, size = 318.786 MiB)
[50689] slot update_slots: id 0 | task 241 | erased invalidated context checkpoint (pos_min = 2389, pos_max = 5460, n_tokens = 5461, n_swa = 1024, pos_next = 1195, size = 318.786 MiB)
[50689] slot update_slots: id 0 | task 241 | erased invalidated context checkpoint (pos_min = 5361, pos_max = 7413, n_tokens = 7414, n_swa = 1024, pos_next = 1195, size = 213.043 MiB)
[50689] slot update_slots: id 0 | task 241 | erased invalidated context checkpoint (pos_min = 5361, pos_max = 7720, n_tokens = 7721, n_swa = 1024, pos_next = 1195, size = 244.901 MiB)
[50689] slot update_slots: id 0 | task 241 | erased invalidated context checkpoint (pos_min = 5361, pos_max = 7836, n_tokens = 7837, n_swa = 1024, pos_next = 1195, size = 256.938 MiB)
[50689] slot update_slots: id 0 | task 241 | n_tokens = 1195, memory_seq_rm [1195, end)
[50689] slot update_slots: id 0 | task 241 | prompt processing progress, n_tokens = 3243, batch.n_tokens = 2048, progress = 0.401610
[50689] slot update_slots: id 0 | task 241 | n_tokens = 3243, memory_seq_rm [3243, end)
[50689] slot update_slots: id 0 | task 241 | 2048 tokens since last checkpoint at 0, creating new checkpoint during processing at position 5291
[50689] slot update_slots: id 0 | task 241 | prompt processing progress, n_tokens = 5291, batch.n_tokens = 2048, progress = 0.655232
[50689] slot update_slots: id 0 | task 241 | created context checkpoint 1 of 32 (pos_min = 171, pos_max = 3242, n_tokens = 3243, size = 318.786 MiB)
[50689] slot update_slots: id 0 | task 241 | n_tokens = 5291, memory_seq_rm [5291, end)
[50689] slot update_slots: id 0 | task 241 | 2048 tokens since last checkpoint at 3243, creating new checkpoint during processing at position 6027
[50689] slot update_slots: id 0 | task 241 | prompt processing progress, n_tokens = 6027, batch.n_tokens = 736, progress = 0.746378
[50689] slot update_slots: id 0 | task 241 | created context checkpoint 2 of 32 (pos_min = 2219, pos_max = 5290, n_tokens = 5291, size = 318.786 MiB)
[50689] slot update_slots: id 0 | task 241 | n_tokens = 6027, memory_seq_rm [6027, end)
[50689] slot update_slots: id 0 | task 241 | prompt processing progress, n_tokens = 8071, batch.n_tokens = 2044, progress = 0.999505
[50689] slot update_slots: id 0 | task 241 | created context checkpoint 3 of 32 (pos_min = 2955, pos_max = 6026, n_tokens = 6027, size = 318.786 MiB)
[50689] slot update_slots: id 0 | task 241 | n_tokens = 8071, memory_seq_rm [8071, end)
[50689] reasoning-budget: activated, budget=2147483647 tokens
[50689] reasoning-budget: deactivated (natural end)
[50689] slot init_sampler: id 0 | task 241 | init sampler, took 0.59 ms, tokens: text = 8075, total = 8075
[50689] slot update_slots: id 0 | task 241 | prompt processing done, n_tokens = 8075, batch.n_tokens = 4
[50689] slot update_slots: id 0 | task 241 | created context checkpoint 4 of 32 (pos_min = 4999, pos_max = 8070, n_tokens = 8071, size = 318.786 MiB)
[50689] srv log_server_r: done request: POST /v1/chat/completions 127.0.0.1 200
srv log_server_r: done request: POST /v1/chat/completions 192.168.50.105 200
@aldehir think we need to remove those for no real reasoning budget as they're misleading.
I did manage to poke around with different llama.cpp configurations and found that the instability/crashing with vulkan + bartowski quants is related for context quantization and flash attention. When i have flash attention on and context quantization set - it crashes, when fa is off and context is not quantized - it does not crash.
Trying 8662 on a cloud machine with A100 and ggml-org/gemma-4-31B-it-Q8_0
$ build/bin/llama-cli --version
ggml_cuda_init: found 1 CUDA devices (Total VRAM: 81151 MiB):
Device 0: NVIDIA A100-SXM4-80GB, compute capability 8.0, VMM: yes, VRAM: 81151 MiB
version: 8662 (650bf14eb)
built with GNU 13.3.0 for Linux x86_64
The segfaults do not occur, even with long prompts, but the repetitive output with llama-server persists. However, it only happens with the completion endpoint, not with the browser UI. I use the following shell script to upload a text prompt (read from stdin) to llama-server (and it has always worked fine with other models).
#!/bin/sh
LLMDATA=$(jq -Rsc "{stream: true, temperature: $1, logit_bias: $2, n_probs: 8, prompt: .}")
curl --request POST --header "Content-Type: application/json" --data "${LLMDATA}" --url http://localhost:8080/completion
I believe https://github.com/ggml-org/llama.cpp/pull/21418 should fix it, about to test
The repetition problem still occurs with the new parser included, unfortunately.
$ build/bin/llama-cli --version
ggml_cuda_init: found 1 CUDA devices (Total VRAM: 81151 MiB):
Device 0: NVIDIA A100-SXM4-80GB, compute capability 8.0, VMM: yes, VRAM: 81151 MiB
version: 8667 (c08d28d08)
built with GNU 13.3.0 for Linux x86_64
So, it will not work when you use simple prompts for completion, regardless of the tool used.
$ build/bin/llama-completion -rea off -no-cnv -m /llm/models/gemma-4-31B-it-Q8_0.gguf -p "Write a TV play about a day in a factory in Sweden 2002."
...
generate: n_ctx = 262144, n_batch = 2048, n_predict = -1, n_keep = 0
Write a TV play about a day in a factory in Sweden 2002.2002.2002.2002.2002.2002.2002.2002.2002.2002
.2002.2002.2002.2002.2002.2002.2002.2002.2002.2002.2002.
@klpn try using the apply-template endpoint to generate a prompt. Some people have observed that the models PPL goes through the roof when not using its chat template. Might be related.
The problem is that neither the /completions endpoint, nor llama-completion works correctly atm because during conversion we set "add BOS == false". So the BOS token is never added if you don't add it manually (or through the chat template). We will fix this by updating the conversion script.
In the meantime, avoid using non-templated endpoints unless you know how to add the BOS token.
Thanks, I changed my script so that it uses the v1/chat/completions endpoint, which works!
#!/bin/sh
LLMDATA=$(jq -Rsc "{stream: true, temperature: $1, logit_bias: $2, n_probs: 8, \
messages:[{role: \"user\", content: .}]}")
curl --request POST --header "Content-Type: application/json" --data "${LLMDATA}" \
--url http://localhost:8080/v1/chat/completions
Now, llama-completion and the /completions endpoint sometimes give sensible output, sometimes garbage, interspersed with control tokens. On an Alpine laptop using CPU.
$ build-alpine/bin/llama-cli --version
version: 8679 (94ca829b6)
built with GNU 15.2.0 for Linux x86_64
$ build-alpine/bin/llama-completion -no-cnv -rea off -m /models/gemma-4-26B-A4B-it-Q8_0.gguf \
-p "Write a TV play taking place in Norway 1580."
...
generate: n_ctx = 262144, n_batch = 2048, n_predict = -1, n_keep = 1
Write a TV play taking place in Norway 1580. ownano-er-er-er-er-er-er-er-er-erano-er-er-er-er-er-er-er-er-er-er-oano-er-er-er-er-er-er-er-er-er-er-
They may start emitting coherent output after a while.
$ build-alpine/bin/llama-completion -no-cnv -rea off -m /models/gemma-4-26B-A4B-it-Q8_0.gguf \
-p "Write a TV play taking place in Norway 1581."
...
Write a TV play taking place in Norway 1581. own enough of데미안어구-<|channel>-상태en-상외-en-상외-en-상외-en-상외-en-상외-en-상외-en-상외-en-상외-en-상외-en-en-상외-en-상외-en-상외-en-상상아래-en-상황-상황-상age-en-en-en-en-en-el-en-en-en-en-en-en-en-en-en-en-en-en-en-en-enen-en-en-en-en-en률-en-en-en
률-en-en-en-en-1581.
| Character | Role |로컬-상황-상황-상en-en-en-en-en-en-en-en-en-en-en-en-en-en-en-en-en-en-en-enen-en-en-en-en-enen-en-en-enen-en-en-enman-en-en-en0.2-en-en-en-en-enen-en-en*
| Character | Role |
| :---thought
<channel|>**TITLE: THE FROZEN THRESHOLD**
**SETTING:**
A remote farmstead in the Gudbrandsdal valley, Norway.
**TIME:**
Winter, 1581. The height of the Little Ice Age.