skillfed

sageattention

Accurate and efficient 8-bit plug-and-play attention.

sageattention v1.0.6 148.5K downloads/30d#11,031 on PyPI3,640
Permissive license BSD 3-Clause License AGING released

What it is and what it does

SageAttention is a specialized attention kernel library that replaces the standard transformer attention computation with quantized variants using 8-bit (or 4-bit in SageAttention2) precision. It integrates smoothing techniques, per-block quantization for queries and keys, and FP16 accumulators to maintain accuracy while reducing memory bandwidth and computation cost during inference.

The package is designed as a drop-in replacement for scaled_dot_product_attention, allowing users to accelerate existing models with minimal code changes. It currently supports head dimensions of 64, 96, and 128, variable sequence lengths between queries and key-values, and group-query attention patterns. Performance is optimized for RTX4090 and RTX3090 GPUs; benefits on other architectures are not guaranteed.

Use it for:

  • Accelerate video generation models like CogVideoX by replacing their attention layers with quantized kernels
  • Speed up large language model inference on supported GPUs by patching scaled_dot_product_attention globally
  • Reduce memory bandwidth requirements in transformer-based inference pipelines without retraining
  • Deploy transformer models with lower latency on resource-constrained inference servers using RTX-series GPUs
  • Benchmark quantized attention accuracy on models with variable sequence lengths per batch

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

SageAttention provides quantized attention kernels for transformer inference that replace the standard scaled dot-product attention with 8-bit or 4-bit quantized variants, designed to accelerate inference on specific GPU architectures.

Yes, if you run transformer inference on RTX4090 or RTX3090 GPUs and can verify that the supported head dimensions and attention patterns match your model. The low install friction, permissive license, and active maintenance make it a reasonable experiment. No, if you use other GPU architectures or require head dimensions outside 64, 96, 128—the stated optimization scope is narrow and performance gains are not guaranteed elsewhere.

Install

sageattention on PyPI

pip

pip install sageattention

uv

uv add sageattention

poetry

poetry add sageattention

Installing sageattention

Before you install

Low install friction with a pure-Python wheel distribution. The package is in beta status and has been actively maintained since its first release on 2024-10-05, with the latest release on 2024-11-20. Requires Python 3.9+ and torch 2.3.0+, with triton 2.3.0+ as a build dependency.

License in practice

BSD 3-Clause License is permissive and poses no significant restrictions on use, modification, or distribution in commercial or private projects.

Quickstart

pip install sageattention

from sageattention import sageattn

attn_output = sageattn(q, k, v, tensor_layout="HND", is_causal=False, smooth_k=True)

Requires Python>=3.9, torch>=2.3.0, and triton>=2.3.0. Performance is optimized for RTX4090 and RTX3090 GPUs; other architectures may not see significant speedup. Head dimension must be one of 64, 96, or 128.

Verify before relying

  • Whether performance gains materialize on GPU architectures other than RTX4090 and RTX3090, given the stated optimization focus
  • Actual accuracy impact of disabling smooth_k in production workloads with irregular q, k, v distributions
  • Compatibility with transformer models that do not use F.scaled_dot_product_attention directly

Package facts

License BSD 3-Clause License (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 632 days since the last release
Last repo commit
First released
Downloads 148,488/month — #11,031 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: sageattention-1.0.6-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

quantized attention kernelstransformer inference acceleration8-bit attention optimizationplug-and-play attention replacementlow-precision attentionGPU-accelerated attentioninference optimization
quantizationinference-optimizationgpu-kernels

More Python Modules packages

Further reading