mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4402] [Engine] Strata 0.2.7 / engine 0.1.52: IQ2_XS collapses into repetition loops in long-context agent sessions (STRATA_ROUTE_PRIOR default-on for ≤13 GiB cards) #1958
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#1958
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 @arianwen27 on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4402
My agents kept imploding into looping messes, disabled route priority, tasked a new agent to figure out what happened and make a write up, here's the write up. This is absolutely written by an agent but it's accurate to what happened. Considering what this project is, I think it's fine to rather have an accurate write up made by an agent than what I could put together myself.
Area
[Engine]
Desktop app, Terminal or source?
Desktop app (Windows) — engine used through its localhost API by coding-agent clients, plus the built-in chat page.
What happened
Strata 0.2.7 turns residency-biased routing on by default for my card (
STRATA_ROUTE_PRIOR=1.5, row "Faster answers on 12 GB NVIDIA cards"). Decode did get faster (~67–98 tok/s on short tasks, 61–88 tok/s at ~50K prompt tokens), and I want it to stay fast. The problem is what happens in long-context agentic traffic.Defaults. Within about two hours of normal agent work with contexts growing from ~50K to ~83K tokens, four assistant turns degenerated into word/fragment loops (found with a character-run scanner over my client's saved replies):
"The engine is NOT throwing on JVM."×9;"DM path not scanned."×11;`debug bypass`'repeated as a 41-long char run; and a glued single-token loopWinWinWin…(~40 repeats). Window counts: 1,839 replies → 4 hits. Caveat: the first case sits in a conversation where I was writing loop-detection tools and the repeated sentence matches a test string I wrote, so treat it as weaker than the other three. (Real human here, this was me getting an agent to diagnose the issue, who then started looping while trying to diagnose the looping)Trying to stop it without losing speed. I raised repetition penalties and set the sampling block (
repetition_penalty1.1, presence 0.1, frequency 0.05,penalty_last_n256). That did not fix collapse — it changed its shape to copying whole turns. In one coding-agent session the model re-ran one command pair 5 consecutive times with the same planning paragraph verbatim ≥9 times and never produced an answer. Nudging it ("continue") made it try again and get stuck in the same loop. Once a collapse starts it does not recover: the chat page shows a turn whose very first action was a shell command repeating the same local script path over and over inside the arguments, ending at "Response reached the model's output token limit" (941 tokens), with no recovery shown. Penalties see only the current response window, so they cannot suppress copying of earlier turns; raising them also made the model echo prompt text back verbatim.Disabling the setting fixed it. Setting "Faster answers on 12 GB NVIDIA cards" Off (
STRATA_ROUTE_PRIOR=0, restart engine) stopped all looping — zero hits from the same scanner in 91 replies since, none of the three shapes recurring.Why this matters for the default-on decision: 0.2.7 measured quality with single-shot tasks on IQ3_XXS ("no copy or code errors"), and its own agent figures go the other way — 4.5/10 passed over 4 runs at prior 1.5 against 5.6/10 over 7 runs with it off. Single-shot tasks cannot see mid-conversation collapse, word loops, or action loops; my quant is IQ2_XS. The row warns about quality ("Turn off if answers look worse") but says nothing about loops/collapse, while "Faster long prompts" is off by default because its docs admit detail loss — precedent for shipping risky speed features off. Expected of a setting advertised as "Quality is the same": no collapses in agentic use. Actual: random collapses that never self-recover, minutes of wasted generation plus full prefill re-reads per episode, ending only at output limits.
Smallest steps or command that reproduce it
Not reproducible on demand. What was running: app native instance
Swift-Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS(swift-1.5-iq2_xs) with 0.2.7 defaults on a 12 GB card; coding-agent client sending"temperature": null,"max_tokens": 1400; contexts ~50K–83K tokens growing every turn (tool results appended); 30+ minutes of normal work → occasional degenerate turns. Turning the row Off stopped all three loop shapes afterwards.Reproduction status
Reproduced locally (observed under defaults, observed shape change after penalties, observed cessation after disabling; no deterministic repro)
Strata version
Strata app 0.2.7 · engine 0.1.52
Graphics card, memory and system
RTX 4070, 12 GB VRAM, 64 GB RAM, Windows 11
Model, size and settings
Swift-Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS ·
--max-context 262144 --kv int8 --kv-resident 32768 --spec 4 --spec-min-p 0.5 --mtp rt --expert-cache auto --prefill auto --vram-reserve-mib 1536, vision on, one request at a time, performance resource profile. Route prior default-on, now Off via env. Sampling block as listed above.What I am asking
STRATA_ROUTE_PRIOR_MAP, KL 0.141→0.108 keeping speed).tool_use.inputare invisible to detectors reading assistant text blocks), and give serve a way to end an episode once degeneration starts, since none of my cases recovered on their own. #3229 already notes ~20-word loops staying under its coverage line. Couple routing to these guards so healthy runs keep the speed win while collapses stop burning minutes.GET /v1/statusplus per-request degeneration counters, so agentic clients can correlate loops with settings. Engine packages for both releases are installed here; I'll run a controlled A/B (engine 0.1.50 vs 0.1.52) posting degenerate-turn counts if that helps pin down what else in 0.1.52 matters.Mechanism note (labelled, not claimed)
Two hypotheses are my reading of logs/code, unconfirmed: resident-expert bonus narrowing eligible experts as contexts grow ("route tail skip" reaches millions of skipped entries in one session), plausibly starving output diversity enough for sampling to lock onto a fragment; and penalty windows (
penalty_last_n) being blind to earlier turns, which fits the verbatim turn duplication after I raised penalties. Reporting failure shapes, not diagnosing them.Workaround today
Set "Faster answers on 12 GB NVIDIA cards" Off (
STRATA_ROUTE_PRIOR=0, restart engine): all looping stopped. Raising repetition/presence/frequency penalties does not fix it — it changes what gets looped and can make the model echo the prompt verbatim. Client-side guards are a stopgap (#4195 measured identical-write note + oscillation stop turning a 790 s run into 287 s with correct results).@ar-nelson commented on GitHub (Oct 28, 2026):
I encountered this issue too. I tried a few different quants and had the same problem each time: the model would get fixated on a single token (the first time I saw it do this, it was "hmm"), and the token would start to "infect" the model's thinking traces, appearing more and more often until it was the only thing present. It stayed somewhat functional for a while, despite ~70% of its thinking traces being "hmm". The first sign something was going wrong was broken tool calls (even though they didn't contain the fixated token): it would print tool call XML as plain text instead of actually calling it. Eventually its thinking degenerated into "hmm hmm hmm hmm hmm hmm hmm hmm ..." ad infinitum.
Turning off
STRATA_ROUTE_PRIORdidn't degrade performance too much, it went from ~55 tps to ~45. I've been running an agent with this change for about an hour without seeing the issue yet. I'll edit this if it breaks again.Is
STRATA_ROUTE_PRIORjust completely broken? Is this a situational issue, or a bug that could be fixed while keeping the speedup?Edit: Turning this off didn't completely fix the problem. I'm now seeing the model fixate on full paragraphs instead of individual words, but it still tends to break down into repetition after about an hour. RTX 3060 12GB on Arch Linux, I've tried both swift IQ3_S and regular Qwen IQ3_XXS.
Edit 2: Maybe I did it wrong. Per the Reddit post linked in another comment, I set
STRATA_ROUTE_PRIORto0(instead ofoff) and also setSTRATA_ROUTE_TAIL_SKIPto0(strata says it doesn't recognize this, maybe did nothing, but worth a shot). This brought my tps down to the 25-30 range, but the difference in intelligence is immediately obvious. The default settings had made Qwen unusably dumb. This version is "slower" but it actually gets to the point of doing something useful much, much quicker.@arianwen27 commented on GitHub (Oct 28, 2026):
I have a theory that since the experts that are already in vram are probably included in the calculation, the average slowly shifts more towards vram experts. So after enough loops of the close enough system running, the average is so swayed that it becomes exponential and optimises itself into a single token.
When I setup a repeat penalty, it optimised itself into being able to say a single tool call and paragraph on loop.
It might be fixable if the experts in vram are somehow ignored or given a lower priority so the average stays balanced. But that might cause other issues.
@rysoda commented on GitHub (Oct 28, 2026):
This should have been tested better. If you look at the first comment thread on this topic on reddit multiple people are experiencing the model getting dumber.
I'm all-in for optimization but new default options shouldn't make the model dumber.
@maverde73 commented on GitHub (Oct 28, 2026):
Adding next-token quality numbers from another ≤ 13 GiB card, in case they help separate "the prior changes wording" from "the prior makes the model worse". I haven't seen the loops myself yet (I only measured, no long agent sessions with the prior on), but the measured cost of 1.5 is large on this setup and it shrinks quickly at lower values.
Setup. RTX 4070 Ti 12 GB, 62 GB RAM, Linux, official v0.2.7 engine 0.1.52 (SHA256
9d415609…ee16ad), Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS native pack,--expert-cache 3102in every arm (3215 effective slots in all quality arms), KV int8, MTP and prefill as in my normal config. OnlySTRATA_ROUTE_PRIORchanges.Quality. Teacher forcing through verify windows with
STRATA_LOGPOS, 8,192 forced positions (3,072 code, 3,072 agent transcript, 2,048 WikiText-2), full-vocabulary log-prob of the forced token. Full KL wasn't available without a custom build (see the end).STRATA_ROUTE_PRIORA second 1.5 run was byte-identical to the first, and the off run was byte-identical across two sessions, so this isn't run-to-run noise. The 1.5 loss appears in all three segments (code, agent, prose).
Speed (decode, 256 forced tokens, 3 fresh-start replicas, median):
STRATA_ROUTE_PRIORSo here 0.5 keeps a large part of the speed-up for about 1% perplexity, while 1.5 pays about 23%. That's consistent with the agent results in the release notes (4.5 vs 5.6 of 10) and with the loops reported above. Limits: one quant, one card, one corpus, next-token quality only, nothing beyond 16K tokens, and no agent-task success measured.
If it's useful for checking full KL with your own tools: the only thing missing on the native path was dumping the full rows that
window_logprobs()already copies to the host. A 12-line diagnostic patch (STRATA_LOGPOS_FULL=<file>, raw float32 [position][vocab], no change to normal runs) is below. I haven't built or run it, so treat it as a sketch:I'm happy to share the corpus token IDs, scripts and raw TSVs (all hashed), or to run other values on this card. And thanks for Strata: the idea behind the prior is good, it's mainly a question of where the default should sit.
@WeiEnzhao commented on GitHub (Oct 29, 2026):
@Niko1221 commented on GitHub (Oct 29, 2026):
Thanks for the write-up and the numbers. We measured it, and the cause is the route prior, the "Faster answers on 12 GB NVIDIA cards" setting (STRATA_ROUTE_PRIOR=1.5), which 0.2.7 turned on for NVIDIA cards with 13 GiB or less. On an RTX 3060 it shifts the model's own text about 8 times as much as the tail skip does, and the model's top choice matches the reference only about 90% of the time.
It is off by default again in the next release. Until then, turn off "Faster answers on 12 GB NVIDIA cards" in the Terminal's Advanced table or the app's Expert settings, or set STRATA_ROUTE_PRIOR=0 if you start the engine yourself. The tail skip (STRATA_ROUTE_TAIL_SKIP) is a separate setting, and you don't need to change it.
We have not reproduced the loops in short runs. We will test a long agent session before offering a lower value such as 0.5.
@arianwen27 commented on GitHub (Oct 29, 2026):
A few screenshots from my own examples of it happening
@WeiEnzhao commented on GitHub (Oct 29, 2026):
Thanks — that matches what I can measure on my box, with one twist worth flagging.
My box: RTX 3080 20 GiB, single slot, engine 0.1.52 (
session is up (engine 0.1.52)), IQ3_XXS-abliterated, 200k-token agent sessions behind a slot save/restore proxy.route_prior_default()is keyed off adapter memory with an inclusive 13 GiB boundary (src/core/arch_defaults_test.cpp:362-366: 8 / 12 / 13.0 GiB → 1.5). My card is 20 GiB,STRATA_ROUTE_PRIORis unset in both Machine and User scope, nothing in my launch path sets it, and my engine log narrates the tail skip on every stats block (route tail skip: 2,303,896 missed experts skipped (2,397,856 entries) since startup) while the route prior is never mentioned once. So on this box the prior reads as off by default — which means if the loops in my screenshots came from this box, the prior can't be the whole story.--spec 4 --spec-min-p 0.70with MTP draft loaded, one slot with save/restore handoffs between concurrent agent sessions, expert arena 11.4 GiB VirtualLock'd, ~7 GiB host RAM free.STRATA_ROUTE_PRIOR=0vs1.5, same multi-hour agent session both sides) and report per-request token accounting (prompt N = R reused + K read), decode tok/s, and the onset of every loop I catch. Say which value you want pinned as the baseline./metricsfield or a startup line? Right now I'm inferring it from the absence of any narration, which is inference, not measurement.Nothing needed from me until the next release — my default is already 0.
@WeiEnzhao commented on GitHub (Oct 29, 2026):
Update — two concrete things on this box make my previous comment stronger than I wrote it, and add a second candidate cause:
Dropping the "if" in my last comment: the collapses in my screenshots are from this 20 GiB box, three samples on 10-28: a 128,520-token run cancelled mid-collapse, a 130,053-token request that emitted 24,569 tokens at
cov=1.00(degenerate distribution), and a 7'57" loop in another agent session. Route prior reads as default-off here by all the checks I listed, so on this box the collapse happened without the prior. The prior may well be a real small-card amplifier, but it is not necessary.A second variable just removed, and it is engine-side: until this afternoon this engine ran a self-trained expert profile —
--expert-profilepointed at a per-tier learned bin that profile-save kept auto-rewriting from the very sessions that were looping (that file's mtime was 11:42 this morning, still mutating when I last checked). All three collapses above happened under that wiring. This afternoon we re-pinned every tier config to the factory-shipped general profile with the save flags dropped from args, so nothing rewrites routing mid-session; the learned bins are sealed on disk, not wired.The hypothesis worth putting next to the route prior: an expert profile continuously retrained by its own looping sessions becomes a self-reinforcing attractor — the routing table learns the collapse pattern and feeds it back on subsequent hops. That reproduces here at 128k+ context with prior off, on a 20 GiB card, i.e. independently of the ≤13 GiB auto-on. Only hours since the switch; I'll report the first recurrence (or sustained absence) either way — and I'll pin prior at 1.5 on top of the sealed-profile wiring if you want the interaction measured.
@arianwen27 commented on GitHub (Oct 29, 2026):
I just had a thought. I bet the degradation speed is based on the number of experts loaded in vram. Since number of experts is automatic based on available vram, we'll all have a slightly different number of experts in vram.
In testing, I'm guessing everything is optimal and many experts are in vram. For us, it's more of a real world situation where the free vram is less so less experts are in vram. Less experts in vram means less options for the "close enough" to pick from, meaning things degrade more as there's less options from the start.
@Niko1221 commented on GitHub (Oct 29, 2026):
0.2.8 is out. With nothing set, the engine now routes exactly as 0.2.6 did. If you mostly chat and want the speed back, turn on "Faster answers on 12 GB NVIDIA cards" under Models, Native engine settings, Speed, or run
strata launch --set STRATA_ROUTE_PRIOR=1.5. Afterstrata update, please tell us whether the loops are gone, and we will close this then.@WeiEnzhao commented on GitHub (Oct 30, 2026):
Recurrence report, as promised (≈30 h after the expert-profile switch):
That narrows the causal chain on my box about as cleanly as I can: the persistent carrier of the collapse is the conversation's own prefix. Once the loop pattern dominates recent context, every turn re-triggers it autoregressively — changing engine-side state mid-conversation does not rescue that session (expert profile was actually switched; route prior per my checks was never on here in the first place). Profile and prior may change how readily a session falls into the basin; the basin itself lives in the history.
Two things that would help me (and probably the other long-session reporters here):
cov=1.00sample suggests top-p coverage saturates. If it is visible in the response stream, I can inject breaker logic at my own proxy and test it against the still-poisoned session.@WeiEnzhao commented on GitHub (Oct 30, 2026):
Closing the loop on my box: I deleted the poisoned sessions. Everything since — fresh conversations under the factory-shipped profile — runs clean, no loop thinking. Per my own conclusion above that is the expected shape: new conversations never carried the basin, and the old conversations were the basin.
Reporter side closed on my box; still interested in the two questions above (per-session repetition breaker / proxy-observable collapse signature) — if a breaker ships, my still-single-slot box is a fine test bed.
@arianwen27 commented on GitHub (Nov 1, 2026):
Been a few days, not had any looping happen, at least on my end it seems to be fixed
@eSun-ws commented on GitHub (Nov 1, 2026):
Same class of collapse on a 16 GB card (RTX 4070 Ti SUPER, Windows, app 0.2.9 / engine 0.1.55) — i.e. completely outside the ≤13 GiB
STRATA_ROUTE_PRIORgate. NoSTRATA_*variables are set at user or machine scope on this box. So this is the half you have not reproduced yet, not the routing half.Setup: Qwen3.8-Flash-Next-GSQ-RCO-abliterated IQ2_XS (SC117 weights, see #4590), engine args
--kv int8 --kv-resident 32768 --spec 2 --mtp --max-context 262144, single slot, MTP on.Session shape: ~90 messages, every request carrying 125k–134k prompt tokens of agent transcript.
Two collapses in one session, both in the reasoning channel
Collapse #1 — the loop locked onto
tonight 'prompt 171805 tokens ... 42533 generated in 248863 ms (170.9 tok/s), drafts accepted 30971 of 31170... tonight 'tonight 'tonight 'tonight '(40+ exact repetitions)Collapse #2 — same session, next turn, the loop locked onto
✓instead✓(47.4%)✓✓and whitespace, zero wordsprompt 125689 tokens ... 8001 generated in 51184 ms (156.3 tok/s), drafts accepted 5253 of 5309hook exit_group in libc ... ✓,/proc/self/fd enumeration ✓,Interceptor with context.pc check ✓✓), so the loop appears to grab whichever fragment was most frequent immediately before it. Same family as thehmm hmm hmmandWinWinWinreports.Two things that may be useful to you
Draft acceptance ≈99% is an early, machine-readable signal. Normal turns on this family accept 65–85%. At 98.9–99.3% the drafter and the model are repeating the same run, and it shows up in
drafts accepted X of Yseveral minutes before the client sees anything wrong. A log warning there would have caught both of these early.reasoning_budget_tokensbounds the damage but does not prevent the collapse. Withreasoning_budget_tokens=8000, collapse #2 self-terminated at 8001 generated tokens / 51 s with the normal wrap-up line (I have thought about this long enough; time to give my answer.), against 42,533 tokens / 249 s in collapse #1. That is a 5x reduction in wasted compute and it is the only lever that changed anything here.Also confirming the 2026-10-29 note:
STRATA_ROUTE_TAIL_SKIPwas never touched on this box, and the log still narratesroute tail skip: N missed experts skipped (N entries) since the starton every stats block — same as the 20 GiB box in the other comment.I am not asking for an ETA. I can collect more samples on request — the state reproduces within roughly an hour of agent work at 130k context on this machine.
@arianwen27 commented on GitHub (Nov 3, 2026):
Not had it occur again, others haven't mentioned anything, @eSun-ws may have an issue related to something else, closing as I believe this is solved
@eSun-ws commented on GitHub (Nov 4, 2026):
Keeping the record straight on the half of this that was not retested — I'm not asking for a reopen, but "solved" now covers a card class nobody re-ran.
1. My report sits outside the
STRATA_ROUTE_PRIORgate, so 0.2.8's revert cannot have removed it.RTX 4070 Ti SUPER 16 GB (Windows), app 0.2.9 / engine 0.1.55, Qwen3.8-Flash-Next-GSQ-RCO-abliterated IQ2_XS (SC117),
--kv int8 --kv-resident 32768 --spec 2 --mtp --max-context 262144, single slot. NoSTRATA_*variable at user or machine scope, so the ≤13 GiB auto-on never applied here. Both collapses were in one ~90-message session at 125k–134k prompt tokens; the second stripped 62,817 of 132,471 thinking characters down to✓(longest single run 256) right after a legitimate checklist had printed✓a few times. So "the prior is off by default now" and "others haven't mentioned it" both address a different configuration than the one reported.2. The failure family is still open upstream, with two more witnesses since this was closed.
The common shape is a low-bit quant at 100k+ context where draft acceptance saturates first. That is one family, not "something else".
The one measurement that would settle it for this class, no new feature required: log or expose
drafts_accepted / drafts_offeredper request and warn above ~98 %. Mine sat at 98.9–99.3 % for minutes before the client saw anything wrong, against 65–85 % on healthy turns in the same session. That single line converts "the agent went strange overnight" into a timestamped event, and it would have caught both my collapses and the #4939 one early.Also worth a line in the notes:
reasoning_budget_tokens=8000bounded my worst case to 8,001 generated tokens / 51 s instead of 42,533 / 249 s, so damage stays containable even with the root cause unknown. If a maintainer wants the onset rate for 0.2.10: #4590 changed how the repeat/frequency/presence penalties count the prompt tail, and I can A/B 0.2.9 vs 0.2.10 on this exact card with a scripted long-session loop and report the first recurrence either way.