WSP-Gym · weight-space repair

We trained an open model to repair neural networks by reading their raw weights

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.

@emeraldant · November 2026 · code, frozen test sets and every rollout log

TL;DR

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

1 · Repair from raw weights 82.9% of broken test networks fixed in ~38 tokens. Untrained: 75.6% in ~10,600. 2 · Trained on Tinker 57,600 networks supervised, then 100 RL steps; $174 of Tinker usage. Validation repair rate: 3 · RL alone, no labels +12.0% of an imperfect network's errors removed with 8 verified proposals. Random edits: +5.0%.

Held-out test networks.@emeraldant

One network, then the same number of tokens

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.

Test network 3000218 · 16 weights · target: Output max(x1 - x0, 0) + 6.
Untrained, reasoning allowed
0 tokens · 1 network
Post-trained on Tinker, no reasoning
repairedmissedthis network
0 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.

Same number of generated tokens, not wall-clock time: 9,149 tokens on one network on the left; 207 networks answered and 176 repaired on the right. Real model output; playback is compressed.

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.

The task

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.

Network 3000218: weights, fault and the trained model's edit
  1. The model reads the weights as text.
  2. The planted fault: the outgoing weights of h1[0] and h1[2] are swapped.
  3. The trained model's answer swaps them back: [{"op": "swap", "tensor": "W2", "axis": "col", "i": 2, "j": 0}]
  4. Accuracy on the task's 1,000 inputs.
Line width shows a weight's magnitude, colour its sign.

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 [].

Three answers for this network
ModelTokensAnswerAccuracy after
Untrained, told to answer at once44[{"op": "set", "tensor": "W1", "index": [0, 2], "value": 0.0}]41% (was 78%)
Untrained, reasoning9,149[{"op": "set", "tensor": "W2", "index": [0, 0], "value": 0}, {"op": "set", "tensor": "W2", "index": [0, 2], "value": 0}]100%
Trained, no reasoning46[{"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%.

The prompt the model sees for this network
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.

Nothing to memorise

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.

One function, five sets of weights · target: Output min(x2 + x0, 8).

    Outputs identical on all 1,000 inputs
    Weights shown to 2 decimals. The gym also adds exactly cancelling neuron pairs, small noise and rounding.

    A statistics-only heuristic that resets or rescales the most unusual row, column or scalar repairs 4.0% of the in-distribution test networks.

    Results on six test sets

    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.

    Share of broken networks repaired, no reasoning
    Post-trained on TinkerUntrainedStatistics-only heuristic
    Whiskers: 95% bootstrap intervals over networks.

    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 setUntrainedTrainedHeuristicHealthy left alone
    In-distribution0.2%82.9% [79.4, 86.5]4.0%100%
    Larger networks than any in training0.0%70.0% [65.6, 74.3]1.9%94%
    Function families never trained on0.7%58.6% [53.6, 63.3]8.4%71%
    Fault types never trained on0.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%

    How it was trained on Tinker

    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.

    Validation repair rate during training
    Hand-built validation networksGradient-made validation networks
    The RL stage is drawn wider than its share of steps.
    1. Supervised, 900 steps × 64 networks (57,600 networks, half of them trained by gradient descent rather than compiled by hand). The target is the inverse of the planted fault.
    2. RL, 100 steps with the tinker-cookbook policy-gradient loop: 64 networks per step, 8 samples of each, rewards centred within each group. The reward is the behavioural score: +1 for [] 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))

    What made the difference

    ChangeMeasured onEffect
    Three times the supervised training dataIn-distribution repair57% → 80%
    Gradient-made networks added to trainingRepair on gradient-made networks14% → 67%
    RL on top of supervised trainingRepair, six test sets pooled; healthy networks left alone (larger networks)about +3 points; 79% → 94%

    Compared with what

    Setup The same test networks and prompts, given to other models and to methods that do not read weights as text.

    Repair rate against tokens generated per network
      Log token axis. Hollow points: other models off the shelf on the first 100 test networks, once told to answer at once and once free to reason (grey: closed; coloured: open-weights). Faint: more than a quarter of that model's answers were cut off at the token limit. Dashed lines: methods that generate no tokens.

      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%.

      MethodRepair rateTokens per networkSample
      Untrained Inkling 2 Small, free to reason75.6% [71.3, 79.6]~10,596422 faulty networks
      Trained Inkling 2 Small, no reasoning82.9% [79.4, 86.5]~38422 faulty networks
      Untrained Inkling 2 Small, no reasoning0.2% [0.0, 0.7]~223422 faulty networks
      Brute-force search over single sign flips and swaps, using forward passes65.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 edit0.7%—422 faulty networks
      Never edit0.0%—422 faulty networks

      Other models, off the shelf

      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.

      ModelWeightsTold to answer at once: repairedCut offTokens (of them reasoning)Free to reason: repairedCut offTokens
      Inkling 2 Small, post-trained on Tinkeropen79.5% [70.5, 87.5]0%~40 (0)not used——
      Inkling 2 Small, untrainedopen0.0% [0.0, 0.0]85%~22477.3% [68.2, 85.2]22%~10,797
      Inkling (first generation, larger)open3.4% [0.0, 8.0]0%~31 (0)30.7% [21.6, 40.9]64%~17,438
      Qwen3.8 2.4Topen10.2% [4.5, 17.0]81%~1,484 (1,412)60.2% [50.0, 70.5]38%~20,260
      DeepSeek V4 Proopen2.3% [0.0, 5.7]0%~34 (0)30.7% [21.6, 39.8]68%~17,670
      Kimi K3.1 Proopen8.0% [2.3, 13.6]7%~69 (0)not run (cost)——
      GLM-5.3open2.3% [0.0, 5.7]87%~505 (467)36.4% [26.1, 46.6]61%~16,822
      Muse Spark Openopen0.0% [0.0, 0.0]89%~500 (398)84.1% [76.1, 92.0]9%~8,110
      Mistral Large 4open0.0% [0.0, 0.0]100%~512 (511)30.7% [21.6, 40.9]63%~17,287
      Nemotron 3 Ultraopen3.4% [0.0, 8.0]0%~59 (0)28.4% [19.3, 37.5]64%~16,216
      Beam 1.0open0.0% [0.0, 0.0]99%~511 (509)50.0% [39.8, 60.2]49%~16,300
      GPT-6.1 Solclosed90.9% [84.1, 96.6]8%~195 (170)100.0% [100.0, 100.0]0%~437
      GPT-6 Astraclosed96.6% [92.0, 100.0]4%~139 (112)100.0% [100.0, 100.0]0%~382
      Claude Fable 5.2closed37.5% [27.3, 47.7]62%~447 (431)not run (cost)——
      Gemini 4 Carbonclosed62.5% [52.3, 72.7]5%~58 (25)96.6% [92.0, 100.0]4%~6,756
      Grok 4.7closed98.9% [96.6, 100.0]0%~11,278 (11,243)96.6% [92.0, 100.0]0%~35,728
      Claude Opus 5.5 *closed43.2% [33.0, 53.4]53%~438 (422)not run——
      Claude Sonnet 5.5 *closed5.7% [1.1, 11.4]69%~390 (5)not run——
      Claude Haiku 5.5 *closed0.0% [0.0, 0.0]0%~21 (0)not run——
      Gemini 4 Hydrogen *closed3.4% [0.0, 8.0]85%~442 (436)not run——
      GPT-6 Luna *closed3.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.

      With a verifier: eight proposals

      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.

      Share of faulty networks fixed within k verified answers
      In-distributionGradient-madescikit-learn8 random edits, verified
      Shaded bands: 95% intervals.

      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 fixedIn-distributionGradient-madescikit-learn
      One answer, no verifier82.9%66.7%51.3%
      Best of 8 verified answers90.5% [87.7, 93.1]77.2% [73.0, 81.4]65.1% [60.5, 69.6]
      8 random valid edits, verified7.3%8.2%10.4%
      Brute-force search over single sign flips and swaps65.2%63.5%64.8%
      Gradient descent on half of the inputs (no edit budget)61.4%71.5%74.9%

      RL alone, no labels: improving imperfect trained networks

      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.

      Propose and verify: test network 42000123 · 22 weights · target: Output min(x4 + x0, 12).
      Network accuracy
        The model's 8 proposals for one network; the best one that beats the unedited network is kept. On 59% of test networks none is kept.
        Share of a network's errors removed, against proposals checked
        RL-trained Inkling 2 SmallUntrained Inkling 2 SmallRandom valid editsRL, second run
        500 held-out imperfect networks; shaded bands are 95% intervals.

        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%.

        Proposer1 proposal8 proposalsNetworks 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%

        What did not work

        Pure RL from the base model: share of faulty networks answered with "no edit"
        lr 2e-4lr 6e-5lr 2e-5
        Three learning rates; at the lowest, no collapse but no improvement either.
        Change in test accuracy after the kept edit, 13 image classifiers
        The point far to the right is the broken model.

        What this does not show

        Credits and related work

        As far as we know, this is the first trained weight-space programmer that works from weights as text.

        Method details

        Reproduce it

        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