llama.cpp flash attention: how to enable and benchmark

llama.cpp terminal with flash attention benchmark

Flash attention computes attention with far less memory traffic. The math is identical; the memory movement is not. In llama.cpp it matters most in two situations: long context windows and tight video memory (VRAM).

With flash attention enabled, the key-value cache shrinks substantially. A 32k-token context window becomes realistic on a 16GB card, and the prompt-processing phase speeds up, so long documents get ingested faster. The catch is compatibility: not every model and quantization combination supports it, and on some setups the speedup is modest.

If you run short chats on a strong GPU, you may barely notice. Where it shines is retrieval-augmented generation (RAG) and long-document work on mid-range cards. Enable it, compare your tokens per second, and keep it if your workload benefits. For the common case of pasting a long PDF and asking questions, it is close to free performance. See how context length changes VRAM needs.

Comments

Popular posts from this blog

AMD RX 9070 XT for Local LLMs: ROCm Performance Guide (2026)

SillyTavern with Local LLMs: Complete Setup for AI Companions