Primers · AI

Handwired: Written, Not Trained

On October 15, 2026, Cheng Lou introduced Handwired: a library that compiles a program into a neural network. No training. The outputs match the program exactly, the network stays differentiable, and it runs in a browser, no graphics processing unit (GPU) required.

His proof is a small desktop operating system running as one compiled program. Lou previously worked on React and ReasonML and created the Pretext text layout library; he is now at Midjourney.

One nuance from his own docs, kept visible throughout: you author the numeric program with his builder application programming interface (API): ordinary JavaScript that appends operations to a circuit. No tool converts existing JavaScript source into a network. The post's phrasing is looser than the library; the docs are accurate.

Researched October 2026AIEngineering
Ink illustration of a hand wiring red threads between nodes arranged in layers on graph paper
A program, wired by hand into a network: every weight placed, none trained.

The brief

A network's weights are usually found by training, but they can also be written, the way you write any other program, staying exact and differentiable.

Handwired is an open source TypeScript library (MIT license) with docs and three working demos. You write builder code: functions that declare values with ranges and add sums, products, comparisons, and table reads. The library compiles it into a network of operations grouped into layers, stored as flat arrays of 32-bit floats, which a host program, ordinary JavaScript around the network, evaluates.

The default story is that nobody knows what the weights should be, so an optimizer searches. When you already know the function, compile it instead: exact behavior, and the option to train later where you choose.

How it works

Start with his README's smallest program with a branch:

const result = a > 4 ? 10 : 12;

In plain words: past 4, answer 10; otherwise, 12.

A network cannot jump, so Handwired turns the test into arithmetic.

Two rectified linear units measure how far the input sits past 4 and past 5; their difference is a gate, fully closed below 4, fully open above 5, and the answer is a blend the gate controls. Try it:

Figure 1 · The Gate Lab: one if statement, as arithmetic
Input a4.50

The real thing, with every symbol defined:

$$\mathrm{relu}(x) = \max(0, x) \qquad \mathrm{above4}(a) = \mathrm{relu}(a - 4) - \mathrm{relu}(a - 5)$$
relu the rectified linear unit: zero for negative inputs, the input itself otherwiseabove4(a) the gate: 0 up to 4, 1 from 5 on, the fraction between
$$\mathrm{result} = \mathrm{above4} \cdot 10 + (1 - \mathrm{above4}) \cdot 12 = 12 - 2 \cdot \mathrm{above4}$$
above4 the gate, from above10 and 12 the two branch answers, mixed by the gate

Checked against the JavaScript ternary. At $a = 5$: $\mathrm{relu}(1) = 1$ and $\mathrm{relu}(0) = 0$, so $\mathrm{above4} = 1$ and $\mathrm{result} = 10$; the program agrees. At $a = 3$ both relus are 0, so $\mathrm{above4} = 0$ and $\mathrm{result} = 12$. At $a = 4.5$: $\mathrm{relu}(0.5) = 0.5$, so $\mathrm{above4} = 0.5$ and $\mathrm{result} = 0.5 \cdot 10 + 0.5 \cdot 12 = 11$, halfway between the branches. At every whole number the gate is exactly 0 or 1, so the network's answer is the program's answer, untouched.

Between 4 and 5 the answer slides smoothly from 12 to 10, so the program has a slope there, minus 2. Outside the ramp the slope is 0, and at exactly 4 and 5 it jumps, so no derivative exists there. One more primitive: multiplying two runtime values is a gated product, $\mathrm{reglu}(\mathrm{left}, \mathrm{gate}) = \mathrm{left} \cdot \max(0, \mathrm{gate})$, Noam Shazeer's 2020 form, so a signed product is $a \cdot \mathrm{relu}(b) - a \cdot \mathrm{relu}(-b)$, one term of which is ever nonzero.

Two mechanisms underneath. Tap to open.

From code to layers

Each step adds operations, and nothing resembling a branch survives to run time.

Figure 2 · Watch the ternary compile
Step 1 of 6

Tap the arrows or swipe

Key voices

The creator's case, and the model-writes-the-weights case.

Where leaders think this goes

Weights are a compile target.

Researched October 2026.

Where they agree
Where they split

Takeaways

Written first, trained only where you choose.

Handwired reframes what a neural network is for. Training is one way to fill a network's numbers, not the definition of them. Lou's compiler shows a second way: write the numbers, and get a program that is exact where you declared it exact, portable to anything that multiplies matrices, and open to gradient descent where you choose.

Keep exploring

Sources

    Honesty notes. Built from the post's video, the repository, and its docs, read firsthand in October 2026. Three of the post's phrases are looser than the docs: no tool converts existing JavaScript source (you write builder code); exactness holds inside declared ranges and grids in 32-bit floats; hard boolean decisions are not differentiable unless you choose a straight-through gradient. Speed and size figures (0.22 milliseconds, 114 KB) are the author's demo measurements. The widgets on this page run the arithmetic live and were checked against the formulas above; nothing here was measured on the author's hardware.