Writing Weights or Training Them? Spatial Reasoning through Weight-Space Programming and Low-Rank Adaptation

Yalin Yang, Xiao Huang, Yanan Wu, Hao Yang, Ryan Zhenqi ZhouarXiv 2026

It’s late, you’ve had a long day of debugging or data wrangling, and you’re probably wondering: Why is it so hard to just fix a model’s brain?

When a Large Language Model (LLM) fails at a specific task—like spatial reasoning—we usually reach for the heavy machinery of gradient descent. We "train" it. But what if we could just "write" the fix directly into the weights, like a software patch? This paper, "Writing Weights or Training Them?", explores this exact tension using a fascinating new technique called Weight-Space Programming.

TL;DR

The researchers compared "surgical" weight editing (Weight-Space Programming) against "total overhaul" training (LoRA) to fix spatial reasoning in a small LLM. They found a stark trade-off: direct weight edits are gentle and preserve the model's existing skills but offer modest gains, while training (LoRA) achieves near-perfect scores on the target task but "greedily" overwrites other abilities, causing the model to hallucinate spatial logic even when asked about product prices.

What Problem Does This Paper Address?

LLMs are notoriously bad at multi-step spatial reasoning—the kind of "if A is north of B and B is west of C, where is A?" logic. Often, they don't just get the answer wrong; they get stuck in infinite loops, repeating the same reasoning steps until they hit the token limit.

Traditionally, we fix this with Low-Rank Adaptation (LoRA), a parameter-efficient way to fine-tune a model. But fine-tuning is a bit of a "black box" and can lead to catastrophic interference, where the model learns the new trick but forgets how to do its old ones.

The authors investigate a newer alternative: Weight-Space Programming (WSP). In WSP, one language model actually inspects the weights of another and writes code to edit them directly. It’s like neurosurgery performed by an AI. The question is: which approach is better for building a reliable, multi-talented spatial reasoner?

Methods

The team used the Qwen3.5-0.8B model as their test subject and compared two main intervention styles:

  1. The "Patch" (WSP): They used a publicly available patch (p50c) created via weight-space programming. This edit affected only two specific tensors in the model (about 0.016% of the weights). It was designed to stop the model from "looping" during reasoning.
  2. The "Adapter" (LoRA): They trained LoRA adapters of various ranks (from rank-16 down to a tiny rank-1). Crucially, they tested two types of supervision: answer-only (just the final label) and worked-solutions (a "scratchpad" showing the step-by-step math).

To see if these fixes broke the model's "common sense," they also tested it on off-target tasks—skills the model already had, like comparing distances between points, which shouldn't be affected by a spatial reasoning fix.

Datasets

The study utilized four distinct task families:

  • Reference-frame (Target): Converting absolute map coordinates into relative directions (ahead, behind, left, right) from an observer's perspective.
  • StepGame (Target): A benchmark for multi-hop spatial reasoning (e.g., "Agent X is north of Y...").
  • Map Distance (Off-target): Simply asking which of two points is closer to a third.
  • Product Distance (Off-target Control): The exact same math as the map distance task, but phrased as comparing product prices and weights to remove spatial language.
Table 1: The four task families. Examples are quoted verbatim from the frozen task file, with the line breaks of the StepGame story replaced by spaces and the closing answer-format instruction omitted (“Answer with one word.”, “Return only the label.” with the list of nine labels, or “Answer with one letter.”). Target families were used for editing, training and the main evaluation; off-target families were used only to measure side effects (Section 9).

Key Insights and Ideas

  • The "Loop" is the Problem: The base model's failure wasn't necessarily a lack of "knowledge," but a failure of termination. It knew how to start the math but didn't know when to stop. The WSP patch fixed this by essentially cutting the "looping" circuits.
  • LoRA is a Greedy Learner: When trained on worked solutions, even a rank-1 LoRA (using only 0.09% trainable parameters) reached near 100% accuracy. However, it became "obsessed." If it saw a coordinate or a pair of numbers, it would force the StepGame reasoning template onto the prompt, even if the question was about something else entirely.
  • Supervision Style Matters: Training on just the answers failed to pass the "learning gate." To truly master the task, the model needed to see the work. This suggests that for complex reasoning, we aren't just teaching the model a mapping; we're teaching it a procedure.
  • The Scalpel vs. The Sledgehammer: The WSP patch was a scalpel—it improved performance slightly while leaving the model's other skills (like distance comparison) perfectly intact. LoRA was a sledgehammer—it mastered the target task but crushed the neighboring skills.

Key Results

  • Target Gains: On the Reference-frame task, the base model scored 0%. The WSP patch raised this to 22.1%. The rank-1 LoRA adapter? A staggering 100%.
  • The Cost of Mastery: On the off-target distance tasks, the WSP patch maintained high accuracy (~94%). The LoRA adapters saw a near-complete collapse, dropping to 0–2% accuracy.
  • Generalization: The LoRA adapters were surprisingly robust to new wording (82% accuracy on unseen templates) but struggled when the logic got deeper (dropping to 42% on harder difficulty levels).
Table 2: Quantitative comparison of accuracy across different conditions. Note the asterisked LoRA results reaching near-ceiling performance.

Limitations and Future Work

The authors note that this study was confined to a relatively small model (0.8B parameters). While small models are great for "mechanistic" studies (seeing exactly which weights do what), larger models might handle the interference differently.

The most promising path forward? Mixing. The researchers suggest that the next step is to mix a small amount of "off-target" data into the training set (rehearsal) to see if we can get LoRA’s high performance without the catastrophic forgetting. Alternatively, we might use trained adapters to locate where a fix should go, and then use Weight-Space Programming to install it permanently and cleanly.

Summary updated

Abstract

Weight-space programming lets a language model inspect and edit another model's weights, offering an alternative to gradient-based adaptation. We evaluated both approaches using Qwen3.5-0.8B on a fixed reference-frame task (128 items), StepGame (200 items), and two untrained distance-comparison tasks. With thinking enabled, the public patch (p50c) raised mean accuracy from 0.0% to 22.1% on the reference-frame task and from 19.2% to 33.7% on StepGame across three sampling seeds. Randomly permuting its weight change removed the gain. Further closed-form edits did not improve on p50c, whereas a rank-1 LoRA adapter trained on worked solutions reached 100% and 98.8%, respectively, with 0.09% trainable parameters. Removing the worked solutions from supervision prevented the adapter from passing the learning gate. The trained adapters reached 82% accuracy on unseen StepGame sentence templates, 42% on held-out difficulty levels 6-10 after training on levels 1-5, and 33-50% on unseen heading-answer combinations. Their target gains coincided with a sharp decline on the distance tasks: accuracy fell from 94% and 92% under p50c to 0-2%, and their outputs applied the StepGame solution template to distance questions. With thinking disabled and reasoning requested in the visible answer, the base model also solved the distance tasks while remaining weak on the target tasks. The comparison reveals a trade-off between improving spatial task performance and preserving neighbouring skills: the public edit restored completion while preserving distance performance, whereas supervised adaptation produced much larger target gains together with interference across tasks.
BibTeX
@misc{yang2026writing,
  author = {Yalin Yang and Xiao Huang and Yanan Wu and Hao Yang and Ryan Zhenqi Zhou},
  title = {{Writing Weights or Training Them? Spatial Reasoning through Weight-Space Programming and Low-Rank Adaptation}},
  year = {2026},
  eprint = {2611.27089},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.27089},
}
Figure