Unfolding lays out the tensor’s values to match how processors read them.UnfoldFold
Unfolding
A tensor’s values are fixed. How they are stored and read is a choice. Unfolding is changing that choice.
Memory is one line. Several values share one machine word, and a kernel takes a handful of values at a time. If its handful is spread over many words, it fetches many words to use a few values. If a word holds c values and the kernel makes m draws, the words it must fetch, Φ, obey:
m ≤ Φ ≤ c·m
Unfolding moves the store to the low end, Φ = m. A real case: a public four-bit model packs eight neighbouring codes into each 32-bit word, but each lane of our decode kernel takes every 32nd code. Unfolded, the eight codes a lane needs share one word, and word fetches fall from 256 to 32 per block.
On one matrix, a test kernel that reads the file as it is ran 4.9× faster than our engine’s loop: 516 GB per second, 94% of the 546 GB per second that Apple states for the chip.
The detail is in our paper, Unfolding Tensors: Storage Order and Fetch Cost of Four-Bit Weights.
Shaping cuts each computation into the shape the processor runs fastest.UnfoldFold
Shaping neural simulation
A matrix product in it has three axes: rows M, output width N, and reduction length K, the number of products summed into each output value.
We expected the size of a program to set its speed. It did not. The rate was set by one axis, the length of the sum K. Past a knee, doubling K halves the rate. So we cut one long sum into P shorter ones and add the partial sums.
On that layer pair, shaping raised the rate 3.12 to 3.46×, while cutting by output channels left it at 0.99 to 1.00×. With the same change, Whisper large-v3-turbo transcription took 21.5% and 21.9% less time on an M4 Max and an M5 Max.
The full detail is in Input-Dimension Shaping for Matrix Products on Apple Silicon.
Pipeline splits one model across machines and keeps each machine computing.UnfoldFold
Pipeline parallelism
We named ours the Choo-Choo Relay Train. Like a train, it connects machines in a line, with a single Thunderbolt cable between them. You can see our setup in the video on our X.
The usual way to use four machines is data parallel: every machine holds the whole model. Apple’s WWDC26 run was data parallel. In a pipeline, each machine holds only its assigned layers, and together they work as one distributed machine.
- It keeps the speed. Four Macs ran at 93% of four single Macs.
- It uses a fraction of the memory. Spread a model over N machines, and each needs 1/N of the RAM for the weights that data parallelism needs.
- It does not require an optical interconnect. Each Mac connects to the next with a single Thunderbolt cable.
its own layers
its own layers
its own layers
its own layers and the loss
Performance
| Model | Result on MacBook Pro M5 Max | |
|---|---|---|
| Nubotics 1.7B | 18.81 ms per decision (1 Mac) | Report |
| GR00T N1.7 | 44.34 ms per decision (1 Mac) | Report |
| Qwen3.5 9B LoRA fine-tuning | 5,358.5 tok/s (4 Macs) | Report |
| Qwen3.8 125B Flash Next 4-bit | 177.7 tok/s @ 1 user (4 Macs) · 859.0 tok/s @ 32 users (4 Macs) | Report |
| Qwen3.6 35B-A3B 4-bit | 517.5 tok/s @ 1 user (1 Mac) · 3,799.6 tok/s @ 32 users (4 Macs) | Report |
| Qwen3.8 27B 4-bit | 200.3 tok/s @ 1 user (1 Mac) · 1,906.2 tok/s @ 32 users (4 Macs) | Report |
| Whisper large-v3-turbo | 89.2× real time · 2.97% word error rate (1 Mac) | Report |
Who it’s for
| AI service providers and start-ups | Serve more users on each machine, with less processing and energy. |
| AI model makers | Make your models run faster. |
| AI data centers | Less RAM and electricity on each machine, and no special interconnect. |
Interested in trying your model or AI service on NukeTorch? Contact us.