The Math AI Ignores: Exact Arithmetic and a Faster Matmul
Strassen found a faster matrix multiply in 1969. Floating point is why nobody shipped it. The fix is to change the arithmetic, not the algorithm.
🎧 Listen to the episode
The Math AI Ignores: Exact Arithmetic and a Faster Matmul
This article is adapted from the podcast episode above. Audio not playing? Download the MP3.
01The workhorse nobody re-wired
Matrix multiplication is the workhorse of AI. Every attention score, every convolution, every fully connected layer bottoms out in multiplying matrices. The obvious way to do it — the one taught in every linear-algebra class — takes cubic time: multiply two n×n matrices and you do on the order of n³ scalar multiplications.
In 1969, Volker Strassen showed this is not the floor. He found a way to multiply matrices in roughly n2.807 operations by recursively splitting matrices into 2×2 blocks and computing the product with seven block multiplications instead of eight, trading multiplications for additions and subtractions (Strassen 1969). If it is faster, why does almost nobody use it in production?
Because Strassen trades multiplications for additions and subtractions, and in floating-point arithmetic those extra additions are exactly where the trouble starts.
02Why Strassen stays on the shelf
The schoolbook algorithm builds the product from dot products of rows and columns. Strassen instead computes intermediate sums before multiplying them, then adds and subtracts nearly equal numbers to recover the four blocks of the output. In exact arithmetic that is harmless algebra. In floating point it is a slow leak.
When you add numbers of very different magnitudes, or subtract numbers that are close to each other, low-order bits are lost. Strassen does a lot of both — recursively, at every level. Those small rounding errors do not stay small; they compound, and the numerical stability of the algorithm is measurably worse than the schoolbook method (see Higham’s Accuracy and Stability of Numerical Algorithms, 2nd ed., SIAM, 2002). At the scale of a large model, where matrix multiplies are applied millions of times in sequence, the error can grow much faster than in ordinary multiplication, and at that scale it matters.
The usual story: the speed is real, but the precision is not reliable enough. So fast matrix multiplication stays theoretical, and production code keeps using the cubic method.
The fix this series proposes is to change the arithmetic, not just the algorithm. Instead of floating point, do the work in residue number systems.
03Exact arithmetic: the residue number system
A residue number system (RNS) represents a large integer not by its digits in some base, but by its remainders modulo several small numbers that share no common factor. Pick pairwise-coprime moduli m₁, m₂, …, mₖ. Any integer X in the range [0, M), where M = m₁·m₂·…·mₖ, is represented by the tuple of its remainders X mod mᵢ (Omondi & Premkumar, Residue Number Systems: Theory and Implementation, World Scientific, 2007; Kornerup & Matula, Finite Precision Number Systems and Arithmetic, Cambridge, 2010).
The useful part is what happens next:
Three properties that change the game
- Each remainder is its own small channel. The channels do not interfere with each other. No carry spills from one channel into the next.
- Addition and multiplication happen channel by channel, in parallel, with no carry to wait for. To add two numbers you add their remainders modulo each small modulus; to multiply them you multiply remainders. There is no global carry chain.
- The Chinese Remainder Theorem says those remainders determine exactly one integer in the range
[0, M). At the end, you reconstruct the exact answer — no rounding involved.
There is no rounding error to compound because there was no rounding in the first place.
The catch, honestly stated: RNS is exact only for integers. Real-valued weights and activations must first be scaled to fixed-point integers, and the product of the moduli must be large enough to hold every intermediate result, including negative ones. Some operations are also hard in RNS: comparing two numbers, detecting the sign, dividing, and converting back to ordinary binary all need extra work (Omondi & Premkumar cover these in depth). Additions and multiplications are cheap; everything else has a cost.
04Does exact arithmetic actually fit hardware?
This is the second half of the idea, and the reason it is interesting rather than just a curiosity. Small, independent, carry-free channels are a natural fit for analog or photonic hardware, where you want many simple lanes running at once rather than one complicated lane doing everything. Fast multiplication gives you fewer multiplications; exact modular arithmetic gives you back the stability; and the hardware gets a shape it can actually run.
The bet behind this series: the obstacle to fast matmul in practice is the number format, not the algorithm. Change the arithmetic to exact modular channels and fast multiplication gets its stability back.
05This is not the only idea in that shape
And that is why the first three ideas on the list belong together. The same move — replace fragile floating-point operations with exact, structure-preserving algebra — shows up in two more places.
Tropical geometry: pruning without approximation
Tropical geometry tells us that a rectified linear unit (ReLU) network is exactly a tropical rational function, where taking a maximum replaces addition and ordinary addition replaces multiplication (Zhang, Naitzat & Lim, Tropical Geometry of Deep Neural Networks, ICML 2018, arXiv:1805.07091). The family of ReLU networks with integer weights is exactly the family of tropical rational maps — not approximately, but identically.
The payoff this series argues for is that pruning can, in principle, be exact too. A network is a tropical polynomial; simplify that polynomial and drop the terms that never change the output, and you have removed dead weight with a proof rather than a heuristic. The arithmetic needs only adding and comparing — no multipliers at all.
Ramanujan and expander graphs: wiring with a proof
The next idea is about wiring. Ramanujan and expander graphs are sparse wiring patterns with a proof behind them. They spread information across all tokens in a logarithmic number of layers with very few edges (Hoory, Linial & Wigderson, Expander Graphs and Their Applications, Bulletin of the AMS 43, 2006, DOI 10.1090/S0273-0979-06-01126-8; Lubotzky, Phillips & Sarnak, Ramanujan Graphs, Combinatorica 1988). So instead of an ad hoc sliding window or random sparsity, you get a principled pattern for sparse attention or for routing between experts.
We cover this one in depth in A Few Good Edges: How Expander Graphs Make Sparse AI Wiring Smarter.
06Put those three together
Coherent design, not three separate tricks:
Residue channels doing tropical or fast multiplication over expander sparse connectivity — as one system for a photonic or neuromorphic accelerator.
Exact arithmetic supplies the stability, tropical algebra supplies the exact, multiplication-free pruning, and expander wiring supplies the connectivity. None of them is new. All of them are largely ignored in practice.
07The rest of the list
The series ranks nine ideas by how much room there is to build something real, and this episode only opens the door. After the top of the list, the remaining ideas are:
- Lattice quantization beyond the 8-dimensional lattice — including the Leech lattice, which we discuss in How a 24-Dimensional Crystal Packs a Model Into Two Bits.
- Submodular guarantees for choosing what to keep in context.
- A tool from algebraic topology that spots contradictions between agents.
- p-adic embeddings for trees and code.
- Hierarchical matrices for attention with error bounds.
- Exact integer transforms for long convolutions.
Each one has papers behind it and each one is, today, largely ignored in production AI.
08The takeaway
Strassen was not wrong. Floating point was the wrong home for his algorithm. Change the arithmetic to exact modular channels and a half-century-old speedup becomes buildable again.
Next time we go deeper into tropical geometry and ask what a network looks like when you prune it exactly instead of approximately.
Frequently asked questions
What is Strassen’s algorithm and why is it faster?
It multiplies two n×n matrices by recursively splitting them into 2×2 blocks and computing the product with seven block multiplications instead of eight. That drops the exponent from 3 to log₂7 ≈ 2.807, so large matrix products use fewer scalar multiplications than the schoolbook method.
Why isn’t Strassen used everywhere if it is faster?
Because it trades multiplications for many more additions and subtractions, and in floating-point arithmetic those extra operations let rounding errors compound. Its numerical stability is worse than the schoolbook method, and at the scale of a large model the accumulated error can become unreliable.
How do residue number systems fix the precision problem?
An RNS represents an integer by its remainders modulo several small pairwise-coprime moduli. Addition and multiplication happen independently in each modulus channel with no carry chain, and the Chinese Remainder Theorem reconstructs the exact integer at the end. Because there is no rounding step, there is no rounding error to compound.
What does tropical geometry have to do with neural networks?
A ReLU network is exactly a tropical rational function: taking a maximum stands in for addition and ordinary addition stands in for multiplication. That means the network can be written and simplified as a tropical polynomial, which opens the door to pruning that is exact rather than heuristic.
Sources and further reading
- V. Strassen. Gaussian Elimination Is Not Optimal. Numerische Mathematik 13, 354–356 (1969). DOI 10.1007/BF02165411
- N. J. Higham. Accuracy and Stability of Numerical Algorithms, 2nd ed., SIAM, 2002.
- A. Omondi & B. Premkumar. Residue Number Systems: Theory and Implementation. World Scientific, 2007. DOI 10.1142/p523
- P. Kornerup & D. W. Matula. Finite Precision Number Systems and Arithmetic. Cambridge University Press, 2010.
- L. Zhang, G. Naitzat, L.-H. Lim. Tropical Geometry of Deep Neural Networks. ICML 2018. arXiv:1805.07091
- S. Hoory, N. Linial, A. Wigderson. Expander Graphs and Their Applications. Bulletin of the AMS 43 (2006). DOI 10.1090/S0273-0979-06-01126-8
- A. Lubotzky, R. Phillips, P. Sarnak. Ramanujan Graphs. Combinatorica 8(3), 261–277 (1988).