A no-training, surgical weight edit that suppresses the semantic reasoning-loop
behaviour of Spark-X2.6-1.7B. The model reaches a correct conclusion and then
spirals into re-decision ("…but wait, should I…"), re-deriving the same answer in
fresh wording instead of acting or stopping. This checkpoint closes that loop by
editing one row of the output head — 2,048 weights.
TL;DR — On a controlled branch-point benchmark, looping drops from 0.875 → 0.062 (a 92.9 % reduction). The tested tool-selection prompts close-and-act (0/24 loops), and math answers are preserved. The edit is conclusion-selective (it does not truncate legitimate reasoning) and improves standard intelligence benchmarks — most notably GSM8K math (0.200 → 0.433). It improves the thinking loop; agent tool looping can still occur on other tasks — see Limitations.
This is a derivative work. Full credit to the upstream authors:
| Stage | Model | License |
|---|---|---|
| Base model | Spark-X2.6-1.7B (XHToken) | Apache-2.0 |
| GGUF quantization (Q4_K_M) | upstream Q4_K_M quant of the base | Apache-2.0 |
| This repo — head-row reasoning-loop edit applied to the Q4_K_M quant | — | Apache-2.0 |
The base architecture is spark2_5 (28 layers, hidden 2048, hybrid attention, 131k
vocab). Unlike the 4B variant, the 1.7B has an untied head: a separate
output.weight (Q8_0) distinct from token_embd.weight (BF16). The edit therefore
touches only the output head — no input-embedding side effect.
The failure is a semantic loop, not verbatim repetition: classic n-gram repetition metrics see almost nothing, because the model re-says the same decision in new words. In an agent setting it re-enumerates the tool list, re-asks "which tool is the browser?", and never emits the action. The correct conclusion is already present in the reasoning trace — the model simply will not commit to it and stop.
The edit was derived by directly observing activations and logits, not by sweeping sampling parameters:
</think> sat far down the ranking while restart vocabulary dominated.logit(t) = output_weight[t] · h,
where h is the final-norm residual. The closure deficit is a head-readout gap;
the lever is row 4 of output.weight (</think>).h at the conclusion of each looping prompt.
The conclusion residual is distinct from mid-derivation, so an edit along it is
conclusion-selective.Solve for the minimum-norm row delta δ that raises log P(</think>) at all four
loop-prompt conclusion states h_p simultaneously, with per-state targets:
H = stack(h_p) # 4 × 2048 conclusion residuals
Δ = [14, 14, 14, 18] # nats; math-multi-2 gets a larger target
δ = Hᵀ (H Hᵀ)⁻¹ Δ # min-norm solution, δ · h_p = Δ_p
output_weight[4] += δ # output.weight row 4 (</think>), Q8_0
‖δ‖ ≈ 0.223. The row is dequantized, edited, and re-encoded at its original Q8_0
type with ggml's own quantizer, then spliced back into the GGUF in place — every
other byte is bit-identical, and token_embd.weight is untouched. No training, no
calibration data, no sampling-time intervention.
Why per-state targets? A uniform +14 left the hardest state (math-multi-2, whose
baseline closure deficit is much deeper, rank ≈ 468) at only P(close) ≈ 0.265 and
still looping 9/12. Giving that state a larger target (+18) raised its branch
P(close) to 0.95 and cut its loops to 2/12 — without raising Δ globally (which
causes </think> spam).
Controlled branch-point benchmark, 12 seeds per prompt, combined semantic + verbatim loop metric. Control = the unedited model continued from the same branch points.
| Prompt | Control loop rate | Edited loop rate | Reduction |
|---|---|---|---|
| tool-ambig-2 | 8/12 | 0/12 | 100 % |
| tool-ambig-3 | 10/12 | 0/12 | 100 % |
| math-multi-1 | 12/12 | 1/12 | 92 % |
| math-multi-2 | 12/12 | 2/12 | 83 % |
| Overall | 42/48 = 0.875 | 3/48 = 0.062 | 92.9 % |
The original (before) and edited (after) checkpoints were run on the same standard
intelligence suites with identical decoding (0-shot; multiple-choice by mean per-token
log-likelihood, GSM8K by greedy exact-match).
| Suite | n | Before | After | Δ |
|---|---|---|---|---|
| ARC-Challenge | 100 | 0.300 | 0.320 | +0.020 |
| WinoGrande | 100 | 0.530 | 0.550 | +0.020 |
| PIQA | 100 | 0.690 | 0.700 | +0.010 |
| HellaSwag | 100 | 0.340 | 0.340 | 0.000 |
| MMLU | 91 | 0.407 | 0.407 | 0.000 |
| GSM8K | 60 | 0.200 | 0.433 | +0.233 |
| Mean | — | 0.411 | 0.458 | +0.047 |
The edit helps general capability on this model — every suite that moves goes up, none regress, and GSM8K math more than doubles. The reasoning-loop fix is not bought at the cost of intelligence; here it improves it.
Conclusion-selective — no premature closure. With the edit applied, P(</think>) at
early derivation stays tiny (e.g. math-multi-1 ≈ 6×10⁻⁹, math-multi-2 ≈ 8×10⁻⁸,
tool-ambig-2 ≈ 0.001), so legitimate reasoning is not truncated.
Known limitation — residual tool looping. The edit improves the thinking loop (the model commits to a conclusion and closes the thinking channel), and the specific tool-selection prompts tested here close-and-act cleanly. It is not a universal cure for agent tool looping: on broader tool-use tasks (e.g. Hermes-style tool tasks) the model can still loop over tool selection / re-enumeration. That behaviour is distinct from the semantic thinking loop this edit targets.
Known limitation — numeric termination. As with the 4B variant, arithmetic conclusions can re-state the answer instead of emitting EOS. The head-row lever fixes the reasoning-commit loop; arithmetic re-derivation termination needs a separate, post-answer-state direction (future work). Treat this checkpoint as a targeted fix for the reasoning-commit loop, not a general guarantee of termination on every task.
Standard GGUF — works with llama.cpp and compatible runtimes:
llama-cli -m Spark-X2.6-1.7B-noloop-headrow-Q4_K_M.gguf \
-c 32768 -ngl 99 -fa -ctk q4_0 -ctv q4_0 \
-p "Your prompt here"
The model uses a thinking channel (`` … </think>); the edit makes the model commit
to </think> once it has reached a conclusion.
The exact edit is included and reproducible offline (CPU only):
delta4_17.f32 — the 2048-float row delta δ.apply_edit.py — applies δ to row 4 of output.weight in the original
upstream GGUF and writes the edited checkpoint.ggml_quant.cpp — ggml's own re-encoder (build against llama.cpp's ggml).edit_report.json — hashes, changed-weight count, and verification.# 1. build the quantizer against a llama.cpp checkout (LLAMA = path to llama.cpp)
g++ -O2 -std=c++17 -I"$LLAMA"/ggml/include ggml_quant.cpp -o ggml_quant \
-L"$LLAMA"/build/bin -lggml -Wl,-rpath,"$LLAMA"/build/bin
# 2. apply the edit to the original upstream Q4_K_M GGUF (untied head: output.weight)
pip install gguf
python3 apply_edit.py \
--model Spark-X2.6-1.7B-Q4_K_M.gguf \
--delta delta4_17.f32 \
--out Spark-X2.6-1.7B-noloop-headrow-Q4_K_M.gguf \
--quant-bin ./ggml_quant \
--tensor output.weight --row 4 --ne0 2048
Apache-2.0, inherited from the upstream base model. See LICENSE.
This derivative adds only the head-row edit described above.
XHToken/Spark-X2.6-1.7B