尽管大型语言模型(LLMs)推动了自然语言处理任务的发展,但其不断增长的计算和内存需求使得在移动电话等资源受限设备上部署的挑战日益严峻。本文提出SHARP(SHaring Adjacent Layers with Recovery Parameters,基于恢复参数的相邻层共享),这是一种通过在相邻层间共享参数以加速LLM推理的新方法,旨在降低内存负载开销,同时引入低秩恢复参数以维持模型性能。受连续层输出相似这一观察的启发,SHARP采用两阶段恢复过程:单层预热(SLW)和监督微调(SFT)。SLW阶段利用L₂损失对齐共享层的输出,为后续SFT阶段进一步恢复模型性能提供良好初始化。大量实验表明,SHARP仅需不超过50k的微调数据即可恢复模型在各类分布内任务上的困惑度,同时将存储的MLP参数数量减少38%至65%。我们还对SHARP进行了多项消融研究,结果显示替换模型后半部分的层能更好地保留性能,且参数数量匹配时不同恢复参数化的表现相似。此外,与原始Llama2-7b模型相比,SHARP在移动设备上节省了42.8%的模型存储,并将总推理时间减少42.2%。我们的结果表明,SHARP是一种无需预训练级资源即可降低LLM部署推理成本的高效解决方案。
英文摘要:
While Large language models (LLMs) have advanced natural language processing tasks, their growing computational and memory demands make deployment on resource-constrained devices like mobile phones increasingly challenging. In this paper, we propose SHARP (SHaring Adjacent Layers with Recovery Parameters), a novel approach to accelerate LLM inference by sharing parameters across adjacent layers, thus reducing memory load overhead, while introducing low-rank recovery parameters to maintain performance. Inspired by observations that consecutive layers have similar outputs, SHARP employs a two-stage recovery process: Single Layer Warmup (SLW), and Supervised Fine-Tuning (SFT). The SLW stage aligns the outputs of the shared layers using L_2 loss, providing a good initialization for the following SFT stage to further restore the model performance. Extensive experiments demonstrate that SHARP can recover the model's perplexity on various in-distribution tasks using no more than 50k fine-tuning data while reducing the number of stored MLP parameters by 38% to 65%. We also conduct several ablation studies of SHARP and show that replacing layers towards the later parts of the model yields better performance retention, and that different recovery parameterizations perform similarly when parameter counts are matched. Furthermore, SHARP saves 42.8% in model storage and reduces the total inference time by 42.2% compared to the original Llama2-7b model on mobile devices. Our results highlight SHARP as an efficient solution for reducing inference costs in deploying LLMs without the need for pretraining-scale resources.
Reducing Fine-Tuning Memory Overhead by Approximate and Memory-Sharing Backpropagation
School of Statistics and Data Science, Nankai University(南开大学统计与数据科学学院);School of Information Science and Technology, ShanghaiTech University(上海科技大学信息科学与技术学院);Department of Automation, Tsinghua University(清华大学自动化系);Central Research Institute, United Imaging Healthcare, Co., Ltd.(联影医疗股份有限公司中央研究院)
Krul: Efficient State Restoration for Multi-turn Conversations with Dynamic Cross-layer KV Sharing
Sun Yat-sen University(中山大学);Hong Kong University of Science and Technology(香港理工大学);Peng Cheng Laboratory(鹏城实验室);Hubei University of Technology(湖北工业大学)
Pushing the Limits of BFP on Narrow Precision LLM Inference
National Center of Technology Innovation for EDA(国家EDA技术创新中心);School of Integrated Circuits, Southeast University(东南大学集成电路学院);Houmo AI(鸿眸人工智能);Nanjing University(南京大学);Huazhong University of Science and Technology(华中科技大学)
Rethinking Parameter Sharing as Graph Coloring for Structured Compression
Institute of Computing Technology, Chinese Academy of Sciences(中国科学院计算技术研究所);University of Chinese Academy of Sciences(中国科学院大学);Peng Cheng Laboratory(鹏城实验室)
CANS: Accelerating Multiuser Collaborative Edge Inference via Cooperative Autodidactic NeuroSurgeon
Harbin Institute of Technology Shenzhen(哈尔滨工业大学(深圳));Politecnico di Milano(米兰理工大学);Harbin Institute of Technology(哈尔滨工业大学);Fudan University(复旦大学);Shanghai Academy of Artificial Intelligence for Science(上海人工智能科学研究院)
Selective KV-Cache Sharing to Mitigate Timing Side-Channels in LLM Inference
University of Connecticut Storrs(康涅狄格大学斯托尔斯分校);Independent(独立研究者);Indiana University Bloomington(印第安纳大学布卢明顿分校);UC Santa Cruz(圣克拉拉大学);Peking University(北京大学)