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

kernel 2411.10958
attentionquantizationINT4FP8tensor-core

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

Jintao Zhang, Haofeng Huang, Pengle Zhang, Jia Wei, Jun Zhu, Jianfei Chen | 2024-11 | https://arxiv.org/abs/2411.10958 Category: kernel | Tags: attention, quantization, INT4, FP8, tensor-core Read: 2026-04-16

Core Contribution #

SageAttention2 proposes a quantized attention mechanism that uses INT4 for $QK^\top$ and FP8 for $PV$ with three key techniques (Q+K smoothing, per-thread quantization aligned to MMA instruction layout, two-level FP32 accumulation for FP22 accumulators), achieving 3x speedup over FlashAttention2 with negligible end-to-end accuracy loss.

核心三问 #

Q1: 这篇论文试图解决什么核心痛点/问题?

Attention计算是Transformer的主要性能瓶颈,尤其在长序列场景下。虽然SageAttention已将QK用INT8加速,但INT8仅有INT4一半的速度;同时其PV的FP16加速方案仅在少数GPU上有效。如何安全地将Attention量化到INT4/FP8以获得极致速度,同时保持精度,是核心问题。

Q2: 作者提出了什么新的"杀手锏"方法/架构?

SageAttention2提出三大技术:(1) 双重Smoothing——不仅smooth K(如SageAttention),还smooth Q(减去block均值),将量化前outlier大幅削减;(2) Per-thread量化——根据PTX mma指令的线程-数据映射关系设计量化分组,使每个GPU线程只对应一个量化scale,精度接近per-token而无额外开销;(3) 两级累加策略——发现FP8 mma指令的累加器实际是FP22(非FP32),通过外层FP32 buffer累加来消除精度损失。

Q3: 最终效果/结论如何?

在RTX4090上达到481 TOPS峰值,比FlashAttention2快约3倍、比xformers快约4.5倍。在Hopper GPU上,SageAttn2-8b匹配FlashAttention3(fp8)的速度但精度显著更高。在10+个语言/图像/视频生成模型上,端到端指标损失可忽略不计。

逻辑故事还原 #

背景 (Context) #

FlashAttention系列通过tiling优化了Attention的内存访问,但计算本身仍使用FP16/BF16。SageAttention首次将 $QK^\top$ 量化为INT8实现了2x加速,但存在两个弱点:INT8 Matmul只有INT4一半的速度;PV使用FP16累加器加速仅在RTX4090等极少数GPU上生效。

破局 (Insight) #

👉 打个比方:想象你在给一幅画拍照(量化),如果画上有一个极亮的光点(outlier),相机为了不让光点过曝,会把其他所有细节都拍得很暗(量化为零)。解决方法是先把那个光点擦掉(smoothing),单独记录它的位置,拍完照再贴回去。SageAttention2对Q和K都做了这样的"擦光点"操作,而且巧妙地利用了GPU线程与数据的对应关系,让"贴回去"的过程零开销。

核心洞察有三:(1) Q和K的token之间高度相似,减去均值后outlier大幅缩小,INT4量化精度从80%→99.5% CosSim;(2) MMA指令的线程布局天然将特定token分配给同一线程,可以把这些token作为一个量化组,实现比per-block更细但比per-token零开销的量化;(3) NVIDIA Ada/Hopper的FP8 MMA累加器实际只有22位有效精度(非标称的FP32),需要外层FP32 buffer累加来补偿。

