Normally a neural network gets its weights from training. You show it data, and gradient descent slowly adjusts millions of numbers until the model works.
A new project from MBZUAI skips that step. Researchers asked Claude Opus 5.5 to write every weight of a small transformer by hand, with no training at all. The transformer has one block of 19,936 weights that runs in a loop. On Maze-Hard, a benchmark of 30x30 mazes, it solves 100% of the test mazes. Claude itself, asked to solve the same mazes directly, solves 26%.
The work is called Looped Weight-Space Programming, by Abdelrahman Elsayed, Ahmed Heakl, Abdelrahman Shaker, Fahad Khan and Salman Khan, with Claude Opus 5.5 listed as a co-author. It was published as a blog post on November 23, 2026, with weights and code on GitHub under the MIT license.
I have not run the code or the demos. Everything below comes from the project's post, and all numbers are the authors' results. It is a blog post, not a peer-reviewed paper.
The short version
- The idea: an LLM that cannot solve a long problem step by step can still write one step of the algorithm into transformer weights. A loop then repeats that step as many times as the problem needs.
- Maze-Hard: the 19,936-weight written transformer solves 100% of test mazes. The best trained model the authors cite, LDT, solves 99.8% with 1.8 million weights. Frontier LLMs solve at most 26%.
- Cost: writing the maze transformer took Claude 39 minutes and about $19 at API list prices.
- Training could not find it: the same architecture, trained from random weights on the same mazes, solved 0% in every run.
- It goes beyond mazes: written transformers also solved Sudoku-Extreme, a 20-disk Tower of Hanoi (1,048,575 moves), million-token GraphWalks prompts and several BIG-Bench tasks, each at 100% on the test sets used.
- The catch: this only works when you already know the algorithm. It is not a way to build a general language model.
What "weight-space programming" means
A trained transformer is, in the end, just a program stored as matrices. If you know exactly what program you want, you could in theory write those matrices yourself.
People have done this before, at small scale. The post credits hand-built examples, compilers like Tracr that turn short programs into transformer weights, and recent work from MIT CSAIL showing that a frontier LLM can edit a model's weights directly.
The problem with earlier LLM-written transformers was size. Each step of a computation needed its own block. A maze with a 110-step path would need a huge transformer, and Claude would have to write every weight in it.
The fix is the loop. Instead of writing 110 blocks, Claude writes one block that does one step, and the transformer runs that block again and again. The authors call this looped weight-space programming. A bigger problem needs more passes, not more weights.
How the maze transformer works
Claude designed the transformer in a Claude Code session. Here is the design, in plain terms:
- One token per cell. A 30x30 maze becomes 900 tokens.
- 35 numbers per cell. Claude decided what each number means before setting any weight. Some say what the cell is (wall, start, goal) and where it is. Others track the search: distance to the goal, which neighbor is the next step, and whether the cell is on the path. The last 20 are scratch space.
- Four attention heads, one per direction. Each head lets a cell read one neighbor: down, left, right or up.
Each pass through the block does one step of a standard shortest-path search:
- A wave spreads from the goal. The goal starts at distance 0. On each loop, every open cell next to a visited cell takes that neighbor's distance plus one. The visited area grows by one step per loop.
- Each cell points toward the goal. Once visited, a cell marks which neighbor is one step closer.
- The path grows from the start. When the wave reaches the start cell, the path follows the pointers back to the goal, one cell per loop.
On the first test maze, the wave reaches the start at loop 111, and the path is complete at loop 222. The transformer runs 1,800 loops on a 30x30 maze to cover any possible path.
The clever trick: distance modulo 3
Almost every number in a cell is either 0 or 1. So how does a cell store a distance like 87?
It does not. It stores only the remainder of the distance divided by 3, using three 0-or-1 values. That turns out to be enough. Two neighboring cells always differ in distance by exactly one, so the remainder alone tells you which neighbor is closer to the goal.
The post explains why 3 and not 2: with remainders of 2, "one step closer" and "one step farther" would look the same. With 3, they differ.
This is why the transformer's size does not depend on the maze's size.
It does not get worse with extra loops
Looped models trained with gradient descent can "overthink": run them for more loops than they were trained on, and their answers get worse. The post cites a 2022 model, DeepThinking, that peaked at 86% on 13x13 mazes and then collapsed below 1% by loop 82.
The written maze transformer cannot do that. Once the path is complete, every cell already holds its final values, so another loop changes nothing. It stays at 100% at 1,800, 3,600 and 7,200 loops.
How it compares on Maze-Hard
Here are the Maze-Hard test scores the authors report, where any shortest path counts as correct:
- Written transformer (19,936 weights): 100%
- LDT (1.8M weights): 99.8%
- EBR (1.8M weights): 94.1%
- TRM (7M weights): 91.9%
- HRM (27M weights): 82.2%
- Claude Opus 5.5: 26%
- GPT-6 Astra: 26%
- GPT-6.1 Sol: 12%
A few notes on these numbers. The LDT, TRM and HRM scores come from another paper (Davis et al., NeurIPS 2026), and EBR's from Chen et al. (2026). The LLMs answered only the first 50 of the 1,000 test mazes. LDT is within 0.2 points, so the headline result is less "written beats trained by a mile" and more "written matches the best trained model with 90 times fewer weights and no training."
The 19,936 weights are not even a minimum. When five fresh Claude Code sessions were given a weight cap, all five still scored 100%. The smallest used 928 weights, about 1,900 times fewer than LDT.
Why Claude can write it but cannot solve the maze
This is the most interesting part of the project.
The authors tried hard to help Claude solve mazes directly. They told it the exact algorithm to use. They gave each cell its own token. They let it answer with just the path. The best prompt raised Claude from 26% to 50%. None went higher.
The reason seems to be execution errors. Every step along a path of 110+ cells has to be right. Even when told how to search, Claude's first wrong step came, on median, 35% of the way along the path.
Writing the transformer is a different kind of task. Claude does not have to run the search. It only has to design one step and set weights to match. Each design choice can be checked on its own.
The post compares this to programmers who write code for arithmetic they could not do in their heads. LLMs already benefit from this on math word problems: writing a short program to do the arithmetic gets more answers right than doing it in text.
The cost numbers make the same point:
- Writing the maze transformer: 196,771 output tokens, about $19, ready in 39 minutes.
- Solving mazes in text: $0.14 to $0.34 per maze, with at most a 50% success rate.
The written transformer pays for itself after about 55 to 134 mazes, and needs no API calls after that. The post notes that these are list-price equivalents: the builds actually ran on a Claude subscription.
Can training find these weights?
If 20,000 weights can solve every maze, why do trained models need millions? Maybe the architecture is the secret. So the authors took Claude's architecture, reset its weights to random, and trained it on the same 1,000 mazes.
Every run solved 0%.
- Without normalization, training broke down within 30 steps.
- With normalization added, training ran smoothly, but every model learned only to copy the maze back. That already gets 87.4% of cells right, because only about one cell in eight is on the path.
- Bigger versions (up to 2.8 million weights), a curriculum from small to large mazes, a rebalanced loss, and extra supervision of the internal distances and pointers all still gave 0% on test mazes.
A plain 6.4 million weight transformer with no loop did better, reaching 46%.
The authors' guess is that gradient descent "finds no partial credit along the way." Marking a path cell only happens after a chain of a hundred or more correct steps, so there is no gradual signal to follow.
They are also careful about what this proves. Each of their training runs used about 5 PFLOPs, which is 230 to 2,000 times less compute than the trained models they compare against. So the result shows that gradient descent did not find these weights under the settings tested, not that the weights cannot be learned.
Generalizing to bigger problems
On three simpler tasks, Claude could only check its transformer on small inputs while writing it. The authors then tested on much larger ones and compared with trained models:
- Graph search: checked on maps of about 12 points, tested on maps of about 48 points with routes of 8 to 16 steps. Written transformer: 100%. Trained models up to 99 times bigger: 0%.
- Parity (odd or even number of 1s): checked on strings of up to 20 bits, correct up to 4,095 bits. Trained models fell to chance (45.5 to 53.8%) beyond 20 bits.
-
Reasoning chains (like
x0 = 7. x1 = x0 + 3.): checked up to 8 steps, correct up to 63. The best trained model reached 93.7% within its training lengths but only 3.5% beyond them.
The maze transformer was checked on mazes of up to 45x45. It then solved every one of 50 mazes at 60x60 and 40 at 100x100, with the same weights.
Beyond mazes
The same recipe produced transformers for more tasks, each solving every test problem the authors ran:
- Sudoku-Extreme: 100% of 141,040 test puzzles. The best trained model the authors cite, Sotaku v2, reaches 98.96% on the first 10,000. This transformer has to guess and backtrack, saving a copy of the grid before each guess. The cost is compute: it runs 40,000 loops on every puzzle and does about 50 times more arithmetic per puzzle than TRM.
- Tower of Hanoi: every size from 1 to 20 disks, including 1,048,575 moves for 20 disks with no mistakes. It uses only 3,686 weights. The reasoning models tested in "The Illusion of Thinking" paper collapsed past 5 to 7 disks.
- GraphWalks: OpenAI's benchmark with prompts of 256k to 1M tokens. The written transformer scores 100% F1 on 200 problems. Claude Opus 5.5 scores 66.8%, and the best LLM the authors found, Gemini 4 Carbon, 96.2%.
- BIG-Bench reasoning: four tasks written in plain English, including Web of Lies and Shuffled Objects from BIG-Bench Extra Hard, all at 100%. The best LLM results the authors found were 81.2% and 56.9%.
- More algorithms: strongly connected components, Prim's minimum spanning tree, longest common subsequence, 3-SAT and three planning domains.
Claude wrote all of these in 18 sessions. Each session cost between $1.19 and $37.06 at list prices, with a median of about $4.
Interpretability for free
Interpretability research usually works backwards: you take a trained model and try to work out what its numbers mean. Here it is the other way around. Claude chose what every number means first, then set the weights.
That makes some things easy to test. Each attention head carries the wave in one direction, so removing a head should stop the wave from crossing that way. It does: without any single head, the wave reaches only about 8% of the cells it should, and 0% of mazes get solved.
The authors also tried the reverse. They gave three fresh Claude Code sessions only the weights and a bare description of the architecture, without saying it was about mazes. Each one worked out the whole design in about two minutes.
The limits
The authors are clear about where this stops working:
- You need to know the algorithm. Every task here has a known procedure: shortest path, constraint propagation, Hanoi's recursive rule. The post says this "suits tasks with a known algorithm better than open-ended ones such as language."
- Each transformer has size limits. The maze transformer reads grids up to 128x128. The Sudoku one has room for 24 saved grids. The Hanoi one needs 64-bit arithmetic and handles at most 20 disks. The GraphWalks and BIG-Bench transformers only read the exact prompt format they were built for.
- Some solutions are expensive to run. The Sudoku transformer always runs 40,000 loops, even though half the puzzles are solved in 273.
- It is a blog post. The results have not been through peer review, and several comparison scores come from other papers rather than the authors' own runs.
Why this matters
The 2024 ICLR paper on looped transformers showed a single looped layer could learn simple algorithms through training. This project flips that around. It shows that a single small looped block can hold an exact algorithm, and that an LLM can write it, even when training fails to find it.
The authors' broader claim is worth repeating: "for algorithmic tasks with a known procedure, what holds small models back is not their size but finding the right weights."
Their next steps are practical: one transformer that holds many of these modules with a router, and using written weights as a starting point for training. If training starts from a solution that already scores 100%, does it keep the ability to handle bigger inputs, or wash it out?
The takeaway
An LLM that solves 26% of hard mazes wrote a 19,936-weight looped transformer that solves 100% of them, in 39 minutes, for about $19. Training the same architecture from scratch got 0%.
The lesson is less about mazes and more about division of labor. LLMs are bad at running long chains of steps without a mistake. They are much better at writing one correct step and letting a loop do the repetition.
If an LLM can write exact algorithms into weights, should future models learn to call small written modules the way they call tools today?
Top comments (0)