预训练LLM中Softmax的近似:模型敏感性与核加速

·

研究论文 · 2026/09/30

在 NVIDIA Blackwell B200 上,张量核心吞吐量比特殊函数指数吞吐量高出两个数量级以上,这暴露了融合注意力内核中指数求值的问题。然而,预训练 Transformer 可能不需要对每个元素都精确求值。我们通过在十个冻结的仅解码器模型(0.5B-72B)中近似 softmax 来表征预训练模型需要什么。softmax 映射分配概率的位置数量以及行内分辨率可以大幅削减,但对相同位置进行均匀加权是有害的。固定分辨率预算的放置位置与其大小同样重要,靠近行最大值的分辨率始终受到青睐。在标量失真上匹配的扰动会产生符号相反的模型相关响应。这些发现推动了 Rowmax-PoT(一种以每行最大值为锚点的粗对数权重表示)及其在 FlashAttention-4 中的硬件特化 Rowmax-H15。在 B200 上,在主机端调用延迟测量中,修补后的 FP8 注意力前向在因果 8K 时快 12.4%,在非因果 8K 时快 25.8%;在因果 16K 时,每次前向的板级能耗下降 8.4%。在 BF16 内核路径上以 2K 单独测量,Rowmax-H15 在来自三个系列的五个模型中将困惑度增加了 0.091-0.492%。

该研究揭示了预训练 LLM 对 softmax 近似的敏感性,提出了实用的硬件加速方案,在保持模型性能的同时显著提升注意力计算效率,对高效推理有重要价值。

On NVIDIA Blackwell B200, tensor-core throughput outpaces special-function exponential throughput by more than two orders of magnitude, exposing exponential evaluation in fused attention kernels. A pretrained Transformer, however, may not need it evaluated accurately at every element. We characterize what a pretrained model does need by approximating softmax at inference in ten frozen decoder-only models (0.5B-72B). The number of positions the softmax map assigns probability to and within-row resolution can be cut substantially, yet uniform weighting of the same positions is damaging. Where a fixed resolution budget is placed matters as much as its size, with resolution near the row maximum consistently favored. Perturbations matched on scalar distortion produce model-dependent responses of opposite sign. These findings motivate Rowmax-PoT, a coarse logarithmic weight representation anchored at each row maximum, and Rowmax-H15, its hardware specialization in FlashAttention-4. On B200, the patched FP8 attention forward is 12.4% faster at causal 8K and 25.8% faster at non-causal 8K in host-side call-latency measurements; board energy per forward falls by 8.4% at causal 16K. Measured separately on the BF16 kernel path at 2K, Rowmax-H15 increases perplexity by 0.091-0.492% across five models from three families.

阅读原文

参与讨论