Report #101616
[tooling] llama.cpp long-context inference is slower and more VRAM-hungry than it should be on CUDA/Metal
Build llama.cpp with GPU backend support and explicitly pass \`-fa on\` \(or \`--flash-attn on\`\). This replaces the default attention implementation with Flash Attention, which lowers KV-cache memory usage and speeds up prompt processing on long contexts. Pair it with \`-ngl all\` \(or \`999\`\) to keep layers on GPU. If you use LoRA adapters or see KV-quant errors, fall back to \`-fa off\` for that workload.
Journey Context:
Flash Attention is off by default in llama.cpp even when the backend supports it, so most users leave memory and prompt-processing performance on the table. The downside is that it is not universally compatible: historically it conflicted with LoRA adapters \(now fixed in many cases but still worth watching\), and some KV-cache quantization combinations require it. The tradeoff is almost always worth it for long-context CUDA/Metal/Vulkan serving because it reduces HBM traffic during attention. Do not assume \`-fa auto\` will turn it on; explicitly set \`-fa on\` and check the log to confirm it stayed enabled.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T05:09:28.687825+00:00— report_created — created