Repository navigation
lanes: --loop-guard also closes a long passage repeated verbatim in the reasoning - #1075
Closed
BobClawblaw wants to merge 1 commit into
Closed
BobClawblaw wants to merge 1 commit into
BobClawblaw wants to merge 1 commit into
Conversation
…he reasoning The guard closed a cycle of at most 8 tokens held for 256. Greedy reasoning also loops on longer passages, which it missed: Qwen3.5-2B (MLX 4-bit) thinking on, greedy, ran 27 of 30 GSM8K and GPQA-Diamond prompts to a 16,384-token limit, on cycles of 36 to 96 tokens and one of 879. long_loop.Index keeps where each 32-token run of the reasoning ended, chained by hash. A token closes the reasoning when the latest earlier end of its run at least 9 back gives a period p, and the last max(p, 1,024) tokens each equal the token p before: a whole period, and at least 1,024 tokens, repeated verbatim. It is a function of the tokens alone, so loopCut cuts a drafted window at the token a token at a time fires on. As before, it acts only with --loop-guard and only while the think block is open, and reports the period. Checks: - long_loop.zig: a 4,500-token passage fires as its second copy completes, a 100-token one 1,024 tokens past its first copy, both at the same token in windows of 1 and 6; no fire on text that does not repeat, or that repeats a token short of the rule. - long_loop_test.zig: through Stream.commit and loopCut, a 300-token passage closes the reasoning at token 1,524 a token at a time and in windows of six, with the think close forced. - Qwen3.5-2B served with and without --loop-guard (M5 Ultra, thinking on, greedy, max_tokens 16384), 20 GSM8K and 10 GPQA-Diamond prompts: the guard fired on 27, each reply's reasoning the unguarded one's up to the fire; the other 3 are byte-identical. GSM8K's first 20: 3 right (3 finished) without the guard, 16 right (17 finished) with it. Eleven guarded replies still reached the limit, looping in the answer after the close; the guard does not watch the answer. - zig build test: 351/351 steps succeeded, 4,927 of 4,949 tests passed (22 skipped).
ashhart
added a commit
that referenced
this pull request
Oct 21, 2026
…dits The 1.1.2 section had no entries for the contributed pull requests carried into this release, so neither their changes nor their authors reached the release notes. Add an entry for each, written from its commits: Flash Next's CUDA prompt tiles and structured output (#1046, #1062), --thinking-reserve, the long-loop guard and the --vision template diagnostic (#1064, #1075, #1076), GLM's Metal eh_proj tile and CUDA waiting ranks (#1066, #1053), M1's simdgroup cap (#1055), Nemotron's CUDA image and shared-window fixes (#1057, #1058), Qwen's live-row expert routing (#1047), the shared CUDA operators and contract fixture (#1056, #1068, #1070, #1071, #1073), the ROCm receipt, drafter and draft-count work (#1043, #1044, #1045), the ModelOpt recipe numbers (#1042), the Windows host build (#1034) and the session store's allocation-free rollback (#637). Thank #643's and #1060's reporters as the other entries thank theirs.
Owner
|
The long repeated-reasoning check for --loop-guard is included in 1.1.2 (https://github.com/ashhart/TensorFold/releases/tag/v1.1.2), with your original authorship retained. When enabled, it closes a long verbatim loop inside reasoning so the reply can continue to its answer. Our follow-up reserves the loop index before publishing tokens, so that allocation can fail without changing the stream's context length. Closing this as carried, and thank you. It landed as e9ba70f. - Synthema, Ash's AI Assistant. |
3 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--loop-guardcloses a reasoning loop only when it's a cycle of at most 8 tokens held for 256. Greedy reasoning also loops on longer passages, and those run to the token limit without an answer. This extends the guard to them.What we saw
max_tokens16384: 27 of 30 GSM8K and GPQA-Diamond prompts ran to the limit. The cycles were 36 to 96 tokens long, plus one of 879.The change (
zig/src/core/lanes/long_loop.zig, hooked into the existing guard instream.zig)long_loop.Indexrecords where each 32-token run of the reasoning ended, chained by hash.loopCutcuts a drafted window at the same token a one-token-at-a-time run fires on.--loop-guardand only while the think block is open, closes the block the same way, and reports the period inruntime.loopand the server log.docs/api.md's loop guard paragraph describe the new rule.Checks (M5 Ultra; the only machine we ran)
long_loop.zigtests:long_loop_test.zig: throughStream.commitandloopCut, a 300-token passage closes the reasoning at token 1,524, one token at a time and in windows of six, with the think close forced.--loop-guard, on 20 GSM8K and 10 GPQA-Diamond prompts:"draft": false, gives the identical reply (same token hash).zig build test:351/351 steps succeeded; 4927/4949 tests passed (22 skipped).zig fmtis clean, and the lean check is unchanged from main (444).