[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-116447":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":14,"stars7d":16,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":17,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":20,"topics":22,"createdAt":9,"pushedAt":23,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":15,"starSnapshotCount":15,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},116447,"AHA","Eppy-EpHard\u002FAHA","Eppy-EpHard","Weight-Space Programming Without LLMs",null,"Python",64,13,55,1,0,4,6,47.84,"MIT License",false,"main",[],"2026-11-18 10:12:18","2026-11-23 18:42:03","# AHA\n\n**Who needs an LLM to program an LLM?** AHA is self-supervised weight-space programming: weight-space programming\nwith no external language model in it at all.\n\nSmall reasoning models often repeat themselves until they run out of tokens and never answer. A rank-one change to two\nweight matrices stops this. Until now, finding that change has needed a frontier AI agent with read and write access\nto the weights. AHA builds the same kind of edit from the model's own samples and a linear program: no agent, no\ngradient step, no training run.\n\n**Blog post:** [*Who Needs an LLM to Program an LLM? Introducing AHA!*](https:\u002F\u002Fhaithamb.github.io\u002Faha\u002F) by Ahmed\nKhamis, Rasul Tutunov and Haitham Bou Ammar, November 2026.\n\n![One GSM8K question answered twice. The unedited model repeats a 505-character block 159 times and stops at the\n32,768-token limit without ever answering; the same checkpoint with 16,241 weights changed reaches 10 in 6,813\ntokens.](assets\u002Faha_before_after.gif)\n\n\u003Csub>GSM8K test item 235 ([MP4](assets\u002Faha_before_after.mp4)). Both transcripts are the real saved generations,\nabridged only where the clip says so. Of the 290 test questions where the unedited model runs out of tokens and the\nedited one answers correctly, this is the median by edited length — chosen by that rule rather than for effect. Across\nall 500, the unedited model hits the limit on 86.4%, and 99.5% of its wrong answers are that truncation rather than bad\narithmetic.\u003C\u002Fsub>\n\n---\n\n## Results\n\nEvery number here is held out:\n- The edit is built only from GSM8K-train and MATH-train traces.\n- IFEval (instruction following, no maths) never enters the pipeline.\n- One sample per problem at seed 0, with Barry's evaluation harness and grader.\n- The unedited and edited models were measured on the same machine.\n\nEach effect is given in standard errors (s.e.): the gap divided by its pooled standard error.\n\n| unedited → edited | GSM8K test (500) | MATH-500 | IFEval (541) |\n|---|---|---|---|\n| **Qwen3.5-0.8B** | 14.0 → **71.2** (+57.2, 18.3 s.e.) | 9.8 → **51.8** (+42.0, 14.4 s.e.) | 19.6 → **62.7** (+43.1, 14.4 s.e.) |\n| **Qwen3.5-2B** | 75.8 → **88.4** (+12.6, 5.2 s.e.) | 69.6 → **79.6** (+10.0, 3.6 s.e.) | 61.4 → **77.1** (+15.7, 5.6 s.e.) |\n\nWhere each number comes from:\n- **Direction:** every cell uses the matched-pair direction. The 0.8B cells use the first version of it, built from\n  continuations sampled at mixed presence penalties.\n- **Layers:** the 2B's GSM8K and MATH-500 edits also use the layers our search chose (2 and 4), so no language model\n  is involved in them at all.\n\nOn the 0.8B:\n- AHA's direction is level with the agent's own edit: the largest gap is 3.0 points, about 1 s.e.\n- It is ahead of Barry's LLM-free difference of means on all three benchmarks, by 2.3 to 5.8 points.\n\nThat is parity with the agent, not a win. [docs\u002FRESULTS.md](docs\u002FRESULTS.md) has every number with its run, its\nstandard error and its caveats, including everything that did not work.\n\n---\n\n## How it works\n\nThe edit adds a rank-one term to the MLP's `down_proj` in two layers:\n\n```\nW' = W + u vᵀ,   so that   W' h_t = W h_t + (v · h_t) u\n```\n\nAt every token the layer now writes one extra term along a fixed direction `u`. Its strength, `v · h_t`, depends on\nwhat the hidden units are doing at that token:\n- `u` decides where the push points.\n- `v` decides which units trigger it and how hard.\n\nWith 8 non-zero entries in `v`, 8 columns of `down_proj` change: at most 8,192 weights per layer in the 0.8B. The edit\nis Takehi et al.'s and the linear program is Barry's. What is new is that all three inputs (the direction, the\nneurons and the layers) now come from the model's own output.\n\n**1. The direction `u`: matched pairs.**\n1. Take a base answer that loops, and find its loop onset with Barry's detector.\n2. Cut the answer 8 tokens before the onset. Sample 8 continuations of up to 3,072 tokens from that identical prefix.\n3. Keep the prefix if at least one continuation loops and at least one does not. Pair the branch that starts looping\n   earliest with the productive branch that runs longest.\n4. Run both branches through the unedited model. At every layer, average the residual stream over the same 160\n   tokens of each branch, starting 64 tokens after the looping branch's onset, and subtract.\n5. `u` is the normalised mean of those differences over 80% of the pairs. The other 20% are held out to check it.\n\nBoth branches follow the same prefix, so the problem, the position and the length cancel and the behaviour is what is\nleft. Nobody labels anything: the detector finds the onsets, and the model writes both branches itself.\n\n**2. The neurons `v`: the linear program** (Barry's, unchanged).\n- Minimise Σ|v_j| subject to two constraints, each with a penalised slack:\n  - every looping token is pushed back along `u` by at least δ (`v · h_t ≤ −δ`);\n  - every productive token moves by at most ε (`|v · h_t| ≤ ε`).\n- Keep the 8 columns with the largest |v_j| · std(h_j), and solve again on those alone.\n- ε is 1. δ is four times the gap between how much of `u` the layer writes on looping tokens and on productive ones.\n\n**3. The layers: the layer search.**\n- Solve the linear program at every layer.\n- Rank the layers by hit rate: the share of held-out looping tokens pushed past −δ.\n- Break ties by how far held-out productive tokens move, relative to the push.\n- Edit the top two layers.\n\nThe rule was written down before any accuracy was seen, and it needs no evaluation run. Hit rates are close to 1 on\nmost layers, so the top pair is nearly a tie and can change between runs: one 0.8B run picked 9 and 21, another\npicked 7 and 13. Four comparisons of derived layers against the agent's layers found no detectable difference (at\nmost +1.5 points, 0.29 s.e.).\n\n### The sampling detail that decides whether it works\n\nThe evaluation protocol sets `presence_penalty=1.5`, which suppresses repetition. Resampling under it gave **12 loops\nin 1,800 continuations**, far too few to make pairs. AHA therefore draws every continuation at\n`presence_penalty=0`:\n- About 60% of continuations loop, and **228 of 300 prefixes** yield a matched pair.\n- Both branches of a pair come from the same sampler, so the contrast cannot pick up the sampler.\n\nThe penalty only shapes which tokens get sampled. The residuals are read by running finished text back through the\nunedited model.\n\n### Why matched pairs rather than better statistics\n\nA whitened (Fisher) direction separates looping tokens from productive ones better than any other direction we scored:\na held-out AUC of 0.953, against 0.895 for the plain difference of means. Yet it makes by far the worst edit: 21.9 on\nthe development split, against 64.1 for matched pairs. Pushing it 2.5× harder still gives 22.7.\n\nSo separability does not predict edit quality. What helps is a contrast whose two sides share everything except the\nbehaviour.\n\n---\n\n## Limits\n\n- **It removes an obstacle and adds nothing.**\n  - A trace that hits the token limit is almost always scored wrong. So the most an anti-loop edit can recover is the\n    share of problems the unedited model loses to the limit.\n  - Measure that cut-off rate first. It takes one generation pass, with nothing graded.\n  - The 2B hits the limit on 25–31% of problems and gains 10 to 16 points.\n  - On clinical multiple choice, the 0.8B barely loops and gains nothing detectable.\n- **Harder problems recover less.** On MATH-500 the 0.8B gains 60.5 points at level 1 and 20.1 at level 5.\n- **Scale beats editing.** The unedited 2B scores 69.6 on MATH-500, more than any edited 0.8B.\n- **The 0.8B held-out numbers come from our earliest build:** the mixed-penalty direction on the agent's layers.\n- **Machines disagree.** vLLM is not bitwise deterministic across GPUs, so every edit is compared against an unedited\n  model run on the same machine.\n\n---\n\n## Running it\n\nYou need a Linux machine with a GPU. One environment holds everything, vLLM included:\n\n```bash\nuv sync\nbash scripts\u002Fsetup.sh                                              # practice problems, Qwen3.5-0.8B and 2B\nuv run python scripts\u002Frun.py configs\u002Fqwen3.5-0.8b.json --dry-run   # every step, nothing run\nuv run python scripts\u002Frun.py configs\u002Fqwen3.5-0.8b.json\n```\n\nOn a GPU that other jobs are using, add `\"gpu_memory\"` to the config. It is vLLM's share of the whole card, so set it\na little under free \u002F total: for example, 0.22 for 20 GB free on an 80 GB H100.\n\n`run.py` runs these steps in order:\n1. A checkpoint of the base model.\n2. The base model's answers to the 512 practice problems the edit is built from.\n3. Matched pairs, then `u`.\n4. Activations, then the linear program at every layer.\n5. The edit on the top two layers, and a checkpoint of the edited model.\n6. Every benchmark, for the edited model and for the base model.\n7. The report.\n\nA step that finished is skipped next time, so a crashed run resumes. `--dry-run` prints the exact command of every\nstep.\n\nEverything goes in `runs\u002F\u003Cname>\u002F`:\n\n| | |\n|---|---|\n| `report.md`, `evals.csv`, `observations.json` | the results, and what the method built: the pairs, the direction's quality per layer, the layer ranking and its neurons, the edit |\n| `manifest.json`, `events.jsonl`, `gpu.csv`, `logs\u002F` | every step's command, timing and exit code; the machine and package versions; GPU use every 30 s; each step's full output |\n| `results\u002F\u003Carm>\u002F\u003Cbenchmark>\u002F` | every answer with its loop statistics, the scores, `summary.json` |\n| `traces\u002F`, `pairs\u002F`, `activations\u002F`, `layers\u002F`, `edits\u002F`, `checkpoints\u002F` | the intermediate products, step by step |\n\nThe configs score MATH-500. To score GSM8K test as well, add `\"gsm8k_test\"` to `\"benchmarks\"`. The IFEval numbers\nwere measured with the IFEval runner in Barry's code (`run_ifeval.py`), which this repository does not include.\n\nBuilding the direction takes about 22 minutes on one RTX 4090, once the base answers exist. Generating those 512\nanswers comes first and takes longer: about 1¾ hours on a shared H100. Barry reports the agent took 15 minutes to find\nits direction, so AHA is not faster. It removes the agent, not the time.\n\n## Layout\n\n```\nsrc\u002Faha\u002F\n  loops.py        the loop detector\n  model.py        load the model, hook its layers, read its weights, build vLLM checkpoints\n  direction.py    matched pairs → u\n  edit.py         activations → the linear program for v → layer ranking → W + u vᵀ\n  evals.py        MATH-500 and GSM8K, with loop statistics for every answer\n  report.py       what a run built and how the edit did → report.md\nscripts\u002F\n  run.py          the whole method from one config, every step logged\n  setup.sh        the practice problems and the base models, once\nconfigs\u002F          qwen3.5-0.8b.json, qwen3.5-2b.json\ndata\u002Fsplits.json  which practice problems the edit is built from\ndocs\u002F             RESULTS (every number), REVIEW, REPRODUCE (the traps), pre-registrations\nassets\u002F           the before\u002Fafter clip, as MP4 and GIF\n```\n\n## Citation\n\n```bibtex\n@misc{khamis2026aha,\n  title  = {Who Needs an LLM to Program an LLM? Introducing AHA!},\n  author = {Khamis, Ahmed and Tutunov, Rasul and Bou Ammar, Haitham},\n  year   = {2026},\n  month  = nov,\n  url    = {https:\u002F\u002Fhaithamb.github.io\u002Faha\u002F},\n  note   = {Blog post}\n}\n```\n\n## Credits\n\n**Takehi, Teoh, Zhang and Khattab.** The idea and the edit are theirs:\n[Sparks of Weight-Space Programming](https:\u002F\u002Frikiyat.github.io\u002Fblog\u002Fweight-space-programming\u002F). They released their\nagent's complete logs, which made every claim about the agent checkable. The grading in `evals.py` comes from their\ncode, and `scripts\u002Fsetup.sh` downloads the practice problems from their logs (CC BY 4.0).\n\n**Nathan Barry.** The linear program and the evaluation harness are his:\n[Can a Linear Program Do Weight-Space Programming?](https:\u002F\u002Fnathan.rs\u002Fposts\u002Fweight-space-lp\u002F)\n([code](https:\u002F\u002Fgithub.com\u002Fnathanrs\u002Fweight-space-lp)). Several parts of `src\u002Faha\u002F` are adapted from his code:\n- the loop detector;\n- the model hooks and the checkpoint builder;\n- the activation collection;\n- the linear-program solver;\n- the maths harness.\n\n`data\u002Fsplits.json` is his split of the practice problems.\n\n**Timothy Chen** pointed us to the linear-program work.\n\n**AHA's contribution** is the matched-pair direction and the layer search.\n\n## License\n\nMIT; see [LICENSE](LICENSE). It also carries the MIT notices of the code adapted from Barry and from Takehi et al.\n","AHA 是一个无需大语言模型（LLM）参与的权重空间编程框架，旨在通过纯自监督方式对小型推理模型进行轻量级权重编辑，以解决其在数学推理任务中因重复生成而耗尽上下文长度的问题。其核心技术是基于模型自身采样轨迹构建线性规划问题，仅需对两个权重矩阵施加秩一更新（约1.6万参数变更），不依赖梯度优化、微调或外部AI代理。适用于提升小型开源语言模型（如Qwen3.5系列）在GSM8K、MATH等数学推理及IFEval指令遵循任务上的泛化表现，特别适合资源受限场景下的模型行为矫正与能力增强。",2,"2026-11-24 04:53:32","CREATED_QUERY"]