Weight-space programming · Qwen · Reproducible experiment

Can an LLM improve Qwen by editing its weights?

Reproduce the published Qwen weight edit, inspect a nine-case agent-grader experiment, and compare saved edits with the original model and random controls.

As of 2026-11-04

What happened

I used Codex to edit a Qwen3.5-9B agent grader. One repeated-output failure stopped. The final checkpoint matched 5/9 development grades versus 6/9 for the original. An earlier targeted edit and its random control tied at 7/9.

Inspect the results below, then download the scripts to reproduce my separate four-problem control of the published Qwen3.5-0.8B edit. All nine grader cases were exposed during development. The reserved validation and test sets stayed untouched.

The edited grader answered faster on one failure and lost a grade overall

Strict grade matches on the same nine development cases

Scale: 0 to 6 · zero baseline

Whole nine-case development set

  • Original Qwen3.5-9B+6
  • Final cumulative edit c7+5

Plan critic, three cases

  • Original+2
  • c7+3

Executor critic, three cases

  • Original+2
  • c7+1

Whole-run critic, three cases

  • Original+2
  • c7+1

All three critics received the same frozen inputs, rubric and labels across these model states. Each critic has three cases. These counts measure grade matches, not correct explanations.

Show the table · 9 rows, 5 columns

Scroll sideways to compare all columns. Select a heading to sort.

Paper-trading explanationWhole runGOODGOODGOOD
Drawdown versus volatilityWhole runBADREPAIRREPAIR
QQQ condition omittedWhole runREPAIRREPAIRGOOD
Duplicate portfolio creationExecutorREPAIRGOODGOOD
Return calculation from dates and P/EExecutorBADBADInvalid JSON
Authorized researchExecutorGOODGOODGOOD
Financial screening planPlanGOODBADGOOD
Bollinger/SMA planPlanREPAIRREPAIRREPAIR
SSO planPlanBADBADBAD

These are the recorded nine-case results. Invalid JSON is a failure even if the text suggests the intended grade. Case descriptions replace private trace identifiers.

I needed a grader for three moments in an agent loop: a proposed plan, an executor decision and a completed run. Each response had to return GOOD, REPAIR or BAD, with evidence, a reason and an appropriate repair.

The final plan critic matched all three labels. On the Bollinger/SMA case, it still invented a prohibition against upper-band breakout logic. The actual defect was unconfirmed band selection, direction and crossing semantics. Matching the grade did not make that explanation correct.

The repeated table stopped. The false GOOD survived.

Time spent on the same repeating executor request

Scale: 0 to 2,216 seconds · zero baseline

One executor response

  • Parent c2, no completed grade+2,216 seconds
  • Child c7, completed response+151 seconds

This is one observed failure case. The parent exhausted 32,768 output tokens; c7 completed 961 tokens. These timings do not establish a general throughput benchmark.

The parent checkpoint copied a financial table repeatedly until its output allowance ended. I continued from that actual saved checkpoint and restored 16 selected columns per edited layer. The other 1,008 edited columns per layer remained exactly as saved.

The child completed the response in about 2.5 minutes. It still accepted invented returns as GOOD and repeated JSON keys in its evidence object. A matched random rollback repeated the table again and lost the earlier source-attribution improvement. This contrast is evidence about that case; it does not establish a generally better grader.

Same executor request

c2: table → same table → same table → output limit
    2,216 seconds · 32,768 tokens · no completed grade

c7: table → completed response → intended GOOD
      151 seconds ·    961 tokens · reviewed label BAD
    Duplicate source_id/quote keys also fail strict JSON validation.

What “typing the weights” actually changes

The published work by Rikiya Takehi, Jayden Teoh, Alex Zhang and Omar Khattab includes several experiments. A small Breakout policy was written directly. The Qwen experiment used a Python workspace and forward-pass tools to inspect a pretrained model and save changed tensors. Those are different experiments.

