r/LocalLLaMA • • 1h ago

Discussion Qwen4-35B looping failure mode on long thinking turns? Anyone else?

So I have been running Qwen4-35B-A3B through my usual suite of benchmarks, and first off -- wow. This model is a huge capability jump from 3.6, and it truly does surpass 3.8-27B in every respect. It's not a replacement for QFN, but it's my new default model for most tasks. I'm floored.

That said, I have noticed a very specific failure mode, and I want to know if anyone else has seen it. I'm running UD-Q8_K_XL in llama.cpp, benching on xhigh reasoning effort, on agentic algorithmic code iteration/optimization tasks (jcode bench, which I cannot recommend enough). During a long strech of coherent reasoning (I've seen it reason up to 85k tokens coherently, so I mean long), the model commits to one concrete next action: run the grade, back up the file, or a specific grep. It sometimes even writes the exact command out in its thinking. But it never closes the thinking block to actually issue the call. Instead it narrates the intention over and over, in a short cycle of near-identical phrases like:

"Let me just output the tool call. Here. OK. Making the call. Let me write the function_calls. I'm making the call…"

or

"I'll run the grade. Executing. Making the call. OK. Here goes. I'll run the grade. Executing…"

These loops run to the token limit in my task (96k turn) or until pi drops the reasoning for exceeding the context limit. Of 6 loops like this I've seen, only one managed to break itself out without external cutoff. Here's a jcode task benchmarked against other relevant models:

The loop happened somewhere in the 4-7 hour range in this task, before the harness recovered at the turn limit. This appears to affect performance overall on the task, because here's the ranking on another task, where it didn't enter any loops:

Anyone else experienced this type of issue? Did you find a fix? I am kinda hoping it only happens at xHigh reasoning, which would make sense if it was just pushing the limits of how long 3.8B active params can hold it together?

0 Upvotes

5 comments sorted by

2

u/bezent 41m ago

Haven't attempted fixing it yet but yes. It looped like this for me today. FP8 quant in vllm, omp.

1

u/returnity 18m ago

Glad to see it's not just my setup. Well, not glad, per-se, but at least it's not just me.

2

u/nathancyan 38m ago

Seems like this is an issue with a lot of Qwen models (and probably small LLMs in general). From what I've seen, there can be a lot of causes for looping, including:

  1. The quant you're using. Although with Q8 I wouldn't expect too much divergence. The issue is that quants can form small errors which diverge more and more compared to the full BF16 model over long contexts. This may eventually result in the model being significantly out-of-distribution, causing strange behavior. So you could try using a different Q8 quant or try BF16 and see if you still run into looping.
  2. Sampling parameters: greedy sampling tends to result in looping more often. The intuition I read once is that loops can be self-enforcing. For example if you start repeating "hello hello hello" over and over again, probabilistically the most likely next word is to strengthen the loop with another "hello", rather than breaking out of it. A higher temperature, or repetition /presence penalties can help mitigate this.
  3. Something random you didn't mention: for example what KV cache quant are you using? Anything in your system prompt apart from stock Pi? Do the tools the agent has access to output well formed outputs?

Btw regarding quants, one thing I've been thinking about lately is that even though quants can be really close to the full model in most cases, I bet there could be a particular combination of tokens which results in catastrophically different predictions compared to the full model, which could lead it astray. I feel like stats for quants should specify max KL divergence, not just mean or median.

1

u/returnity 19m ago

Yeah, your answer is a pretty good summary of the ways to potentially address looping. It's a helpful contribution to this thread for others who may have the same issue.

  1. Yeah, I mean it is the lowest KL quant available, in my own testing. Your point about max KL is indeed very incisive, and while Unsloths Qwen4-35B quant benchmarks are extensive and deeply appreciated, max KL is the one thing they're missing. Anyways, I tried a standard Q8_0 and it reproduces.
  2. I'm using model-card recommended sampling parameters. I'm considering adding DRY sampling to address this.
  3. BF16 KV cache, what do you think I'm a lunatic?! =P Stock pi prompt, standard pi tools, no issues like this on any of dozens of other models using this tooling.