A coder built a custom compiler, Torchwright, that writes the multiplication algorithm directly into a small language model's (Phi 3) internal parameters, with no training step.
A Phi-3 transformer hits 100% accuracy on 12-digit multiplication, not because it was trained on examples but because a developer hand-wrote the grade-school multiplication algorithm directly into its weights. The trick uses a custom compiler, Torchwright, that turns a Python computation graph into a stock Phi-3 architecture checkpoint, with no training step in the pipeline.
The Hugging Face checkpoint loads with no custom code, so the arithmetic is sitting in the model's parameters rather than a wrapper. A 3-digit variant hits 100% across all 3 million three-by-three expressions, and a longer checkpoint extends the same approach to 12-digit by 12-digit multiplication. The author, physicsrob, published the long-form writeup alongside the compiler source and the loadable model.
In the author's own benchmark, six frontier models with reasoning disabled scored below 30% on 500 random 5-digit multiplications, and five of six fell to 0 out of 500 once operands hit 7 digits. The compiled model held at 100%. Physicsrob frames the gap as a distinction between what transformers can express and what standard training usually teaches them: the architecture can hold the algorithm, but the usual training path rarely puts it there.
The demo is reproducible now. Whether the trick generalizes past multiplication is open, and the author's Reddit post leaves it there.