gemma icon indicating copy to clipboard operation
gemma copied to clipboard

[BUG] Gemma-4-26B-A4B: Deterministic Repetition Loop at 14th item in list ("Wait, I found it. The 14.")

Open ghost opened this issue 8 months ago • 11 comments

I've been testing Gemma 4 26B with both Ollama and LMStudio. In both tools I gave the simple query "List all of the episodes of the TV series Firefly". In Ollama/terminal this resulted in the model thrashing for a long time and eventually printing the line "Wait, I found it. The 14. I will provide the 14" over and over until I killed the session. The LMStudio session with the same question did a lot of thrashing with increasingly wrong answers and eventually just gave up.

Image

ghost avatar Apr 04 '26 05:04 ghost

I'm facing the same issue. I asked the model to classify a few entities in a list, and it just keeps looping. am using gemma-4-26b-a4b-it via Cloudflare

... reasoning output

*Wait*, I should check "A". Yes.
*Wait*, I should check "B". Yes.
*Wait*, I should check "C". Yes.
*Wait*, I should check "A". Yes.
*Wait*, I should check "B". Yes.
*Wait*, I should check "C". Yes.
...

Willis0826 avatar Apr 06 '26 23:04 Willis0826

same issue - omlx

T-Klug avatar Apr 15 '26 15:04 T-Klug

I've encountered this a couple times tonight while playing around with generating rust code. In one case, I saw:

state: enough_state_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone_clone <repeated dozens of times>

This was in the middle of a tool call to write.

And recently at the start of a project:

(Note: I'req/ollama-health-tui/ is already present in the directory. Note: I'req/ollama-health-tui/ is already present in/ollama-dashboard/                   
is already present/ollama-dashboard/ is already present/                                                                                                           
(Note: I'req/ollama-health-tui/ is already present in/ollama-dashboard/ isuma/ollama-health-tui/ is already present in/ollama-dashboard/ is                        
already present/                                                                                                                                                   
(Note: I'req/ollama-health-tui/ is already present in/ollama-dashboard/ is already present/                                                                        
(Note: I'req/ollama-health-tui/ is already present in/ollama-dashboard/ is/ollama-health-tui/ is already present in/ollama-dashboard/ is                           
already present/                                                                                                                                                   
(Note: I'req/ollram/ollama-health-tui/ is already present in/ollama-dashboard/ is already present/                                                                 
(Note: I'req/ollama-health-tui/ is already present in/ollama-dashboard/ is already present/                                                                        
(Note: I'req/ollama-health-tui/ is already present in/ollama-dashboard/ is already present/                                                                        
(Note: I'req/ollama-dashboard/ is already present in/ollama-dashboard/ is already present/                                                                         
(Note: I'req/ollama-health-tui/ is already-present/ollama-health-tui/ is already present in/ollama-dashboard/ is already present/                                  
(Note: I/ollama-health-basic/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is                             
already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is                            
already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is                            
already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama/ollama-tui/                        
is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is                         
already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is                            
already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is                            
already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-ram/ollama-tui/ is already present in/ollama-                        
tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/                       
 is already present in/ollama-tui/ is/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/                       
ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/                           
ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/ollama-tui/ is already present in/                           
ollama-tui/

This one was during thinking at the outset of a broad prompt:

Help me create a rust TUI project that queries ollama's built in API and creates an "at a glance" health dashboard. I'd want to see basic health checks, stats on usage (esp. VRAM), and if at all possible some idea of in-flight inferences and corresponding KV-cache usage.

Both were using a rather vanilla opencode and ollama hosting gemma-4-26B-a4b-it-q4_K_M with q8_0 for kv cache.

notlesh avatar Apr 17 '26 02:04 notlesh

I asked it to review a PR and it keeps looping on pulling it from the repo (vllm-mlx + OpenCode/KiloCode)

eranbet avatar Jun 14 '26 10:06 eranbet

This issue was mentioned in a Medium article and partially fixed by a paper titled Can Editing 1 Neuron Fix Repetition Loops in LLMs?.

dwgb93 avatar Jun 15 '26 17:06 dwgb93

I have tried DRY settings from that article but generally nearly all settings that penalize repetition seem to destroy tool calling reliability for me. They also make gemma 4 much more prone to making typos.

The most common cause of looping for me has been trying to make the model read multiple small files/scripts, I wanted to use it for generating synthetic data (based on the scripts) for finetuning but it didn't work well.

BoneHorror avatar Jun 16 '26 19:06 BoneHorror

I'm experiencing something very similar with oMLX and Pi. Sometimes it surprises and delights me, but a lot of the times it gets stuck in this loop. And I'm being forced to work around it using things like subagents and highly prescriptive prompts and those are just overloading my context window with space that I don't really have to spare, sadly.

hkay-dev avatar Jun 17 '26 05:06 hkay-dev

Did anyone end up finding any solution for this at all? DRY on llama.cpp completely annihilates Gemma performance and actually makes the model loop more as it tries to self-correct typos caused by DRY penalties.

If someone more competent than me wants to reproduce a form of this issue, try prompting Gemma4 26B with something along the lines of "List all the episodes of the TV series Firefly" similarly to how the 1st post describes it. The model should not have access to an internet search tool. The issue is not actually 100% reproducible, but it's trivial to trigger bad-feeling loops over a few tries. This is with no DRY, and otherwise only recommended settings in llama.cpp with BF16. I believe this is about the only major generation bug I have stumbled into, and it really sucks because it seems to happen with 'listing things' in general which the model really likes to do.

I would really love it if we can get any sort of official response/fix. If I'm stupid and there is a better way to report the issue than here - please let me know.

BoneHorror avatar Jul 09 '26 17:07 BoneHorror

Still having problems with Gemma 26B, are there any known workarounds?

MaverickBlue avatar Oct 04 '26 16:10 MaverickBlue

Plus 1 here. Does 12B have this issue as well?

jsiegers avatar Oct 19 '26 11:10 jsiegers

16. Plus 1 here. Does 12B have this issue as well?

12B forgets to make it's toolcalls 25% of the time, merely announcing the tool it intends to run....

MaverickBlue avatar Oct 22 '26 04:10 MaverickBlue