cd /news/artificial-intelligence/altivec-had-intels-neural-network-in… · home › topics › artificial-intelligence › article
[ARTICLE · art-174945] src=pub.towardsai.net ↗ pub= topic=artificial-intelligence verified=true sentiment=↑ positive

AltiVec Had Intel’s Neural-Network Instruction 20 Years Early.

A Power Mac G5 Dual 1.8 GHz from June 2004 running MorphOS 3.20 executes a 110-million-parameter TinyStories language model at 1.91 tokens per second without AltiVec and 13.7 tokens per second on one core using the vmsummbm instruction, reaching 18.2 tokens per second with both processors under Mac OS X Leopard, according to the author's own end-to-end measurements. The author notes AltiVec's 1999 vmsummbm — vector multiply-sum of 16 signed bytes by 16 unsigned bytes into 32-bit accumulators — performs the same 8-bit integer dot-product operation Intel added to its server CPUs in 2019 as VNNI, and that the port of Andrej Karpathy's llama2.c to MorphOS appears to be the first local language model on that OS. The G5's memory bandwidth measured 2.25 GB/s, and the author reports every figure comes from the original 130 nm PowerPC 970 (PVR 0x0039 rev 2.2) rather than the 90 nm 970FX Apple's specifications list for PowerMac7,3.

recommendation

Use AltiVec vmsummbm for 8-bit weight dot products on PowerPC G4/G5 hardware; it raised throughput from 1.91 to 13.7 tokens per second on one core, with the G5's 2.25 GB/s memory bandwidth as the remaining limit.

more in playbook: Inference and self-hosting
by read9 min views6 publishedNov 23, 2026

This article was written with the help of Claude (Anthropic), from my notes, ideas and measurements; I reviewed and edited the text. Every measurement was run on my own machines.

In 2019 Intel added an instruction to its server CPUs for one job: multiplying 8-bit integers in groups of four and summing them into 32-bit totals. It’s part of a set Intel called VNNI, Vector Neural Network Instructions, and it’s what quantized neural networks spend most of their time doing.

The PowerPC chips in Apple’s G4 and G5 Macs had that operation in 1999. AltiVec calls it vmsummbm, Vector Multiply Sum Mixed-Sign Byte Modulo. It takes 16 signed bytes and 16 unsigned bytes, multiplies them in pairs, adds the products in groups of four, and accumulates the four sums into 32-bit integers. Intel's version even keeps the odd mix of one signed and one unsigned operand. Intel itself had used that mix since SSSE3 in 2006, where the same job took three instructions; VNNI fused them into one. In 1999 the mix made sense: AltiVec was built for media work, where pixels are unsigned bytes and filter coefficients are signed, and that is most likely why the instruction looks the way it does.

I have a Power Mac G5 from 2004 on my bench, and it runs MorphOS. I wanted to know how much that 1999 instruction is worth on a real language model, measured end to end on a real machine.

The answer: on one core, it takes a 110-million-parameter model from 1.91 to 13.7 tokens per second. With both processors under Mac OS X Leopard it reaches 18.2. That last stretch doesn’t come from the instruction: it comes from the second processor’s memory bus, and from cutting the overhead of OpenMP itself.

The G5 is a Power Mac G5 Dual 1.8 GHz from June 2004:

One detail about the processors. Apple’s specifications for this model, PowerMac7,3, list the 90 nm PowerPC 970FX, but both processors in mine report PVR 0x0039 rev 2.2, the original 130 nm 970. I don’t know the machine’s history, so I report what the chips say: every figure in this article comes from the 130 nm 970.

One disk has Mac OS X Leopard, the other MorphOS 3.20, released in May 2026. MorphOS is an operating system for PowerPC in the Amiga tradition. It runs AmigaOS software and is still developed. I grew up on Commodore machines, so on this Mac MorphOS is the system I boot.

MorphOS sees both processors, but it runs everything on the first one. Every number in this article is from one core, except the Leopard test near the end.

Before writing anything I looked for prior work, and there is a fair amount.

So I’m not the first to use vmsummbm for a language model on a G5, nor the first to run 8-bit weights with AltiVec.

On MorphOS I found nothing. I searched morph.zone and Aminet: the AI software there, AmigaGPT and the newer AI4MorphOS, are clients for cloud APIs. As far as I can tell, this is the first language model running locally on MorphOS.

What this article adds:

llama2.c is Andrej Karpathy’s single-file C inference for the Llama 2 architecture. I used it with his two TinyStories models, which were trained to write short children’s stories:

These are toy models. What they offer here is a real transformer (attention, RoPE, SwiGLU, a 32,000-token vocabulary) in a size that fits a 2004 machine.

The MorphOS SDK on the G5 has GCC 6.4 from 2018. The port needed three changes:

To check the byte-swapping, I built the same code on my Linux PC with the swap forced on and fed it pre-swapped files. The output was byte-for-byte the same as the original program’s.

Two things on the G5 cost me some time:

I started with the original 32-bit floating-point weights. The AltiVec version keeps four vec_madd accumulators per row, four floats each.

To see where the limit is, I wrote a small program that reads a 256 MB buffer and timed it, keeping the best of five runs. The G5 reads memory at 2.25 GB/s with AltiVec loads and 1.90 GB/s with plain C.

Generating a token means reading every weight once, so the 110M model at 4.47 tokens per second reads 1.96 GB/s. That’s 87% of what the machine can deliver. In fp32 the G5 can’t go meaningfully faster. To go faster, it has to read fewer bytes.

For comparison, the G5 runs the 110M model 5.1 times faster than the PowerBook G4.

