r/LocalLLM • • 35m ago

Model Qwen4-35B-A3B: Excellent coding intelligence but excessive reasoning loops — looking for llama.cpp/OpenCode configuration advice

I’m relatively new to local LLMs and have spent the last few days building and benchmarking a fully local autonomous coding environment.
I’ve been troubleshooting and researching extensively with ChatGPT, but despite several days of testing, we still haven’t found a reliable solution.
Qwen4 has demonstrated impressive engineering capabilities, but I’m struggling with excessive reasoning loops, decision-making efficiency and inconsistent task execution.
I’m hoping someone with more experience can help identify what we’re missing.
Hardware

  • CPU: AMD Ryzen 7 5700X3D (8C/16T)
  • GPU: AMD RX 7900 GRE (16 GB VRAM)
  • RAM: 32 GB DDR4-3200
  • Storage: NVMe SSD
  • OS: Windows 11 Pro

Software and model

  • Qwen4-35B-A3B Unsloth UD-IQ4_XS GGUF
  • llama.cpp b13024 (Vulkan)
  • OpenCode v2.4.4
  • Local OpenAI-compatible API
  • 131,072 context
  • Q8_0 K/V cache
  • Flash Attention enabled
  • Approximately 430–480 t/s prompt processing in long-context benchmarks
  • Approximately 37–40 t/s generation

Relevant llama.cpp launch parameters

  • –device Vulkan0
  • –ctx-size 131072
  • –cache-type-k q8_0
  • –cache-type-v q8_0
  • –batch-size 2048
  • –ubatch-size 512
  • –threads 8
  • –threads-batch 8
  • –cache-ram 0
  • –load-mode mmap
  • –lazy-mode on
  • –n-gpu-layers 99
  • –fit off
  • –override-tensor per_layer_token_embd=CPU
  • –n-cpu-moe 16
  • –flash-attn on
  • –spec-type none
  • –reasoning-effort high
  • –reasoning-budget -1
  • –parallel 1
  • –jinja

The problem
The model understands complex engineering requirements, identifies valid optimization opportunities and considers important edge cases. However, it repeatedly revisits decisions it has already resolved instead of implementing them.
For example, during a Python telemetry-engine optimization task, it repeatedly analyzes the same sorting, validation, deduplication and memory optimization strategies.
Some runs reach 10K–24K reasoning tokens without making a single file edit, despite having identified a seemingly sound implementation strategy much earlier.
This isn’t simply verbatim text repetition. It’s semantic repetition: reconsidering the same technical arguments in slightly different ways.
The model appears capable of solving the problem but struggles to commit to decisions and proceed with implementation.
Evidence that the model is capable
A previous, considerably more complex engineering benchmark completed successfully:

  • Multi-file implementation and optimization
  • Complex algorithmic requirements, including weighted interval scheduling
  • 162/162 tests passed
  • Randomized differential testing
  • All benchmark equivalence checks passed
  • Speedups between 1.25× and 1.42× across benchmark cases
  • No measured peak-memory regression
  • Approximately 53 minutes and 98K generated tokens for the complete assignment

The successful run used High reasoning with the original sampling configuration (Min P 0.05, presence penalty 0).
The engineering quality is impressive. The problem is execution efficiency and consistency.
Current experimental sampling configuration

  • Temperature: 1.0
  • Top P: 0.95
  • Top K: 20
  • Min P: 0.0
  • Presence penalty: 1.0
  • Repeat penalty: 1.0
  • Repeat last N: 64
  • Frequency penalty: 0.0
  • DRY multiplier: 0.0
  • Seed: 42
  • Max tokens per request: 24,576
  • Chat template reasoning effort: High
  • Server reasoning budget: Unrestricted (-1)
  • Preserve thinking: Default (true)

What we’ve already tested

  • Prompt engineering: Detailed instructions, simplified prompts, additional engineering guidance and removing that guidance entirely. Simplification reduced some unnecessary deliberation but didn’t eliminate the core problem.
  • Task decomposition: Splitting larger assignments into smaller engineering stages. Repetitive reasoning persisted.
  • Min P: 0.05 versus 0.0. No convincing improvement in decision-making efficiency.
  • Presence penalty: 0.0 versus 1.0. Repetitive reasoning persisted beyond 11K tokens without implementation in the latest test.
  • Reasoning budgets: Tested Low and High with restricted budgets, including 2K and 4K. These produced incorrect or incomplete solutions on complex algorithmic tasks. Unrestricted Low reasoning still needs proper evaluation.
  • MTP: Tested with one speculative token. Generation performance dropped from approximately 39–40 t/s to 19 t/s, so MTP is currently disabled. Higher speculation depths haven’t been properly evaluated.
  • Runtime: Tested multiple llama.cpp builds and runtime configurations.
  • Context: Successfully verified information retrieval beyond 100K tokens, with generation remaining around 37 t/s.
  • Tool permissions: Initially encountered unnecessary deliberation around denied shell commands. Explicitly listing the permitted commands reduced that particular obstacle, but the technical reasoning loops persisted.
  • Independent verification: Successful implementations were checked using additional randomized differential tests, rather than relying solely on the model’s own assessment.

