Skip to content

Backport opt-in long reasoning-loop guard to the pinned TP2 engine - #138

Open
otherview wants to merge 2 commits into
MiaAI-Lab:mainfrom
otherview:backport/long-loop-guard
Open

otherview wants to merge 2 commits into
MiaAI-Lab:mainfrom
otherview:backport/long-loop-guard

Conversation

@otherview

@otherview otherview commented Nov 12, 2026 •

Copy link
Copy Markdown

Description and motivation

A reasoning passage longer than eight tokens can repeat until the reply budget
is exhausted on this recipe's pinned TP2 engine. Backport TensorFold's indexed
long-loop detector and allocation-safety follow-up; preserve original authorship
and byte-identical detector code. Adapt only the older stream lifecycle.

Expose opt-in LOOP_GUARD=1 (default off) to pass --loop-guard. A hit closes
reasoning and continues the same reply. Reasoning history, compaction and
thinking budgets are unchanged. This mitigates verbatim loops; it does not fix
the checkpoint or guarantee correct continuation.

Refs ashhart/TensorFold#1075 and its later allocation-safety follow-up. No new
PR is proposed against TensorFold main, which already has this detector.

Testing

  • Independent clean application on current recipe c7f2b851 / engine fbbc971
    after all 53 patches; no dependency on zig/patches/0063: Preserve long cached prefixes when a separate continuation copy cannot fit #115, zig/patches/0061: the call gate's first token is the drawn token (#80) #118 or the cache-protection PR.
  • CPU-only Linux ARM64 zig build -j2 test --summary all: 23/23 steps succeed
    (cached successful targets reused on non-root rerun).
  • Offline recipe script suite: 33/33 pass, including guard opt-in/default and
    reasoning-history policy checks; bash syntax checks pass.
  • Prior guard off/on/off controls retained 160/164 HumanEval, 151/164 HumanEval+
    and 12/18 agent results, with identical coding samples. These quality profiles
    disable thinking, so they are serving controls, not recovery correctness proof.
  • Latest-Mia combined deployment retained three actual guard continuations
    (periods 168, 181, 1285), with identical outputs versus prior guarded production
    and distinct proposed actions. Tool results were simulated and reasoning was
    retained. Separate deterministic workflows completed 252 valid actions per
    phase with no duplicates; the same count-31 instead of 32 report error remained.

docs/long-loop-guard.md separates this PR's host checks from prior combined-image
GPU evidence and states remaining limits. The patch intentionally changes
output after a detected loop; unaffected native token equivalence on this exact
standalone branch is still pending.

Checklist

  • Read the recipe configuration and kept existing defaults.
  • One independent change, with a reproducible patch and host tests.
  • Document settings, defaults, behavior and measurement limits.
  • Standalone two-Spark branch build and native API qualification.
  • Native drafted-versus-plain, resumed and concurrent equivalence.
  • Headroom at upstream default 4-stream / 1,048,576-context configuration.

Submitted for maintainer review with the live checks above still outstanding;
no standalone GPU qualification is claimed. Production was not interrupted for
this preparation. No private conversation capture is published.

Backport ashhart/TensorFold e9ba70f and allocation-safety follow-up 0ce409c, retaining original authorship and detector bytes. Adapt the pinned TP2 stream lifecycle and expose default-off LOOP_GUARD with offline launcher coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant