ShiftAddLLM:通过训练后无乘法重参数化加速预训练大语言模型
ShiftAddLLM: Accelerating Pretrained LLMs via Post-Training Multiplication-Less Reparameterization
AI总结:
ShiftAddLLM通过训练后移位相加重参数化将预训练LLM中的乘法替换为移位和加法,并结合多目标优化与自动比特分配,在保持精度的同时显著降低内存、能耗和延迟。
摘要:
大语言模型(LLMs)在语言任务上表现出色,但由于其庞大的参数量和对密集乘法的依赖,在资源受限设备上部署时面临高内存需求和延迟瓶颈等挑战。移位相加重参数化通过在LLM的注意力层和多层感知机(MLP)层中用硬件友好的原语替代代价高昂的乘法,提供了一种有前景的解决方案。然而,当前的重参数化技术需要从头训练或全参数微调来恢复精度,这对LLM而言资源消耗巨大。为解决这一问题,我们提出通过训练后移位相加重参数化来加速预训练LLM,创建高效的免乘法模型,称为ShiftAddLLM。具体来说,我们将每个权重矩阵量化为二值矩阵,并配以分组缩放因子。相关的乘法被重参数化为(1)激活值与缩放因子之间的移位操作,以及(2)根据二值矩阵进行的查询与加法操作。为减少精度损失,我们提出一种多目标优化方法,以同时最小化权重和输出激活的重参数化误差。此外,基于各层对重参数化敏感度的差异,我们开发了一种自动比特分配策略,以进一步降低内存使用和延迟。在五个LLM家族和八个任务上的实验一致验证了ShiftAddLLM的有效性,在与最具竞争力的3比特和2比特量化LLM相比时,在相当或更低的延迟下分别实现了平均困惑度改善5.6点和22.7点,并且相比原始LLM减少了超过80%的内存和能耗。代码和模型可在https://github.com/GATECH-EIC/ShiftAddLLM获取。
英文摘要:
Large language models (LLMs) have shown impressive performance on language tasks but face challenges when deployed on resource-constrained devices due to their extensive parameters and reliance on dense multiplications, resulting in high memory demands and latency bottlenecks. Shift-and-add reparameterization offers a promising solution by replacing costly multiplications with hardware-friendly primitives in both the attention and multi-layer perceptron (MLP) layers of an LLM. However, current reparameterization techniques require training from scratch or full parameter fine-tuning to restore accuracy, which is resource-intensive for LLMs. To address this, we propose accelerating pretrained LLMs through post-training shift-and-add reparameterization, creating efficient multiplication-free models, dubbed ShiftAddLLM. Specifically, we quantize each weight matrix into binary matrices paired with group-wise scaling factors. The associated multiplications are reparameterized into (1) shifts between activations and scaling factors and (2) queries and adds according to the binary matrices. To reduce accuracy loss, we present a multi-objective optimization method to minimize both weight and output activation reparameterization errors. Additionally, based on varying sensitivity across layers to reparameterization, we develop an automated bit allocation strategy to further reduce memory usage and latency. Experiments on five LLM families and eight tasks consistently validate the effectiveness of ShiftAddLLM, achieving average perplexity improvements of 5.6 and 22.7 points at comparable or lower latency compared to the most competitive quantized LLMs at 3 and 2 bits, respectively, and more than 80% memory and energy reductions over the original LLMs. Codes and models are available at https://github.com/GATECH-EIC/ShiftAddLLM.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。