拆解 (Deconstruction) #

  1. 预处理阶段:对K减去全局均值(smooth K),对每个Q block减去block均值(smooth Q),计算补偿向量 $\Delta S = \bar{q}_i \cdot \gamma(K_j)^\top$;同时对V做per-channel FP8量化
  2. Per-thread量化:根据mma.m16n8k64指令的线程-数据映射,将Q的每 $8k+i$ 个token分为一组、K的每 $8k+2i$ 和 $8k+2i+1$ 分为一组,每组共享一个scale
  3. Attention kernel内部:执行INT4 GEMM得到 $QK^\top$,反量化并加上 $\Delta S$ 补偿;softmax后将 $\tilde{P}$ 乘以448转为FP8 E4M3
  4. 两级累加:$\tilde{P}V$ 的FP8 GEMM结果(FP22精度)累加到FP32 buffer中,外层再用FP32做跨block累加
  5. 后处理:反量化V的per-channel scale,输出最终O
  6. Key Figures #

    Figure 1: Overall Performance and Demo #

    Figure 1: Overall Performance and Demo

    What it shows: 左上为RTX4090上的kernel速度对比(SageAttn2 vs FlashAttention2/xformers),右上为Llama3.1在100K序列长度下的首token生成加速和Needle-in-a-Haystack任务表现,下方为CogvideoX生成的视频对比。

    Why it matters: 一图展示了SageAttention2的核心价值——3x kernel加速、端到端推理加速、以及视觉质量无损。

    Detailed description: 左上bar chart显示随序列长度增加,SageAttn2-4b达到~480 TOPS,FlashAttention2约160 TOPS,xformers更低。右上展示Llama3.1在L20上100K序列的首token延迟从39.9s降至23.2s(1.72x加速),同时NIAH热力图显示精度完全保持。下方两组视频帧对比表明CogvideoX 1.5-5B使用SageAttention2加速1.8x且视频质量无差异。

    Figure 3: Workflow of SageAttention2 #

    Figure 3: Workflow of SageAttention2

    What it shows: SageAttention2的完整数据流管线,包含5个阶段:①Smooth Q,K,V → ②GEMV计算 $\Delta S$ → ③Per-thread量化Q,K和per-channel量化V → ④执行SageAttention2 kernel → ⑤修正输出。

    Why it matters: 这是论文的"灵魂图",清晰展示了从FP16输入到最终输出的完整处理流程,以及各量化/补偿技术如何协同工作。

    Detailed description: 图左侧显示Q经过减均值(smooth Q)后进行per-thread INT4量化,K经过减全局均值(smooth K)后同样per-thread INT4量化。中间GEMV计算 $\bar{q}_i$ 与 $\gamma(K_j)$ 的向量积作为 $\Delta S$ 补偿。V做per-channel FP8量化。kernel内部执行INT4 $QK^\top$ + $\Delta S$ → softmax → FP8 $PV$(两级累加),最后乘以V的per-channel scale得到输出。

    Figure 4: Per-thread Quantization Example #

    Figure 4: Per-thread Quantization Example

    What it shows: 左侧展示量化scale与GPU warp内token的对应关系,右侧展示MMA.m16n8k64指令中GPU线程与量化token的映射。

    Why it matters: 这是per-thread量化的核心机制图,说明了为何每个线程只需一个scale就能完成反量化——因为MMA指令天然将特定token映射到同一线程。

    Detailed description: 左图显示bq=128个query token被4个warp分割,每个warp处理32个token,其中token $i$, $8+i$, $16+i$, $24+i$ 共享一个量化scale。右图是mma.m16n8k64指令的线程布局,展示32个线程(T0-T31)如何分别持有结果矩阵D的不同元素,每个线程仅对应 $\delta_Q$ 和 $\delta_K$ 各一个scale值。

    Figure 5: Speed Comparison #

    Figure 5: Speed Comparison

    What it shows: RTX4090上headdim=128时,SageAttention2与FlashAttention2、xformers在不同序列长度下的速度对比(有/无causal mask)。

    Why it matters: 直观展示SageAttn2-4b达到~480 TOPS,约为FlashAttention2的3倍和xformers的4.5倍。

    Detailed description: 四张子图分别对应headdim=128 non-causal、headdim=128 causal、headdim=64 non-causal、headdim=64 causal。在所有配置下,SageAttn2-4b(红色线)均显著领先,SageAttn2-8b(橙色线)次之,两者均大幅超越FlashAttention2(蓝色线)和xformers(灰色线)。

    Key Tables #

    Table 2: End-to-end Metrics (Main Results) #

    ModelAttentionKey MetricValue
    Llama3.1Full-PrecisionWikiText PPL↓6.013
    SageAttn2-8bWikiText PPL↓6.019
    SageAttn2-4bWikiText PPL↓6.256
    CogvideoX 1.5-5BFull-PrecisionVQA-t↑70.928
    SageAttn2-8bVQA-t↑74.415
    FlashAttn3-fp8VQA-t↑2.181
    HunyuanVideoFull-PrecisionVQA-a↑82.516
    SageAttn2-8bVQA-a↑81.786
    FlashAttn3-fp8VQA-a↑4.433

    Takeaway: SageAttn2-8b在所有模型上几乎无损,SageAttn2-4b有轻微损失但远优于其他baseline。FlashAttn3-fp8在视频生成模型上严重退化。

    Table 4: Smoothing Methods Comparison (CogvideoX) #

    MethodCosSim↑Relative L1↓RMSE↓
    None80.04%0.39060.2223
    HadmdAttn79.77%0.37820.2180
    SmoothAttn90.21%0.33830.1952
    Smooth K98.07%0.14930.0743
    Smooth Q98.30%0.12500.0712
    Smooth Q+K99.46%0.06480.0334

    Takeaway: Smooth Q+K将CosSim从80%提升至99.46%,是所有smoothing方法中效果最好的,证明了双重smoothing的关键价值。

    Table 6: Quantization Granularity Comparison #

    MethodCos Sim↑Relative L1↓RMSE↓
    Per-token99.45%0.06490.0335
    Per-thread99.45%0.06220.0313
    Per-block98.03%0.14920.0744
    Per-tensor97.15%0.18000.0865

    Takeaway: Per-thread量化精度与per-token几乎相同(99.45% vs 99.45%),但比per-block(98.03%)显著更好,且无额外速度开销。

    Table 8: End-to-end Latency Speedup #

    ModelGPUOriginalSageAttn2-8bSageAttn2-4b
    CogvideoX 1.5-5BRTX40901040s577s555s
    HunyuanVideoL202221s1486s1435s
    MochiL202336s1316s1190s
    Llama3.1 100KL2039.9s25.4s23.2s

    Takeaway: CogvideoX获得1.8x端到端加速,Mochi获得近2x加速,长序列LLM首token延迟显著降低。

    Algorithm 1: SageAttention2 #

    
    Input: Q(FP16), K(FP16), V(FP16) ∈ R^{N×d}, block size bq, bkv, warp count cw
    
    Preprocessing:
      K = K - mean(K)                    // Smooth K: 减去全局token均值
      (δV, V̂) = ψV(V)                   // Per-channel FP8 quantize V
    
    Divide Q into Tm = N/bq blocks {Qi}
    Divide K, V into Tn = N/bkv blocks {Ki}, {Vi}
    
    for i = 1 to Tm do                   // 外层循环:遍历Q blocks
      q̄i = mean(Qi)                     // 计算Q block均值
      (δQ, Q̂i) = ψQ(Qi - q̄i)           // Smooth Q + per-thread INT4 quantize
    
      for j = 1 to Tn do                 // 内层循环:遍历K,V blocks
        (δK, K̂j) = ψK(Kj)              // Per-thread INT4 quantize K block
    
        // INT4 GEMM + dequant + GEMV compensation (per warp parallel)
        Sij = ψ⁻¹(Q̂i · K̂j^T) + GEMV(q̄i, Kj^T)
    
        // Online softmax
        mij = max(mi,j-1, rowmax(Sij))
        P̃ij = exp(Sij - mij)
        lij = exp(mi,j-1 - mij) · li,j-1 + rowsum(P̃ij)
    
        // FP8 PV matmul (two-level accumulation)
        Oij(FP22) = Matmul((P̃ij * 448).to(FP8.E4M3), Vj)  // Level 1: FP22
        Oij(FP32) = diag(exp(...)) · Oi,j-1(FP32) + Oij(FP22)  // Level 2: FP32
      end for
    
      Oi = diag(li,Tn)⁻¹ · Oi,Tn(FP32) / 448 * δV  // Final rescale
    end for
    return O = {Oi}
    

    逐行解读:

    • Smooth K: 全局一次性操作,减去K的token-wise均值消除channel-wise outlier
    • Per-thread量化: 基于mma.m16n8k64指令布局,Q每 $8k+i$ 个token一组,K每 $8k+2i$ 和 $8k+2i+1$ 一组
    • GEMV补偿: $\bar{q}_i \cdot \gamma(K_j)^\top$ 是 $1 \times N$ 向量,补偿smooth Q引入的偏差。因为 $b = \bar{q}_i \cdot \bar{k}^\top + \gamma(Q_i) \cdot \bar{k}^\top$ 是row-wise常数,softmax后消除,无需计算
    • 静态scale $\tilde{P}$: $\tilde{P} \in [0,1]$,乘以448映射到FP8 E4M3的全范围 $[-448, +448]$
    • 两级累加: 内层FP22累加器仅累加 $b_k$ 个token(如64),外层FP32累加器跨block累加,将精度损失限制在block范围内

    Key Findings #

    • Smooth Q+K将INT4 $QK^\top$ 的CosSim从80%提升至99.46%,是实现INT4 Attention精度的关键
    • Per-thread量化利用MMA指令布局实现零开销的细粒度量化,精度接近per-token
    • NVIDIA Ada/Hopper FP8 MMA累加器实际为FP22(1+8+13 bits),非标称FP32
    • SageAttn2-4b在RTX4090上达到481 TOPS,3x于FlashAttention2
    • SageAttn2-8b在Hopper上匹配FlashAttention3(fp8)速度但精度远优
    • 在CogvideoX、HunyuanVideo、Mochi等视频生成模型上,FlashAttention3(fp8)严重退化而SageAttention2几乎无损

    Limitations #

    • INT4 tensor core仅在NVIDIA Ada架构上可用,Hopper需退回INT8变体
    • 4-bit量化在某些模型上仍有轻微精度损失(如Llama3.1 MMLU从0.635降至0.607)
    • 需要预处理步骤(smooth + GEMV),增加约3.7%的kernel开销
    • 未讨论训练场景(仅推理),backward pass的量化兼容性未知
    • 未评估AMD或Intel GPU上的可移植性
    • Smooth V技术是可选的,在LLM(如Llama)上无效果(V无channel-wise bias)

    Infrastructure Impact #

    • Algorithm: 为长序列LLM推理和视频生成提供即插即用的Attention加速,可与稀疏注意力方法正交组合
    • Kernel: 首次系统利用INT4 tensor core加速Attention,发现FP22累加器问题并提出通用解决方案
    • Framework: 作为drop-in替换集成到推理框架中,已开源CUDA kernel(github.com/thu-ml/SageAttention)
    • LLM: 长上下文LLM(100K+ tokens)的首token延迟降低40-50%,直接提升用户体验
    • Agent: 降低Attention延迟使实时agent场景更可行,特别是需要处理长上下文的agent

    Deep Analysis (kernel) #

    1. Target Operation #

    Computational primitive: Attention — 包含两个核心矩阵乘法 $QK^\top$($N \times d \cdot d \times N = N \times N$)和 $PV$($N \times N \cdot N \times d = N \times d$),以及中间的softmax操作。

    Input/output shapes and data types:

    • Input: $Q, K, V \in \mathbb{R}^{N \times d}$,原始FP16,其中 $d = 64$ 或 $128$
    • 量化后: Q,K → INT4(per-thread granularity),$\tilde{P}$ → FP8 E4M3(static scale \$1/448\$),V → FP8 E4M3(per-channel)
    • Output: $O \in \mathbb{R}^{N \times d}$,FP16

    Theoretical arithmetic intensity: 对于Attention整体,$2N^2d$ FLOPs(两个matmul),数据量约 $6Nd$ bytes(读Q,K,V + 写O,忽略中间S,P的HBM访问因FlashAttention tiling)。$\text{AI} \approx 2N^2d / 6Nd = N/3$。当 $N > 1000$ 时远超大多数GPU的计算/带宽比,是compute-bound

    Roofline position: 对于 $N \geq 4K$, $d = 128$ 的典型配置,Attention是计算密集型操作,使用低精度tensor core(INT4/FP8)正好能最大化计算吞吐。

    2. Hardware Model #

    Target architectures:

    • NVIDIA Ada Lovelace (SM89): RTX4090, L20, L40 — 原生INT4 tensor core
    • NVIDIA Hopper (SM90): H100, H20 — 无原生INT4 TC,使用INT8变体

    Hardware units:

    • INT4 Tensor Cores: mma.m16n8k64 PTX指令,用于 $QK^\top$(仅Ada)
    • FP8 Tensor Cores: mma.f32.f8.f8.f32,用于PV(Ada + Hopper)
    • CUDA cores: 用于smooth操作、在线softmax、scale计算
    • SFU: 用于exp()计算

    Memory hierarchy:

    • Registers: 存储Oij的FP32累加器、量化scale、当前tile的中间结果
    • Shared memory (SRAM): 存储当前处理的Qi, Kj, Vj tiles(FlashAttention tiling策略)
    • L2 Cache: 隐式利用,K/V tiles在多个Q blocks间复用
    • HBM: Q, K, V的原始存储,通过tiling最小化访问次数

    Theoretical peak on RTX4090: INT4 tensor core理论峰值约660 TOPS(mma.m16n8k64),论文实测达到481 TOPS(约73%利用率)。FlashAttention2在FP16约160 TOPS。

    3. Optimization Techniques #

    Figure 3: Workflow of SageAttention2 #

    Figure 3

    解读: 如Figure 3所示,SageAttention2的完整pipeline包含预处理(smooth + quantize)和kernel内部(INT4 $QK^\top$ + FP8 $PV$ + two-level accumulation)两个阶段。预处理中smooth和quantize操作被fuse成单个kernel以避免额外的HBM读写。

    TechniqueApplied?Details
    Tiling / blockingFlashAttention-style, $b_q = 128$, $b_{kv} = 64$, 4 warps per SM
    Software pipelining部分K,V tiles的加载与前一个tile的计算重叠
    Warp specialization4个warp并行处理Q block的不同段(cw=4)
    Vectorized memory accessINT4数据紧凑存储,128-bit向量化加载
    Shared memory optimization标准FlashAttention共享内存布局
    Register pressure中等FP32累加器Oij + scale + softmax状态
    Kernel fusionsmooth + quantize + GEMV fuse为单个预处理kernel

    4. Performance Analysis #

    Figure 5: Speed Comparison (RTX4090) #

    Figure 5

    解读: 如Figure 5所示,SageAttn2-4b在RTX4090上随序列长度增加趋近481 TOPS,而FlashAttention2稳定在约160 TOPS,加速比约3x。在短序列(<2K)时加速比略低,因为预处理kernel的固定开销占比更大。

    Peak utilization: 481 TOPS / ~660 TOPS(INT4理论峰值)≈ 73%,在实际attention workload中是很好的利用率。

    vs vendor library:

    MethodRTX4090 TOPSvs FA2
    SageAttn2-4b4813.0x
    SageAttn2-8b~4302.7x
    FlashAttention2~1601.0x
    xformers~1070.67x

    Scaling: 速度随序列长度增加趋于稳定(compute-bound区域)。在短序列下($N < 1K$),固定开销(smooth、quantize预处理)占比增大,加速比下降。

    跨GPU表现: 如Table 9所示,SageAttention2在不同GPU上的加速比从2.46x(L20)到3.12x(H20)不等,Hopper上使用8b变体仍能匹配FlashAttention3(fp8)速度。

    5. Numerical Considerations #

    Figure 4: Per-thread Quantization #

    Figure 4

    解读: 如Figure 4所示,per-thread量化的核心是将MMA指令的线程布局映射为量化分组。左图展示了每个warp内token与量化scale的对应——token $i$, $8+i$, $16+i$, $24+i$ 共享一个scale,形成32个量化组(8×4 warps),比per-block(1个scale)细32倍。右图展示MMA指令中每个线程仅持有D矩阵128个元素中的4个,且这4个元素恰好对应同一个Q scale和同一个K scale。

    Accuracy vs baseline:

    • Smooth Q+K: CosSim 99.46%(vs 80.04% without smoothing)
    • Per-thread vs per-token: 99.45% vs 99.45%(几乎相同)
    • E4M3 for PV: 99.44% vs FP16's 99.45%(几乎相同)
    • End-to-end: Llama3.1 PPL 6.019 vs 6.013(+0.1%),CogvideoX VQA-t 74.4 vs 70.9(实际略有提升)

    Numerical stability tricks:

    1. Q smoothing数学保正确性: 利用softmax对行常数不变的性质,$b = \bar{q} \cdot \bar{k}^\top + \gamma(Q) \cdot \bar{k}^\top$ 是行常数,无需计算
    2. Static $\tilde{P}$ scaling: $\tilde{P} \in [0,1]$,乘以448映射到E4M3全范围,避免动态量化开销
    3. FP22累加器发现: 通过实验验证mma(f32f8f8f32)的累加器D实际只有13位尾数(非23位),当D > 13位尾数时低10位被截断
    4. 两级累加: 内层FP22仅累加 $b_k$ 个token,误差限制在小范围内;外层FP32跨block累加保持高精度
    5. Edge cases: 论文未明确讨论NaN/Inf/subnormal处理。INT4范围[-7,+7]加上smoothing后,实际输入值应在合理范围内。

      6. Portability #

      DimensionAssessment
      Cross-GPU within NVIDIAAda全功能(INT4 TC),Hopper降级为INT8变体(无INT4 TC),Ampere未提及
      Cross-vendorCUDA-only,依赖PTX mma指令,无HIP/Triton版本
      Integration独立CUDA kernel,可作为drop-in替换FlashAttention
      Compiler dependency需要CUDA 12.x+(PTX mma.m16n8k64 INT4指令支持)

      7. Source Code & Repository #

      • Repository: https://github.com/thu-ml/SageAttention
      • Language: CUDA C++ with PTX inline assembly
      • Build requirements: CUDA 12.x, PyTorch
      • Benchmark scripts: 论文附录A.8描述了benchmark setup
      • Integration: Python wrapper,可直接替换PyTorch的F.scaled_dot_product_attention

      8. Key Source Code Walkthrough #

      8b. Pseudocode Annotation (Algorithm 1) #

      
      // [Grid level] Each CUDA block processes one Q tile (bq tokens)
      // Grid dim: (N/bq, num_heads, batch_size)
      for i = 1 to Tm do    // → maps to block index
      
        // [Block level] Compute Q block mean and smooth (SRAM → registers)
        // This is compute-bound: FP16 reduction over bq tokens
        q̄i = mean(Qi)                    // Shared memory reduction
        (δQ, Q̂i) = ψQ(Qi - q̄i)          // Per-thread INT4 quantize in registers
      
        for j = 1 to Tn do  // → sequential K,V tile iterations
      
          // [Block level] Load Kj from HBM → SRAM, quantize
          (δK, K̂j) = ψK(Kj)             // Per-thread INT4 quantize
      
          // [Warp level] INT4 GEMM via mma.m16n8k64 (compute-bound)
          // Each of 4 warps processes cw=bq/4=32 query tokens
          // Dequantization: each thread multiplies by its single δQ·δK
          Sij = ψ⁻¹(Q̂i · K̂j^T)         // Tensor Core (INT4)
      
          // [Warp level] GEMV compensation (memory-bound, small)
          Sij += GEMV(q̄i, Kj^T)          // CUDA cores, 1×N vector
      
          // [Thread level] Online softmax (registers)
          // Standard FlashAttention online softmax
          mij, P̃ij, lij = online_softmax(Sij)
      
          // [Warp level] FP8 PV matmul (compute-bound)
          // Static scale: P̃ * 448 → FP8 E4M3 (no dynamic quantization)
          // Two-level accumulation:
          //   Level 1: mma(f32f8f8f32) → FP22 result in registers
          //   Level 2: accumulate to FP32 buffer (also in registers)
          Oij(FP22) = Matmul(P̃ij.to(FP8), Vj)  // Tensor Core (FP8)
          Oij(FP32) += Oij(FP22)                 // FP32 register accumulation
      
          // [Sync] Barrier before loading next K,V tile
        end for
      
        // [Block level] Final rescale and writeback to HBM
        Oi = normalize(Oij) * δV          // Apply V per-channel scale
        // Write Oi to global memory (HBM)
      end for
      

      8c. Data Layout & Memory Access Patterns #

      • Input layout: Q, K, V in row-major (standard PyTorch layout), (batch, heads, seq, dim)
      • Memory coalescing: INT4 packing — 2 elements per byte,连续线程访问连续内存地址
      • Per-thread quantization alignment: 量化分组严格匹配mma.m16n8k64的线程-数据映射,确保反量化时每个线程只需一个scale值,无需线程间通信
      • Register allocation: 估计每线程约80-100个寄存器(FP32 $O_{ij}$ 累加器 $b_q/4 \times d/8 = 32 \times 16 = 512$ values需要128个FP32 regs,加上softmax状态、scales等),可能导致中等occupancy(2-3 blocks/SM)

      9. Infrastructure Impact #

      LayerImpact
      Algorithm为所有基于标准Attention的模型提供免费的推理加速,与sparse attention、linear attention正交
      Framework可作为PyTorch custom op集成,已有Python wrapper;适合集成到vLLM、SGLang等serving框架
      LLM长上下文推理(100K+ tokens)首token延迟降低40-50%,直接提升用户体验;使更长上下文窗口在现有硬件上可行
      AgentAttention延迟降低使实时multi-turn agent更可行,特别是需要处理长对话历史或大量工具输出的场景