Buckets:
3.91 MB
31 files
Updated 27 days ago
Ctrl+K
| Name | Size | Uploaded | Xet hash |
|---|---|---|---|
| assets | 2 items | ||
| sageattn | 25 items | ||
| .gitattributes | 1.78 kB xet | dec4df9e | |
| LICENSE | 11.4 kB xet | c080b1f2 | |
| README.md | 4.56 kB xet | 4d59a645 | |
| setup.py | 6.1 kB xet | b83b42fb |
license: apache-2.0 (Commercial applications are also allowed!)
SageAttention3
This repository provides the official implementation of SageAttention3
SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit Training
Paper: https://arxiv.org/abs/2505.11594
Jintao Zhang, Jia Wei, Pengle Zhang, Xiaoming Xu, Haofeng Huang, Haoxu Wang, Kai Jiang, Jun Zhu, Jianfei Chen
Limitaitions:
Currently, SageAttention3 works well for:
- Video generation models: CogVideoX-2B, HunyuanVideo, Mochi.
- Almost all image generation models, including Flux and Stable-Diffusion3.5.
Note: SageAttention3 does not guarantee lossless acceleration for all models. For other video generation models, we recommend selectively using SageAttention2++ in certain layers or timesteps.
For example:
- Apply SageAttention2++ only at the first and last timesteps,
- Use SageAttention3 for all the others.
This hybrid approach may achieve lossless acceleration.
Installation
Base environment
python>=3.13,torch>=2.8.0,CUDA >=12.8
Install Package
To use SageAttention3, please compile from source:
git clone https://huggingface.co/jt-zhang/SageAttention3
cd SageAttention3
python setup.py install
How to Use
from sageattn import sageattn_blackwell
attn_output = sageattn_blackwell(q, k, v, is_causal=False)
q, k, vare FP16/BF16 dtype with the shape(batch_size, head_num, seq_len, head_dim)is_causaldetermines the use of a causal mask.
Performance
Speed of Kernels
Video and Image Generation Examples
Citation
If you use this code or find our work valuable, please cite:
@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}
}
@inproceedings{zhang2024sageattention2,
title={Sageattention2: Efficient attention with thorough outlier smoothing and per-thread int4 quantization},
author={Zhang, Jintao and Huang, Haofeng and Zhang, Pengle and Wei, Jia and Zhu, Jun and Chen, Jianfei},
booktitle={International Conference on Machine Learning (ICML)},
year={2025}
}
@article{zhang2025sageattention2++,
title={Sageattention2++: A more efficient implementation of sageattention2},
author={Zhang, Jintao and Xu, Xiaoming and Wei, Jia and Huang, Haofeng and Zhang, Pengle and Xiang, Chendong and Zhu, Jun and Chen, Jianfei},
journal={arXiv preprint arXiv:2505.21136},
year={2025}
}
@article{zhang2025sageattention3,
title={SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit Training},
author={Zhang, Jintao and Wei, Jia and Zhang, Pengle and Xu, Xiaoming and Huang, Haofeng and Wang, Haoxu and Jiang, Kai and Zhu, Jun and Chen, Jianfei},
journal={arXiv preprint arXiv:2505.11594},
year={2025}
}
- Total size
- 3.91 MB
- Files
- 31
- Last updated
- Jul 28
- Pre-warmed CDN
- US EU US EU

