SageAttention2: Efficient Attention with Thorough Outlier Smoothing and Per-thread INT4 Quantization
Jintao Zhang, Haofeng Huang, Pengle Zhang, Jia Wei, Jun Zhu, Jianfei Chen
摘要
Although quantization for linear layers has been widely used, its application to accelerate the attention process remains limited. To further enhance the efficiency of attention computation compared to SageAttention while maintaining precision, we propose SageAttention2, which utilizes significantly faster 4-bit matrix multiplication (Matmul) alongside additional precision-enhancing techniques. First, we propose to quantize matrices (Q, K) to INT4 in a hardware-friendly threadlevel granularity and quantize matrices ( P , V ) to FP8. Second, we propose a method to smooth Q, enhancing the accuracy of INT4 QK ⊤ . Third, we propose a two-level accumulation strategy for P V to enhance the accuracy of FP8 P V . The operations per second (OPS) of SageAttention2 surpass FlashAttention2 and xformers by about 3x and 4.5x. Moreover, SageAttention2 matches the speed of FlashAttention3(fp8) on the Hopper GPUs, while delivering much higher accuracy. Comprehensive experiments confirm that our approach incurs negligible end-to-end metrics loss across diverse models, including those for language, image, and video generation. The code is available at https://github.com/ thu-ml/SageAttention .
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 49 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- SLA: Beyond Sparsity in Diffusion Transformers via Fine-Tunable Sparse–Linear Attention 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- QLoRA: Efficient Finetuning of Quantized LLMs 引用了 Measuring Massive Multitask Language Understanding
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness 引用了 Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit Training 引用了 Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit Training 引用了 Measuring Massive Multitask Language Understanding
- SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit Training 引用了 SLA: Beyond Sparsity in Diffusion Transformers via Fine-Tunable Sparse–Linear Attention
- SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit Training 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit Training 引用了 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Frame Context Packing and Drift Prevention in Next-Frame-Prediction Video Diffusion Models 引用了 Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- Frame Context Packing and Drift Prevention in Next-Frame-Prediction Video Diffusion Models 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- Mixture of Contexts for Long Video Generation 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- Radial Attention: 𝒪(n log n) Sparse Attention with Energy Decay for Long Video Generation 引用了 Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- Radial Attention: 𝒪(n log n) Sparse Attention with Energy Decay for Long Video Generation 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- Radial Attention: 𝒪(n log n) Sparse Attention with Energy Decay for Long Video Generation 引用了 SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit Training
- Radial Attention: 𝒪(n log n) Sparse Attention with Energy Decay for Long Video Generation 引用了 Frame Context Packing and Drift Prevention in Next-Frame-Prediction Video Diffusion Models
引用它的顶会 Paper49
- Frame Context Packing and Drift Prevention in Next-Frame-Prediction Video Diffusion ModelsLvmin Zhang, Shengqu Cai, Muyang Li, Gordon Wetzstein 等NeurIPS 2025 · 132 次引用
- Mixture of Contexts for Long Video GenerationShengqu Cai, Ceyuan Yang, Lvmin Zhang, Yuwei Guo 等ICLR 2026 · 92 次引用
- SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit TrainingJintao Zhang, Jia Wei, Haoxu Wang, Pengle Zhang 等NeurIPS 2025 · 81 次引用
- Radial Attention: 𝒪(n log n) Sparse Attention with Energy Decay for Long Video GenerationXingyang Li, Muyang Li, Tianle Cai, Haocheng Xi 等NeurIPS 2025 · 66 次引用
- SLA: Beyond Sparsity in Diffusion Transformers via Fine-Tunable Sparse–Linear AttentionJintao Zhang, Haoxu Wang, Kai Jiang, Shuo Yang 等ICLR 2026 · 57 次引用
它引用的 Paper36
- Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu 等ICCV 2021 · 31,683 次引用
- Measuring Massive Multitask Language UnderstandingDan Hendrycks, Collin Burns, Steven Basart, Andy Zou 等ICLR 2021 · 7,905 次引用
- QLoRA: Efficient Finetuning of Quantized LLMsTim Dettmers, Artidoro Pagnoni, Ari Holtzman, Luke ZettlemoyerNeurIPS 2023 · 5,863 次引用
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessTri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra 等NeurIPS 2022 · 5,493 次引用
- Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 次引用
相关 Paper
- SageAttention: Accurate 8-Bit Attention for Plug-and-play Inference AccelerationJintao Zhang, Jia Wei, Pengle Zhang, Jun Zhu 等ICLR 2025
- Attn-QAT: 4-Bit Attention With Quantization-Aware TrainingPeiyuan Zhang, Matthew Noto, Wenxuan Tan, Chengquan Jiang 等ICML 2026 · 2 次引用
- FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precisionJay Shah, Ganesh Bikshandi, Ying Zhang, Vijay Thakkar 等NeurIPS 2024 · 727 次引用
- SpargeAttention: Accurate and Training-free Sparse Attention Accelerating Any Model InferenceJintao Zhang, Chendong Xiang, Haofeng Huang, Jia Wei 等ICML 2025
- FPSAttention: Training-Aware FP8 and Sparsity Co-Design for Fast Video DiffusionAkide Liu, Zeyu Zhang, Zhexin Li, Xuehai Bai 等NeurIPS 2025 · 19 次引用
