arXiv:2410.06441cs.LGcs.CL2024-10ICLR被引 13

Addax融合零阶与一阶梯度,让大模型微调更快更省显存。

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

  • 根据数据点内存消耗选择零阶或一阶梯度,动态优化更新方向。
  • 在OPT-13B上比MeZO快15倍、准确率高14%,显存相近。
  • 适合资源受限场景下高效微调大语言模型,尤其对显存敏感任务。

使用Adam优化器微调语言模型通常需要大量显存,限制了可及性。尽管已提出IP-SGD和MeZO等方法以降低内存开销,但前者仍需较多内存,后者因零阶特性导致收敛慢且最终性能下降。本文提出Addax,将IP-SGD与MeZO结合,根据数据点的内存消耗动态计算零阶或一阶梯度,并融合更新方向。对高内存需求样本采用零阶梯度,低内存样本采用一阶梯度,从而克服MeZO收敛慢的问题,同时避免IP-SGD的高内存占用。此外,零阶梯度还起到对一阶梯度的正则化作用,进一步提升模型性能。理论上,在温和假设下,Addax实现更快收敛且对超参数要求更宽松。实验表明,无论在多种语言模型和任务上,Addax均显著优于MeZO:在单张A100 GPU上微调OPT-13B时,平均准确率/精确率提升14%,速度加快15倍,显存与MeZO相当;在更大的OPT-30B模型上,平均准确率提升超过16,速度提升30倍。同时,Addax在多数任务上超越标准微调方法(如IP-SGD、Adam),且显存需求显著更低。

原文摘要 · Abstract (English)

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.

微调显存优化梯度估计大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。