Papers › SageAttention2: Efficient Attention with Thorough Outlier Smoothing and Per-thread...

SageAttention2: Efficient Attention with Thorough Outlier Smoothing and Per-thread INT4 Quantization

17 Nov 2024arXiv:2411.10958archive 2025-07-28

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 thread-level 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 PV to enhance the accuracy of FP8 PV. The operations per second (OPS) of SageAttention2 surpass FlashAttention2 and xformers by about 3x and 4.5x on RTX4090, respectively. 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.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2411.10958")

Code

Syntology Ran 0 of 6 code samples harvested from 1 repository linked to this paper; 6 have no recorded run.

By repository: official repository: 3 samples from 1 repository, 0 ran; 3 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

thu-ml/SageAttention officialmentioned in papermentioned on GitHubpytorch report
thu-ml/spargeattn mentioned on GitHubpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

6 samples harvested; 0 ran; 0 honoured the contract we drafted; 6 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

6unverified

Licence: 3 of the 6 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from thu-ml/sageattention. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

sageattn thu-ml/sageattention/sageattention/core.py official repository unverified Apache-2.0 (permissive) · 0d53f0eb082706d1 · report
sageattn_qk_int8_pv_fp16_triton thu-ml/sageattention/sageattention/core.py official repository unverified Apache-2.0 (permissive) · b342df7dc419a801 · report
sageattn_varlen thu-ml/sageattention/sageattention/core.py official repository unverified Apache-2.0 (permissive) · c9ff307a043756a1 · report
sageattn identical code first harvested elsewhere unverified licence of this copy not recorded · e629740e34804cac · report
sageattn_qk_int8_pv_fp16_triton identical code first harvested elsewhere unverified licence of this copy not recorded · 8343610f1f3a1e09 · report
sageattn_varlen identical code first harvested elsewhere unverified licence of this copy not recorded · 2e6007cdb50ffa71 · report

Tasks

Image GenerationQuantizationVideo Generation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AttentionSPEEDSoftmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections