SNES LLM: a Language Model Running on a Super Nintendo

The Super Nintendo has a signed hardware multiply hiding in its picture processor. We expected that to change the answer. It did not, and finding out why produced the most useful result in the whole series.

SNESSuper Famicom65816Ricoh 5A22Mode 7ternary weightsretro computing

What it is

A transformer running on the SNES’ Ricoh 5A22 (a 65816 core) with no enhancement chip — stock console, stock cartridge. It generates 7.03 tokens/sec on slow ROM and 8.02 on fast ROM, and across a 64-seed survey 1,280 of 1,280 generated tokens matched the reference implementation exactly at both speeds.

The prediction we got wrong

The SNES picture processor provides a signed 16×8 multiply into 24 bits, available with no wait states. Every other console in this series lacks that. So we predicted int8 weights would finally beat ternary here.

They did not. Measured before a single line of engine was written:

primitivecycles/MAC
software 8×8 shift-add1503.9
square-table lookup570.9
CPU multiply register317.3
PPU signed multiply, tuned220.5
ternary gather109.2

Ternary is 2.02× cheaper, and the multiply is not why. The PPU multiply is genuinely free — all 214 cycles in that arm are data movement.

The rule underneath

A ternary accumulate touches three memory locations. An int8 accumulate touches six.

That one sentence replaced three platform-specific explanations. Ternary’s advantage is not that it deletes a multiply; it is that it halves the operands the machine must fetch. So it lasts exactly as long as the machine charges per operand, and decays as machines get better at moving data: 2.02× on the SNES CPU, 1.27× on the SuperFX coprocessor, and it inverts on the Nintendo 64’s vector unit, which fetches eight operands in one transaction.

The cheapest gather is no gather

The 65816 has a 24-bit address space and the weights never change. So the index does not need to be fetched at all — it lives in the operand byte of the accumulate instruction, and the weight stream becomes straight-line code. That measured 33.09 against 72.11 master clocks per multiply-accumulate, and it deleted four data structures the NES port needed.

Source

Not yet run on real hardware. The ROM is LoROM, NTSC, 2 Mbit, with battery-backed save RAM and no enhancement chip, verified from the image bytes as compatible with a standard flash cartridge.


Part of a five-console series from Elyan Labs. See also: NES · Sega Genesis · Super Nintendo · Nintendo 64 · Game Boy Color · the full measurements, including the conclusions we had to retract.