arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2410.06441cs.LGcs.CL
收藏

Addax:利用零阶梯度提升语言模型微调中SGD的内存效率与性能

Addax: Utilizing Zeroth-Order Gradients to Improve Memory Efficiency and Performance of SGD for Fine-Tuning Language Models

Google Research(谷歌研究院)

Zeman Li, Xinwei Zhang, Peilin Zhong, Yuan Deng, Meisam Razaviyayn, Vahab Mirrokni

AI总结:

针对语言模型微调中Adam内存占用高、MeZO收敛慢且性能差的问题,提出Addax方法,结合零阶与一阶梯度优化,在降低内存的同时提升收敛速度与性能,效果优于现有多种微调方法。

摘要:

使用Adam优化器微调语言模型(LM)通常需要占用大量内存,限制了其可及性。为此,研究人员已提出随机梯度下降的“原位”版本(IP-SGD)和内存高效零阶优化器(MeZO)来解决这一问题。但IP-SGD仍需大量内存,而MeZO由于其零阶特性,存在收敛速度慢、最终性能下降的问题。\n本文提出Addax这一全新方法,将IP-SGD与MeZO相结合,同时提升IP-SGD的内存效率与性能。具体而言,Addax根据小批量中各数据点的内存消耗,计算其零阶或一阶梯度,结合这些梯度估计值得到更新方向。通过对内存需求更高的数据点计算零阶梯度,对其余数据点计算一阶梯度,Addax既克服了MeZO收敛慢的问题,也解决了IP-SGD内存需求过高的缺陷。此外,零阶梯度可作为一阶梯度的正则项,进一步提升模型的最终性能。\n理论上,我们在温和假设下证明了Addax的收敛性,表明其相比MeZO收敛速度更快,超参数选择的限制更少。我们在多种语言模型和任务上开展的实验显示,Addax在内存占用与MeZO相当的情况下,在准确率和收敛速度上始终优于MeZO。使用单张A100 GPU微调OPT-13B时,Addax的准确率/F1值平均比MeZO高14%,运行速度快15倍,且内存使用量与MeZO相近。在更大的OPT-30B模型上的实验中,在单张H100 GPU上,Addax的准确率/F1值平均比MeZO高16%以上,运行速度快30倍。此外,在大多数任务中,Addax的性能优于IP-SGD、Adam等标准微调方法,且内存需求显著更低。

英文摘要:

Fine-tuning language models (LMs) with the Adam optimizer often demands excessive memory, limiting accessibility. The "in-place" version of Stochastic Gradient Descent (IP-SGD) and Memory-Efficient Zeroth-order Optimizer (MeZO) have been proposed to address this. However, IP-SGD still requires substantial memory, and MeZO suffers from slow convergence and degraded final performance due to its zeroth-order nature. This paper introduces Addax, a novel method that improves both memory efficiency and performance of IP-SGD by integrating it with MeZO. Specifically, Addax computes zeroth- or first-order gradients of data points in the minibatch based on their memory consumption, combining these gradient estimates to update directions. By computing zeroth-order gradients for data points that require more memory and first-order gradients for others, Addax overcomes the slow convergence of MeZO and the excessive memory requirement of IP-SGD. Additionally, the zeroth-order gradient acts as a regularizer for the first-order gradient, further enhancing the model's final performance. Theoretically, we establish the convergence of Addax under mild assumptions, demonstrating faster convergence and less restrictive hyper-parameter choices than MeZO. Our experiments with diverse LMs and tasks show that Addax consistently outperforms MeZO regarding accuracy and convergence speed while having a comparable memory footprint. When fine-tuning OPT-13B with one A100 GPU, on average, Addax outperforms MeZO in accuracy/F1 score by 14% and runs 15x faster while using memory similar to MeZO. In our experiments on the larger OPT-30B model, on average, Addax outperforms MeZO in terms of accuracy/F1 score by >16 and runs 30x faster on a single H100 GPU. Moreover, Addax surpasses the performance of standard fine-tuning approaches, such as IP-SGD and Adam, in most tasks with significantly less memory requirement.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