SageAttention: Accurate 8-Bit Attention for Plug-and-play Inference Acceleration
Summary
PTQ attention: subtract the token-mean of K to smooth channel outliers so QK can be INT8, and keep PV in FP16 with an FP16 accumulator (INT8 PV is too noisy on some layers). Triton kernels on RTX4090/3090; peak ~341 TOPS at headdim 64/128 vs FlashAttention2 ~165. ~2.1× FA2 and ~2.7× xformers. Plug-and-play: Llama2-7B WikiText 5.824 vs FP 5.823, MMLU 0.46=FP; CogVideoX/Unidiffuser/UltraPixel/TIMM/Llava1.6 near-parity. ICLR 2025. Code https://github.com/thu-ml/SageAttention.
- Venue
- arXiv / Tsinghua University
- License
- CC BY 4.0
- License family
- Permissive
- Purpose
- Accelerate attention at inference with plug-and-play INT8 quantization that keeps end-to-end metrics
- Scale
- RTX4090/3090; Llama2-7B, CogVideoX, Unidiffuser, UltraPixel, TIMM ViT-B/16, Llava1.6; headdim 64/128; CogVideoX QKV (2, 30, 17776, 64)
- Time period
- 2024-10-03 (arXiv 2410.02367 v1); last revised 2025-10-01 (v9). ICLR 2025. HF paper publishedAt 2024-10-03.
- Added
- Oct 1, 2026
- Research status
- done
From the source
- Published
- Oct 3, 2024
- Last revised
- Oct 1, 2025
- arXiv categories
- cs.LG
- Journal reference
- The Thirteenth International Conference on Learning Representations (ICLR 2025)
- Author comment
- @inproceedings{zhang2025sageattention, title={SageAttention: Accurate 8-Bit Attention for Plug-and-play Inference Acceleration}, author={Zhang, Jintao and Wei, Jia and Zhang, Pengle and Zhu, Jun and Chen, Jianfei}, booktitle={International Conference on Learning Representations (ICLR)}, year={2025} }
- Citations
- 185 (13 influential)
- References
- 80
- Published in
- International Conference on Learning Representations
Abstract (from arXiv)
The transformer architecture predominates across various models. As the heart of the transformer, attention has a computational complexity of $O(N^2)$, compared to $O(N)$ for linear transformations. When handling large sequence lengths, attention becomes the primary time-consuming component. Although quantization has proven to be an effective method for accelerating model inference, existing quantization methods primarily focus on optimizing the linear layer. In response, we first analyze the feasibility of quantization in attention detailedly. Following that, we propose SageAttention, a highly efficient and accurate quantization method for attention. The OPS (operations per second) of our approach outperforms FlashAttention2 and xformers by about 2.1 times and 2.7 times, respectively. SageAttention also achieves superior accuracy performance over FlashAttention3. Comprehensive experiments confirm that our approach incurs almost no end-to-end metrics loss across diverse models, including those for large language processing, image generation, and video generation. The codes are available at https://github.com/thu-ml/SageAttention.
Tags
Topics
quantization, attention kernels, inference
Research notes
- Primary: arxiv abs (cs.LG). License CC BY 4.0 on HTML at check. Comment: ICLR 2025 bibitem; journal_ref The Thirteenth International Conference on Learning Representations (ICLR 2025). Corresponding Jianfei Chen; Tsinghua CST / Institute for AI / BNRist / Tsinghua-Bosch Joint ML Center. Code https://github.com/thu-ml/SageAttention (HF projectPage; 3,640 stars at check; Apache-2.0). HF paper page 50 upvotes; unofficial linked model jt-zhang/SageAttention2_plus not copied into hf_* fields. Discord posted abs with a speed/accuracy blurb. Kernel library, not a new corpus, so no datasets_local row.
Cites, within this collection
Cited by, within this collection
Similar entries
- Paper Disaggregated Quantization: Specializing LLM Prefill and Decode
- Paper FlashHead: Efficient Drop-In Replacement for the Classification Head in Language Model Inference
- Code VBR: Variable Bit-Rate KV Cache for llama.cpp
- Paper BitNet a4.8: 4-bit Activations for 1-bit LLMs
- Code KohakuFA: Attention Kernel with Fixed Backward-Pass Precision
- Paper Bi-Mamba: Towards Accurate 1-Bit State Space Models