There are only 23,844 parameters (model weights) · and it runs in your browser

A universal computer learned by a Transformer

Gradient descent shaped these weights from the steps of random machines. Now they run programs they never saw, one window of three tokens at a time. Watch both: the training, then the machine.

Drag to orbit · hover a bar
1 · The network

2 · The universal machine

3 · The program

Height

How large a number is. Scaled within each block, so a small matrix still reads.

Shade

The sign of a weight. Deep navy is positive, pale slate negative, near zero fades to fog.

Movement

Train mode only: how far gradient descent moved a weight in the latest steps.

Buoy orange

Run mode only: the pass itself, the weights that carried it, and the machine's head on the tape. The one warm thing on the page.

New to this? Start from the basics: what a Turing machine and a transformer are, how their constraints were matched up, and how this network was found, one checked step at a time.

Learn more

One scene, two lives.

Every bar is one parameter, drawn from the trained network. In Train mode you watch gradient descent put them there. In Run mode they stand still, and a forward pass travels through them.

01 · Train

Gradient descent, bar by bar

Full-batch Adam on the 100,697 different steps a universal machine takes while running 4,000 random machines of 1 to 256 states and 200 tour machines. Bars glow green where the weights are still moving.

Step 0The trainer's random start, before any gradient descent.
LearningCaught from your own run, when half the training steps are right.
Waiting for your run
TrainedThe network this page runs. Every training step right.

Step 0 and Trained are real: the trainer's starting weights and the network this page runs. The middle frame is caught live when you train one yourself, above.

Before the scene

What it learned from, and what it runs.

Two different things. It learned from steps of a universal machine running random machines. It runs programs people wrote, which it never saw.

01 · The training data

It never sees a program.

Random machines are written onto a universal machine's tape and run. Every distinct step the universal machine takes, three tokens in and what comes next, becomes one training example. The network learns those steps, nothing else.

A · A random machine
One of 4,000

5 states, rules drawn at random, a random tape _10_. It computes nothing in particular.

B · Written on the tape

C · Run, step by step

Different steps found, as machines are addedLog scale →
100,697

training examples: every different step, from 4,000 random machines of 1 to 256 states and 200 “tour” machines that visit their states in a random order

1,351tokens it can read
1,356outputs it can write
0demo programs among them
02 · The programs it runs

A program is a list of rules.

A program is a Turing machine: a list of rules over 0, 1 and blank. It is written onto the same tape the random machines were, and the network runs the universal machine that runs it. Pick one to see how it is written.

PROGRAMSTATESRULES
1 Write it

2 Compile it onto the tape
3 Run it on the network
configurations that match a direct run of the rules
distinct windows, each checked against the exact rule
The tape alphabet · every program is written with these
* | ;the current state; between states; end of a rule
a b cwrite 0, 1, blank
L R Smove left, right, or stay
d e f … kthe next state's number, one letter per 1 bit: 1, 2, 4 … 128; up to 256 states
A Haccept; halt (no rule)
$ O I Uthe program ends and the tape begins; the head, on 0, 1 or blank
02 · The big program

The sieve of Eratosthenes, in 250 states.

The largest program the network runs: the last row of the table of costs further on. A 2,000-year-old way to find prime numbers, written as a Turing machine of 250 states and 680 rules, then run by UMT to find every prime up to 1,680.
What this section shows →

1 · The idea

Cross out the multiples

Write out the numbers. Take the first one not crossed out, 2: it is prime, so cross out every second number after it. The next one left, 3, is prime: cross out every third. Then 5, then 7. Whatever is never crossed out is prime.

2 · Written as a Turing machine

The tape is the numbers

Cell n of the tape stands for the number n: it holds 1 while n may be prime, and 0 once it is crossed out. For each k in turn, the machine looks at cell k. If it is still 1, k is prime: the machine walks right to the end of the tape, crossing out every k-th cell, then walks back and moves on to k + 1.

A Turing machine has no counter to say “every k-th”, so it counts with states: a chain of k states for each prime k, one state per step of the count. To sieve up to 1,680 it needs strides up to 40, and that is what makes it big.

3 · Run on the network

263 primes, every one right

The numbers 1 to 1,680 laid out as an Ulam spiral: 1 in the middle (orange), the rest winding outward. Each raised bar is a number the network never crossed out, and every one is prime. Primes tend to line up along the spiral's diagonals, which in this view run straight up and straight across, a pattern nobody has fully explained.

Steps of the sieve39,991
Steps of the universal machine1.33 billion
Forward passes9.9 trillion
Inputs it had never seen48, all right
Time in a browserabout 2½ minutes
Watch it sieve
03 · How it differs from your mom's Transformers

These are not hand-coded weights, they are learned by gradient descent

Papers on Turing-complete transformers mostly do one of two things: set the weights by hand, or coax a giant pretrained model into following rules. This one trains a small network on steps of a universal machine, then checks every step it takes.

A · Built by hand

Weights written as a proof

Each weight is chosen so the layers carry out a construction: a Turing machine, or a one-instruction computer whose program sits in the input. Nothing is learned. The classic proof assumes numbers of unbounded precision, which no real machine has.

B · Found in a giant model

Rules carried in the prompt

A pretrained language model, weights untouched, is given a system prompt that makes it apply the 2,027 rules of a universal Lag system, one generated token at a time, as its context window slides along. Universality is shown to be there even before training; training makes it easier to program.

C · Learned from steps · this work

Rules learned into the weights

The same Lag-system decoding, with a window of three tokens. The universal machine's step table is not in a prompt: gradient descent put it in 23,844 weights, from steps of random machines only. It runs programs it never saw, and every step of every run we report is checked against the exact rule.

universal-machine-transformer · experiments/fast-universal-machine1 layer · 2 heads · width 8 · full-batch Adam on 100,697 steps
Side by sideA · Built by handB · Found in a giant modelC · This work
Where the weights come fromWritten by hand to carry out a proofPretrained on text, left untouchedTrained by gradient descent on steps of a universal machine
Where the universal machine livesIn the construction, layer by layerIn the prompt: 2,027 production rulesIn the weights: its step table, learned. The prompt is only the program
SizeA few layers; a 13-layer loop for the programmable computerA frontier model (gemini-1.5-pro-001)23,844 parameters: 1 layer, 2 heads, width 8
What one step reads
Everything so far: attention over the whole sequence

A long window that slides along as tokens are appended

Three tokens. The tape lives in the transcript, not in the context
What universality rests onNumbers of unbounded precision (Pérez et al.); later work shows constant precision suffices given a long enough contextThe decoding loop: Lag systems are universal, and the model follows the rulesThe same loop. The network itself is a finite map from three tokens to the next; the unbounded part is the transcript
How we know it worksA proof, plus demonstrations of the built networkThe model is checked to apply each of the 2,027 rules correctlyEvery step of every run we report compared with the exact rule: the sieve to 1,680, 9.9 trillion passes, 48 windows never in training, 0 wrong
04 · Universal Machine Transformer (UMT)

The tape is the transcript, not the context.

A Turing machine needs memory without bound. The usual picture puts it in the context window, so the window has to grow. UMT keeps its context at three tokens and writes its memory out: the transcript it leaves behind is the tape.

The usual picture

Memory is the context window

A large model attends to every cell it holds. Whatever slides out of the window is gone, so a bigger computation needs a longer window, and in the classic proofs, more precision too. (Lag-system constructions also write their memory out, but read it through a long window.)

Memorythe context window
Read per stepall of it
More tape meansa longer window
Universal Machine Transformer

Memory is the transcript

Each row is one ring of the transcript: the universal machine's whole tape at one moment, its head in orange. The network reads three tokens of the newest ring and writes one into the next. Rings pile up behind it; the memory grows on paper, not in the network.

Memorythe transcript, without bound
Read per stepthree tokens
More tape meanslonger rings; the network does not change

One ring, one step.

A ring is a whole configuration of the universal machine. The window crosses it once, writing the next ring as it goes; when it is through, the machine has taken one step.

1 · ReadThree neighbouring tokens of the newest ring.
2 · WriteThe token for the middle one's place in the next ring, appended to the transcript.
3 · SlideOne token to the right. Nothing else is remembered between passes.
4 · StepAcross a whole ring, the next one is complete: one step of the universal machine.
23,844parameters, the same for every one of them

What a step costs.

The network is the same for every program; the ring is not. A bigger program makes a longer ring, and each of its steps takes more universal steps, so the passes per step grow fast. Measured on the network, every program with its default input. Pick a row to run it above.

05 · Constraints

Every limit of a Turing machine has a counterpart in UMT.

A Turing machine is defined by what it may not do: see more than one cell, move more than one cell, hold more than finitely many states. Those limits are exactly what let a window of three tokens run one.

A Turing machine

One cell, one move, one state

A finite control, in one of finitely many states, over a head on one cell. Each step it reads that cell, writes it, moves one cell left or right, and changes state. The tape never runs out. Here it runs the two-state busy beaver.

Universal Machine Transformer

Three cells make the next one

The same machine through time: each row is a ring, the next ring below it, the head in orange. A step only touches the head's cell and moves the head one place, so each cell of the next ring depends on three cells of this one. Those cones are why a window of three is enough.

ConstraintThe Turing machineUMT
StatesFinitely many. The universal machine has 82↔Finitely many tokens: the head is a token, state:symbol, 1,313 of them
AlphabetFinite: 37 symbols on the universal machine's tape↔A vocabulary fixed at training: 1,351 tokens in, 1,356 outputs
SightOne cell, under the head↔Three tokens: a cell and both neighbours, since the head can arrive from either side
ReachWrite one cell, move at most one↔One token per cell of the next ring; two when the head walks off an end, so the tape grows
The ruleA finite, deterministic table: 2,137 rules↔A finite, deterministic function of three tokens, learned; its output is the best-scoring one
MemoryA tape without bound↔The transcript, without bound
HaltingEnter accept or reject, and stop↔Write nothing: the decoder stops
TimeOne step↔One ring: as many passes as the ring is long
Many at once

Every two-state machine, side by side.

One program's steps must happen in order, but separate programs share nothing, so they can all run side by side. Here are all 20,736 Turing machines with two states, each run by its own rules for seven steps, and the busy beaver stands out. Running them on the network, all at once on a GPU, is the next step for this page.
What this section shows →

Step 0 of 7 · each machine run by its own rules Drag to orbit · hover a column
never halts: lies flat halts: as tall as the steps it took halts late the record: 6 steps, 4 ones laid out in blocks of 64
20,736machines
0halt
—never halt
—most steps · most ones
Why 7 steps is enough

No two-state machine that halts takes more than 6 steps: that is a known result. So any machine still running at step 7 never halts, and a 7-step limit sorts all 20,736 exactly.

STATESMACHINESLONGEST HALT
220,7366
316,777,21621
425.6 billion107
563 trillion47,176,870
6232 quadrillionunknown