Apple Silicon LLM Memory Bandwidth & Sizing Dataset
Apple Silicon Local LLM Sizing: Memory Bandwidth Rooflines, GQA KV-Cache Math & macOS Wired Limits
Why this problem wastes time
Engineers buying a MacBook Pro, Mac mini, or Mac Studio for local LLM inference routinely get burned by misleading rules of thumb. "Just divide parameters by two for 4-bit" or "an M3 Pro is always faster than an M2 Pro" sounds convenient—until a 32B model swaps to SSD or decodes 35% slower than expected. Four hardware and math traps explain almost every sizing surprise on Apple Silicon:
- Binned memory buses and the M3 Pro regression: Apple's M3 Pro narrowed its memory bus to 192-bit (
150 GB/s), making single-stream token decode slower than the older M2 Pro (200 GB/s). Similarly, binnedM3 Max (14c/30c GPU)runs at300 GB/s(384-bit) while the fullM3 Max (16c/40c GPU)runs at400 GB/s(512-bit), and binnedM4 Max (14c/32c GPU)runs at410 GB/svs546 GB/son the full 16c/40c die. - Naive
4.0 bpwunderestimates real GGUF weights by ~20%: Inllama.cpp/ MLX GGUF quantizations, embedding layers, output projection heads, and quantization block scales push effectiveQ4_K_Mstorage closer to4.85 bpw(not4.0 bpw). On a 32.5B parameter model likeQwen2.5-32B, that difference is3.4 GBof unexpected RAM. - macOS Metal wired-memory caps trigger early OOM: Buying a
64 GBMac does not give Metal64 GBof GPU-allocatable memory. By default, macOS caps wired GPU memory at roughly67%on<= 24 GBmachines and75%on>= 32 GBmachines (48 GBusable on a64 GBsystem) unless you raisesysctl iogpu.wired_limit_mb. - Non-uniform KV-cache geometries across modern models:
Qwen2.5-7Buses4KV heads,Phi-4-14Buses10KV heads, andGemma-2-9Buseshead_dim=256with alternating 50% global / 50% sliding-window-4096 attention layers. Ignoring hybrid sliding-window attention overstates Gemma-2 KV memory by up to 2× at long context.
Step-by-step workflow
Autoregressive token generation (batch size 1) is strictly memory-bandwidth bound: for every single token emitted, the GPU streams all active model weights plus the active KV cache across unified memory. You can compute an exact, zero-guesswork roofline in pure Python:
QUANT_BPW = {"Q4_K_M": 4.85, "Q5_K_M": 5.70, "Q6_K": 6.56, "Q8_0": 8.50, "FP16": 16.0} def roofline_estimate(bandwidth_gbs: float, params_b: float, layers: int, kv_heads: int, head_dim: int, ctx: int, quant: str = "Q4_K_M", kv_bytes: float = 2.0, hybrid_swa_4096: bool = False) -> dict: weights_gb = params_b * (QUANT_BPW[quant] / 8.0) if hybrid_swa_4096: g_layers = layers // 2 s_layers = layers - g_layers kv_gb = (2 * kv_heads * head_dim * kv_bytes * (g_layers * ctx + s_layers * min(ctx, 4096))) / 1e9 else: kv_gb = (2 * layers * kv_heads * head_dim * kv_bytes * ctx) / 1e9 active_gb = weights_gb + kv_gb ceiling = bandwidth_gbs / active_gb return { "weights_gb": round(weights_gb, 2), "kv_cache_gb": round(kv_gb, 2), "roofline_tok_s": round(ceiling, 1), "typical_range_tok_s": (round(ceiling * 0.65, 1), round(ceiling * 0.80, 1)), } Checking macOS usable GPU headroom
Before downloading a 40 GB GGUF file, verify both OS headroom and the Metal wired-memory ceiling:
def usable_gpu_gb(ram_gb: int, os_reserve_gb: float = 4.0) -> float: wired_ratio = 0.67 if ram_gb <= 24 else 0.75 return max(0.0, min(ram_gb - os_reserve_gb, ram_gb * wired_ratio)) Common pitfalls & edge cases
- Confusing decimal GB with GiB: Apple publishes memory bandwidth in decimal
GB/s(10^9 B/s). Computingweights_gbandkv_cache_gbin matching decimal GB (10^9 B) keeps the dimensional ratioGB/s / GB = tok/sexact. - Assuming 100% bus utilization: Real
llama.cppand MLX Metal kernels typically achieve65%–80%of theoretical memory bandwidth during single-stream decode due to dequantization compute, attention overhead, and cache misses. Always plan around the realized band, not the 100% ceiling. - Invalid hardware pairings: Not every RAM size ships on every chip (e.g.,
M4 Max 14c/32cis36 GBonly;M3 Ultraships in96 / 256 / 512 GB; there is noM4 Ultra).
Automating it in seconds
Use the Interactive Apple Silicon LLM Sizing Calculator to explore all 17 verified Apple Silicon SKUs and 14 published open-weight LLM profiles, toggle FP16 vs Q8_0 KV-cache precision, and inspect FITS / TIGHT / OOM status instantly in your browser.
You can download the complete $0.00 Free Open Dataset & Python CLI Kit (Gumroad, GitHub Release, and Kaggle Datasets), including identical canonical apple_silicon_specs.csv/.json and llm_arch_profiles.csv/.json files, llm_sizing_cli.py (estimate, matrix --format md|csv|json, validate), METHODOLOGY.md, and test_llm_sizing.py.
Live Demo & Full Guide
- Live Interactive Demo / Tool: https://nuan2779.github.io/auto-tools/products/show-hn-open-dataset-of-real-world-llm-performan-439/
- Full Canonical Guide: https://nuan2779.github.io/auto-tools/blog/show-hn-open-dataset-of-real-world-llm-performan-439/

