Metal Acceleration on macOS: Maximize Apple Silicon LLM Speed

Apple's Metal GPU framework is the engine behind llama.cpp's macOS performance. With the right build flags and settings, you can push your Mac M-series chip to its theoretical maximum throughput for local LLM inference.

Build llama.cpp with Metal

git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp

# Metal is enabled by default on macOS, but verify:
cmake -B build -DGGML_METAL=ON -DGGML_METAL_EMBED_LIBRARY=ON
cmake --build build --config Release -j$(sysctl -n hw.ncpu)

# Verify Metal backend loaded
./build/bin/llama-cli --version
# Should show: Metal backend enabled

Optimal Settings for Apple Silicon

# M4 Max (14-core GPU) optimized settings
./build/bin/llama-server   -m ./models/qwen3.6-32b-q4.gguf   --n-gpu-layers 999 \    # all layers to Metal GPU
  --flash-attn   --ctx-size 32768   --threads 8 \            # P-core count on M4 Max
  --batch-size 512   --host 0.0.0.0 --port 8080

Metal Performance by Chip

ChipGPU CoresBWLlama 3.1 8BQwen 32B
M4 (MacBook)10120 GB/s28 tok/sN/A
M4 Pro20273 GB/s62 tok/s22 tok/s
M4 Max40546 GB/s98 tok/s28 tok/s
M4 Ultra80800 GB/s145 tok/s42 tok/s

For a comparison of Apple Silicon vs NVIDIA GPUs for local LLM inference, see the full analysis at LLMHardware.io.

Comments

Popular posts from this blog

AMD RX 9070 XT for Local LLMs: ROCm Performance Guide (2026)

llama.cpp flash attention: how to enable and benchmark

SillyTavern with Local LLMs: Complete Setup for AI Companions