WSP-Gym · weight-space repair
Inkling 2 Small, post-trained with LoRA on Tinker, reads a broken network's weights as plain text and answers with a small edit that fixes it. No tools, no forward passes and, after training, no reasoning.
Weight-space programming, a language model reading a network's weights and writing better values with no gradients, had only been shown with models used off the shelf, mostly closed frontier ones. We trained an open-weights model to do it on one task: repairing small ReLU networks that each contain one planted fault.
Untrained, Inkling 2 Small fixes 75.6% of held-out broken networks, and only by reasoning for about 10,600 tokens per network. After supervised training and RL on Tinker it fixes 82.9% [79.4, 86.5] in about 38 tokens, with no reasoning. Training buys speed, not better answers: the untrained model's misses are mostly answers that ran out of its 20,000-token limit (22% of networks), and it repairs 97.6% of those it finishes.
Off the shelf, the 4 other open-weights models that would answer at once fix at most 8.0% of a sample of the same networks; given 20,000 tokens to reason, Muse Spark Open matches the trained model at about 200 times the tokens. GPT-6 Astra and GPT-6.1 Sol fix 91-100%. The networks are tiny, and most of the gain comes from the supervised stage.
Inkling 2 Small, post-trained on Tinker, repairs small neural networks from their raw weights
Held-out test networks.@emeraldant
Setup One test network with a planted fault. Left: untrained Inkling 2 Small, allowed to reason. Right: the post-trained model, told to answer at once, on this network and then on the next faulty test networks, until both have generated the same number of tokens.
Animation: on the left, the untrained model's 9,149-token reasoning on one network streams past until it answers with an edit that repairs it. On the right, in the same number of generated tokens, the trained model answers 207 faulty test networks, starting with this one, and repairs 176 of them.
Over all 422 faulty test networks, the untrained model with reasoning fixes 75.6% [71.3, 79.6] at ~10,600 tokens, and runs out of its 20,000-token allowance on 22% of them (it repairs 97.6% of those it finishes). The trained model fixes 82.9% [79.4, 86.5] at ~38 tokens, about 278 times fewer.
Setup A small ReLU network that should compute a one-line function contains at most one planted fault. The model sees the specification, the architecture and every weight as text, and replies with at most 3 edit operations, each touching one row, one column or one scalar.
[{"op": "swap", "tensor": "W2", "axis": "col", "i": 2, "j": 0}]An edit is scored only by how the edited network behaves: recovery = (acc_after - acc_faulty) / (acc_clean - acc_faulty), and a network counts as repaired at a recovery of 0.95 or more. Any equivalent fix counts. About one network in six is healthy, and the right answer there is the empty edit [].
| Model | Tokens | Answer | Accuracy after |
|---|---|---|---|
| Untrained, told to answer at once | 44 | [{"op": "set", "tensor": "W1", "index": [0, 2], "value": 0.0}] | 41% (was 78%) |
| Untrained, reasoning | 9,149 | [{"op": "set", "tensor": "W2", "index": [0, 0], "value": 0}, {"op": "set", "tensor": "W2", "index": [0, 2], "value": 0}] | 100% |
| Trained, no reasoning | 46 | [{"op": "swap", "tensor": "W2", "axis": "col", "i": 2, "j": 0}] | 100% |
The reasoning model found a different fix: it silenced both swapped paths and kept the neuron that already computes the target. Told to answer at once, the untrained model usually starts reasoning anyway and is cut off; only 16% of its answers are valid, and it repairs 0.2%.
You are debugging a small ReLU network by reading its weights. The network was built to implement the specification below. It either works correctly or contains exactly one fault (for example a corrupted, mis-scaled, sign-flipped, shifted or swapped part of one tensor). Some neurons are legitimately redundant or inactive; those are not faults.
## Specification
Inputs: 3 inputs x0..x2, each an integer from 0 to 9.
Target: Output max(x1 - x0, 0) + 6.
Outputs: 1 output(s). An output counts as correct when it is within 0.5 of the target value.
## Architecture
h1 = relu(W1 @ x + b1) [3 neurons]
y = W2 @ h1 + b2 [1 output, no relu]
## Weights
W1 (3 rows x 3 cols) and b1. Row i = incoming weights of h1[i]; column j = outgoing weights of x[j].
W1[0] = [1.71, -1.71, -1.71] b1[0] = 3.41
W1[1] = [-1.31, 1.31, 0] b1[1] = 0
W1[2] = [1.95, -1.95, -1.95] b1[2] = 3.91
W2 (1 rows x 3 cols) and b2. Row i = incoming weights of y[i]; column j = outgoing weights of h1[j].
W2[0] = [-0.51, 0.76, 0.58] b2[0] = 6.01
## Your task
Reply with a JSON list of at most 3 edit operations that repairs the network, or [] if it has no fault. Each operation changes one row, one column or one scalar. Indices are 0-based. Allowed operations (examples):
{"op": "scale", "tensor": "W2", "axis": "col", "index": 4, "factor": -1} multiply one row or column of a weight matrix
{"op": "swap", "tensor": "W2", "axis": "col", "i": 1, "j": 5} swap two rows or two columns of a weight matrix
{"op": "set", "tensor": "W1", "index": [3, 0], "value": 0.5} overwrite one weight (index is [row, col])
{"op": "set", "tensor": "b1", "index": 3, "value": -1.5} overwrite one bias
{"op": "add", "tensor": "W2", "axis": "col", "index": 2, "vector": [0.5, -0.5]} add a vector to one row or column
{"op": "swap", "tensor": "b2", "i": 0, "j": 2} swap two biases (scale and add also work on a bias: use "index" with "factor" or "value")
Your edit is scored only by how the edited network behaves on held-out inputs, so any edit that restores the specified behaviour is accepted. Editing a network that has no fault is penalised, and so is an invalid or over-budget answer. End your reply with the JSON list and nothing after it. Answer immediately from your reading of the weights: output only the JSON list, with no reasoning, no calculations and no explanation.Every network is disguised with function-preserving symmetries, so the same function never looks the same twice. Here one compiled circuit goes through the gym's disguises, one at a time.
A statistics-only heuristic that resets or rescales the most unusual row, column or scalar repairs 4.0% of the in-distribution test networks.
Setup 500 networks per test set, generated before training from seeds disjoint from training. One adapter for every row; no reasoning; temperature 1.0, one answer per network.
In-distribution the trained model repairs 82.9% [79.4, 86.5], +82.7 points over the untrained model. It carries over to function families it never trained on (59%) and to larger networks (70%). On networks fitted by scikit-learn, an optimiser never used in training, it repairs 51% and wrongly edits 28% of the healthy ones. Fault types it never saw are the weak row: 20%.
| Test set | Untrained | Trained | Heuristic | Healthy left alone |
|---|---|---|---|---|
| In-distribution | 0.2% | 82.9% [79.4, 86.5] | 4.0% | 100% |
| Larger networks than any in training | 0.0% | 70.0% [65.6, 74.3] | 1.9% | 94% |
| Function families never trained on | 0.7% | 58.6% [53.6, 63.3] | 8.4% | 71% |
| Fault types never trained on | 0.5% | 19.9% [16.2, 23.8] | 2.9% | 99% |
| Networks made by gradient descent (our trainer) | 0.2% | 66.7% [62.0, 71.2] | 1.5% | 95% |
| Networks fitted by scikit-learn (an optimiser never used in training) | 1.7% | 51.3% [46.5, 56.4] | 2.4% | 72% |
Setup Rank-16 LoRA on Inkling 2 Small. Tinker runs the forward and backward passes; the gym and the reward run locally. Checkpoint chosen on validation networks.
[] on a healthy network, a penalty for editing one, -1 for an invalid answer.The final model used $174 of Tinker compute ($418 for the whole project). The supervised loop is a few Tinker calls per step:
211tc = await service.create_lora_training_client_async(base_model=a.model, rank=a.rank, seed=a.seed)
···
227eps = [train_example(a, step * a.batch_size + i, trained_cache) for i in range(a.batch_size)]
228data = [sft_datum(a.model, ep, a.effort, a.direct) for ep in eps]
229lr = a.lr * (1.0 - a.decay * step / max(1, a.steps)) # linear decay to (1 - decay) * lr
230fb = await tc.forward_backward_async(data, "cross_entropy")
···
252 sw = await (await tc.save_weights_for_sampler_async(f"sft-sampler-{step + 1:05d}"))
The RL stage passes the gym to the tinker-cookbook RL loop:
422from tinker_cookbook.rl import train
···
426cfg = train.Config(
···
437 learning_rate=a.lr,
438 lora_rank=a.rank,
439 max_tokens=a.max_tokens,
440 temperature=1.0,
441 loss_fn=a.loss_fn,
442 num_substeps=a.num_substeps,
443 remove_constant_reward_groups=True,
···
450asyncio.run(train.main(cfg))
| Change | Measured on | Effect |
|---|---|---|
| Three times the supervised training data | In-distribution repair | 57% → 80% |
| Gradient-made networks added to training | Repair on gradient-made networks | 14% → 67% |
| RL on top of supervised training | Repair, six test sets pooled; healthy networks left alone (larger networks) | about +3 points; 79% → 94% |
Setup The same test networks and prompts, given to other models and to methods that do not read weights as text.
After training, Inkling 2 Small uses far fewer tokens than its own reasoning mode, and repairs more networks only because that mode runs out of its token limit. GPT-6 Astra and GPT-6.1 Sol are well ahead: off the shelf they repair 91-100% of the same networks in a few hundred tokens, and 88-91% of the gradient-made ones. Search with forward passes repairs 65.2%, gradient descent 61.4%.
| Method | Repair rate | Tokens per network | Sample |
|---|---|---|---|
| Untrained Inkling 2 Small, free to reason | 75.6% [71.3, 79.6] | ~10,596 | 422 faulty networks |
| Trained Inkling 2 Small, no reasoning | 82.9% [79.4, 86.5] | ~38 | 422 faulty networks |
| Untrained Inkling 2 Small, no reasoning | 0.2% [0.0, 0.7] | ~223 | 422 faulty networks |
| Brute-force search over single sign flips and swaps, using forward passes | 65.2% | — | 422 faulty networks |
| Gradient descent on half of the inputs (ignores the edit budget) | 61.4% | — | 422 faulty networks |
| Statistics-only heuristic (most unusual row, column or scalar) | 4.0% | — | 422 faulty networks |
| Random valid edit | 0.7% | — | 422 faulty networks |
| Never edit | 0.0% | — | 422 faulty networks |
Told to answer at once, the 6 models with reasoning switched off repair 0.0% to 8.0%; the trained Inkling 2 Small repairs 79.5% in about 40 tokens. GPT-6 Astra and GPT-6.1 Sol are ahead (96.6% and 90.9%, after about 112 and 170 reasoning tokens), and Gemini 4 Carbon repairs 62.5%. Another 9 models kept reasoning past the 512-token limit, so their figure there is not a fair score. Free to reason, every model repairs 90% to 100% of the faulty networks it finishes within 20,000 tokens; most rows are decided by how often it finishes. Of the open models, Muse Spark Open finishes most (91%) and matches the trained model, at about 200 times the tokens.
| Model | Weights | Told to answer at once: repaired | Cut off | Tokens (of them reasoning) | Free to reason: repaired | Cut off | Tokens |
|---|---|---|---|---|---|---|---|
| Inkling 2 Small, post-trained on Tinker | open | 79.5% [70.5, 87.5] | 0% | ~40 (0) | not used | — | — |
| Inkling 2 Small, untrained | open | 0.0% [0.0, 0.0] | 85% | ~224 | 77.3% [68.2, 85.2] | 22% | ~10,797 |
| Inkling (first generation, larger) | open | 3.4% [0.0, 8.0] | 0% | ~31 (0) | 30.7% [21.6, 40.9] | 64% | ~17,438 |
| Qwen3.8 2.4T | open | 10.2% [4.5, 17.0] | 81% | ~1,484 (1,412) | 60.2% [50.0, 70.5] | 38% | ~20,260 |
| DeepSeek V4 Pro | open | 2.3% [0.0, 5.7] | 0% | ~34 (0) | 30.7% [21.6, 39.8] | 68% | ~17,670 |
| Kimi K3.1 Pro | open | 8.0% [2.3, 13.6] | 7% | ~69 (0) | not run (cost) | — | — |
| GLM-5.3 | open | 2.3% [0.0, 5.7] | 87% | ~505 (467) | 36.4% [26.1, 46.6] | 61% | ~16,822 |
| Muse Spark Open | open | 0.0% [0.0, 0.0] | 89% | ~500 (398) | 84.1% [76.1, 92.0] | 9% | ~8,110 |
| Mistral Large 4 | open | 0.0% [0.0, 0.0] | 100% | ~512 (511) | 30.7% [21.6, 40.9] | 63% | ~17,287 |
| Nemotron 3 Ultra | open | 3.4% [0.0, 8.0] | 0% | ~59 (0) | 28.4% [19.3, 37.5] | 64% | ~16,216 |
| Beam 1.0 | open | 0.0% [0.0, 0.0] | 99% | ~511 (509) | 50.0% [39.8, 60.2] | 49% | ~16,300 |
| GPT-6.1 Sol | closed | 90.9% [84.1, 96.6] | 8% | ~195 (170) | 100.0% [100.0, 100.0] | 0% | ~437 |
| GPT-6 Astra | closed | 96.6% [92.0, 100.0] | 4% | ~139 (112) | 100.0% [100.0, 100.0] | 0% | ~382 |
| Claude Fable 5.2 | closed | 37.5% [27.3, 47.7] | 62% | ~447 (431) | not run (cost) | — | — |
| Gemini 4 Carbon | closed | 62.5% [52.3, 72.7] | 5% | ~58 (25) | 96.6% [92.0, 100.0] | 4% | ~6,756 |
| Grok 4.7 | closed | 98.9% [96.6, 100.0] | 0% | ~11,278 (11,243) | 96.6% [92.0, 100.0] | 0% | ~35,728 |
| Claude Opus 5.5 * | closed | 43.2% [33.0, 53.4] | 53% | ~438 (422) | not run | — | — |
| Claude Sonnet 5.5 * | closed | 5.7% [1.1, 11.4] | 69% | ~390 (5) | not run | — | — |
| Claude Haiku 5.5 * | closed | 0.0% [0.0, 0.0] | 0% | ~21 (0) | not run | — | — |
| Gemini 4 Hydrogen * | closed | 3.4% [0.0, 8.0] | 85% | ~442 (436) | not run | — | — |
| GPT-6 Luna * | closed | 3.4% [0.0, 8.0] | 0% | ~21 (0) | not run | — | — |
The first 100 networks of the in-distribution test set (88 faulty), through OpenRouter, with the same prompts as Inkling 2 Small. An answer cut off at the token limit counts as not repaired. Tokens include reasoning; the figure in brackets is how many were reasoning. Where an API would not switch reasoning off, its lowest setting was used. The limits were chosen for Inkling 2 Small and the other models reasoned at their default effort, so the with-reasoning column compares models at a fixed budget, not at their best. * Added after the first results, answer-at-once only.
Setup The trained model samples 8 answers per faulty network; a verifier runs each edited network and keeps the first that repairs it. This uses forward passes.
With eight verified answers the model fixes 90.5% in-distribution and 77.2% of gradient-made networks, above both forward-pass baselines. On scikit-learn networks (65.1%) it matches simple search and stays below gradient descent. The 8 samples contain 2.4 to 3.4 distinct answers on average.
| Share of faulty networks fixed | In-distribution | Gradient-made | scikit-learn |
|---|---|---|---|
| One answer, no verifier | 82.9% | 66.7% | 51.3% |
| Best of 8 verified answers | 90.5% [87.7, 93.1] | 77.2% [73.0, 81.4] | 65.1% [60.5, 69.6] |
| 8 random valid edits, verified | 7.3% | 8.2% | 10.4% |
| Brute-force search over single sign flips and swaps | 65.2% | 63.5% | 64.8% |
| Gradient descent on half of the inputs (no edit budget) | 61.4% | 71.5% | 74.9% |
Setup Small networks trained by gradient descent that only partly learned their function. Nothing is planted. The model proposes an edit; the gym keeps it only if the network gets more accurate. Trained by RL from the base model, with no supervised stage.
Eight proposals from the trained model remove +12.0% [10.2, 14.0] of errors, about what 32 random edits do (+11.9%); eight random edits remove +5.0%. On function families never used in training: +7.9% against +5.0%. A second, shorter training run reached +7.4% [6.0, 8.9]. Exhaustive search over simple edits removes +21.7%.
| Proposer | 1 proposal | 8 proposals | Networks improved (8) |
|---|---|---|---|
| Untrained Inkling 2 Small | +0.4% | +2.1% [1.2, 3.0] | 5% |
| Random valid edits | +0.6% | +5.0% [4.1, 6.0] | 20% |
| RL-trained Inkling 2 Small | +3.9% | +12.0% [10.2, 14.0] | 31% |
| RL-trained, second, shorter run | +1.8% | +7.4% [6.0, 8.9] | 20% |
| Random edits, 32 / 128 proposals | +11.9% / +18.7% | 36% / 54% | |
| Exhaustive search over simple edits | +21.7% | 57% |
As far as we know, this is the first trained weight-space programmer that works from weights as text.
The code, the frozen test sets and every rollout log are in the repository https://github.com/emeraldant/WSP-Gym.
uv sync
uv run pytest -q # gym invariants: symmetries, faults, DSL, rewards, determinism
uv run python -m weightgym.splits # regenerates data/ deterministically
export TINKER_API_KEY=... # never committed
uv run python -m weightgym.tinker_train sft --log-path runs/sft --lr 3e-4 --decay 0.8 --steps 300 --batch-size 64
uv run python -m weightgym.rl_chunks --log-path runs/rl --load tinker://<sft state> --init-sampler tinker://<sft sampler> \
--init-val 0.754 --lr 2e-5 --chunks 6 --chunk-steps 10 --group-size 8 --groups-per-batch 64
uv run python -m weightgym.final_eval --arm untrained --arm sft_rl=tinker://<sampler> --baselines --thinking-ref 500
uv run python -m weightgym.tinker_train sft --log-path runs/sft_mixed --lr 3e-4 --decay 0.8 --steps 300 --batch-size 64 \
--mix repair,repair_trained --val-sets "repair:data/val.jsonl,repair:data/val_trained.jsonl"
uv run python -m weightgym.rl_chunks --log-path runs/rl_improve --init-val 0.0 --lr 6e-5 --rank 16 --chunks 8 --group-size 16 \
--groups-per-batch 32 --mix improve_loop --val-task improve_loop --val-split data/val_imperfect.jsonl --val-samples 8 --select loop_gap
uv run python -m weightgym.gen_cache train_trained 0 28800 cache/train_trained.jsonl # gradient-made training networks (CPU)
scripts/scale_up.sh sft # final model: 900-step mixed-source supervised stage
scripts/scale_up.sh rl <mean validation repair> # 10 x 10 RL steps, validation after every chunk
scripts/scale_up.sh final tinker://<selected sampler> # the six test splits, once
uv run python -m weightgym.plot --arms untrained,scale_rl --labels "Untrained,Post-trained on Tinker"
uv run python -m weightgym.verify_eval eval scale_rl tinker://<selected sampler> --k 8 # secondary: 8 verified proposals
uv run python -m weightgym.cost