Qwen3.5-0.8B-WSP-patched (weight-space repetition fix)
Independent method-level reproduction of "Sparks of Weight-Space Programming: LLMs can natively read & write neural network weights" (MIT CSAIL blog by R. Takehi et al., 2026-11-02, https://rikiyat.github.io/blog/weight-space-programming/).
An automated statistical pipeline stands in for the original's LLM optimizer (no gradient descent, no training): diagnose the repetition-loop failure of Qwen3.5-0.8B in thinking mode, attribute it to MLP neurons, then directly scale their down_proj columns (64 neurons x 1024 x 2 layers = 131,072 weights = 0.016% of the model, beta=0.5, i.e. columns x0.5).
Deviation from the blog: their optimizer highlighted layers 15/19. Our dense all-layer
scan (stage diagall in code/wsp_gpu.py, results/diagall.npz) locates the strongest
repetition direction at layers 11 and 10 on this model snapshot, so the patch targets
those empirically strongest layers (128 neurons total).
Results (24 held-out MATH-500 problems, greedy, thinking mode, 4096-token budget)
| metric | base | patched |
|---|---|---|
| strict repetition-loop rate | 100.0% | 100.0% |
| finished (produced answer) | 0.0% | 0.0% |
| accuracy | 0.0% | 0.0% |
| mean length (words) | 1712 | 1828 |
Honest reading: at this budget the strict metrics do not improve - every problem still ends in a repetition state. The patch does change generation dynamics (mean length +116 words; the hardest diagnostic case self-terminates early instead of running to the cap), and the direction diagnosis replicates cleanly, but the fixed statistical patch does not convert into finished answers the way the blog's interactive optimizer (GPT-6 Astra, 32768-token budget, MATH-500 7.9%->48.1%, truncation 93%->33.1%) reports.
Patch-config sweep (dev = 4 most repetitive diagnostic problems, 3072-token greedy)
| patch target | beta | k/layer | dev words (dm3/dm0/dg3/dg5) | dev all still loop? |
|---|---|---|---|---|
| layers 15/19 (blog's pick) | 0.5 | 64 | 1218 / 1537 / 1795 / 1644 | yes |
| layers 15/19 (blog's pick) | 1.0 | 64 | 848 / 1409 / 1624 / 2008 | yes |
| layers 15/19 (blog's pick) | 0.7 | 256 | 1484 / 1590 / 1707 / 1950 | yes |
| layers 11/10 (our scan) | 0.5 | 64 | 712 / 1573 / 1344 / 2092 | yes |
| layers 11/10 (our scan) | 1.0 | 64 | 1075 / 1624 / 1719 / 1801 | yes |
| layers 11/10 (our scan) | 0.5 | 256 | 731 / 1602 / 1745 / 1780 | yes |
| layers 11/10/9/13 (our scan) | 0.5 | 64 | 974 / 1537 / 1757 / 2095 | yes |
| The bolded cell is the config shipped here: strongest effect on the worst | ||||
| case, gentlest intervention; guard generation (a chat intro) is unaffected in every | ||||
config. Full sweep JSONs are in results/. |
Usage
Option A - use the patched weights directly (this repo, same license as Qwen3.5).
Option B - apply the patch to official weights:
import numpy as np, torch
from transformers import AutoModelForCausalLM
z = np.load("wsp_weight_patch_beta0.5_k64.npz")
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-0.8B", dtype=torch.bfloat16)
lm = model.model
for L in z["layers"].tolist():
idx = torch.from_numpy(z[f"indices_L{L}"])
W = lm.layers[L].mlp.down_proj.weight
with torch.no_grad():
W[:, idx] *= float(1 - z["beta"][0])
Files
model.safetensorsetc. - patched Qwen3.5-0.8B weightswsp_weight_patch_beta0.5_k64.npz- patch indices (64 neurons/layer) and metadataresults/- paired eval records (full generations), direction diagnosis, all-layer scan, patch-config sweepscode/wsp_gpu.py- full pipeline (diagnose -> attribute -> patch -> eval)
Caveats
- Partial replication: the diagnosis/attribution half reproduces (a single repetition direction, strongest at layers 9-13 on this snapshot), but the repair half does not transfer to this snapshot/budget without the original's interactive optimizer.
- Numbers here are our own runs, not verified by the original authors; magnitudes are not directly comparable (4096 vs 32768-token budget, statistical patch vs LLM optimizer).
- The patch suppresses the repetition behaviour it was built from; it is a research artifact, not a production model fix.
- Not affiliated with MIT CSAIL, OpenAI or Alibaba/Qwen. Base model (c) Qwen team, Apache-2.0; patch and analysis code follow the same license.