Compile, Learn, or Both? When Weight-Space Programming Helps, What It Breaks, and Why Combining It with LoRA Matters
Working paper, version 1.1.2 ·
Abstract
Weight-space programming (WSP) lets a language-model agent edit another model's weights directly, without gradients. We compare it with LoRA fine-tuning on Qwen2.5-1.5B across four tasks, from knowledge the model already holds to knowledge it lacks, using 20 independent programmer runs, and repeat the key tests on SmolLM2-1.7B. WSP reliably corrected a deliberately wrong sentiment readout and compiled explicit tables into the weights, but LoRA was better at ordinary sentiment classification. The highest-scoring compiled circuits bypassed the network: one recalled all 900 fictional facts while the model's MMLU accuracy fell from 59.6% to 22.2%. A preservation instruction changed the kind of edit an agent built, at a cost in accuracy. Starting LoRA from a non-destructive programmed memory reached 99.0–99.7% fact accuracy with 4,000 training presentations, against 22.2% for LoRA alone, and the combined models kept general ability (MMLU 58.0–59.6%). On mirrored sentiment, the swap let LoRA learn on every seed at the default budget; LoRA alone learnt on every seed only when given three times the data. Programming is most useful for targeted changes and as a starting point for training, judged by what each edit does to the rest of the model.
1. Introduction
We asked a programming agent to put 900 facts about fictional people into a small language model. It worked: every test question was answered correctly, even when it used wording not seen during construction. Then we tested the same model on general knowledge. MMLU accuracy had fallen from 59.6% to 22.2%, near the chance level of that benchmark.
By target-task accuracy, this was a perfect edit. As a change to a general-purpose model, it was difficult to call a success.
Weight-space programming (WSP) lets a capable language-model agent inspect another model’s weights and write changes directly, without gradients [1, 2]. It offers another route besides fine-tuning. But when an edit improves a score, we still need to ask what was changed, whether ordinary LoRA would do as well, and what abilities were lost.
We began with predicting real survey answers, where a baseline that ignores the person and predicts each question’s most common answer (47.1%) beat both LoRA (42.8%) and the first programmed edit (32.8%). That made us separate three possibilities: a model may need its existing knowledge redirected, a known table written into its weights, or a better mapping learnt from examples.
We compare those cases under a common evaluation, test whether preservation requirements change the edit, and finally try programming before LoRA. Compiling rules into weights has been studied already [3, 4]. Closest to our work, Yang et al. [10] compare one published weight patch with LoRA on spatial reasoning in a 0.8B model: LoRA gains far more on the target tasks but breaks two neighbouring distance tasks that the patch preserves. They conclude that written edits disturb less, and leave broader capability checks and the combination of the two methods open. We add 20 independent programmer runs, 18 of them audited, across tasks where the needed knowledge ranges from present to absent, general-ability checks, and a test of programming as a starting point for LoRA. Written edits turn out to be far more destructive than LoRA when built as bypass circuits, and the combination saves training data where LoRA alone fails.
2. Experimental setup
We used Qwen2.5-1.5B-Instruct for the main study. All four tasks used five shuffled options, scored from the next-token probabilities of A–E, with about 20% chance accuracy. Ordinary SST-5 asks for the sentiment of a movie review [5]. Its mirrored version uses the same review but reverses the correct sentiment label, so the model starts confidently wrong. Twin-2K asks for the survey answer of a real respondent [6]. The last task asks for the city, profession or hobby of 300 invented people: the same 900 facts appear in train and test, but in different phrasings. It measures storing and recalling a table, not generalisation to unseen people.
A linear probe of the base model’s activations found substantial unused information for mirrored sentiment, but almost none for fictional facts [7]. This is a guide to the tasks, not proof of everything a model does or does not know.
The WSP agents (Claude Fable 5.2, Fable 5.1 for the pilot, and Claude Opus 5.5) worked from a common brief: no gradients or label-fitted solvers, at most 50 recorded forward passes of up to 512 examples, and no test access. They could write disclosed tables derived from training labels. Twenty programmer runs completed. Eighteen were independently audited; the exceptions are an early pilot and one Opus run that produced no edit. One Twin-2K run that broke the no-fitting rule was excluded and documented separately, and four runs that stopped at a usage limit are not used. The programmer runs cost about $1,350 at API list prices. LoRA used rank 16 and a default of 4,000 training presentations (250 optimizer steps at batch 16) [8]. We also tested longer training where that budget failed. The key redirection and compilation tests were repeated on SmolLM2-1.7B-Instruct. The full briefs, configurations, audits and per-run results are in the repository.
| Task | Base | Best WSP | LoRA | Label prior | What it tests |
|---|---|---|---|---|---|
| Ordinary SST-5 | 44.9 | 48.0 | 59.0 | 23.1 | Learn: improve a mapping |
| Mirrored SST-5 | 4.0 | 48.1 | 49.3* | 23.1 | Redirect: correct a readout |
| Twin-2K | 30.9 | 45.0† | 42.8 | 47.1 | Compile: population answer prior |
| Fictional facts | 21.1 | 100.0† | 98.8‡ | 27.4 | Compile: known fact table |
3. Results
3.1 A wrong readout needs a correction; an imperfect mapping needs learning
On mirrored SST-5, Qwen’s accuracy was only 4.0%. The model still recognised the review’s original sentiment; it just chose what had become the wrong label. Every completed programmer attempt found the same main change: swap the embedding rows for “negative” and “positive”. The swap alone reached 46.2%, and final programmed edits scored 45.7–48.1%. Swapping two unrelated words left accuracy at 4.0%. On SmolLM2 the programmer found the same swap (38.6% alone) and, with a further edit, moved the model from 11.4% to 45.4%.
LoRA reached 49.3% on one Qwen seed, significantly above three of the four WSP runs (paired bootstrap, p = 0.005–0.023) but level with the best (p = 0.37). But its other two seeds stayed at 23.9% and 27.7%; with 256 distinct examples it reached 29.1%. A three times larger learning rate did not help (19.4–20.0%), but three times the data let every Qwen seed escape the plateau (58.1–61.2%). On SmolLM2, LoRA stayed at 21.5–22.7% on all three seeds; we did not try either change there. Under the default budget, directly fixing a known mistake was more reliable.
Ordinary SST-5 tells the opposite story. The model already read sentiment reasonably well, and the problem was improving that mapping. WSP reached at most 48.0%, while LoRA reached 59.0%. Even with 256 distinct examples, LoRA scored 54.2%. There was no small correction that matched what training learnt.
3.2 Programming can add facts. What does it cost?
Three independent Fable runs wrote the fictional-fact table into early-layer lookup circuits and each scored 100% on the 900 held-out phrasings. Default LoRA stayed near chance at 22.2%. After about 15 epochs and 40,500 presentations, LoRA reached 98.8%. WSP could therefore store knowledge that was absent from the base model; it did so by writing the supplied answers into a circuit, not by discovering them.

