Just sort it! A note on the LP behind rank-one anti-loop edits

Matteo FischettiarXiv 2026

TL;DR

Researchers found that the complex Linear Programming (LP) used to stop LLMs from "looping" is largely unnecessary. By simply sorting neurons based on how consistently they activate and applying a constant bias, you can achieve nearly identical performance at a fraction of the computational cost.

What Problem Does This Paper Address?

Small reasoning models (like the 0.8B parameter version of Qwen) often fall into "thinking loops," where they repeat the same logic or tokens indefinitely. A recent technique called AHA (Weight-Space Programming) fixes this by applying a "rank-one edit" to the model's weights.

Essentially, AHA identifies a "loop direction" ($u$) in the model's activation space and then solves a massive, sparse Linear Program (LP) to find a vector ($v$) that tells the model which neurons to tweak to push activations away from that loop. However, these LPs are dense and computationally heavy—often involving tens of millions of nonzeros and requiring specialized GPU solvers. This paper asks a simple question: Do we actually need the math, or is there a shortcut?

Methods

The author compares the standard LP-based edit against a much simpler "Sort" method:

  1. The LP Baseline: Solves an optimization problem to find a sparse set of neurons that "push" looping tokens while leaving "productive" tokens alone.
  2. The Sort Method (sort_k8): Instead of optimizing, the author simply calculates the mean ($m_j$) and standard deviation ($\sigma_j$) of each neuron's activation. Neurons are then sorted by their coefficient of variation ($\sigma_j / |m_j|$). The 8 neurons with the smallest variation (the most "constant" neurons) are selected and given equal shares of the "push."
  3. The Knapsack Control (knap_k8): A control group that picks the 8 neurons with the largest mean activation, ignoring variance.

The core hypothesis is that the LP isn't actually performing a complex separation of tokens; it’s just finding "always-on" neurons to act as a constant bias.

Datasets

The study evaluates these methods on a combined set of 1,000 reasoning problems:

  • MATH-500: A subset of the MATH benchmark.
  • GSM8K: The first 500 problems from the GSM8K test set.

The model used for all tests is Qwen3.5-0.8B.

Key Insights and Ideas

  • The LP is a Bias in Disguise: The most surprising finding is that the LP solution doesn't actually separate looping and productive tokens. Instead, it pushes both almost equally. This means the edit is essentially acting as a constant bias along the loop direction $u$.
  • Consistency is Key: The neurons that matter most are those that are "almost always active." By picking neurons with the lowest coefficient of variation, the "Sort" method captures the same functional benefit as the LP.
  • Structural Overlap: Even though the Sort method doesn't "solve" the LP, the neurons it picks carry 88% to 95% of the total "push" that the LP solution intended to deliver.
  • The "Dose" Matters More Than the Solver: The magnitude of the edit (the "dose") is more important than the specific neurons chosen, provided those neurons are stable.

Key Results

The "Sort" method proved to be non-inferior to the expensive LP approach across multiple tests.

  • Accuracy: On the initial run (Seed 0), the LP edit achieved 67.4% pooled accuracy. The simple sort_k8 method achieved 67.0%. This 0.4-point difference is negligible, especially considering the unedited base model only scores 9.5%.
Table 1: Accuracy in %, seed 0. “Diff” is the paired difference with respect to lp on the 1000 problems; the 95% confidence interval comes from the discordant pairs.
  • Efficiency: Solving the LP for 20 layers takes about 2.2 minutes on a high-end NVIDIA RTX 6000 Blackwell GPU. In contrast, the sort requires only a single pass over the activations to calculate two moments (mean and variance) per neuron—a trivial computational task.
  • Generalization: When tested across three additional sampling seeds, the performance gap remained tiny (between -0.6 and -0.8 points), confirming the robustness of the sorting approach.
Table 3: Seeds 1, 2 and 3. Accuracy in %, averaged over the seeds. “Diff” is the paired difference with respect to lp, with the 95% confidence interval clustered by problem.

Limitations and Future Work

The author notes a few constraints:

  • Model Specificity: This was tested specifically on Qwen3.5-0.8B. While the results are striking, it's unclear if larger models or different architectures would rely more heavily on the LP's optimization.
  • The "Dose" Source: In the primary sort_k8 test, the "dose" (the total magnitude of the push) was still borrowed from the LP. While a follow-up (sortd_k8) showed that using a pre-calculated threshold $\delta$ also works well, more work is needed to determine the optimal dose without any LP involvement.
  • Steering vs. Editing: The paper suggests that if the edit is just a constant bias, "activation steering" (modifying activations during inference) might be a more natural and flexible approach than permanent weight editing.

Summary updated

Abstract

Weight-space programming removes the thinking loops of a small reasoning model by a rank-one edit W' = W + u v^T of an MLP output matrix, where u is a loop direction and v is the solution of a sparse Linear Program (LP) over the neuron activations. We investigate whether the LP is needed. We replace it by a sort: we take the 8 neurons whose activation has the smallest coefficient of variation, and give them equal shares of the push that the LP solution realizes. On Qwen3.5-0.8B the sorted edit scores 67.0% on 1000 problems (MATH-500 and GSM8K) against 67.4% for the LP edit and 9.5% for the unedited model; the paired difference is -0.4 points, with 95% confidence interval [-2.9, +2.1], inside a non-inferiority margin of 5 points declared before the runs. On three further sampling seeds the difference is -0.6 points, interval [-2.0, +0.8], and -0.8 points, interval [-2.3, +0.6], when the dose is set without the LP. The sort does not solve the LP, but the neurons it shares with the LP solution carry most of its mean push. The outcome is that, on this model, the edit acts as a nearly constant bias along u.
BibTeX
@misc{fischetti2026just,
  author = {Matteo Fischetti},
  title = {{Just sort it! A note on the LP behind rank-one anti-loop edits}},
  year = {2026},
  eprint = {2611.21432},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.21432},
}
Figure