llama2.c also has an 8-bit version, runq.c. Weights are stored as int8 in groups of 64 (32 for the 15M model), each group with its own fp32 scale. Activations are quantized to int8 on the fly before each matrix multiply.

That cuts the 110M model from 438 to 116 MB, nearly four times less to read per token. Karpathy’s export script needs PyTorch and pickled checkpoints. I wrote a small NumPy quantizer that works from the fp32 .bin instead. Its worst-case rounding error is 0.0076 for the 110M model.

In plain C, int8 is slower than fp32: 1.91 tokens per second against 2.26. Without an instruction for it, every 8-bit product costs a sign extension, an integer multiply and an add. Fewer bytes don’t help when the core can’t keep up.

vmsummbm fixes that, with one catch: one operand must be signed and the other unsigned, while both weights and activations are signed. I took four steps:

// weights were stored as w+128 at load time; activations x stay signedfor (int k = 0; k < 64; k += 16)    acc = vec_msum(vec_ld(k, x), vec_ld(k, w), acc);   // vmsummbm: 16 products// x·w = x·(w+128) − 128·Σx, and Σx is computed once per group, not once per row

The algebra is one line. Adding 128 to every weight adds 128 times the sum of the activations to the dot product, whatever the weights are, so subtracting that sum undoes it. The correction happens per quantization group and in integers: each group’s sum is corrected first, then multiplied by that group’s two scales, one for the weights and one for the activations. The inner loop is left with two loads and one vmsummbm per 16 bytes.

The trick itself isn’t new. It is the zero-point algebra that Google’s gemmlowp library documents, and llama.cpp has precomputed the activation sum the same way since 2023. What the G5 adds is that the cost of each choice shows up directly in tokens per second.

The final version runs the 110M model at 13.7 tokens per second. That’s 7.2 times plain C int8, 6.1 times plain C fp32, and 3.1 times the best fp32 AltiVec version. It runs the small model at 79 tokens per second.

The output didn’t change. Across every int8 version, the 110M model writes the same story to the letter. A test build compares the AltiVec matrix multiply with the plain C one on the first three matrix multiplies (768 × 768). The largest absolute difference is about 1e-7, from the order of the float additions. The integer sums can’t overflow: a group of 64 products adds up to at most 64 × 127 × 255, about 2.1 million, a thousand times below what a 32-bit integer holds, and every group starts from zero. With the prompt “Once”, the model writes:

Once upon a time, there was a little girl named Lily. She loved to play outside in the sunshine. One day, she saw a big, red apple on a tree. She wanted to eat it, but it was too high up.

I read the PowerPC’s timebase register before and after each part of the forward pass. These are the shares for the final version on the 110M model:

In the profiling run, the matrix multiplies read their weights at 1.94 GB/s, 86% of the measured bandwidth. If everything else took no time, 116 MB per token at 2.25 GB/s would give about 19 tokens per second. 13.7 is 71% of that ceiling.

I also tried software prefetch (dcbt) and gained 1.5%, which is within noise. The core already waits on memory most of the time.

The Radeon 9600 XT can’t help much, by my estimate (I didn’t build it).

The second processor is a different matter. MorphOS doesn’t use it, but Leopard does. I rebooted the G5 into Mac OS X 10.5.8 and built the same code with Apple’s GCC 4.2 and OpenMP, which splits the rows of each matrix multiply between the two CPUs.

So the best G5 result comes from Leopard with both processors and fused regions: 18.2 tokens per second on the 110M model, 33% faster than MorphOS on one. What’s left runs on one CPU: the activation quantization, SwiGLU, RoPE and the rest of the attention take 10 to 12 ms per token either way.

On one core of a 2023 Ryzen 9 7900, the same C code without my AltiVec kernels, built with plain -O3, runs the 15M model at 127 tokens per second in fp32 and 474 in int8. The G5's best figures are 28.9 and 79.1: the Ryzen core is 4.4 times faster in fp32 and 6.0 times in int8. That is a minimum, not the real gap: built this way, the Ryzen runs without AVX2 and without the VNNI instructions Zen 4 has.

The int8 gap is partly the cache, not the core. In int8 the 15M model takes 17 MB, which fits in the 32 MB of L3 cache a single Ryzen core can use, so the Ryzen reads it from cache. In fp32 it takes 61 MB and doesn’t fit. The G5 has 512 KB of L2 cache and no L3, so it reads every byte from its DDR400.

The models themselves are tiny. The 110M writes children’s stories, and nobody should run an assistant on a G5. What matters here is the instruction and the measurement.

My previous articles ran a 125-billion-parameter model on old PCs, and the result there was the same as here: when generation is limited by memory, its ceiling is the memory bandwidth divided by the bytes each token has to read. It held on a 2013 workstation, on two PCs sharing a gigabit cable and on a 2014 Xeon, and it holds on a 2004 Power Mac.

The steps are the ones every modern inference engine takes. Quantize, so each token reads fewer bytes. Then use the processor’s 8-bit dot-product instruction, so the arithmetic keeps up with the memory. On the G5, fp32 hit the bandwidth wall at 4.47 tokens per second. In int8, plain C was slower than that, and it took vmsummbm to turn a quarter of the bytes into speed: 13.7 tokens per second on one processor, 18.2 on two. Today the instruction is called VNNI on Intel and SDOT on Arm, and IBM's POWER line, where AltiVec lives on, added xvi8ger4, which still multiplies signed bytes by unsigned ones, to the matrix unit of POWER10. Memory is far faster than in 2004, but arithmetic has grown faster still, which is why the bandwidth wall matters more today, not less.

AltiVec Had Intel’s Neural-Network Instruction 20 Years Early. was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @altivec 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/altivec-had-intels-n…] indexed:0 read:9min 2026-11-23 · —