Skip to content

gemma-4-12B-it: Infinite thinking loop, system prompt non-adherence (>10k tokens), and context loss in multi-turn conversations #727

Description

@titansonico10

Bug Report + Improvement Request

Model

google/gemma-4-12B-it (original, non-fine-tuned)

Runtime

llama.cpp / LM Studio (local inference)


Issue 1 — Infinite thinking loop (no exit condition)

The model frequently enters an infinite loop inside the <|channel>thought ... <channel|> reasoning block and never terminates generation. The only way to recover is to manually stop generation.

This has been independently confirmed by multiple users running the model locally via llama.cpp and Ollama:

Partial workaround found by the community: increasing repeat-penalty to 1.08 with repeat-last-n 4096 reduces — but does not eliminate — the issue.


Issue 2 — Complex system prompts (>10,000 tokens) cause unreliable behavior

When a system prompt exceeds ~10,000 tokens, the model exhibits several failure modes:

  • Extremely long time spent "reading" the system prompt before producing any output
  • Contradicts or ignores rules explicitly stated in the system prompt
  • Does not know what to do next after processing the instructions, producing confused or empty responses
  • Mixes up steps, skips required actions, or applies rules from one context to another incorrectly

This makes the model unreliable for complex agentic workflows, roleplay frameworks with detailed character cards, or any use case requiring strict instruction-following over a long system prompt.


Issue 3 — Conversation context loss in multi-turn sessions

In longer conversations, the model progressively loses track of:

  • Instructions given in the system prompt (behaves as if it never read them after a few turns)
  • Content discussed in earlier turns of the conversation
  • The current state or "thread" of the dialogue

This is distinct from simply running out of context window — it appears to be a failure of attention over the full sequence even when the content is still within the model's context length.


Expected Behavior

  • The thinking channel should always terminate and produce a coherent final response
  • Rules and steps defined in the system prompt should be followed consistently regardless of prompt length
  • The model should maintain coherent reference to prior conversation turns throughout the session

Suggested Improvements

  • Add a maximum thinking budget / token limit for the reasoning channel to prevent runaway loops
  • Improve instruction following for system prompts in the 5,000–15,000 token range
  • Investigate attention degradation over long multi-turn contexts and consider fine-tuning on longer conversation datasets

Environment

  • Model: google/gemma-4-12B-it
  • Backend: llama.cpp (also reproducible with Ollama)
  • Hardware: Local GPU inference
  • Quantization: Q4 to Q8 variants (issue present across quantization levels)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions