mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #728] Infinite loop issue #333
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#333
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @davidliudev on GitHub (Oct 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/728
Having switch-1.50iq2_xs, 8 bit KV cache, 128k context size, engine version v0.1.38 running out of the box after install on 4090 and 64 GB RAM, Windows 11.
Tried OpenCode and Qwen Coder but both will enter endless loop after a while.
Performance is good at 103 tok/s except when this issue was hit.
Is there anything I can tweak to prevent this?
@tarunpaul commented on GitHub (Oct 4, 2026):
Most likely this is related to model settings and not the engine it self.
When a reasoning model gets stuck in a loop, it means the token probabilities have collapsed.
change the temperature and top_p values for your model.
Lower temperatures in LLMs actually make them more prone to looping.
@davidliudev commented on GitHub (Oct 4, 2026):
@tarunpaul That is a good point and I also suspected so. But I was using the default setting right after running setup.
My understanding is that Strata is particularly optimized for Qwen Flash Next and everything should already be in place nicely? No?
Also do you have a recommended setting? From the very limited docs I saw these default:
"sampling": {"temperature": 1.0, "top_p": 0.95, "top_k": 20}
Correct me if I am wrong.
@tarunpaul commented on GitHub (Oct 4, 2026):
@davidliudev Since you mentioned that you’re using it with OpenCode and Qwen Coder, it might be worth checking whether either of them is overriding the model’s sampling settings. That could potentially explain the looping behavior.
@davidliudev commented on GitHub (Oct 4, 2026):
@tarunpaul I just double checked and the default setting is actually indeed the official qwen flash next recommended settings.
Found a reddit post and someone suggested adding presence_penalty of 1.5. That is originally supposed to be only for the non-thinking mode, but considering the quantization loss I enabled it with thinking mode anyway.
I then updated
strata-swift-iq2_xs.jsonand add that to it.So far it works for a while without the looping issue anymore. If it comes back I will update this thread.
@tarunpaul commented on GitHub (Oct 4, 2026):
@davidliudev Glad to hear that the presence penalty seems to be helping. I'll be interested to hear if you experience the looping issue again.
It might also be worth taking a look at the issue below, as it describes a somewhat similar looping behavior with Qwen Flash Next and could provide some additional clues:
https://github.com/Niko1221/Strata/issues/75
@RobinMeyer commented on GitHub (Oct 4, 2026):
I had the same issue with swift1.5-iq2_xs and tried a few things. But the issue was completely solved, when switching to standard (non-swift) iq3_xxs. So I think, it's more a general behaviour of swift. For coding it worked good for me, but not much else. With standard iq3_xxs, I wrote even a 300 page story without any repetition.
@davidliudev commented on GitHub (Oct 4, 2026):
Just report back that it still happen, but much less frequently so at least it is usable for now. I would just treat that as a temporary workaround and keep this issue open.
@davidliudev commented on GitHub (Oct 4, 2026):
@RobinMeyer Do you mind sharing what is your setup? I am wondering if I should also switch to it. Not sure if my setup can handle iq3 though.
@RobinMeyer commented on GitHub (Oct 4, 2026):
@davidliudev :
Because of Strata, I updated extra to 64GB RAM and I have also a RTX5070ti and a 7950x3d.
At first, I used Swift1.5-iq2_xs with 32GB RAM, which worked well with paging with 40-80t/s.
But according the docu, 12GB VRAM and 64GB RAM is sufficient. Perhaps it works with paging with 48GB RAM. RAM is filled with 53GB.
@christopherrobertbrooks-tech commented on GitHub (Oct 4, 2026):
Another data point, from the Coder (not Swift), with what looks like a specific trigger and a tested way to bound it.
Setup: Coder IQ1_M, engine 0.1.39, Tesla V100 32 GB (low-RAM mode), default sampling from setup, reached through
/v1/messagesby a coding agent (Claude Agent SDK,output_config.effortmedium).What happened: in 1 of 20 agent jobs, one thinking block ran to 140,267 characters and stopped only at the client's
32K output cap (about 5 minutes on this card). It is a loop of a single sentence, repeated 1,110 times:
The 256-repeated-token guard (#606) does not catch this, since the repeat is a whole sentence.
Likely trigger: the block opens with the model puzzling over numbers "in the desktop screenshot" that contradict the
data it had just read from the app's web page. It never received that screenshot: images inside a
tool_resultwere beingdropped (that's #819), so it reasoned about a picture it had imagined, met a contradiction it could not resolve, and
circled. That may not be the cause of every loop here, but "the model reasons about input it cannot see" seems worth
knowing. Since applying #819 we have run two agent jobs without a recurrence -- far too few to say more.
Bounding it: a
reasoning_budget_tokenscap. On a prompt built to make it think at length (effort high,max_tokens6000): no cap -> ~3.4K tokens of thinking until
finish_reason: lengthand no answer;reasoning_budget_tokens: 400->the server's wrap-up line ("I have thought about this long enough; time to give my answer.") and a full answer, 28 s
instead of 75 s. In our agent runs the longest normal thought was ~4K tokens, so we now run with
"reasoning_budget_tokens": 8192instrata-<model>.json. In the two agent jobs since (16K and 8K caps) it never fired,and it would cut a loop like the one above to roughly 8K tokens. It bounds the damage; it does not stop the loop from starting.
Drafted with an AI assistant (Claude) from our logs and tests, and checked by me.
@MicEs1 commented on GitHub (Oct 5, 2026):
Another data point from the original Qwen3.8-Flash-Next model. I was able to trigger this with a very simple standalone coding prompt, without an agent, tools, images, MCP, or external context.
Setup:
Strata 0.1.39
Qwen3.8-Flash-Next IQ3_XXS
RTX 5080 16 GB
Ryzen 9 5900X
64 GB RAM
Windows
64K context, INT8 KV, vision disabled
temperature 0.60, top_p 0.95, top_k 20
reasoning effort: High
The test prompt was a small PowerShell task: write a function that performs a TCP reachability check with a maximum 5 second timeout and returns only a boolean result. Nothing unusual in the context.
I repeated the same prompt in fresh chats and got the following results:
presence_penalty=0, no reasoning budget)presence_penalty=1.0, no reasoning budgetpresence_penalty=1.5, no reasoning budgetpresence_penalty=1.0+reasoning_budget_tokens=8192The final answers from all completed runs were technically usable; in particular, adding the 8192-token reasoning budget did not produce an obvious quality regression in this test.
I also fully restarted Strata and retried the same prompt with Thinking disabled. It still went beyond 17K generated tokens without reaching the final answer before I stopped it, so in my case this does not appear to be limited to
reasoning_effort=high.A second unrelated Home Assistant/state-machine design prompt completed successfully with the current workaround (
presence_penalty=1.0,reasoning_budget_tokens=8192): 12,397 output tokens in 165.4 s, and the result was coherent and useful.My current workaround is therefore:
This makes the model usable for me, but I see both settings as mitigation rather than a real fix.
presence_penaltychanges sampling behavior, while the reasoning budget only bounds the damage once a loop has already started.The recent report about a loop triggered by reasoning over a missing image is very interesting, but my reproducible case contains no image or tool result at all, so there appear to be additional triggers.
It might be useful to detect repetition over longer token sequences / repeated n-grams or sentences inside the thinking block, rather than only identical-token repetition, and then use the same wrap-up path as
reasoning_budget_tokens.I can provide the exact prompt and logs if that would help reproduce it.
@talisp commented on GitHub (Oct 5, 2026):
Two data points that may explain why loops come back even with the "official" settings in
strata-<model>.json.1. The web chat sends its own temperature, 0.6 by default. In
serve/web/app.js,DEFAULTS = {thinking: "high", temperature: 0.6, top_p: 0.95, top_k: 20, ...}, and every chat request sendstemperature,top_pandtop_kexplicitly. Request values win over the config'ssampling, so the browser chat runs at 0.6, not the 1.0 that setup writes (1.0 / 0.95 / 20 / presence 0 is the published Qwen3.8 thinking default). With "Use for other apps too" on, the chat's settings are also applied to API clients for every field they don't send. So an agent can end up at 0.6 as well. @MicEs1's loop above was at temperature 0.60.2. Agents often send their own sampling, sometimes per task. In our setup (Hermes Agent, Qwen3.8-Flash-Next IQ3_S, later UD-IQ4_XS), the loops came from:
After putting the official values in the config and raising that side task to 1.0, we saw 0 runaway loops in the following ~19.5 h of agent work (#980).
"reasoning_budget_tokens"(we use 16000) also bounds the worst case.My suggestion (opinion): check what each request really carries.
"api_monitor": trueinstrata-<model>.json, thenhttp://127.0.0.1:<port>/api-monitor, shows every request's body. If you use the web chat, set its temperature to 1.0 under the sampling settings. If you set an API key, add it there too (About > Settings).@christopherrobertbrooks-tech commented on GitHub (Oct 5, 2026):
Following up on @talisp's point about requests that carry no sampling: we checked ours, and then compared greedy against
the Qwen3.8 thinking defaults on real agent work.
What our client sends: a coding agent built on the Claude Agent SDK, talking to
/v1/messages. Logging its requestsshowed
"temperature": null(notop_p/top_keither), only"thinking": {"type": "adaptive"}and"output_config": {"effort": "medium"}. Ourstrata-coder-iq1_m.jsonhad nosamplingblock, so every agent requestran greedy. Our one loop earlier in this thread (the sentence repeated 1,110 times) happened under those settings.
The comparison: Coder IQ1_M, engine 0.1.39, Tesla V100 32 GB,
reasoning_budget_tokens: 8192in both. The secondconfig only adds
"sampling": {"temperature": 1.0, "top_p": 0.95, "top_k": 20, "presence_penalty": 0.0}. Same fiveagent jobs on each: four real coding tasks in an existing Python project, graded by hidden acceptance tests the agent
never sees, plus one six-phase web app built from scratch.
thought noticeably more (prompts up to 97K vs 60K) and took longer. That is one run, so treat the time as a hint.
(The 40 min greedy run lost about 12 min to an unrelated problem in our own tooling.)
choice for our setup, not a general recommendation: 15 jobs are far too few to measure a roughly 1-in-20 event.
The part that seems worth knowing for others: an agent that sends no temperature gets greedy unless the config has a
samplingblock, and nothing in the client shows it."api_monitor": trueor a logging proxy makes it visible.Drafted with an AI assistant (Claude) from our runs and logs, and checked by me.
@Niko1221 commented on GitHub (Oct 6, 2026):
Fixed in 0.1.40: an opt-in repeat stop for reasoning that repeats whole passages: "reasoning_loop_recovery": "stop" ends the reply there, "recover" goes on with the low-effort instruction (#869). Off by default. See DETAILS.
@davidliudev commented on GitHub (Oct 6, 2026):
Thanks @Niko1221 for the fast action.
I will try to test this out tonight.
@davidliudev commented on GitHub (Oct 6, 2026):
Oh one more thing @Niko1221 , do you think that is the root cause or just a workaround? Or should I change model as suggested by others?
@BlueKingMuch commented on GitHub (Oct 6, 2026):
The fact that a request with no sampling fields decodes greedy is also confusing other users. In this r/LocalLLaMA thread, someone compared the engine to llama.cpp with the same GGUF and observed looping on Strata, but "normal" behaviour on llama.cpp. After othe users pointed out that the reason may be his sampling settings, the poster retried it with different sampling settings and the loops stopped.
My recommendation would be to copy what llama.cpp does: every GGUF that setup offers carries Qwen's recommended sampling for thinking mode in general.sampling.* (temperature 1.0, top_p 0.95, top_k 20; checked on the ISTA, Swift, Coder and Unsloth quants), and llama.cpp uses it when neither the request nor the command line sets it (ggml-org/llama.cpp#17120).
@Niko1221: as a minimal change, would it make sense to take these as Strata's defaults, i.e. setup reads them from the GGUF and writes them into a new config's "sampling" block, and the web chat starts from them instead of 0.6? #869 deals with a loop once it has started; this changes what a client gets before that, so I'm asking first. A fallback in the server (the GGUF's values whenever a config has no "sampling" block) would be the bigger step: it also changes existing configs and the documented greedy default.
@Niko1221 commented on GitHub (Oct 7, 2026):
Answer to your question: the opt-in reasoning_loop_recovery (false, stop or recover) is a workaround, not the root cause. The cause is greedy default sampling when the client sends none, and the model itself. Set temperature, top_p and a presence penalty the way Qwen recommends in the config. Note that the web chat sends 0.6 where the config says 1.0.
@sharathanaik commented on GitHub (Oct 12, 2026):
I see looping too.. I traced it to these settings --resident-experts or --resident-cpu-experts or resident-budget-gib. remove all of these the looping goes away, but takes a 15-30% hit on token generation speed. This find is repeatable. Just to add i am on intel gpu, so could be backend specific, unless it can be confirmed for other GPUs showing the same behavior.
temperature/presence_penalty does not fix this, just shows up at different points.
@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.
If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.