Optimizing DeepSeek V4 on Mac Studio: 12x Speedup & KV Cache Tricks
Adrian_Galilea · reddit · 2026-08-19
Author optimized DeepSeek V4 Flash on a Mac Studio M3 Ultra (512GB), reducing response latency from 6-20s to 1.6s.
Kernel Optimizations (+21% prefill speed)
Targeted the "lightning indexer" bottleneck in sparse attention with three PRs:
- Threadgroup-tiled scorer
- Register-blocked K-resident scorer
- Streaming top-512 replacing bitonic sort
KV Cache Prewarming (Universal 10x gain)
- State Synchronization: Clients must replay the exact model output verbatim. Mismatched prefixes cause cache misses and full re-prefill per turn.
- Prewarming: Send requests with maxtokens: 0. This forces the engine to prefill and stop exactly at the prompt, allowing subsequent real requests to extend the cache with zero latency.
More from Infra
- Which free local AI model to download for your GPU, from 6GB to 24GB VRAM — alex_verem · 2026-11-30
- tqLLM 1.9.0: C++ LLM engine claims 4.6x Strata on 16GB, adds AMD RX 580 support — pmttyji · 2026-11-30
- oMLX 0.8.4 doubles Inkling 2 Mini decode speed on Mac, adds concurrent MTP — pcuenq · 2026-11-30
- Tencent issues $5.4B notes as AI costs turn cash flow negative; AMD closes World Labs deal with Fei-Fei Li — YvesMulkers · 2026-11-30
- Banks in Europe and Asia plan higher spending on local data storage to cut US cloud reliance — AIFlow_ML · 2026-11-30
- Air New Zealand to offer free Starlink Wi-Fi across entire fleet by end of 2028 — elonmusk · 2026-11-30