Ramkumar's blog

GPU is not all you need for local LLMs - Part 2

This is part 2 of a two part series. Read part 1 to understand unique features needed in local LLM inference engines compared to cloud inference.

This experimental work is a result of me driving LLMs with my intuitions. Under Gemini 4 Argon's oversight, Gemini 4 Hydrogen and Deepseek V4.1 Flash wrote all the code and benchmarks. Total cost was ~$50 with API pricing. The term "we" in this post refers to me and LLM models I used.

Local LLM inference engines often only utilize GPUs for large models. Let’s see the compute power in Apple Silicon apart from the GPU. We have something called a neural engine. A closer look at the CPU will reveal the presence of AMX (Apple Matrix Coprocessor) inside it. AMX is yet another accelerator for working with matrices.

Block diagram of Apple's Unified Memory Architecture Source: What Is Unified Memory on Your Mac and How Does It Work?

The AMX and Apple Neural Engine (ANE), which I paid for, sit idle while the GPU saturates during prefill compute. Uzu claims the best token generation speed in Apple Silicom because of its speculative decoding. But its input prompt processing (prefill) was painfully slow in my base M4 chip. Based on its published metrics, prefill speed was already on-par with the alternatives. I decided to implement split prefill in Uzu by summoning a few LLMs. Split prefill is where the prefill compute work is split across multiple accelerators - GPU, CPU and ANE in Apple Silicon.

Long story short, prefill got a huge speedup by sharing the work with CPU and the Apple Neural Engine (ANE). For every large matrix-matrix multiplication, we made each engine work on its own share of the matrix and write output to a shared memory. The GEMM is split along the output-channel dimension such that all three engines read the same input activation matrix and write to disjoint column offsets with zero cross-device communication. Because of the unified memory in Apple Silicon, this heterogeneous GEMM split results in zero cross-device copies. Having said that, there is an overhead of storing layout transposes to match the ANE’s requirement.

Illustration showing how a matric multiplication is split across the output columns

AI generated image

The split ratio must be carefully engineered so that all three engines complete work at the same time and not get blocked on others. For finding the optimal split ratio, there is an initial tuning step that runs at model load time.

The CPU split uses AMX via BNNS API. Apple’s ANE has somewhat a closed API designed only for running complete neural network inference. ANE does not expose APIs to perform custom matrix multiplications. Thanks to this work of reverse engineering the ANE.

With our experimental patch on Macbook M4 Air (24GB) running Qwen3.5-9B (Mirai M-quantized, 4-bit) model, we see 2.78x prefill speedup on 1024 and 2048 token prompts (and up to 2.89x on real summarization tasks). This directly converts to faster Time to First Token (TTFT).

Performance numbers of GEMM split by split mode Performance numbers of GEMM split by summarization benchmarks Performance numbers of GEMM split by controlled prompt lengths

There are challenges shipping the prefill split feature. These are also the reasons it is not found in many popular inference engines, I assume.

While it is nothing novel, the experiment was a good learning experience. I don't plan to submit this upstream, rather I use it as a makeshift solution for Qwen family models in my Macbook without NAX.

Tags: #llm #performance