The catch was the rest of the model. The bypass circuits changed early-layer computation used by ordinary inputs. On Qwen, they reduced MMLU from 59.6% to 22.2–25.8%, and next-token top-1 accuracy on WikiText-2 from 45.9% to almost zero. The Twin-2K prior circuit caused similar damage. On SmolLM2, another 100%-accurate fact circuit drove MMLU from 48.8% to 22.6%. The failure repeated across the two model families.
Not every edit failed like this. An Opus programmer repurposed 900 neurons in the layer-8 MLP (of 28) to hold the facts, in a way related to factual model editing [9]. It recalled 76.9% of facts while keeping MMLU at 59.6% and next-token top-1 at 45.6%. The difference is between a bypass circuit that dominates the model’s normal computation and a through edit that works with it.
We also asked whether the instruction could change the choice. Under the original brief, preservation was not required. When told to preserve other abilities, the Fable programmer used a gated attention change on Twin-2K instead of a bypass circuit. Accuracy rose from 30.9% to 35.2%, while accuracy on the SST-5 dev set, an unrelated task, stayed at 42.2% (42.3% before editing). On fictional facts, the programmer could not find an edit that both learnt the table and met the preservation check. Keeping the model useful sometimes costs most of the gain.
A related measurement problem appeared: some edits changed logit temperature. One mirrored-sentiment edit combined the swap with a temperature change. It raised WikiText-2 perplexity from 15.9 to about 1,800, which the swap alone does not do, while next-token top-1 accuracy stayed at 45.8% (base 45.9%); one rescaling of the logits brought its NLL back to 2.79 (base 2.77). Checking top-1 accuracy and general-knowledge performance separated these calibration effects from real damage. Target accuracy or raw perplexity alone would have given the wrong picture.
4. Programming, then LoRA
The two methods failed in different places. On the mirrored task, LoRA sometimes struggled to escape a confidently wrong start. On fictional facts, its default training budget was too short to store the table. Could a small programmed edit give training a better starting point?
We applied LoRA after the non-destructive Opus factual-memory edit and after the sentiment embedding swap, using the same 4,000-presentation budget as LoRA alone. We ran three seeds for each combination. On mirrored sentiment we also trained LoRA after a hand-written version of the swap, and after the SmolLM2 programmer’s edit.
Figure 2 shows why the starting point matters. Under the short training budget, LoRA alone had not stored the fictional-fact table. Beginning from a working factual memory let it refine that structure and reach 99.0–99.7% across all three seeds. On mirrored sentiment, the embedding swap removed the confidently wrong readout that had held back two LoRA seeds, and all three reached 57.3–58.5%. A hand-written swap of the two label words did just as well (57.6–58.5%), so the agent’s contribution was finding the swap; its other changes added nothing once LoRA trained. On Qwen, LoRA alone reached 58.1–61.2% with three times the data, so the edit saves training data rather than raising the ceiling. On SmolLM2, where LoRA alone failed on every seed at the default budget, the combination reached 55.9–56.6%; we did not run LoRA alone with more data there.
With the edit as a starting point, 4,000 presentations matched what LoRA alone reached with 40,500 (98.8%). At the default learning rate we tried no budget in between, so the true saving may be smaller. Both see the same 900 facts, so the saving is in training presentations, not in facts. The combined models also kept general ability. MMLU stayed at 58.0–59.6% on facts and 58.0–58.6% on mirrored sentiment (base 59.6%; the 95% interval is about ±4 points), next-token top-1 at 45.5–45.8% (base 45.9%), and accuracy on the SST-5 dev set, an unrelated task, at 42.6–43.6% for the facts models (base 42.3%). On SmolLM2, the combined sentiment models kept MMLU at 46.6–48.0% (base 48.8%) and top-1 unchanged at 46.0%. Yang et al. [10] found that LoRA, whether trained from the base model or on top of a weight patch, broke two neighbouring tasks. Here both starting edits worked through the model’s own pathways, and training on top of them left general ability intact.

5. Discussion and limitations
The practical distinction is between a fix we can write down and a mapping we still need to learn. When a model has the right information but reads it out wrongly, direct programming found a small, repeatable correction. When the answer was a finite table, programming could write the table into weights, sometimes at a severe cost to the model. So a written edit is not gentler than training by nature, as Yang et al. [10] found for one patch; it depends on whether the edit works through the model or around it. For improving an ordinary input-to-answer mapping, LoRA was better in our tests. Starting LoRA from a safe edit cut the training it needed, by up to tenfold for facts and threefold for mirrored sentiment on Qwen, and was more useful than insisting that one method should replace the other.
These findings come from 1.5–1.7B instruction-tuned models and a limited set of tasks. The replication on SmolLM2 covers only the two central regimes and the sentiment combination. We have 20 programming runs, only a few per task, and LoRA was not exhaustively tuned: three times the data fixed its mirrored-task seed failures on Qwen, we did not try that on SmolLM2, and we did not test the combination at that budget. The tasks differ in more than knowledge availability, and the two methods do not use identical kinds of computation. A programmer is allowed to build mechanisms from label tables, whereas LoRA updates weights through a fixed training procedure. Some agent runs used development-set selection; the audit and excluded-run records are available for inspection. These limitations matter when generalising the regime labels.
For anyone changing a model, our lesson is to define what must not change before making the edit. Evaluate the target task, an unrelated task and general behaviour. If a non-destructive edit solves part of the problem, test whether gradient training can do the rest. A 100% target score is not enough when the model stops working elsewhere.
Reproducibility and disclosure. Code, result files and audits are at https://github.com/Puneet-Bajaj-IITM/wsp-vs-lora. Claude (Anthropic) helped with coding, and ChatGPT (OpenAI) helped with copy-editing.
References
- Takehi, R., Teoh, J., Zhang, A., & Khattab, O. (2026). Sparks of Weight-Space Programming: LLMs can natively read & write neural network weights. Research blog. https://rikiyat.github.io/blog/weight-space-programming/
- Hu, J., Tang, C., Li, W., et al. (2026). Exploring Weight-Space Programming: Capabilities, Generalization, and Limitations. arXiv:2611.09382.
- Lehmann, J. (2026). Compiling Known Rules into Compact Neural Agents: Weight-Space Programming on Unseen Games. arXiv:2611.16981.
- Goworek, R., Hickey, A., Nanni, F., & O’Reilly, M. (2026). Replicating and Extending Weight-Space Programming: Frontier LLMs Compile Programs into Weights and Read Input Layers. arXiv:2611.21449.
- Socher, R., Perelygin, A., Wu, J., et al. (2013). Recursive Deep Models for Semantic Compositionality over a Sentiment Treebank. EMNLP.
- Toubia, O., Gui, G. Z., Peng, T., et al. (2025). Twin-2K-500: A Dataset for Building Digital Twins of over 2,000 People Based on Their Answers to over 500 Questions. Marketing Science 44(6), 1446–1455.
- Alain, G., & Bengio, Y. (2016). Understanding Intermediate Layers Using Linear Classifier Probes. arXiv:1610.01644.
- Hu, E. J., Shen, Y., Wallis, P., et al. (2022). LoRA: Low-Rank Adaptation of Large Language Models. ICLR.
- Meng, K., Bau, D., Andonian, A., & Belinkov, Y. (2022). Locating and Editing Factual Associations in GPT. NeurIPS.
- Yang, Y., Huang, X., Wu, Y., Yang, H., & Zhou, R. Z. (2026). Writing Weights or Training Them? Spatial Reasoning through Weight-Space Programming and Low-Rank Adaptation. arXiv:2611.27089.
Cite this
BibTeX
@misc{bajaj2026compile,
title = {{Compile, Learn, or Both? When Weight-Space Programming Helps, What It Breaks, and Why Combining It with LoRA Matters}},
author = {Bajaj, Puneet},
year = {2026},
month = nov,
note = {Working paper, version 1.1.2},
url = {https://puneetbajaj.dev/papers/compile-learn-or-both/},
doi = {10.5281/zenodo.24515792}
}Licence
Published under CC BY 4.0.