On a phone or a microcontroller, a token's cost is not the arithmetic. It is the bytes: every weight the model touches has to come out of flash or DRAM, and in a small transformer two thirds of those bytes belong to the feed-forward layers. Our attention-only study showed that the feed-forward network's parameters matter and its functional form largely does not. That leaves a design question: if what the block needs is channel mixing and a nonlinearity, how few parameters can buy it? Needle's answer is the Hadamard MLP. This post is the construction, with the maths, and the bill.
What a feed-forward layer does
A standard block mixes across positions with attention and across channels with a two-layer network,
so at it stores parameters and spends the same number of multiply-adds on every token. A dense matrix is the most general linear map, and also the most expensive: it lets every channel talk to every other channel, but it pays to do so. The question is whether every-to-every mixing has a cheaper form.
The transform that mixes everything for free
It does. The Walsh-Hadamard transform is an orthogonal matrix of entries defined recursively,
and it can be applied with the butterfly network below: stages of pairwise sums and differences, additions in total, and not a single stored weight.
Every output channel depends on every input channel, which is exactly the property a channel mixer needs. What it lacks is anything to learn. Needle 2 used the transform as is, with learned diagonal scalings on either side, on the observation that a fixed rotation plus learned per-channel gains is already a surprisingly capable mixer. Needle 3 keeps the idea and makes the rotation itself learnable, without giving back the cost.
Kronecker factors, and why 32 × 32
Write the channels of a token, after padding from 768, as a tile . A Kronecker-factored matrix with acts on the tile by mixing its rows with one factor and its columns with the other,
which is two small matrix products, multiply-adds, against the of a dense matrix of the same size, and parameters against a million. The Walsh matrix is itself a Kronecker product of smaller Walsh matrices, so initialising and to makes the stage an exact Hadamard transform on the first step of training, and every step after that can move it.
One Kronecker stage only mixes within rows and within columns of the tile. Two channels in different rows and different columns never meet. The fix is the same one that turns butterflies into a full transform: permute between stages. Needle applies three Kronecker mixes with a fixed random shuffle of the channels after the first and the second, so that by the third stage every channel has had a path to every other. This is the Monarch construction, a product of block-structured matrices with permutations between them, and it is expressive enough to represent the dense mixers a transformer actually learns while staying a few tiny matmuls to apply.
The whole layer
Putting the pieces in order, with the fixed permutations, learned diagonals and a bias, the layer computes
with one addition that earns its keep: the gain on the middle diagonal is conditioned on the input through a rank-8 bottleneck,
with zero at initialisation so the gain starts at exactly one. It costs 14K multiply-adds and lets a token scale its own channels before the nonlinearity, a small amount of the input-dependence a dense feed-forward layer gets from its width, bought with a vector rather than a matrix. starts at 0.02 so each new layer writes gently into the residual stream, the same small-init convention as the attention output.
Counting everything, a layer holds factor weights, five vectors of length 1,024 and the two rank-8 matrices: 25.6K parameters, and about 0.21M multiply-adds per token.
The bill
Per layer the Hadamard MLP is 180 times smaller than the dense layer it replaces and 22 times cheaper to run. Across the 20 blocks of Needle 3 the difference is 94M parameters, which would have taken the model from 121M to 215M, and 196 MFLOPs per token, which would have taken it from 100 to 296. Attention and the engram memory are unchanged by the swap, and the engram is where Needle keeps the knowledge a feed-forward layer would otherwise have to hold: 70.8M of its 121M parameters live in hashed n-gram tables that are read by gather, a few rows per token, costing no arithmetic at all. The feed-forward budget was spent on memory that is only touched when it is needed, rather than on a matrix that is touched every token.
On the device
The bytes argument is what the engine cashes in. Each Kronecker stage is applied as the two products of the diagram, on a tile that fits in vector registers, so a layer's entire channel mixer streams through the CPU in a few hundred fused multiply-adds per lane with no weight matrix to fetch. The three factor pairs, the diagonals and the rank-8 gain are a little over a hundred kilobytes per layer at full precision, and far less in the shipped 2-bit archive, so the mixer stays resident in cache for the life of a session. Decode on a Raspberry Pi 5 runs at 400 to 4,000 tokens per second across the depth ladder, and the Hadamard MLP is a large part of why the number has that many digits.
What it gives up
A dense feed-forward layer can represent any linear map on its hidden width; three Kronecker mixes with permutations cannot represent all of them, and the rank-8 gain is a narrow substitute for the input-dependence of a wide hidden layer. On the reasoning-dense, tool-shaped data Needle trains on, where the block's job is to route and transform what is already in context, that expressivity was not where the loss lived, and the engram absorbs the storage role. Whether the same trade holds for knowledge-heavy general text at larger scale is the open question, and the same one the attention-only study left on the table. Within Needle's regime the numbers above are the argument: a 121M model that beats models ten times its size on mobile tool calls, spending a third of the compute a transformer of its shape would.
