Train Small, Infer Large: Memory-Efficient LoRA Training for Large Language Models
该论文提出了一种名为LORAM的内存高效的LoRA训练方案,通过训练一个修剪的小型模型来减少大语言模型的内存占用,同时保持推理性能。
更新于 2025-02-20。作者:Jun Zhang、Jue Wang、Huan Li、Lidan Shou、Ke Chen、Yang You、Guiming Xie、Xuejian Gong、Kunlong Zhou。
中文摘要
大型语言模型(LLMs)在自然语言处理领域取得了显著进步,具有卓越的任务泛化能力。低秩适配(LoRA)提供了一种成本效益高的微调解决方案,通过冻结原始模型参数,仅训练轻量级的低秩适配矩阵。然而,LoRA的内存占用主要受原始模型参数的影响。为了缓解这一问题,我们提出了LoRAM,这是一种基于以下直觉的内存高效LoRA训练方案:在过度参数化的LLMs中,许多神经元在训练中的效用较低,但对于推理却是必不可少的。LoRAM提出了一个独特的思路:在修剪(小型)模型上进行训练,以获得修剪的低秩矩阵,然后恢复并利用原始(大型)模型进行推理。此外,由模型发布者在事先进行的低成本持续预训练,使修剪模型和原始模型之间的知识差异得到对齐。我们广泛的实验表明,LoRAM在各种修剪策略和下游任务中均表现出有效性。对于拥有700亿参数的模型,LoRAM允许在只有20G HBM的GPU上进行训练,取代了用于LoRA训练的A100-80G GPU和用于完全微调的15个GPU。具体来说,通过结构化修剪结合4位量化实现的QLoRAM,针对LLaMA-3.1-70B(LLaMA-2-70B),将低秩矩阵训练中占主导地位的参数存储成本降低了15.81倍(16.95倍),同时实现了相对于原始LLaMA-3.1-70B(LLaMA-2-70B)和LoRA训练的LLaMA-3.1-8B(LLaMA-2-13B)的显著性能提升。
英文摘要
Large Language Models (LLMs) have significantly advanced natural language processing with exceptional task generalization capabilities. Low-Rank Adaption (LoRA) offers a cost-effective fine-tuning solution, freezing the original model parameters and training only lightweight, low-rank adapter matrices. However, the memory footprint of LoRA is largely dominated by the original model parameters. To mitigate this, we propose LoRAM, a memory-efficient LoRA training scheme founded on the intuition that many neurons in over-parameterized LLMs have low training utility but are essential for inference. LoRAM presents a unique twist: it trains on a pruned (small) model to obtain pruned low-rank matrices, which are then recovered and utilized with the original (large) model for inference. Additionally, minimal-cost continual pre-training, performed by the model publishers in advance, aligns the knowledge discrepancy between pruned and original models. Our extensive experiments demonstrate the efficacy of LoRAM across various pruning strategies and downstream tasks. For a model with 70 billion parameters, LoRAM enables training on a GPU with only 20G HBM, replacing an A100-80G GPU for LoRA training and 15 GPUs for full fine-tuning. Specifically, QLoRAM implemented by structured pruning combined with 4-bit quantization, for LLaMA-3.1-70B (LLaMA-2-70B), reduces the parameter storage cost that dominates the memory usage in low-rank matrix training by 15.81times (16.95times), while achieving dominant performance gains over both the original LLaMA-3.1-70B (LLaMA-2-70B) and LoRA-trained LLaMA-3.1-8B (LLaMA-2-13B).
解读
一句话总结
该论文提出了一种名为LORAM的内存高效的LoRA训练方案,通过训练一个修剪的小型模型来减少大语言模型的内存占用,同时保持推理性能。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:大语言模型(LLMs)的微调需要大量内存,限制了其在资源受限环境中的应用。
- 现有方案不足:现有的LoRA方法虽然内存效率高,但仍然需要存储大量原始模型参数。
- 研究目标:提出一种内存高效的LoRA训练方案,以减少LLMs微调的内存占用。
问题2:论文的核心创新点是什么?
- 技术创新:提出LORAM,通过训练一个修剪的小型模型来减少内存占用。
- 方法改进:在原始模型上进行推理,以利用完整的参数集。
- 优势:显著减少内存占用,同时保持推理性能。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:在多个任务和模型规模上进行了实验,包括数学推理、常识推理和代码生成。
- 性能提升:QLORAM在LLaMA-2-70B上实现了15.81倍的参数减少,同时性能优于原始模型和LoRA微调的模型。
- 对比结果:与LoRA微调的模型相比,LORAM在大多数任务上实现了性能提升。
问题4:这个研究的实际应用价值是什么?
- 应用场景:适用于资源受限的环境,如移动设备或边缘计算。
- 实施建议:模型发布者可以在发布模型时进行预训练,以减少用户端的内存需求。
- 局限与展望:未来可以探索更有效的修剪和恢复策略,以及将LORAM应用于其他类型的模型。
来源
机器可读索引:llms.txt