arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2410.00907cs.CL
收藏

加法是节能语言模型的全部所需

Addition is All You Need for Energy-efficient Language Models

BitEnergy AI, Inc.(BitEnergy AI公司)

Hongyin Luo, Wei Sun

AI总结:

本文提出线性复杂度 L-Mul 算法,以整数加法近似浮点乘法,显著降低张量计算与点积能耗,并在多类任务和 transformer 微调、推理中验证其接近 float8 的精度。

摘要:

大型神经网络将大部分计算消耗在浮点张量乘法上。在本工作中,我们发现一个浮点乘法器可以用一个整数加法器以高精度近似。我们提出了线性复杂度乘法 L-Mul 算法,用整数加法运算近似浮点数乘法。与8位浮点乘法相比,该新算法所需计算资源显著更少,却实现更高精度。由于浮点数乘法相比整数加法运算需要高得多的能量,在张量处理硬件中应用 L-Mul 运算,有可能将逐元素浮点张量乘法的能耗降低95%,并将点积的能耗降低80%。我们计算了 L-Mul 的理论误差期望,并在广泛的文本、视觉和符号任务上评估了该算法,包括自然语言理解、结构推理、数学和常识问答。我们的数值分析实验与理论误差估计一致,表明具有4位尾数的 L-Mul 可达到与 float8_e4m3 乘法相当的精度,而具有3位尾数的 L-Mul 优于 float8_e5m2。在流行基准上的评估结果表明,直接将 L-Mul 应用于注意力机制几乎无损。我们进一步表明,在 transformer 模型中用3位尾数 L-Mul 替换所有浮点乘法,在微调和推理中都能达到与使用 float8_e4m3 作为累加精度等效的精度。

英文摘要:

Large neural networks spend most computation on floating point tensor multiplications. In this work, we find that a floating point multiplier can be approximated by one integer adder with high precision. We propose the linear-complexity multiplication L-Mul algorithm that approximates floating point number multiplication with integer addition operations. The new algorithm costs significantly less computation resource than 8-bit floating point multiplication but achieves higher precision. Compared to 8-bit floating point multiplications, the proposed method achieves higher precision but consumes significantly less bit-level computation. Since multiplying floating point numbers requires substantially higher energy compared to integer addition operations, applying the L-Mul operation in tensor processing hardware can potentially reduce 95% energy cost by element-wise floating point tensor multiplications and 80% energy cost of dot products. We calculated the theoretical error expectation of L-Mul, and evaluated the algorithm on a wide range of textual, visual, and symbolic tasks, including natural language understanding, structural reasoning, mathematics, and commonsense question answering. Our numerical analysis experiments agree with the theoretical error estimation, which indicates that L-Mul with 4-bit mantissa achieves comparable precision as float8_e4m3 multiplications, and L-Mul with 3-bit mantissa outperforms float8_e5m2. Evaluation results on popular benchmarks show that directly applying L-Mul to the attention mechanism is almost lossless. We further show that replacing all floating point multiplications with 3-bit mantissa L-Mul in a transformer model achieves equivalent precision as using float8_e4m3 as accumulation precision in both fine-tuning and inference.

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

↑