Unified Memory Bandwidth Roofline Physics: Sparse MoE vs Dense GGUF Decode on Apple Silicon M1 to M4 Pro

Deriving Metal 3 single-token decode bounds on Apple Silicon (273 GB/s M4 Pro) across sparse MoE (LFM2-8B-A1B: 78.62 tok/s measured vs 78.33 tok/s model) and dense 27B weights, q8_0 KV-cache math, macOS wired-page headroom, and deterministic sizing via estimate_apple_silicon_tok_per_sec.
Unified Memory Bandwidth Roofline Physics: Sparse MoE vs Dense GGUF Decode on Apple Silicon M1 to M4 Pro

Unified Memory Bandwidth Roofline Physics: Sparse MoE vs Dense GGUF Decode on Apple Silicon M1 to M4 Pro

Autoregressive token generation at batch size 1 is memory-bandwidth bound, not ALU-FLOPS bound. Every generated token requires streaming every active parameter and attention key-value (KV) state from Apple Unified Memory into the GPU shader cores once per forward pass.

In commit 4e9b17d8 inside mcp/destiny_mcp_server.py, we added estimate_apple_silicon_tok_per_sec to turn manufacturer Unified Memory bandwidth specs and Ed25519-verified byte counts into deterministic roofline and realistic decode bounds paired with Apple Silicon GGUF VRAM Calculator.


1. Bandwidth Roofline & Active-Parameter Equation

For a chip with peak Unified Memory bandwidth BW (GB/s), model file size W (GB), active sparse routing ratio alpha (0 < alpha <= 1.0), and live KV-cache footprint K (GiB):

active_read_gb_per_tok = W * alpha + 0.12 * K
roofline_decode_tok_s  = BW / active_read_gb_per_tok
realistic_metal_tok_s  = (BW * 0.615) / active_read_gb_per_tok
  • Why alpha dominates latency: On Apple M4 Pro (273 GB/s), dense Qwen3.8-27B UD-Q4_K_M (16,817,244,384 B, alpha = 1.00) reads 16.840 GB/token at 8192 tokens (q8_0 KV): 273 / 16.840 = 16.21 tok/s theoretical ceiling and 9.97 tok/s sustained solo Metal decode (29.37 tok/s when accelerated by DFlash2 speculative drafting).
  • Sparse Mixture-of-Experts (LFM2-8B-A1B Q8_0): With 8,868,428,480 B total weights and alpha = 0.24 (~2.0B active weights per token), per-token read drops to 2.143 GB (8192 context, q8_0 KV). That yields a 127.37 tok/s hardware ceiling and 78.33 tok/s realistic decode (0.615 Metal efficiency) — matching our measured 78.62 tok/s single-stream M4 Pro benchmark in nandai.org/benchmarks and Destiny-M4-Pro-Hardware-Benchmarks.

2. q8_0 KV-Cache Byte Math (fp16 vs q8_0 vs q4_0)

Long contexts shift bottlenecks from weights into attention cache growth:

  • Scaling factors: fp16 = 1.0x, q8_0 = 0.5x, q4_0 = 0.25x (32 MiB / 1K tokens base on LFM2-8B-A1B, 40 MiB / 1K on Inkling-2-Mini, 48 MiB / 1K on Qwen3.8-27B).
  • At 8192 tokens (8 × 1K) with q8_0 KV quantization (0.5x), LFM2-8B-A1B needs only 8 * 16 MiB = 128 MiB (0.125 GiB), whereas fp16 doubles to 0.250 GiB and 131,072 tokens expands to 2.000 GiB (q8_0) vs 4.000 GiB (fp16).

3. macOS Wired-Memory Pool, vm.compressor & MAP_SHARED Headroom

Exceeding macOS’s Metal recommendedMaxWorkingSetSize wired budget forces kernel vm.compressor paging and swap thrashing, collapsing decode throughput by 4x–10x:

  • Usable Metal wired pools: 11.50 GiB on 16 GB Macs (71.9%), 18.00 GiB on 24 GB Macs (75.0%), and ~79% of physical Unified Memory on 36 GB–512 GB systems (37.9 GiB on 48 GB, 101.1 GiB on 128 GB, 151.7 GiB on 192 GB).
  • Required footprint (W_GiB + K_GiB + 0.45 GiB runtime scratch):
    • On 24 GB M4 Pro: LFM2-8B-A1B Q8_0 uses 8.834 GiB (+9.17 GiB headroom), while Qwen3.8-27B UD-Q4_K_M uses 16.300 GiB (+1.70 GiB wired headroom — clean MAP_SHARED residency with zero 0 B dirty GGUF pages).
    • Across M1 (68.25 GB/s), M2 Pro (200 GB/s), M3 Pro (150 GB/s), M3 Max (300/400 GB/s), M4 Max (546 GB/s), and M3 Ultra (819 GB/s), scaling is linear with BW until context KV reads approach active weight bytes.

Verified Specifications & Interactive Sizing Tools


Write a comment