Bare-metal C LLM engine for a 2006 PS3 (150.7 tok/s, 137x llama.cpp) A from-scratch pure-C inference engine for the 2006 Sony PlayStation 3 reached 150.72 tokens per second decoding SmolLM2-135M-Instruct (Q4), 137.0× faster than a tuned 2-thread build of upstream llama.cpp (1.10 tok/s) on the same console, the project reports. The engine, cell-llm v6, uses the Cell Broadband Engine's 6 Synergistic Processing Elements with integer mpya instructions and 128-byte DMA, sustaining 17.36 GB/s on the LM head with 0.09% imbalance across SPEs, and prefills 41 tokens at 185.8 tok/s versus llama.cpp's 29.45 seconds. It runs with zero llama.cpp, CUDA, Python runtime or ML frameworks, fits in 24.7 KiB of SPU .text (versus 12 MB stripped llama.cpp), and compiles natively on the PS3 in about 2.5 seconds against roughly 60 minutes for upstream llama.cpp. Bare-metal-style LLM inference engine written from scratch in pure C + Cell SPU intrinsics for a 2006 Sony PlayStation 3 Cell Broadband Engine: 1 PowerPC PPE + 6 Synergistic Processing Elements, 215 MiB usable XDR DRAM . - Zero llama.cpp , zero CUDA, zero Python runtime, zero ML frameworks - 150.72 tok/s peak decode 139.5–150.7 tok/s across --bench 7 runs and 185.8 tok/s prefill running SmolLM2-135M-Instruct Q4 100% resident in PS3 XDR DRAM - 137.0× faster than tuned 2-thread upstream llama.cpp 1.10 tok/s on the exact same PlayStation 3 — 655× faster than default llama.cpp 0.23 tok/s , and 162× faster than the PS3 PPE -O3 baseline 0.93 tok/s - 17.36 GB/s sustained LM-head XDR DRAM bandwidth 0.09% imbalance across all 6 SPEs with 25,288 bytes 24.7 KiB of SPU .text machine code 156.8 KiB / 256 KiB Local Store vs 12 MB stripped llama.cpp - Compiles natively on the PS3 in ~2 seconds vs ~60 min for upstream llama.cpp Hardware: 2006 Sony PlayStation 3 Linux 6.12.62 ppc64 , Cell Broadband Engine 3.192 GHz , 6 active SPUs, 79.8 MHz decrementer, 215 MiB visible XDR DRAM . Model: HuggingFaceTB/SmolLM2-135M-Instruct 30 layers, dim=576 , hidden=1536 , GQA 9/3 , vocab=49,152 , 4-bit block-32 quantization, MAX SEQ=512 Q8 KV cache . | Metric | Upstream llama.cpp ee46715 , 2-thr best | cell-llm PPE -O3 baseline | cell-llm v5 6× SPE fp32 | cell-llm v6 6× SPE int mpya + 128B DMA | Speedup vs llama.cpp | |---|---|---|---|---|---| | Peak Decode Speed | 1.10 tok/s 908.9 ms/tok | 0.93 tok/s 1,074 ms/tok | 105.6 tok/s 9.5 ms/tok | 150.72 tok/s 6.63 ms/tok | 137.0× | | Sustained Mean --bench 7 | 1.10 tok/s | 0.93 tok/s | 94.8–101.3 tok/s | 139.5–139.6 tok/s 150.6 peak | 126.9× | | Prefill 41 tokens | 29.45 s 1.39 tok/s | 37.2 s 1.1 tok/s | 0.40 s 101.7 tok/s | 0.22 s 185.8 tok/s | 133.7× | | Model Load Time | 33.36 s BE GGUF | ~6 s | 5.3–8.3 s mlock | 5.3–8.3 s mlock | 4.0× – 6.3× | | Weight File Size | 85.93 MiB Q4 0 BE GGUF | 80.29 MiB CELL-Q4 32 | 80.29 MiB CELL-Q4 32 | 80.29 MiB CELL-Q4 32 | 1.07× smaller | | Context / KV Cache | fp16 KV | fp32 KV | 256 tok 11.8 MiB fp32 | 512 tok 7.03 MiB Q8 | 2× ctx / 40% less RAM | | SPU .text / Binary | 12 MB stripped 18 MB raw | 67 KB | 12.6 KiB .text 82 KB total | 24.7 KiB .text <100 KB total | 120× smaller | | Native PS3 Compile | ~60 min | ~1.4 s | ~2.0 s | ~2.5 s | ~1,440× faster | Upstream llama.cpp compiled natively on the PS3 with libggml / libggml-cpu at -O3 -mcpu=cell -mtune=cell PowerPC AltiVec quants enabled and endian-swapped SmolLM2-135M-Instruct-Q4 0-BE.gguf . Default n threads=4 scored 0.23 tok/s 4,380 ms/tok , 655× slower than v6 ; n threads=1 scored 1.03 tok/s ; n threads=2 matching the PPE's 2 SMT threads was llama.cpp 's best score at 1.10 tok/s . Measured with --bench 7 on the live PS3 desktop which wakes once per second for the status bar, dipping ~2 of 7 runs to 124–132 tok/s while clean runs consistently hit 150.2–150.7 tok/s . Per-Token Millisecond Breakdown v6 , --profile at 147.3 tok/s / 6.79 ms/tok ; 6.63 ms/tok unprofiled - 30-Layer Q4×Q11 Integer MatVec QKV , W o , fused gate+up+SwiGLU , W down : 4.89 ms - Tied LM Head 49,152 × 576 + In-SPE SIMD Argmax + Rep Penalty: 1.07 ms 17.36 GB/s sustained XDR DRAM across 6 SPEs - 6-SPE GQA-Paired Q8 FlashAttention-2 GQA 9/3 , head dim=64 : 0.45 ms - Standalone SwiGLU Dispatch: 0.00 ms 100% fused into CELL CMD GATE UP SWIGLU - PowerPC AltiVec RoPE + Fused Residual add rmsnorm PPE : 0.30 ms 0.09 ms RoPE + 0.21 ms norm - 6-SPE Hardware Decrementer Balance 79.8 MHz , LM head : 81,332 – 81,595 ticks 0.09% spread across SPE0 – SPE5 1. Native Big-Endian CELL-Q4 32 Weight Format tools/convert cellq4.c : - Packs 4 output rows × 32 input columns into an 80-byte, 16-byte-DMA-aligned tile 4 fp32 scales + 64 bytes of packed 4-bit nibbles, 5.0 bits/weight . - Zero byte-swapping on big-endian ppc64 ; mlock pins the entire 80.29 MiB weight buffer in physical XDR DRAM so Linux never pages out a layer. 2. Packs 4 output rows × 32 input columns into an 3. Integer Q4 × Q11 SPU mpya / mpyhha MatVec spu/cell llm spu.c : - Quantizes the activation vector x to 11-bit signed int16 pairs xl = q << 4 matching pk & 0x0F , xh = q matching unshifted pk & 0xF0 = 16 hi , eliminating all 32 cuflt instructions and all 4 rotm nibble shifts per tile while cutting shufb in half 32 → 16 . - Uses 8 dual int32 accumulators spu mule / spu mulo / spu mhhadd / spu madd to completely hide the SPU's 7-cycle integer multiply latency. 4. Quantizes the activation vector 5. 128-Byte Cell Cache-Line DMA Alignment + 4-Deep Power-of-2 Ring: - Clamps each SPE's tile batch size to a multiple of 4 batch tiles &= ~3u , e.g. 8 × 1440 = 11,520 B = 90 × 128 B , preventing unaligned 16-byte Element Interconnect Bus splits and jumping LM-head XDR bandwidth from 12.7 GB/s to 17.36 GB/s . - Splits run matvec out and run lm argmax with a 4-deep branchless cur + 3u & 3u DMA ring and single 128B-aligned mfc put writes per slice eliminating ~900 partial-cacheline false-sharing writes per token . 6. Clamps each SPE's tile batch size to a multiple of 4 7. Fused CELL CMD GATE UP SWIGLU + GQA-Paired 8-Bit KV FlashAttention-2: - Computes gate directly into Local Store, streams up , applies 4-wide SIMD SiLU gate up in-register, and issues a single 1,024 B mfc put — eliminating 30 SPE dispatches/token. - Compresses KV cache steps to 80 bytes 64 × uint8 + fp32 scale + 12 B pad, MAX SEQ=512 , 7.03 MiB , halving KV DMA on 2-head SPEs SPE 0, 2, 4 via paired integer Q·K dot products and shared V unpacking. 8. Computes 9. Zero-Syscall MMIO Mailboxes + PowerPC AltiVec PPE ppe/cell llm.c , ppe/cell llm web.h : - Persistent SPE contexts dispatched via direct SPE MAP PS memory-mapped SPU In Mbox / SPU Out Mbox registers with lwsync ordering. - PowerPC AltiVec