While fine-tuning large language models (LLMs) for specific tasks often yields impressive results, it comes at the cost of memory inefficiency due to back-propagation in gradient-based training. Memory-efficient Zeroth-order (MeZO) optimizers, recently proposed to address this issue, only require forward passes during training, making them more memory-friendly. However, compared with exact gradients, ZO-based gradients usually exhibit an estimation error, which can significantly hurt the optimization process, leading to slower convergence and suboptimal solutions. In addition, we find that the estimation error will hurt more when adding to large weights instead of small weights. Based on this observation, this paper introduces Sparse MeZO, a novel memory-efficient zeroth-order optimization approach that applies ZO only to a carefully chosen subset of parameters. We propose a simple yet effective parameter selection scheme that yields significant performance gains with Sparse-MeZO. Additionally, we develop a memory-optimized implementation for sparse masking, ensuring the algorithm requires only inference-level memory consumption, allowing Sparse-MeZO to fine-tune LLaMA-30b on a single A100 GPU. Experimental results illustrate that Sparse-MeZO consistently improves both performance and convergence speed over MeZO without any overhead. For example, it achieves a 9\% absolute accuracy improvement and 3.5x speedup over MeZO on the RTE task. Code is available at https://github.com/NUS-HPC-AI-Lab/SparseMeZO.


翻译:尽管针对特定任务微调大语言模型(LLMs)通常能取得显著效果,但由于基于梯度的训练中反向传播的存在,这种方法往往以内存效率低下为代价。近期提出的内存高效零阶(MeZO)优化器通过仅需前向传播的训练方式有效缓解了这一问题,使其更具内存友好性。然而,与精确梯度相比,基于零阶(ZO)的梯度通常存在估计误差,这种误差可能严重干扰优化过程,导致收敛速度减缓和解质量下降。此外,我们发现估计误差对较大权重的负面影响远比对小权重的更显著。基于这一观察,本文提出了稀疏MeZO——一种新型的内存高效零阶优化方法,该方法仅对精心筛选的参数子集应用零阶优化。我们提出了一种简洁而有效的参数选择方案,该方案使稀疏MeZO获得了显著的性能提升。同时,我们开发了针对稀疏掩码的内存优化实现,确保算法仅需推理级别的内存消耗,从而使稀疏MeZO能够在单张A100 GPU上完成LLaMA-30b的微调。实验结果表明,稀疏MeZO在无额外开销的情况下,持续在性能和收敛速度上超越原始MeZO。例如,在RTE任务中,其绝对准确率较MeZO提升9%,且加速比达到3.5倍。代码已发布于 https://github.com/NUS-HPC-AI-Lab/SparseMeZO。

0
下载
关闭预览

相关内容

【ICLR2025】大型语言模型的动态低秩稀疏适应
专知会员服务
14+阅读 · 2025年2月21日
大型语言模型对齐技术综述:RLHF、RLAIF、PPO、DPO 等
专知会员服务
55+阅读 · 2024年7月24日
【ICML 2024】零阶优化器微调大模型,大幅降低内存
专知会员服务
32+阅读 · 2024年7月8日
稀疏大模型简述:从MoE、Sparse Attention到GLaM
夕小瑶的卖萌屋
14+阅读 · 2022年3月22日
入门 | 深度学习模型的简单优化技巧
机器之心
10+阅读 · 2018年6月10日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
VIP会员
相关VIP内容
【ICLR2025】大型语言模型的动态低秩稀疏适应
专知会员服务
14+阅读 · 2025年2月21日
大型语言模型对齐技术综述:RLHF、RLAIF、PPO、DPO 等
专知会员服务
55+阅读 · 2024年7月24日
【ICML 2024】零阶优化器微调大模型,大幅降低内存
专知会员服务
32+阅读 · 2024年7月8日
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员