mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2901] [CLOSED] STRATA_LOOP_BREAK=1 (opt-in): a --serve reply that repeats one span three times is pushed out of the copy #4320
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#4320
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2901
Author: @zsariboga
Created: 10/17/2026
Status: ❌ Closed
Base:
main← Head:pr-loop-break📝 Commits (1)
06dfff3STRATA_LOOP_BREAK=1 (opt-in): a --serve reply that repeats one span three times gets a ban on the token continuing its copy for the next 1024 tokens📊 Changes
4 files changed (+150 additions, -0 deletions)
View changed files
📝
docs/DETAILS.md(+12 -0)📝
include/strata/kernels/sampler.hpp(+5 -0)📝
src/kernels/cuda/sampler.cu(+28 -0)📝
src/program/generate.cpp(+105 -0)📄 Description
The problem
repeat_stop_tokens(#606) ends a reply stuck on one token. It never sees a model that writes the same sentence orparagraph again and again, and that is the loop we meet in agent use: across 4.06M tokens of one user's opencode
sessions (Swift 1.5 IQ3_XXS on a 12 GB laptop), 11% of the sessions longer than 3K tokens had a hard loop and 5.7% of
all tokens were repetition. One regex task ran a 29K-token loop of the same paragraph. Once a span has been written
three times the model's own probabilities keep it in the copy; sampling rarely leaves it.
What it changes
With
STRATA_LOOP_BREAK=1, the serve decode path watches the reply (not the prompt):run[p], the number of tokens in a row equal to the one p before them (onecompare per period per token). When
run[p] >= 2p(three copies) andrun[p] >= STRATA_LOOP_BREAK_MIN(default256 tokens), the reply enters break mode for
STRATA_LOOP_BREAK_SPANtokens (default 1024). A<think>,</think>,<tool_call>,</tool_call>or ``` token ends break mode early, so it stays inside the span it began in.8-gram -> where it last ended) and takes the token that followed them there: the token that would continue the copy.
That one id gets
STRATA_LOOP_BREAK_BIAS(default -100) in the window's FIRST row only. Rows past the first followdrafts the target has not taken yet.
sample_tokensand insample_tokens_spec(after its early returns, so a fallback neveradds it twice), on the target's full-vocabulary rows only. The id and bias live in mapped host memory and are read
by a one-thread kernel, so captured windows pick up each new value.
strata serve: loop break: N loops broken, M windows with a banned copy tokenline per request that needed it.What it leaves alone
set_loop_banis never called and no kernel is launched, so the default path is unchanged.picks are the same as unset.
--pipeline-windowsdecode (its next window is built before this one's tokens are known), batch slots and themulti-card drive are not covered.
Measured / checked
src/kernels/cuda/sampler.cu, a plain kernel launch, andgenerate.cpp).--serverebased on the currentmain, the branch's own server; the model ran in the RAM-budget file tier, so the run's tok/s are not comparable andare not a speed claim): with
STRATA_LOOP_BREAK=1the repetition prompt ("write this sentence exactly 60 times,nothing else") ended after 9 lines / 2 unique (305 tokens) and the log carried
strata serve: loop break: 1 loops broken, 2 windows with a banned copy token; with the variable unset the sameprompt produced 50 identical lines / 1 unique (1750 tokens, 5.7x). A normal prompt (a median function) answered
correctly in both arms; the two answers are equivalent but not byte-identical (temperature 1.0, and GPU/CPU expert
rounding differs run to run in this configuration). The engine line above is the one the change promises.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.