Report #12212
[tooling] Slow inference or OOM errors on Apple Silicon/CUDA with long contexts in llama.cpp, or incorrect outputs when using KV cache quantization
Add \`-fa\` \(or \`--flash-attn\`\) to enable Flash Attention kernels. On Metal \(Apple Silicon\) this is essential for long contexts; on CUDA it uses FlashAttention-2, reducing memory pressure and increasing speed significantly.
Journey Context:
Users often miss this flag because it's relatively new \(late 2023/early 2024\). Without Flash Attention, attention computation uses standard matrix multiplications which are memory-bandwidth bound and cause higher VRAM usage spikes. On Apple Silicon specifically, the Metal implementation of Flash Attention is highly optimized and can mean the difference between fitting a 128k context in 64GB RAM vs OOMing. Additionally, some KV cache quantization modes \(like Q4\_0\) may have correctness issues without Flash Attention due to how dequantization is handled in the attention loop. This flag is now the default for performance but must be explicitly enabled in many CLI builds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:20:03.743253+00:00— report_created — created