arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2604.02292cs.LGcs.AR
收藏

驯服指数增长:一种用于整数原生边缘推理的快速Softmax替代方案

Taming the Exponential: A Fast Softmax Surrogate for Integer-Native Edge Inference

SLAC National Accelerator Laboratory(SLAC国家加速器实验室)

Dimitrios Danopoulos, Enrico Lupi, Michael Kagan, Maurizio Pierini

AI总结:

本文提出HCCS替代方案,通过截断线性映射稳定概率分布,提升小模型低精度推理效率,优化AMD Versal AI引擎的整数运算性能。

摘要:

Softmax在Transformer模型的多头注意力(MHA)块中可能成为计算瓶颈,特别是在小模型低精度推理中,指数运算和归一化带来显著开销。为此,我们建议使用Head-Calibrated Clipped-Linear Softmax(HCCS),一种有界、单调的Softmax函数替代方案,通过截断线性映射最大中心注意力logits。该近似产生稳定的概率分布,保持原始logits的顺序并具有非负值。HCCS不同于以往的Softmax替代方案,因为它包含一组轻量级校准参数,这些参数基于代表性数据集离线优化,并针对每个注意力头进行校准以保持各头的统计特性。我们描述了针对AMD Versal AI引擎高吞吐量场景的HCCS硬件驱动实现。当前AMD平台的参考实现依赖于bfloat16算术或查找表(LUTs)执行指数运算,这可能限制平台吞吐量并无法利用AI引擎的高吞吐量整数向量处理单元。相比之下,HCCS提供了一种自然映射到AI引擎int8乘加(MAC)单元的方案。据我们所知,这是首个针对AMD AI引擎优化的int8 Softmax替代方案,其速度性能显著超过其他参考实现,同时在小规模或高度量化MHA工作负载后经过量化感知重训练仍能保持竞争性的任务准确性。

英文摘要:

Softmax can become a computational bottleneck in the Transformer model's Multi-Head Attention (MHA) block, particularly in small models under low-precision inference, where exponentiation and normalization incur significant overhead. As such, we suggest using Head-Calibrated Clipped-Linear Softmax (HCCS), a bounded, monotone surrogate to the exponential softmax function, which uses a clipped linear mapping of the max centered attention logits. This approximation produces a stable probability distribution, maintains the ordering of the original logits and has non-negative values. HCCS differs from previous softmax surrogates as it includes a set of lightweight calibration parameters that are optimized offline based on a representative dataset and calibrated for each individual attention head to preserve the statistical properties of the individual heads. We describe a hardware-motivated implementation of HCCS for high-throughput scenarios targeting the AMD Versal AI Engines. The current reference implementations from AMD for this platform rely upon either bfloat16 arithmetic or LUTs to perform the exponential operation, which might limit the throughput of the platform and fail to utilize the high-throughput integer vector processing units of the AI Engine. In contrast, HCCS provides a natural mapping to the AI Engines' int8 multiply accumulate (MAC) units. To the best of our knowledge, this is the first int8 optimized softmax surrogate for AMD AI engines that significantly exceeds the speed performance of other reference implementations while maintaining competitive task accuracy on small or heavily quantized MHA workloads after quantization-aware retraining.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