Scottcjn/llama-cpp-power8
À propos
llama.cpp optimizations for IBM POWER8: vec_perm non-bijunctive collapse, PSE hardware entropy, DCBT prefetch. Sovereign inference. Part of the Proof of Physical AI stack.
IA et apprentissage automatiqueProgression mesurée des étoiles
- in 24h
- +1
- in 7 days
- Historique en cours
- in 15 days
- Historique en cours
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
Originalllama.cpp for IBM POWER8
AltiVec/VSX Optimized LLM Inference for POWER8
Run your own models on your own hardware. This provides POWER8-specific optimizations for llama.cpp, enabling efficient LLM inference on IBM POWER8 servers using vec_perm non-bijunctive collapse and PSE hardware entropy — techniques built around POWER8's single-instruction two-source vec_perm (AArch64 TBL can do the same in one instruction; x86 needs several below AVX-512 VBMI).
What's Included
- power8-compat.h - POWER9 intrinsics compatibility layer for POWER8
- ggml-dcbt-resident.h - Full L2/L3 cache-resident prefetch hints
- altivec_benchmark.c - AltiVec/VSX performance benchmark
Performance
Tested on IBM Power System S824 (dual 8-core POWER8, 576GB RAM):
| Model | pp128 (tokens/s) | tg32 (tokens/s) |
|---|---|---|
| TinyLlama 1.1B Q4 | ~85 | ~15 |
| Llama-7B Q4 | ~20 | ~5 |
| DeepSeek-33B Q4 | ~5 | ~1 |
| Gemma 4 26B-A4B MoE Q4 (2026-06) | ~16.6 | ~6.4 |
Speedup on TinyLlama 1.1B Q4, prompt processing (pp128), same S824:
| Build | pp128 (tokens/s) | vs scalar | vs stock VSX |
|---|---|---|---|
| Stock llama.cpp, scalar (no vector code) | 16.7 | 1.0x | — |
| Stock llama.cpp with POWER8 VSX | 66.5 | 4.0x | 1.0x |
| This patch set (PSE + resident prefetch) | 147.5 | 8.8x | 2.2x |
2026-06 update: the PSE patch set ported cleanly onto Gemma 4-era llama.cpp (master
ac4cdde) and delivered 1.7x generation / 3.1x prompt processing on the Gemma 4 26B-A4B mixture-of-experts vs the same master without PSE (10.7x vs stock-unbound). Details + the PSE-2 "Expert Coffers" direction in PSE_IMPLEMENTATION_LOG.md.
Building llama.cpp for POWER8
Prerequisites
- Ubuntu 20.04 LTS (last POWER8-supported release)
- GCC with POWER8 support
- CMake 3.14+
Build Commands
# Clone llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
# Copy POWER8 headers
cp /path/to/powerpc/* ggml/src/ggml-cpu/arch/powerpc/
# Configure for POWER8
mkdir build-power8 && cd build-power8
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_OPENMP=ON \
-DCMAKE_C_FLAGS="-mcpu=power8 -mvsx -maltivec -O3 -mtune=power8 -funroll-loops" \
-DCMAKE_CXX_FLAGS="-mcpu=power8 -mvsx -maltivec -O3 -mtune=power8 -funroll-loops"
# Build
make -j$(nproc)
With IBM MASS Library (Optional)
IBM Mathematical Acceleration Subsystem (MASS) provides optimized math functions:
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_OPENMP=ON \
-DCMAKE_C_FLAGS="-mcpu=power8 -mvsx -maltivec -O3 -mtune=power8 -funroll-loops -DGGML_USE_MASS=1 -DGGML_USE_IBM_MASS=1 -I/opt/ibm/mass/include" \
-DCMAKE_CXX_FLAGS="-mcpu=power8 -mvsx -maltivec -O3 -mtune=power8 -funroll-loops -DGGML_USE_MASS=1 -DGGML_USE_IBM_MASS=1 -I/opt/ibm/mass/include" \
-DCMAKE_EXE_LINKER_FLAGS="-L/opt/ibm/mass/lib -lmassvp8 -lmass"
The ggml-mass-integration.h wrappers in this repo are gated on GGML_USE_IBM_MASS,
which is why the flags above pass -DGGML_USE_IBM_MASS=1. -DGGML_USE_MASS=1 alone
leaves them disabled (GGML_MASS_AVAILABLE 0).
Fallback Behavior (Without VSX Acceleration)
When building or running on targets where POWER8 VSX vector extensions are unavailable (or when compiling with generic PowerPC flags without -mvsx -maltivec), llama.cpp automatically falls back to scalar floating-point and integer routines. This ensures functional compatibility across all generic PowerPC environments while maintaining optimal vectorized paths when VSX hardware acceleration is present.
Running Inference
# Basic inference
./bin/llama-cli -m ~/models/llama-7b-q4.gguf -p "Hello world" -n 64
# With optimal thread count (64 threads is usually best on POWER8)
OMP_NUM_THREADS=64 ./bin/llama-cli -m ~/models/llama-7b-q4.gguf -p "Hello" -n 64
# NUMA-aware (for dual-socket systems)
numactl --interleave=all ./bin/llama-cli -m ~/models/large-model.gguf -p "Test" -n 32
# Benchmark
./bin/llama-bench -m ~/models/tinyllama-1.1b-q4.gguf -t 64 -p 128 -n 32
POWER8 Optimization Notes
Thread Scaling
64 threads is typically optimal on POWER8 (NOT 128):
- 16 threads: ~40 t/s
- 32 threads: ~65 t/s
- 64 threads: ~85 t/s (optimal)
- 96 threads: ~75 t/s
- 128 threads: ~65 t/s
Cache Prefetch
The ggml-dcbt-resident.h header provides cache-resident prefetch hints:
DCBT_RESIDENT_FULL()- Keeps data in L2/L3 until explicit eviction- Critical for weight reuse in attention/matmul
Memory Alignment
POWER8 prefers 128-byte aligned data for optimal VSX performance.
power8-compat.h does not align data for you. It leaves vec_xl/vec_xst as
the compiler's native unaligned VSX loads/stores (correct at any address), so
128-byte alignment is a performance choice for the caller, not a correctness
requirement.
Files
powerpc/
├── power8-compat.h # POWER9 → POWER8 intrinsic compatibility
└── ggml-dcbt-resident.h # Cache-resident prefetch hints
altivec_benchmark.c # VSX/AltiVec performance test
Hardware Tested
- System: IBM Power System S824 (8286-42A)
- CPUs: Dual 8-core POWER8, 128 threads (SMT8)
- RAM: 576 GB DDR3
- OS: Ubuntu 20.04 LTS
Video Demos
DeepSeek Running on POWER8 - LLM inference on IBM POWER8 S824
Claude Code on POWER8 - Proving Claude Code works on POWER8!
Community
Join the RustChain Discord for PowerPC/POWER8 AI discussion:
The Proof of Physical AI Stack
This repo is one piece of a vertically integrated system where the hardware that runs inference also earns tokens:
| Layer | Project | What It Does |
|---|---|---|
| Inference | llama-cpp-power8 (this repo) | vec_perm collapse, PSE entropy, DCBT prefetch |
| Memory | RAM Coffers | NUMA-distributed weight banking, 147 t/s on POWER8 |
| Consensus | RustChain | Proof of Antiquity — 1 CPU = 1 Vote, vintage hardware earns more |
| DePIN | RustChain Network | 2 live attestation nodes (volunteer nodes come and go), hardware fingerprinting, RTC token rewards |
The same POWER8 S824 (2.2x over stock VSX llama.cpp on pp128) also mines RTC via Proof of Antiquity at a 1.5x POWER8 multiplier ("power8": 1.5 in node/rip_200_round_robin_1cpu1vote.py; base value before the ~15%/year antiquity decay). Sovereign inference, sovereign earnings.
Related Projects
- llama.cpp - Main project
- RAM Coffers - NUMA-aware weight banking (companion project)
- Claude Code POWER8 - Claude Code for POWER8
- RustChain - Proof of Antiquity blockchain
Attribution
Months of research, tuning, and testing on real POWER8 hardware went into this.
If you use this project, please give credit:
llama.cpp POWER8 Optimizations by Scott (Scottcjn)
https://github.com/Scottcjn/llama-cpp-power8
If this helped you, please:
- ⭐ Star this repo - It helps others find it
- 📝 Credit in your project - Keep the attribution
- 🔗 Link back - Share the love
Credits
- ggerganov/llama.cpp - Original project
- Scott (Scottcjn) - Creator, architect, hardware lab, POWER8 optimizations
- Claude (Opus 4.1/4.5) - Implementation assistance
Designed by Scott, coded with Claude
License
Apache License 2.0. See LICENSE.
ggml/src/ggml-cpu/arch/powerpc/quants.c and ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp are modified copies of files from llama.cpp/ggml, which are MIT-licensed (Copyright (c) 2023-2026 The ggml authors). Those two files keep their MIT terms.
"576GB RAM. 128 threads. Your POWER8 was built for AI - it just didn't know it yet."
Elyan Labs · 1,882 commits · 97 repos · 1,334 stars · $0 raised
⭐ Star RustChain · 📊 Q1 2026 Traction Report · Follow @Scottcjn
Part of the Elyan Labs Ecosystem
Explorer des projets similaires
Chargement…

