What does SageAttention do?

last edited

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.

fp16 valuesint8 gridq and k rounded to 256 levels

How does SageAttention speed up attention?

-127127k minus its mean fits int8

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?

flashattention 1xsage 1 2.1xsage2 3xsage2++ 3.9xsage3 5xpaper-reported attention speedup
versionspeedup vs fastest baseline
SageAttention 12.1x
SageAttention23x, RTX 4090
SageAttention2++3.9x
SageAttention35x, 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?

exact 16-bit8-bit stepssmall gap, negligible end-to-end loss

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?

sageattnsm80sm86sm89sm90sm120fp16 pv · triton · fp8 pv · sm90 · per-warpone dispatch call per attention layer
architecturecode path chosen by sageattn
A100INT8 QK, FP16 PV
RTX 30same math, compiler-generated code
RTX 40INT8 QK, FP8 PV
H100FP8 PV, own tuning
RTX 50per-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