SageAttention does one job: it swaps the 16-bit matrix math inside the attention step for 8-bit math, so image and video models finish sooner. Users do not retrain or convert checkpoints. The method replaces the stock PyTorch attention call, and ComfyUI selects it with --use-sage-attention.
How does SageAttention speed up attention?
Attention multiplies Q by K, scales the scores, then multiplies by V. SageAttention smooths K, quantizes Q and K to INT8, and quantizes V plus the attention weights to FP8.
FlashAttention stays exact, while this method trades a little precision for speed. Only activations shrink, so checkpoints keep their size, unlike weight quantization.
How much faster is it?
| version | speedup vs fastest baseline |
|---|---|
| SageAttention 1 | 2.1x |
| SageAttention2 | 3x, RTX 4090 |
| SageAttention2++ | 3.9x |
| SageAttention3 | 5x, RTX 5090, FP4 |
These paper figures compare against FlashAttention and cover attention alone. Other layers are unchanged, so whole-run gains are smaller. In the repository docs, one CogVideoX run on an H20 takes 12 minutes with it. The baseline needs twice that.
Does it change the output?
The papers report negligible end-to-end loss, though the repository advises version 2 over 3 for fidelity (version guide). A failed call logs an error and falls back to PyTorch (troubleshooting). Noise on long sequences was reported on sm_120 cards.
Which GPUs get which code path?
| architecture | code path chosen by sageattn |
|---|---|
| A100 | INT8 QK, FP16 PV |
| RTX 30 | same math, compiler-generated code |
| RTX 40 | INT8 QK, FP8 PV |
| H100 | FP8 PV, own tuning |
| RTX 50 | per-warp FP8 |
Other architectures raise "Unsupported CUDA architecture". Steps are on the setup page. Related levers: video speed-ups, GGUF vs FP8 and first-run slowness.
Sources
- SageAttention README and core.py: precision options, per-GPU dispatch and timings.
- SageAttention2 paper and SageAttention3 paper: INT4 and FP4 results (abstracts).
- ComfyUI attention.py: backend switch and fallback on errors.