Why Transformers Need Adam: A Hessian Perspective

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Zhang, Yushun, Chen, Congliang, Ding, Tian, Li, Ziniu, Sun, Ruoyu, Luo, Zhi-Quan
Natura: Preprint
Pubblicazione: 2024
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866914979479814144
author Zhang, Yushun
Chen, Congliang
Ding, Tian
Li, Ziniu
Sun, Ruoyu
Luo, Zhi-Quan
author_facet Zhang, Yushun
Chen, Congliang
Ding, Tian
Li, Ziniu
Sun, Ruoyu
Luo, Zhi-Quan
contents SGD performs worse than Adam by a significant margin on Transformers, but the reason remains unclear. In this work, we provide an explanation through the lens of Hessian: (i) Transformers are "heterogeneous": the Hessian spectrum across parameter blocks vary dramatically, a phenomenon we call "block heterogeneity"; (ii) Heterogeneity hampers SGD: SGD performs worse than Adam on problems with block heterogeneity. To validate (i) and (ii), we check various Transformers, CNNs, MLPs, and quadratic problems, and find that SGD can perform on par with Adam on problems without block heterogeneity, but performs worse than Adam when the heterogeneity exists. Our initial theoretical analysis indicates that SGD performs worse because it applies one single learning rate to all blocks, which cannot handle the heterogeneity among blocks. This limitation could be ameliorated if we use coordinate-wise learning rates, as designed in Adam.
format Preprint
id arxiv_https___arxiv_org_abs_2402_16788
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Why Transformers Need Adam: A Hessian Perspective
Zhang, Yushun
Chen, Congliang
Ding, Tian
Li, Ziniu
Sun, Ruoyu
Luo, Zhi-Quan
Machine Learning
Artificial Intelligence
SGD performs worse than Adam by a significant margin on Transformers, but the reason remains unclear. In this work, we provide an explanation through the lens of Hessian: (i) Transformers are "heterogeneous": the Hessian spectrum across parameter blocks vary dramatically, a phenomenon we call "block heterogeneity"; (ii) Heterogeneity hampers SGD: SGD performs worse than Adam on problems with block heterogeneity. To validate (i) and (ii), we check various Transformers, CNNs, MLPs, and quadratic problems, and find that SGD can perform on par with Adam on problems without block heterogeneity, but performs worse than Adam when the heterogeneity exists. Our initial theoretical analysis indicates that SGD performs worse because it applies one single learning rate to all blocks, which cannot handle the heterogeneity among blocks. This limitation could be ameliorated if we use coordinate-wise learning rates, as designed in Adam.
title Why Transformers Need Adam: A Hessian Perspective
topic Machine Learning
Artificial Intelligence
url https://arxiv.org/abs/2402.16788