In the Breakout reply, the following statements assign actual entries in a weight matrix and bias vector. The network then uses those numbers during inference.

Python
# Two exact statements from Astra’s published Breakout reply.
W2[0, 0:2] = [-1000, 1000]
b2[0:8] = -415

First, I reconstructed the published Qwen edit

Correct answers in my four-problem public practice control

Scale: 0 to 3 of 4 · zero baseline

Qwen3.5-0.8B, MLX runtime

  • Original+1 of 4
  • Published p50c edit+3 of 4

The same two GSM8K train and two MATH train problems, selected with seed 20261104 before inference. The edited tensors match the authors’ published hashes.

Show the table · 4 rows, 4 columns

Scroll sideways to compare all columns. Select a heading to sort.

gsm8k_train_60711200Output limitCorrect
gsm8k_train_51791360Output limitCorrect
math_train_algebra_17308Output limitOutput limit
math_train_geometry_18665CorrectCorrect

These problem identifiers and paired results are included in the public reproduction package.

Two answers that had reached the output limit finished correctly after the published edit. One problem still reached the limit in both states. A fourth was correct in both.

The authors reported 7.9% versus 48.1% on MATH-500 using their evaluation setup. My four-problem control checks reconstruction and a small observable behavior change. It does not recreate their full benchmark.

Reproduce the public control on an Apple Silicon Mac

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
git clone https://github.com/RikiyaT/lm_understand-logs.git upstream
git -C upstream checkout 4d09ba6d6a7e891dd8063974dfe81b3d78e3494f
python download_control.py
python prepare_control.py
python run_control.py --arm base
python run_control.py --arm published-edit

Scroll horizontally to read the full command, or copy it.

Download and unzip the reproduction package. It contains the actual download, reconstruction and MLX inference scripts, pinned dependencies, expected tensor hashes and observed results. Use Python 3.12, git, about 8 GB of free disk and 24 GB of available unified memory for the configured adapter cap. Run the two model arms sequentially.

The commands download the public model and run inference on your Mac. They do not use a paid model API. Repeated answers can make the 32,768-token protocol slow; let a deliberate reproduction finish under its recorded limit.

Step 1 of 3

Verify the edit before generating

Run prepare_control.py and inspect reconstruction-verified.json. It calls the authors’ unchanged reconstruction script and checks every tensor.

What you should see

The p50c edit changes two tensors. The remaining 486 tensors stay unchanged. Both changed tensor hashes must match the expected reconstruction file.

Step 2 of 3

Compare the actual answers

Open outputs/base/ and outputs/published-edit/. Compare each case’s output, extracted answer, correct flag and finish_reason.

What you should see

My run scored 1/4 and 3/4. Your recorded generations establish your outcome; matching weights alone does not guarantee identical sampled text.

Step 3 of 3

Keep the protocol fixed

Use thinking on, temperature 0.6, top_p 0.95, top_k 20, presence penalty 1.5 and seed 0. The supplied adapter checks sampling semantics against NumPy.

What you should see

The run records package versions, model hashes and prompt-token hashes with each response. MLX and the authors’ vLLM setup can produce different random samples and kernel behavior.

Apply the method to your own agent grader

For the 9B branch, I used Qwen/Qwen3.5-9B at revision c202236235762e1c871ad0ccb60c8ee5ba337b9a. I constructed an attribution direction from paired forward-pass activations, applied it to MLP down-projection weights at layers 15 and 22, and saved each edited checkpoint. No gradient optimizer ran.

The equation below describes the starting edit. W is the parent matrix, u is a normalized direction derived from the observed activation contrast, and alpha controls the edit strength. Arithmetic runs in float32 before the saved values are rounded to BF16. An arbitrary direction or copied layer number is not a validated correction for a different model.

Step 1 of 4

Freeze your labeled development inputs

Use your own consented traces with a fixed rubric. Keep the same request, compact tool history, capability context, attachments and reviewed label across comparisons. Save the original model outputs first.

What you should see

Every model state sees identical evidence. Keep separate validation and test sets unread during edit search.

Step 2 of 4

Measure a failure and propose an edit

Inspect a real wrong grade or repeated-output case. Use forward-pass probes and contrastive activations to form a specific weight-edit hypothesis. Save the tensor names, formula and parent hash before evaluating.

What you should see

The edit has an explicit relationship to an observed failure. A preference-probe improvement is recorded separately from a correct full grading response.

Step 3 of 4

Evaluate the saved child and matched control

Reload the actual saved weights. Run complete single-call responses with frozen generation settings. Compare the child with its parent, the original and a random control matched for edit size.

What you should see

Score format, grade, evidence, reasoning and repair separately. A grade that happens to match while citing an invented rule remains a reasoning error.

Step 4 of 4

Reserve the final test for a selected candidate

Select on development evidence, then evaluate once on a previously unused comparison. Use the held-out test only after the candidate and scoring protocol are fixed.

What you should see

A result describes the cases actually evaluated. In my experiment, the candidate still failed development cases, so the test remained reserved.

Python
# Weight-space projection used for the starting 9B intervention.
# u comes from the measured attribution activation contrast.
W_child = BF16(FP32(W_parent) - alpha * u[:, None] * (u @ FP32(W_parent))[None, :])

# Continue from saved numerical values.
# Original → c0-source-a4 → c2-source-selective1024 → c7-loop-rollback16
# A cumulative child already contains its inherited edits.
# Load the original model plus ONE selected cumulative overlay.

The random control and the checkpoint lineage matter

In an earlier edit-search round, the targeted intervention and a matched random intervention returned the same grade vector and both matched 7/9 labels. That comparison did not establish a targeted grading benefit.

The later cumulative search produced nine saved checkpoints and 34 completed grading responses. Each child retained its named parent’s numerical edits. Partial trials used different numbers of cases, so their partial counts should not be ranked against complete nine-case runs. The complete final c7 run matched 5/9 labels.

Show the table · 10 rows, 4 columns

Scroll sideways to compare all columns. Select a heading to sort.

base96Original baseline
c0-source-a493Cumulative development trial
c1-source-damped20Cumulative development trial
c2-source-selective102495Cumulative development trial
c3-source-selective25610Cumulative development trial
c4-source-selective51210Cumulative development trial
c5-source-selective76810Cumulative development trial
c6-source-delta09010Cumulative development trial
c7-loop-rollback1695Final complete candidate
c8-loop-random-control10Cumulative development trial

Completed-output counts vary. An aborted or unfinished generation is not a successful grade. The public JSON includes these aggregate observations.

What you can verify and what remains private

The downloadable package reproduces the public four-problem control. It pins the original paper’s repository and Qwen0.8B revision, reconstructs the exact edited tensors, and records full local generations. The grader results JSON exposes the aggregate outcomes and anonymized nine-case grade comparisons.

The original agent conversations, attachments and proprietary grader construction inputs remain private. To run the 9B workflow on your own task, supply your own reviewed traces and frozen labels. Those inputs determine the activation contrast and the appropriate edit. The public control and the private agent-grading experiment answer different questions.

This experiment used the local Mac GPU. New paid model API and GPU rental spend was $0. Codex subscription usage and local electricity are separate costs. No supervised fine-tuning, reinforcement learning or production deployment occurred in this batch.

Reproduction ZIP SHA-256
74b48453e8f77db7cdb68c2605d45a844ace8db0ea1455dafca0769bfc708dd0

Original public repository commit
4d09ba6d6a7e891dd8063974dfe81b3d78e3494f

Qwen3.5-0.8B base revision
2fc06364715b967f1860aea9cf38778875588b17

Discussion

Sign in or create a free account to join the discussion.

No comments yet.