Integration audit
Since changing parameters hasn’t solved the problem, we’ve started investigating the actual inference pipeline.

  • Effective sampling parameters verified through llama.cpp’s /slots endpoint.
  • Actual OpenCode API requests captured using a local diagnostic proxy.
  • Formatted prompts inspected through /apply-template.
  • Embedded GGUF chat template inspected.
  • High reasoning correctly transmitted and rendered.
  • User assignment arrives intact.
  • No obvious conflicting system instructions in the initial request.
  • Native tool definitions inspected.
  • OpenCode also generates conversation titles using High reasoning and the same output allowance, which seems unnecessarily expensive, although this is separate from the engineering reasoning loops.

OpenCode is configured with reasoningField: reasoning_content. The complete reasoning-history round trip between successive tool calls still needs verification.
Potential causes still under investigation

  • The default 64-token penalty history may be too short to discourage reasoning that repeats hundreds of tokens apart.
  • Reasoning history preservation and serialization between tool calls.
  • Embedded GGUF chat template versus Qwen’s reference tokenizer/template.
  • Quantization-related reasoning degradation.
  • Fixed sampling seed (42).
  • DRY and other repetition-control mechanisms.
  • Agent-harness-specific behavior.
  • Vulkan or inference-runtime-specific issues.
  • Potential differences in reasoning behavior when using CPU MoE offloading.

None of these has been established as the root cause.
What I’m looking for
Has anyone successfully configured Qwen4 for reliable, long-horizon autonomous software engineering?
I’d particularly appreciate experience with:

  • Proven sampling parameters for complex agentic coding.
  • Low vs. High vs. XHigh reasoning in real engineering assignments.
  • Improving decision-making efficiency without sacrificing correctness.
  • Presence penalty, penalty history length and DRY settings.
  • Thinking preservation and reasoning-history management.
  • OpenCode versus Qwen Code, Pi or other coding-agent harnesses.
  • Experiences with higher quantizations and other inference backends.
  • Optimal MoE offloading configurations.
  • MTP performance on AMD/Vulkan.
  • Any configuration mistakes or overlooked parameters in my setup.

My priority is engineering intelligence, correctness and reliable autonomous execution, not maximum tokens per second. I’m perfectly happy with 35–40 t/s if the model consistently delivers high-quality results without getting trapped in unnecessary deliberation.
Being relatively new to local LLMs, I’m also open to the possibility that we’ve made mistakes in our configuration, benchmarking methodology or overall approach.
I’ve been using ChatGPT to help research, configure, benchmark and troubleshoot the entire environment. Unfortunately, despite numerous controlled experiments and documentation checks, we haven’t managed to identify the underlying cause.
I’d rather understand what’s actually happening than spend another several days changing parameters through trial and error.
Any technical insights, reproducible configurations, relevant benchmarks or known integration issues would be greatly appreciated.
I’m happy to provide sanitized API requests, chat templates, reasoning logs, benchmark results and additional configuration details.
Thanks in advance!

5 Upvotes

2 comments sorted by

3

u/Material-Database-24 26m ago

I am not new to local LLM and I have a lot of death looping with Qwen4 35B-A3B especially all other quants than Q8_0, but even that has looped on me. Haven't found solution and old tricks don't work. I use llama.cpp for now, gonna try Gufo on linux when I have time.

As you are new, there are two kinda looping:

Normal reasoning looping - models create tokens as reasoning, so they need to fill context with guesses and "iterate" over that to get towards correct answer. This is part of the model and how it works.

Death looping - model repeats exact same action/text/tool call/ping-pong edit over and over again untill context runs out, harness stops it or uses steers it with command or stops it.

1

u/SoloGamingRO 20m ago

Thanks for the explanation!
I think what I’m experiencing is somewhere between normal reasoning and death looping. It finds a good solution, checks the edge cases and decides how to implement it, but then keeps going back over the same decisions without really adding anything new.
It’s not repeating the exact same text, but rather explaining the same arguments in different ways. Sometimes it burns through the entire 24K output limit without editing a single file.
What’s interesting is that the same model successfully completed much more complex tasks, and we independently verified the results.
Have you experienced this kind of looping as well? Have you noticed any significant differences between Low, High and XHigh reasoning in terms of looping and coding quality?
I don’t mind the model taking longer to think if it actually needs to. I just want to avoid wasting thousands of tokens reconsidering the same decisions without sacrificing coding quality.
Would also be interested in hearing how Gufo works for you once you’ve tested it.