Accurate and efficient 8-bit plug-and-play attention.
Low maintenance activity. Last release over 2 years ago, commits in 0 of the last 26 weeks. Weaker on commit activity and recent releases.
Consider insteadflash-attnPythie’s Index: 81272.6K downloads/moCompare →
pip install sageattentionSageAttention
This repository provides the official implementation of SageAttention.
SageAttention: Accurate 8-Bit Attention for Plug-and-play Inference Acceleration
Paper: https://arxiv.org/abs/2410.02367
Jintao Zhang, Jia Wei, Haofeng Huang, Pengle Zhang, Jun Zhu, Jianfei Chen
SageAttention2 Technical Report: Accurate 4-Bit Attention for Plug-and-play Inference Acceleration
Paper: https://arxiv.org/abs/2411.10958
Jintao Zhang, Haofeng Huang, Pengle Zhang, Jia Wei, Jun Zhu, Jianfei Chen
SageAttention
SageAttention2
Project Updates
- News 2024-11-19: SageAttention2 will be released soon.
- News 2024-11-12: Support for
sageattn_varlenis available now. - News 2024-11-11: Support for different sequence length between
qandk,v,(batch_size, head_num, seq_len, head_dim)or(batch_size, seq_len, head_num, head_dim)input shapes, andgroup-query attentionis available now.
Base environment
python>=3.9
torch>=2.3.0
triton>=2.3.0
We recommend to install: (the kernel will be faster a little)
python>=3.11
torch>=2.4.0
triton-nightly
Installation
Install using pip:
pip install sageattention
Or compiling from source:
cd sageattention
pip install .
Note: SageAttention is currently optimized for RTX4090 and RTX3090 GPUs. Performance improvements may not be significant on other GPU architectures. We will progressively extend support to other GPUs.
How to use
from sageattention import sageattn
attn_output = sageattn(q, k, v, tensor_layout="HND", is_causal=False, smooth_k=True)




