Research log Small Model Experimentation
GitHub

Qwen Slot Repair Distillation

Fixable programs exist; the editor can't find them

The one idea you need

A model writes short number-crunching programs that run correctly only about a quarter of the time. A fix almost always sits one or two small edits away. But a helper must spot which pieces are wrong from the program alone, with no answer key to check against.

The question

If a computer usually writes a slightly-wrong program, can a small model learn to spot and fix the few wrong pieces on its own, without ever seeing the answer?

What we found

No. A correct program almost always sits one or two edits away — a search that peeks at the answer lifts solve rates from about a quarter to roughly 86%. But the blind helper couldn't pick which edits to make: on reworded problems it dropped accuracy from 25% to 19%, and on fresh problems it barely moved. It only helped on the exact problems it was tuned on.

Why it matters

Before bolting a learned fixer onto a model's output, test it on fresh and reworded inputs, and keep a do-nothing baseline. A high "a fix exists nearby" ceiling proves fixes are reachable — not that a blind one-shot patcher can find them.

Fixes are almost always reachable25% → 86%a search that checks the answer lifts solve rate this far above the base program
Reworded problems after editing25% → 19%the helper made paraphrased problems worse, not better
Tuning-set accuracy after editing33% → 35%the only split where editing helped, and only slightly
Same answer to both phrasings70% → 38%editing nearly halved agreement across two wordings of a problem
On this page
  1. Results at a glance
  2. Overview
  3. Report
    1. Abstract
    2. Setup
    3. Results
    4. Interpretation
    5. Limitations
    6. Artifacts
  4. Experiment log
  5. Figures
  6. Data files
  7. Reproduce
  8. Related

Results at a glance 6

Editor helps only on its tuning set, not on new problems

How to read

Grouped bars of how often programs run correctly across four problem sets — the tuning set plus three sets of fresh problems. Each set has three bars: the untouched base program, the trained editor's fix, and the answer-key repair ceiling. Higher is better.

0%25%50%75%100%validationvalidation32.8%35.2%85.2%fresh standardfresh standard28.5%27.7%87.1%fresh paraphrasefresh paraphrase25%18.8%85.2%fresh pairedfresh paired25.4%24.8%86.1%

Takeaway → The editor bar tops the base only on the tuning set; on every fresh set it ties or dips below, all far under the roughly 85% ceiling.

Data table
Evaluation splitfrozen base compilerdistilled slot editorlocal repair oracle
validation32.8%35.2%85.2%
fresh standard28.5%27.7%87.1%
fresh paraphrase25%18.8%85.2%
fresh paired25.4%24.8%86.1%

Numbers from experiments/qwen_slot_repair_distillation/analysis/final_metrics.csv (run main_slot_repair_distill_s512)

Technical framing

Slot-repair editor vs frozen compiler vs local-repair oracle — The editor beats the frozen base only on validation; on fresh prompts it matches or hurts, far below the ~85% oracle ceiling.

How much of the fixable gap the editor actually closed

How to read

One bar per problem set showing the share of the base-to-ceiling gap the editor captured. Positive means it fixed programs; negative means it broke them; zero is doing nothing. Higher is better.

-15%-10%-5%0%5%10%traintrain6.4%validationvalidation4.5%fresh standardfresh standard-1.3%fresh paraphrasefresh paraphrase-10.4%fresh pairedfresh paired-1%

Takeaway → Bars are positive on the training and tuning sets but turn negative on all three fresh sets, worst at minus ten percent on rewordings — the skill doesn't transfer.

Data table
Evaluation splitgap recovered
train6.4%
validation4.5%
fresh standard-1.3%
fresh paraphrase-10.4%
fresh paired-1%

Numbers from experiments/qwen_slot_repair_distillation/analysis/summary.md table

Technical framing

Share of the base-to-oracle gap the editor recovers, by split — Positive gap recovery on train/validation flips negative on every fresh distribution - the learned repair signal does not transfer.

Editor only edges past the baseline on the final round

How to read

A line of the editor's tuning-set accuracy across 18 training rounds against a flat line for the untouched base program. Above the flat line is better; higher means more programs run correctly.

10%20%30%40%51015distilled slot editordistilled slot ed…frozen base compilerfrozen base compi…

Takeaway → The editor line bounces between 13% and 35% and only clears the flat base line on the last round — the win is fragile, not a settled skill.

Data table
Training epochdistilled slot editorfrozen base compiler
113.3%32.8%
226.6%
322.7%
428.1%
531.2%
629.7%
729.7%
830.5%
927.3%
1022.7%
1130.5%
1218.8%
1315.6%
1430.5%
1519.5%
1632.8%
1727.3%
1835.2%32.8%

Numbers from experiments/qwen_slot_repair_distillation/runs/main_slot_repair_distill_s512/editor_train_log.csv

Technical framing

Editor validation accuracy across training epochs — The editor only overtakes the frozen base at the final epoch, and the curve is noisy - the validation gain is marginal, not a stable capability.

Editing makes answers more sensitive to wording

How to read

For pairs of prompts asking the same question two ways, bars for the base program, the answer-key repairs, and the editor. Two series: giving the same answer to both wordings, and getting both right. Higher is better.

0%25%50%75%100%Base compilerBase compiler69.5%23.4%Local-repair oracleLocal-repair oracle88.3%84%Slot editorSlot editor37.9%16.8%

Takeaway → The editor's same-answer bar falls to about 38% from the base's 70%, while answer-key repairs lift it to 88% — the editor's patches make rewordings disagree.

Data table
Program source (fresh paired split)Same answer on both phrasingsBoth phrasings correct
Base compiler69.5%23.4%
Local-repair oracle88.3%84%
Slot editor37.9%16.8%

Numbers from experiments/qwen_slot_repair_distillation/analysis/all_final_metrics.csv

Technical framing

Editing breaks paraphrase consistency on paired prompts — The editor nearly halves cross-paraphrase answer agreement (69.5% to 37.9%), while oracle repairs raise it to 88.3%.

No editor recipe wins on both the tuning set and fresh problems

How to read

For six editor setups, paired bars compare tuning-set accuracy against fresh-problem accuracy. Higher is better; a good recipe would raise both bars together.

0%10%20%30%40%distill b3 w8 (96ex)distill b3 w8 (96ex)18.8%10.9%distill b5 (96ex)distill b5 (96ex)29.2%31.2%gated (96ex)gated (96ex)31.2%34.4%gated oracle-base (96ex)gated oracle-base (96ex)22.9%23.4%gated value-stabilized (96ex)gated value-stabilized (96ex)27.1%35.9%main distill (512ex)main distill (512ex)35.2%27.7%

Takeaway → No setup wins both — the main run tops tuning accuracy at 35% yet a smaller value-stabilized pilot beats it on fresh problems, 36% versus 28%.

Data table
Editor configurationValidation accuracyFresh standard accuracy
distill b3 w8 (96ex)18.8%10.9%
distill b5 (96ex)29.2%31.2%
gated (96ex)31.2%34.4%
gated oracle-base (96ex)22.9%23.4%
gated value-stabilized (96ex)27.1%35.9%
main distill (512ex)35.2%27.7%

Numbers from experiments/qwen_slot_repair_distillation/analysis/all_final_metrics.csv

Technical framing

Pilot ablations: no editor variant wins on both validation and fresh prompts — The 512-example main run is best on validation (35.2%) but pilots like value-stabilized beat it on fresh prompts (35.9% vs 27.7%).

The model never reliably learns which parts to change

How to read

Two lines across 18 training rounds: how precisely the editor targets the parts to change (of edits it makes, how many were right) and how completely (of needed edits, how many it made). Higher and steadier is better.

20%40%60%80%51015Gate precision (val)Gate precision (v…Gate recall (val)

Takeaway → Precision swings between 45% and 71% round to round and never settles — the choice of which few parts to edit stays unreliable throughout training.

Data table
Training epochGate precision (val)Gate recall (val)
137.3%62.5%
260.3%59.9%
351%66.4%
465.3%63.2%
561.4%51.3%
671%57.9%
766.2%61.8%
865.6%56.6%
959%62.5%
1051%65.1%
1160.4%63.2%
1245.3%70.4%
1348.9%70.4%
1457.1%61.2%
1545.2%67.8%
1668.7%59.2%
1766.4%56.1%
1866%65.1%

Numbers from experiments/qwen_slot_repair_distillation/runs/main_slot_repair_distill_s512/editor_train_log.csv

Technical framing

Edit-gate precision never stabilizes during training — Which-slot-to-edit precision oscillates between 45% and 71% across 18 epochs, so the sparse edit decision never becomes reliable.

In the author’s words from the Report · “Abstract”

This experiment tests whether local repair headroom can be distilled into a gated slot editor for a frozen Qwen-attached numeric compiler. The compiler first emits an executable modular-arithmetic program. Offline candidate search identifies a corrected local program when one exists. A small transformer editor is then trained to decide which init/op/arg slots to edit and what replacement values to emit from the base compiler trace, without candidate enumeration at evaluation time.

Overview

This standalone experiment tests whether local repair headroom can be distilled into a deployable gated slot editor for a frozen Qwen-attached numeric compiler. The compiler emits an executable modular-arithmetic program. Offline local repair search supplies corrected-program labels when available, and the editor learns to decide which init/op/arg slots to edit plus what replacement values to emit from the base compiler trace.

At evaluation time, the editor emits one program. It does not receive target answers, target states, or a candidate list to rerank.

Small experiment files live here:

experiments/qwen_slot_repair_distillation/

Large checkpoints live separately:

large_artifacts/qwen_slot_repair_distillation/checkpoints/

Main Result

The primary run was main_slot_repair_distill_s512.

SplitBaseEditorOracle
validation32.8%35.2%85.2%
fresh standard28.5%27.7%87.1%
fresh paraphrase25.0%18.8%85.2%
fresh paired25.4%24.8%86.1%

The editor learned a validation signal but did not transfer cleanly to fresh prompt distributions. The local oracle ceiling stayed high, so nearby corrected programs usually exist; the failure is the one-shot policy's ability to select the right sparse edits and values from the base trace alone.

Primary Command

python experiments/qwen_slot_repair_distillation/src/qwen_slot_repair_distillation_experiment.py \
  --run_name main_slot_repair_distill_s512 \
  --train_examples 512 \
  --val_examples 128 \
  --eval_examples 256 \
  --eval_pairs 256 \
  --repair_topk 3 \
  --repair_max_edits 2 \
  --repair_max_pair_arg_slots 24 \
  --qwen_batch_size 8 \
  --editor_d_model 128 \
  --editor_layers 3 \
  --editor_heads 4 \
  --editor_ff_mult 4 \
  --editor_epochs 18 \
  --editor_lr 0.001 \
  --editor_target_mode oracle_or_gold \
  --changed_slot_weight 4.0 \
  --unchanged_value_loss_weight 0.05 \
  --edit_gate_pos_weight 8.0 \
  --edit_threshold_grid 0.15,0.2,0.25,0.3,0.4,0.5,0.6,0.7 \
  --max_length 384 \
  --seed 66 \
  --eval_seed 66001

Analysis

python experiments/qwen_slot_repair_distillation/src/analyze_qwen_slot_repair_distillation.py

Key outputs:

Report

Rendered from reports/qwen_slot_repair_distillation_paper.md

Abstract

This experiment tests whether local repair headroom can be distilled into a gated slot editor for a frozen Qwen-attached numeric compiler. The compiler first emits an executable modular-arithmetic program. Offline candidate search identifies a corrected local program when one exists. A small transformer editor is then trained to decide which init/op/arg slots to edit and what replacement values to emit from the base compiler trace, without candidate enumeration at evaluation time.

Setup

  • Primary run: main_slot_repair_distill_s512
  • Qwen substrate: Qwen/Qwen3-4B
  • Modulus: 97
  • Max program length: 24
  • Best editor epoch: 18
  • Best validation threshold: 0.7
  • Editor target mode: oracle_or_gold
  • Unchanged-slot value loss weight: 0.05

Training labels come from exact offline trajectories. At evaluation time, the editor receives only the base compiler trace and predicts a single program. The oracle column is the local candidate-search ceiling, not an inference method.

Results

Fresh Splits

SplitBaseEditorOracleGap recoveredEditor in candidates
fresh_standard_len2428.5%27.7%87.1%-1.3%49.6%
fresh_paraphrase_len2425.0%18.8%85.2%-10.4%34.8%
fresh_paired_len2425.4%24.8%86.1%-1.0%43.9%

Executor accuracy

Fresh Paired Details

MetricBaseEditorOracle
Executor accuracy25.4%24.8%86.1%
Program exact25.4%24.8%85.7%
State prefix fraction52.3%53.4%88.7%
Pair both-correct23.4%16.8%84.0%
Pair state consistency69.5%37.1%88.3%

The final paired editor uses 1.17 edits per program on average. Against its training target definition, gate precision is 66.9% and gate recall is 59.7%.

Paired details

Training Dynamics

The training curve tracks validation accuracy after each editor epoch.

Training curve

Iteration Summary

The direct full-slot editor either copied the base program or damaged too many slots. The gated editor fixed that interface problem, and a small unchanged-slot value loss made one pilot improve fresh paired accuracy. The larger primary run did not preserve that fresh-split gain.

RunValidationFresh paired baseFresh paired editorFresh paired oracleAvg edits
pilot_slot_repair_distill_s96_b529.2%->29.2%25.8%25.8%88.3%0.00
pilot_slot_repair_distill_s96_b3_w833.3%->18.8%28.9%10.9%83.6%2.40
pilot_slot_repair_gated_s9625.0%->31.2%30.5%28.1%86.7%0.18
pilot_slot_repair_gated_s96_oracle_base20.8%->22.9%24.2%20.3%87.5%0.84
pilot_slot_repair_gated_s96_value_stabilized20.8%->27.1%28.1%32.8%88.3%0.39
main_slot_repair_distill_s51232.8%->35.2%25.4%24.8%86.1%1.17

Iteration summary

Interpretation

On the fresh paired split, the editor moves exact execution from 25.4% to 24.8%. The local oracle ceiling is 86.1%, so the editor recovers -1.0% of the measured base-to-oracle gap.

The main result is therefore not a successful distillation of the local oracle. The editor learns a real validation signal, but its selected edits do not transfer robustly to fresh prompt distributions. The high oracle ceiling shows that nearby corrected programs usually exist; the failure is the one-shot policy's ability to choose the right sparse edits and values from the base trace alone.

Limitations

  • The task is synthetic modular arithmetic.
  • Candidate labels use exact trajectories during training.
  • The frozen compiler and deterministic runtime are specialized.
  • The editor consumes engineered base-trace features, not only raw Qwen hidden states.
  • The main result is one primary seed.
  • The deployable editor emits one program and does not get to evaluate candidate executions at inference time.

Artifacts

Small experiment files live in:

experiments/qwen_slot_repair_distillation/

Large artifacts live in:

large_artifacts/qwen_slot_repair_distillation/checkpoints/

Primary files:

Experiment log 9

Show the running log (9 entries)

Objective

Train a deployable slot editor that distills local repair headroom into direct corrected-program predictions for a frozen Qwen-attached numeric compiler. At evaluation time, the editor emits one program and does not receive target answers, target states, or a candidate list to rerank.

File Layout

Success Criteria

  • Keep source, runs, analysis, reports, and manifest in this experiment directory.
  • Store bulky checkpoints under large_artifacts/qwen_slot_repair_distillation/.
  • Evaluate base compiler, deployable editor, and local oracle ceiling.
  • Run smoke, pilot, and main configurations.
  • Iterate when a design fails rather than one-shotting the final run.
  • Produce CSVs, figures, a markdown report, and an HTML report.

Implementation Iterations

Direct Full-Slot Editor

The first editor predicted every init/op/arg slot directly.

  • smoke_slot_repair_distill: path check passed, but the model changed many slots and destroyed accuracy.
  • smoke_slot_repair_distill_bias: adding base-copy logit bias made the editor copy the base program.
  • pilot_slot_repair_distill_s96_b5: copied the base program; fresh paired stayed 25.8% -> 25.8%.
  • pilot_slot_repair_distill_s96_b3_w8: edited too aggressively; fresh paired fell 28.9% -> 10.9%.

Conclusion: full-slot prediction is the wrong deployable interface. It lacks an explicit decision about whether a slot should be edited.

Gated Edit Policy

The second editor predicts edit gates separately from replacement values. It starts from the base program, then applies only slots whose gate probability passes a validation-selected threshold.

  • smoke_slot_repair_gated: path check passed.
  • pilot_slot_repair_gated_s96: validation improved 25.0% -> 31.2%, but fresh paired fell 30.5% -> 28.1%.
  • pilot_slot_repair_gated_s96_oracle_base: using copy-base fallback for no-oracle examples was too conservative and still hurt fresh paired 24.2% -> 20.3%.
  • pilot_slot_repair_gated_s96_value_stabilized: adding a small unchanged-slot value loss stabilized false-positive edits. Fresh standard improved 28.1% -> 35.9%, paraphrase 23.4% -> 25.0%, and paired 28.1% -> 32.8%.

Conclusion: gated editing plus weak unchanged-slot value supervision was the only pilot worth scaling.

Primary Run

Run: main_slot_repair_distill_s512

Configuration:

  • 512 train examples
  • 128 validation examples
  • 256 fresh standard examples
  • 256 fresh paraphrase examples
  • 256 paired programs, evaluated as 512 paired prompt variants
  • top-3/two-edit local teacher
  • gated edit policy, 128 hidden width, 3 layers
  • editor_target_mode=oracle_or_gold
  • unchanged_value_loss_weight=0.05
  • validation threshold grid: 0.15,0.2,0.25,0.3,0.4,0.5,0.6,0.7

Final selected checkpoint:

  • best epoch: 18
  • best threshold: 0.7

Main metrics:

SplitBaseEditorOracleGap recovered
train_len2427.5%31.2%85.4%6.4%
val_len2432.8%35.2%85.2%4.5%
fresh_standard_len2428.5%27.7%87.1%-1.3%
fresh_paraphrase_len2425.0%18.8%85.2%-10.4%
fresh_paired_len2425.4%24.8%86.1%-1.0%

Fresh paired diagnostics:

  • editor average edits per program: 1.17
  • editor gate precision: 66.9%
  • editor gate recall: 59.7%
  • editor pair both-correct: 16.8% versus base 23.4%
  • editor pair state consistency: 37.1% versus base 69.5%

Interpretation

The main run is not a successful local-oracle distillation. The editor learned a validation signal but did not improve fresh distributions. The high local oracle ceiling means the repair headroom is real; this experiment shows that a single feed-forward gate/value policy over engineered base traces is not enough to recover that headroom robustly.

The most useful next direction is likely not a larger version of this exact editor. A stronger follow-up should keep some form of execution-grounded selection at inference time, or train the Qwen-attached compiler on on-policy repair traces so the base compiler itself moves toward repairable/correct programs instead of relying on a small post-hoc editor.

Final Artifacts

  • Markdown report: reports/qwen_slot_repair_distillation_paper.md
  • HTML report: reports/qwen_slot_repair_distillation_paper.html
  • Summary: analysis/summary.md
  • Main metrics: runs/main_slot_repair_distill_s512/metrics.csv
  • Main train log: runs/main_slot_repair_distill_s512/editor_train_log.csv
  • Figures: analysis/figures/
  • Checkpoint manifest: checkpoint_manifest.csv

Figures 4

executor accuracy
executor accuracy · analysis/figures/
iteration summary
iteration summary · analysis/figures/
paired details
paired details · analysis/figures/
training curve
training curve · analysis/figures/

Data files 20

Result tables and metrics copied from the experiment folder — preview inline or open the raw file.

Reproduce

The run commands are documented inside the experiment folder (see the README).

Browse the experiment folder on GitHub ↗