A sovereign ARM-NEON CPU inference backend (Raspberry Pi 4B): Q8 and multicore are complementary, not additive
Ran Tao (Octoryn Research)
摘要
A CPU-only inference backend was brought up on a Raspberry Pi 4B (Cortex-A72, ARMv8.0-A) as hand-written ARM-NEON C++ with no BLAS/HIP/CUDA. Two dense decoders (~0.36B Llama-style, ~0.5B Qwen2-style) match a recent fp32 reference (cosine 1.0 and 0.99999988), byte-identical across two boards. On this bandwidth-starved target, 8-bit weight quantization and multicore threading are complementary, not additive: neither alone moved decode throughput; only Q8 plus four threads won (~9.83 tok/s, ~3.65x). A clock-sensitivity control confirms Q8 flips the workload compute-bound. Single measured run.
本 Research Object 以其原始语言(英文)发表。
A sovereign ARM-NEON CPU inference backend (Raspberry Pi 4B): Q8 and multicore are complementary, not additive
1. Contribution
Claimed. We brought up a CPU-only text inference backend from zero on the Raspberry Pi 4B (Cortex-A72, ARMv8.0-A) as pure hand-written ARM-NEON host C++ with zero BLAS/HIP/CUDA (a dynamic-library check shows only the C/C++ runtime and math library). Two dense decoder architectures run end to end without external math libraries: a ~0.36B Llama-style model (no attention bias) and a ~0.5B Qwen2-style model (with QKV bias). The load-bearing research result is a composition finding on a bandwidth-starved edge target: narrow weights (fp16/Q8) and multicore threading are complementary, not additive. Neither quantization alone nor threading alone moved decode throughput; only Q8 combined with 4 threads won (~3.65x). This echoes an earlier GPU-side observation that Q8 is "memory-mode-positive / compute-mode-negative," now reproduced on a CPU-only backend.
NOT claimed. We do NOT claim a production-serving stack, batched/chunked prefill, cross-box single-stream tensor/pipeline parallel, MoE/SSM/RWKV/fused-QKV coverage, sustained-thermal endurance, or multi-run statistical variance on the throughput numbers. The throughput figures are single measured runs under one governor/clock condition. The two-box figure is aggregate throughput over independent requests, not a single-stream speedup.
2. Methods
| Aspect | Value |
|---|---|
| Models | A ~0.36B Llama-style dense decoder (tied embeddings, no attention bias) and a ~0.5B Qwen2-style dense decoder (tied embeddings, with QKV bias). |
| Hardware | 2-node Pi 4B cluster. Node A: 8GB, A72 @ 1.8GHz. Node B: 4GB, A72 @ 1.5GHz. Both aarch64 Linux. A72 = ARMv8.0-A: CPU features are fp asimd only — NO int8 dot-product, NO native fp16 arithmetic. fp16↔fp32 conversion is base v8.0 and is used. |
| Build | On-box C++20 build with -O3 and OpenMP for an ARMv8-A target using a recent GCC. Development on an Apple-silicon Mac (also aarch64 + NEON, v8.0 baseline); final parity and throughput measured on-box. |
| Oracle | A recent transformers fp32 build, identical token ids. |
| Precision | Weights load bf16→fp32, then optionally fp16 or group-wise symmetric 8-bit. All GEMV accumulation is fp32 (A72 has no int8 dot-product). |
| Measurement | Decode tok/s on-box, greedy, CPU governor pinned to performance. Kernel micro-parity vs double-precision references. |
3. Results
Correctness / parity (vs a recent transformers fp32 oracle).
| Model | Precision | Cosine vs reference | Argmax/top-5 |
|---|---|---|---|
| Llama-style ~0.36B | fp32 | 1.0000000000 | identical |
| Llama-style ~0.36B | fp16 | 1.000000 | match |
| Llama-style ~0.36B | q8 | 0.999901 | match |
| Qwen2-style ~0.5B | fp32 | 0.99999988 | identical |
Kernel micro-parity (NEON vs scalar/double reference, on the dev Mac and both A72 nodes): GEMV f32/f16/q8 max_abs ≤ 1e-5; norm/rope/swiglu/gelu max_abs < 3.4e-7; attention decode (GQA) max_abs < 1e-7; composed 2-layer block cosine = 1.0. Generations are byte-identical across both Pi nodes on a fixed prompt.
Throughput — the composition finding (Llama-style ~0.36B decode, Node A 4 cores @ 1.8GHz, greedy, single run).
| Precision | weight bytes/token | cosine vs reference | 1 thread | 4 threads | multicore speedup |
|---|---|---|---|---|---|
| fp32 | ~1.45 GB | 1.0 (ref) | 2.84 | 2.72 | none |
| fp16 | ~724 MB | 1.000000 | 3.01 | 5.13 | 1.7x |
| q8 | ~362 MB | 0.999901 | 2.69 | 9.83 | 3.65x |
Mechanism:
- fp32 is memory-bandwidth-bound. Roughly 1.45 GB of weight traffic per token saturates the single LPDDR4 bus; adding cores does not help (they stall on the same bus) and CPU clock does not matter.
- Q8 single-thread is a wash (~2.69 vs fp32 2.84). A72 has no int8 dot-product, so the int8→fp32 dequant adds roughly 2x the vector ops of fp32's fused-multiply-add, approximately cancelling the 4x weight-bandwidth saving. Q8 alone is a memory-footprint win, not a speed win.
- Q8 + 4 threads is the win (~3.65x, 9.83 tok/s). Cutting weight traffic to ~362 MB/token frees enough bandwidth that the workload flips compute-bound and the 4 cores parallelise. The speedup tracks bytes-freed monotonically (none → 1.7x → 3.65x).
2-node data-parallel (Llama-style ~0.36B q8 / 4T). Concurrent independent streams: Node A 9.75 + Node B 8.33 = ~18 tok/s aggregate. This is aggregate throughput over INDEPENDENT requests (data-parallel), NOT one stream made faster.
4. Ablations / negative controls
- Clock-sensitivity flip (the mechanism's confirming control). Under Q8+4T the workload is clock-dependent: Node B @ 1.5GHz = 8.40 tok/s, ~14% below Node A @ 1.8GHz's 9.83, matching the 1.5/1.8 clock ratio. Under bandwidth-bound fp32, clock does not matter. This flip is the positive evidence that Q8 moved the workload from bandwidth-bound to compute-bound.
rms_norm_epsperturbation: moving the norm epsilon far off its configured value collapses cosine to −0.67 and the output degenerates to "is is is is". Proves the norm path is load-bearing and config is honoured. (Source note: the Llama-style config ships eps=1e-5, NOT 1e-6 — a recurring trap.)rope_thetaperturbation (1e5 → 1e4): argmax flips (Paris → the), text degrades. Honest caveat: cosine only dips to 0.9999 at 5-token context (RoPE angles are tiny there), so the argmax flip — not cosine — is the discriminating signal; cosine is weak on short prompts.
5. Threats to validity / limitations
- Single-run throughput, no variance. All tok/s figures are single measured runs under one governor (performance) / one clock condition. No multi-run mean/std is recorded — hence evidence level is experimental, not reproduced. (Correctness, by contrast, was confirmed byte-identical across two boxes.)
- Decode only (M=1). Prefill reuses the same per-token path; no chunked/batched prefill.
- Coverage. Only two dense architectures (Llama no-bias, Qwen2 QKV-bias). Fused-QKV, scalar-multiplier, MoE, SSM/RWKV not yet wired.
- Kernel correctness-first overheads. Attention recopies a compact KV slice per layer per token (a strided-view kernel would remove the copy); transcendentals use exact libm scalar (vectorized polynomial approximations are future work). These bound absolute tok/s but do not affect the relative composition finding.
- Thermal. Both boxes idle ~45-50°C, no throttling observed; sustained multi-minute decode under load was NOT endurance-tested.
- Bandwidth figure is effective, not bus-spec. The ~4 GB/s effective bus figure underlying the mechanism narrative is an observed-saturation interpretation, not an independently profiled bus benchmark.
- 2-box aggregate is not single-stream. Cross-box single-stream tensor/pipeline parallel is LAN-latency-bound and out of scope.
6. Reproducibility (high-level)
The implementation is a config-driven driver over hand-written NEON kernels, reusing an external-math-library-free safetensors loader and a BPE tokenizer (Llama- and Qwen-compatible), with a header-only JSON dependency vendored to the on-box build directory. Provisioning sets swap and pins the CPU governor to performance; deployment builds on-box with the recent GCC toolchain noted above. Parity is validated by dumping last-token logits and comparing to the transformers fp32 oracle.
声明边界
作者对范围的明确界定——本工作证明了什么、未证明什么——沿用自 Octoryn Research 的发表模型。
证明
- On Cortex-A72 / ARMv8.0 (no int8 dot-product), 8-bit weight quantization alone is a memory/footprint win not a speed win, and fp32 multithreading is bus-bound; only Q8 combined with four threads wins (~9.83 tok/s, ~3.65x).
- A clock-sensitivity control (Q8+4T scales with the CPU clock ratio while fp32 does not) confirms Q8 moves the workload from bandwidth-bound to compute-bound.
- Sovereign correctness: the two dense models match a recent fp32 transformers reference (cosine 1.0 and 0.99999988), byte-identical across two boards, with no BLAS/HIP/CUDA linkage.
未证明
- No multi-run or statistical variance on throughput; tok/s are single runs under one governor and clock, so the numbers are not reproduced-grade.
- Not a serving or production stack; decode-only (M=1), with no batched or chunked prefill and no single-stream cross-board parallelism.
- Says nothing about MoE/SSM/RWKV/fused-QKV, larger models, sustained thermal endurance, or non-A72 ARM cores with an int8 dot-product or native fp16 arithmetic.
适用于
- Cortex-A72 / ARMv8.0-A class cores (fp + asimd only, no int8 dot-product, no native fp16 arithmetic) on a single shared LPDDR4 memory bus.
- Small dense decoder LLMs (~0.36B-0.5B), greedy decode, CPU governor set to performance, group-wise symmetric 8-bit weight quantization.
- A memory-bandwidth-bound regime where per-token weight traffic saturates the bus.
不适用于
- ARMv8.2+ cores with an int8 dot-product or native fp16 arithmetic, where the int8 dequant overhead is absent.
- GPU or accelerator backends, or compute-bound regimes where memory bandwidth is not the limiter.
- Batched or multi-request serving, prefill-dominated workloads, or single-stream cross-node tensor/pipeline parallelism.
作者
- Ran Tao — 调查研究, 写作
引用本文
引用格式
Tao, R., Octoryn Research. (2026). A sovereign ARM-NEON CPU inference backend (Raspberry Pi 4B): Q8 and multicore are complementary, not additive (TR-2026-0050). Octopus Research Institute.
BibTeX
@techreport{oritr20260050,
title = {A sovereign ARM-NEON CPU inference backend (Raspberry Pi 4B): Q8 and multicore are complementary, not additive},
author = {Tao, Ran and {Octoryn Research}},
institution = {Octopus Research Institute},
year = {2026},
note = {Permanent ID TR-2026-0050. Not peer reviewed.}
}披露
- 资助
- 硬件与基础设施由 Octoryn / Octopus Core Pty Ltd 提供。
- 利益冲突
- Octoryn 提供商业推理与治理工具;相关发现独立报告。
