提出无需预测的动态输入剪枝,提升移动设备上大模型推理效率。
Efficient LLM Inference using Dynamic Input Pruning and Cache-Aware Masking
- 采用无预测的动态输入剪枝,利用激活特性实现高效内存压缩。
- 在Phi-3-Medium上减少46%内存占用,吞吐提升40%,困惑度损失小于0.1。
- 结合缓存感知掩码策略,适合移动端低功耗大模型部署场景。
尽管移动设备计算能力不断提升,但DRAM带宽增长缓慢,这对依赖内存的大语言模型(LLM)生成极为不利。以往工作利用ReLU激活带来的自然动态稀疏性降低每令牌的内存带宽需求,但近年主流模型采用SwiGLU替代ReLU,导致内在稀疏性极低。虽可基于幅值剪枝,但其稀疏模式难以预测,使旧方法失效。为此,本文提出动态输入剪枝(DIP),一种无需预测器的动态稀疏化方法,可在极少微调下保持精度。DIP还可结合轻量级LoRA适配器恢复剪枝损失的部分性能。此外,我们设计了一种新型缓存感知掩码策略,综合考虑缓存状态与激活幅值,进一步提高缓存命中率,从而提升移动端的生成速率。在模拟硬件环境下,DIP在准确率、内存与吞吐量权衡上优于现有方法。在Phi-3-Medium模型上,相比从Flash流式传输密集模型,内存减少46%,吞吐提升40%,困惑度损失低于0.1。相关代码与仿真工具已开源:https://github.com/Qualcomm-AI-research/dynamic-sparsity。
原文摘要 · Abstract (English)
While mobile devices provide ever more compute power, improvements in DRAM bandwidth are much slower. This is unfortunate for large language model (LLM) token generation, which is heavily memory-bound. Previous work has proposed to leverage natural dynamic activation sparsity in ReLU-activated LLMs to reduce effective DRAM bandwidth per token. However, more recent LLMs use SwiGLU instead of ReLU, which results in little inherent sparsity. While SwiGLU activations can be pruned based on magnitude, the resulting sparsity patterns are difficult to predict, rendering previous approaches ineffective. To circumvent this issue, our work introduces Dynamic Input Pruning (DIP): a predictor-free dynamic sparsification approach, which preserves accuracy with minimal fine-tuning. DIP can further use lightweight LoRA adapters to regain some performance lost during sparsification. Lastly, we describe a novel cache-aware masking strategy, which considers the cache state and activation magnitude to further increase cache hit rate, improving LLM token rate on mobile devices. DIP outperforms other methods in terms of accuracy, memory and throughput trade-offs across simulated hardware settings. On Phi-3-Medium, DIP achieves a 46\% reduction in memory and 40\% increase in throughput with $<$ 0.1 loss in perplexity when compared to streaming the dense model from Flash. The open source code for HW simulator, methods, and experiments in this paper is available at https://github.com/Qualcomm-AI-research/dynamic-sparsity .
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。