无需训练即可实现大模型高效推理的激活稀疏技术
R-Sparse: Rank-Aware Activation Sparsity for Efficient LLM Inference
- 基于输入通道与奇异值的秩感知稀疏机制,不依赖激活预测
- 在Llama-2/3和Mistral上实现50%模型级稀疏,性能接近原模型
- 适合边缘设备小批量推理,可提升43%端到端效率
大型语言模型(LLMs)虽在各类应用中表现卓越,但其庞大的模型规模在推理阶段带来显著挑战,尤其在边缘设备部署时。激活稀疏性为减少计算量和内存移动提供了可行方案,尤其适用于小批量的本地推理。然而,现有方法对非ReLU激活函数支持不足,或需大量持续训练;同时,活跃通道难以预测、可达到的稀疏率有限,制约了其有效性。本文提出R-Sparse,一种无需训练的激活稀疏方法,可在先进LLMs中实现高稀疏度。我们对单个线性层中各组件的贡献进行了两项初步研究,发现:(i) 非稀疏输入部分可视为少量偏置项;(ii) 通过输入通道与权重奇异值的合理组合,可有效近似完整计算。基于此,我们将LLMs中的线性层替换为基于秩感知的稀疏推理方法,利用输入通道与奇异值成分的稀疏性,无需主动通道预测,避免了输出稀疏方法的瓶颈。在十项不同任务上对Llama-2/3和Mistral模型的实验表明,R-Sparse在50%模型级稀疏下保持相近性能,配合定制内核实现43%的端到端效率提升。
原文摘要 · Abstract (English)
Large Language Models (LLMs), while demonstrating remarkable capabilities across various applications, present significant challenges during inference due to their substantial model size, especially when deployed on edge devices. Activation sparsity offers a promising solution to reduce computation and memory movement, enabling more efficient inference, particularly for small-batch on-device applications. However, current approaches face limitations with non-ReLU activation function, which are foundational to most advanced LLMs, or require heavy continual training. Additionally, the difficulty in predicting active channels and limited achievable sparsity ratios constrain the effectiveness of activation sparsity-based methods. In this paper, we introduce R-Sparse, a training-free activation sparsity approach capable of achieving high sparsity levels in advanced LLMs. We conducted two preliminary investigations into how different components contribute to the output within a single linear layer and found two key observations: (i) the non-sparse components of the input function can be regarded as a few bias terms, and (ii) The full computation can be effectively approximated by an appropriate combination of input channels and weight singular values. Building on this, we replace the linear layers in LLMs with a rank-aware sparse inference method that leverages the sparsity of input channels and singular value components, eliminating the need for active channel prediction like the output sparsity based approaches. Experiments on Llama-2/3 and Mistral models across ten diverse tasks demonstrate that R-Sparse achieves comparable performance at 50% model-level sparsity, resulting in a significant 43% end-to-end efficient improvements with customized kernels.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。