New Tool Radar

Local AI

How to Turn On Flash Attention in llama-server with –flash-attn

Enable flash attention in llama-server for faster long-prompt processing.

Schematic illustration with three step boxes: Check your build; Start with the flag; Compare a long prompt.

llama-server accepts a –flash-attn flag that turns on flash attention for the attention computation. On long prompts it can cut the prompt-processing time noticeably, because attention cost grows with context length. This guide starts the server with the flag and checks the gain on a long prompt.

Before you start

  • llama.cpp installed, with llama-server on your PATH.
  • A GGUF model file, for example a Qwen3 8B Q4_K_M file.
  • A GPU with flash attention support, or an Apple Silicon Mac; the gain on plain CPU is small.

Check the flag exists in your build

Print the server help and look for the flag:

llama-server --help | grep flash

If nothing matches, your build is too old for the flag; update llama.cpp first.

Start the server with the flag

Start the server with flash attention on:

llama-server -m qwen3-8b-q4_k_m.gguf --flash-attn --port 8080

Leave the terminal open or run it in the background. The server prints its startup lines and listens on port 8080.

Compare a long prompt

Send a prompt of a few thousand tokens to the completion endpoint and note how long prompt processing takes, then restart without the flag and repeat with the same prompt. Keep the model and the prompt identical for both runs.

Worked example

Worked example: send a 3,000-word project note with the request “List the five decisions in this note.” With –flash-attn, the prompt-processing step should finish sooner than without it; on a short prompt the difference is too small to measure.

Expected result

UNTESTED in this guide: no server was run while writing it. The expected result is that llama-server starts with the flag, answers the long prompt, and prompt processing is faster than without the flag.

Limitations

Flash attention needs a backend that supports it; on some builds the flag is accepted and then ignored. It changes speed, not the answers, so do not expect different text.

Sources

See all