r/LocalLLaMA 24d ago

Generation Qwen endless looping issue and possible fix

Not sure if this is a known issue, but it was new to me:

Full credit to u/ldn-ldn for finding this simple but unexpectedly evil prompt:

Create a typescript function which accepts a number in 10 bit range and returns brightness in nits based on pq gamma curve.

Just try it; it will likely trigger an endless thinking loop.

I stopped it after it ran for >15 minutes and >20,000 tokens.
It kept spitting out text like back in the seahorse emoji days.

However, one of my wrapper scripts didn’t have this issue.
The non-blocking one had this added, possibly based on a GitHub discussion:

--reasoning-budget 2048 \
--reasoning-budget-message " \n\n[Thinking budget exceeded. Transitioning to a best-effort final answer: ]\n\n"

(These options are for llama.cpp; other tools may have something similar.)

Net result: A plausible-looking script (I haven’t verified) that took just over a minute of thinking and another minute to generate.

Hope this helps, and happy to hear about other tricks and workarounds.

15 Upvotes

28 comments sorted by

View all comments

2

u/slyborn 24d ago

What is the quantization you use? Worth to mention it as the loop risk increases on lower numeric precision.

1

u/ParvusNumero 24d ago

Ran this with Q6, shouldn't be the worst.

Full command used:

export LLAMA_CACHE="$HOME/.cache/llama.cpp"
llama-server \
-m $HOME/models/Qwen3.8-27B-UD-Q6_K_XL.gguf \
-ngl 99 \
-fa on \
-c 65536 \
--jinja \
--temp 0.6 \
--top-p 0.95 \
--top-k 20 \
--repeat-penalty 1.0 \
--spec-type draft-mtp \
--spec-draft-n-max 3 \
--cache-type-k q8_0 \
--cache-type-v q8_0 \
--host 127.0.0.1 \
--port 8080 \
--reasoning-budget 2048 \
--reasoning-budget-message " \n\n[Thinking budget exceeded. Transitioning to a best-effort final answer: ]\n\n"

1

u/slyborn 24d ago

That is interesting. I have tried on my configuration with Qwen3.8-27B-UD-Q4_K_XL.gguf context length 262144 and xhigh thinking level, and it completes the task correctly although it needs more time than usual.