arXiv:2502.00213cs.LGcs.AI2025-02被引 6

揭示Transformer优化中梯度异质性的根源及其对优化器的影响

Gradient Heterogeneity Complements Hessian Heterogeneity in Transformer Optimization

  • 从梯度异质性角度解析Adam优于SGD的机制
  • 发现Post-LN架构导致梯度差异显著增大
  • 理论与实验验证梯度异质性影响优化收敛,适合研究优化算法者阅读

Transformer模型在随机梯度下降(SGD)下优化困难,主要依赖自适应优化器如Adam。尽管已有大量研究,但Adam在Transformer优化中的优势仍不明确。本文通过分析微调场景下的梯度异质性(即参数块间梯度范数的差异),提出理论证明:梯度异质性与Hessian异质性共同导致基于梯度的方法(如SGD)收敛变差,而符号类方法对此不敏感。Adam和SignSGD均进行坐标轴更新,对单个梯度坐标的尺度不敏感。因此,本文以SignSGD作为Adam行为的可分析代理。理论推导基于SGD与SignSGD在不同范数下遵循最陡下降方向,给出迭代复杂度上界,并指导SignSGD的学习率缩放。进一步研究发现,梯度异质性源于层归一化的位置,Post-LN架构表现出显著异质性。在自然语言处理与视觉任务的微调实验中,结果验证了理论分析。

原文摘要 · Abstract (English)

Transformers are difficult to optimize with stochastic gradient descent (SGD) and largely rely on adaptive optimizers such as Adam. Despite extensive efforts, the mechanisms behind Adam's advantage over SGD in Transformer optimization are still not fully understood. In this study, we analyze the optimization of Transformer models in the fine-tuning setting through the lens of gradient heterogeneity, defined as the variation in gradient norms across parameter blocks. We provide a theoretical analysis showing that gradient heterogeneity, together with Hessian heterogeneity, degrades the convergence of gradient-based methods such as SGD, while sign-based methods are substantially less sensitive to this effect. Adam and SignSGD both perform coordinate-wise updates and are less sensitive to the scale of individual gradient coordinates than SGD. This motivates our use of SignSGD as an analytically tractable proxy for Adam-like behavior. Our analysis uses the fact that SGD and SignSGD follow steepest descent directions under different norms, and derives upper bounds on the iteration complexity with implications for learning-rate scaling for SignSGD. We further investigate the origin of gradient heterogeneity in Transformer architectures and show that it is strongly influenced by the placement of layer normalization, with Post-LN architectures exhibiting particularly pronounced heterogeneity. Experimental results from fine-tuning Transformers in both NLP and vision domains validate our theoretical analysis.

Transformer优化梯度异质性优化器分析

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