Report #14994
[tooling] llama.cpp slow inference on long contexts \(>8k\) despite GPU acceleration
Compile llama.cpp with LLAMA\_FLASH\_ATTN=ON and run with --flash-attn flag to enable Flash Attention, which reduces KV cache memory bandwidth by recomputing attention on-the-fly instead of reading the full cache from VRAM
Journey Context:
Standard attention reads the entire KV cache from memory for each new token, hitting bandwidth bottlenecks on long contexts \(32k\+\). Flash Attention fuses the attention computation and uses tiling to avoid materializing the full attention matrix, trading compute for memory bandwidth. Essential for 70B\+ models on consumer GPUs where VRAM bandwidth is the bottleneck, not compute. Many users enable CUDA but miss this specific flag, leaving 2-3x performance on the table for long contexts. Note: requires compile-time support and the runtime flag.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:53:24.570552+00:00— report_created — created