atlas

Research map / Architectures and efficiency / Attention and transformers

SageAttention: Accurate 8-Bit Attention for Plug-and-play Inference Acceleration

ICLR 2025 · Architectures and efficiency › Attention and transformers · approach: Sparse attention for long-context LLMs · 2 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes SageAttention, a plug-and-play post-training 8-bit quantization method for attention (INT8 QK^T with K mean-smoothing, FP16 PV with FP16 accumulator) that speeds up attention about 2x over FlashAttention2 and xformers with negligible end-to-end metric loss.

Problem

Attention has O(N^2) cost and dominates latency for long sequences, but prior quantization work focuses on linear layers; directly quantizing attention to 8-bit degrades accuracy substantially across models.

Approach

Quantize Q and K to INT8 with per-token or per-block scales after subtracting the mean of K across tokens (which leaves softmax attention unchanged), keep P and V in FP16 with an FP16 accumulator for the PV matmul, and adaptively pick the fastest kernel per layer that preserves cosine similarity above 99.8%.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Add adaptive selection of SAGEAttn-vB for suitable layers, using SAGEAttn-B otherwise (ablation)SageAttention · CogvideoX attentionTOPS: 292.17 -> 327.57Helped
Add adaptive selection of SAGEAttn-vB for suitable layers, using SAGEAttn-B otherwise (ablation)SageAttention · Llama2 attentionTOPS: 208.59 -> 231.74Helped
Add K smoothing by subtracting the mean key across tokens (ablation)SAGEAttn-T per-token quantization · Attention output accuracycosine similarity: 62.24% -> 99.47%Helped
Add K smoothing by subtracting the mean key across tokens (ablation)SAGEAttn-B per-block quantization · Attention output accuracycosine similarity: 30.60% -> 99.31%Helped
Add K smoothing by subtracting the mean key across tokens (ablation)Per-tensor Q,K quantization · Attention output accuracycosine similarity: 41.40% -> 98.06%Helped
Enable K smoothing (ablation)SAGEAttn-B · CogvideoX attentionTOPS: 327.57 -> 327.52No clear effect
Enable K smoothing (ablation)SAGEAttn-B · UltraPixel attentionTOPS: 325.18 -> 324.56No clear effect
Use FP16 instead of FP32 accumulator (ablation)FP16 P,V attention matmul · Attention output accuracy across real-model layerscosine similarity: 99.98% -> 99.98%No clear effect
Quantize P,V to INT8 rather than retaining FP16 (ablation)SageAttention · Attention output accuracy across real-model layerscosine similarity: 99.94% -> 99.70%Hurt
Use per-block rather than per-token Q,K quantization (ablation)SageAttention · Attention output accuracy across real-model layerscosine similarityNo clear effect
Use per-block rather than per-token Q,K quantization (ablation)SAGEAttn-vT · Attention output accuracy across real-model layerscosine similarity: 99.9% -> 98.9%Hurt
Replace full-precision attention with SageAttentionLlama2 · WikiTextperplexity: 5.823 -> 5.824No clear effect

Surprising findings

Limitations

Experimental setup

Datasets: WikiText LAMBADA MMLU open-sora prompt set COCO 2014 val ImageNet ImageNet-Sketch ImageNet-Rendition TextVQA POPE VQAv2

Benchmarks: WikiText LAMBADA MMLU VBench-style CogVideoX metrics (CLIPSIM, CLIP-T, VQA-a, VQA-t, FScore) COCO FID/sFID/CLIP/ImageReward ImageNet ImageNet-Sketch ImageNet-Rendition TextVQA POPE VQAv2

Metrics: perplexity accuracy cosine similarity relative L1 RMSE TOPS FID sFID CLIPSIM CLIP-T

Baselines: FlashAttention2 xformers FlashAttention3 (FP8) Torch attention AWQ Q-diffusion ViDiT-Q

Builds on: FlashAttention-2 dynamic quantization online softmax Triton

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy