A no-training, surgical weight edit that suppresses the semantic reasoning-loop
behaviour of Spark-X2.6-4B-heretic. 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 tied output head — 2,560 weights, ≈ 6×10⁻⁷ of the model.
TL;DR — On a controlled branch-point benchmark, reasoning looping drops from 0.750 → 0.312 (a 58.4 % reduction), and the tested tool-selection prompts close-and-act (0/24 loops). The edit is conclusion-selective (it does not truncate legitimate reasoning) and is roughly neutral on standard intelligence benchmarks. It improves the thinking loop; agent tool looping can still occur on other tasks, and arithmetic re-derivation is only partially fixed — see Limitations.
This is a derivative work. Full credit to the upstream authors:
| Stage | Model | License |
|---|---|---|
| Base model | XHToken/Spark-X2.6-4B | Apache-2.0 |
| Decensored finetune (Heretic / ARA abliteration) | daydreamwarrior/Spark-X2.6-4B-heretic | Apache-2.0 |
GGUF imatrix quantization (i1, Q4_K_M) |
mradermacher/Spark-X2.6-4B-heretic-i1-GGUF | 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 (36 layers, hidden 2560, hybrid attention, 131k
vocab, tied input/output embeddings). The upstream heretic finetune removes refusals;
this edit is orthogonal — it targets reasoning termination, not refusal behaviour.
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 at rank ≈ 54, log p ≈ −11.8 (P ≈ 7×10⁻⁶), while restart vocabulary
dominated — " But" was the top token at log p ≈ −0.80 (P ≈ 0.45).logit(t) = emb[t] · h, where h is the
final-norm residual (result_norm). The ~11-nat closure deficit is therefore a
head-readout gap, not an MLP "loop direction". (An earlier attempt ablating an
MLP down_proj circling direction was correlated-but-not-causal: ±sign symmetric,
max +2.85 nats — too weak.)h at the conclusion of each looping prompt
(‖h‖ ≈ 91). The conclusion residual is distinct from mid-derivation
(cos ≈ 0.28), so an edit along it is conclusion-selective.Solve for the minimum-norm row delta δ that raises log P(</think>) by
Δ = 14 nats at all four loop-prompt conclusion states h_p simultaneously:
H = stack(h_p) # 4 × 2560 conclusion residuals
δ = Hᵀ (H Hᵀ)⁻¹ (Δ · 1) # min-norm solution, δ · h_p = 14
emb[4] += δ # token_embd.weight row 4 (</think>)
‖δ‖ ≈ 0.199 (≈ 15 % of that one row). The row is dequantized, edited, and re-encoded
at its original Q6_K type with ggml's own quantizer, then spliced back into the GGUF
in place — every other byte is bit-identical. No training, no calibration data, no
sampling-time intervention.
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 | 9/12 | 0/12 | 100 % |
| tool-ambig-3 | 4/12 | 0/12 | 100 % |
| math-multi-1 | 12/12 | 8/12 | 33 % |
| math-multi-2 | 11/12 | 7/12 | 36 % |
| Overall | 36/48 = 0.750 | 15/48 = 0.312 | 58.4 % |
54,945,594, 17:48).To check that the edit does not damage general capability, 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.650 | 0.610 | −0.040 |
| WinoGrande | 100 | 0.480 | 0.510 | +0.030 |
| PIQA | 100 | 0.720 | 0.710 | −0.010 |
| HellaSwag | 100 | 0.490 | 0.490 | 0.000 |
| MMLU | 91 | 0.494 | 0.516 | +0.022 |
| GSM8K | 60 | 0.533 | 0.517 | −0.017 |
| Mean | — | 0.561 | 0.559 | −0.002 |
The edit is essentially neutral overall (mean −0.002): it trades a little ARC-Challenge and GSM8K for WinoGrande and MMLU, with HellaSwag/PIQA unchanged. The reasoning-loop fix is not bought at the cost of general capability.
Conclusion-selective — no premature closure. With the edit applied, P(</think>) at
early derivation stays tiny, so legitimate reasoning is not truncated:
| Prompt | early P(close) | conclusion P(close) |
|---|---|---|
| tool-ambig-2 | 0.0041 | 0.902 |
| tool-ambig-3 | 1.7×10⁻⁶ | 0.933 |
| math-multi-1 | 2.1×10⁻⁹ | 0.950 |
| math-multi-2 | 3.5×10⁻⁸ | 0.387 |
A clean control ("reply with exactly: OK") behaves correctly (brief think → </think> →
OK → stop).
Known limitation — numeric </think> spam. On arithmetic conclusions the model
closes the thinking channel but then re-derives/re-states the answer instead of emitting
EOS, repeating </think>. A modest EOS-row boost was tested and rejected: it reduced
math looping but regressed some tool/clean seeds into spam, i.e. it is not selectively
safe. The head-row lever fully fixes the agent re-decision 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.
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 and is characterized separately.
Standard GGUF — works with llama.cpp and compatible runtimes:
llama-cli -m Spark-X2.6-4B-heretic-noloop-headrow-i1-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. Sampling defaults from the upstream
quant (temp ≈ 0.8, top-p ≈ 0.95) work well.
The exact edit is included and reproducible offline (CPU only):
delta4.f32 — the 2560-float row delta δ.apply_edit.py — applies δ to row 4 of token_embd.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
pip install gguf
python3 apply_edit.py \
--model Spark-X2.6-4B-heretic.i1-Q4_K_M.gguf \
--delta delta4.f32 \
--out Spark-X2.6-4B-heretic-noloop-headrow-i1-Q4_K_M.gguf \
--quant-bin ./ggml_quant
Apache-2.0, inherited from the upstream base model and finetune. See LICENSE.
This derivative adds only the head-row edit described above.
XHToken/Spark-X2.6-4B