[Paper Review] Large Batch Optimization for Deep Learning: Training BERT in 76 minutes
Introduces Lamb, a layerwise adaptive large-batch optimizer, enabling Bert training with batch sizes up to 32K and reducing Bert pretraining time from 3 days to 76 minutes on TPUv3 pods, with convergence guarantees for Lamb and Lars.
Training large deep neural networks on massive datasets is computationally very challenging. There has been recent surge in interest in using large batch stochastic optimization methods to tackle this issue. The most prominent algorithm in this line of research is LARS, which by employing layerwise adaptive learning rates trains ResNet on ImageNet in a few minutes. However, LARS performs poorly for attention models like BERT, indicating that its performance gains are not consistent across tasks. In this paper, we first study a principled layerwise adaptation strategy to accelerate training of deep neural networks using large mini-batches. Using this strategy, we develop a new layerwise adaptive large batch optimization technique called LAMB; we then provide convergence analysis of LAMB as well as LARS, showing convergence to a stationary point in general nonconvex settings. Our empirical results demonstrate the superior performance of LAMB across various tasks such as BERT and ResNet-50 training with very little hyperparameter tuning. In particular, for BERT training, our optimizer enables use of very large batch sizes of 32868 without any degradation of performance. By increasing the batch size to the memory limit of a TPUv3 Pod, BERT training time can be reduced from 3 days to just 76 minutes (Table 1). The LAMB implementation is available at https://github.com/tensorflow/addons/blob/master/tensorflow_addons/optimizers/lamb.py
Motivation & Objective
- Motivate and address the inefficiency of training large deep networks with large minibatches.
- Develop a layerwise adaptive optimization method (Lamb) suitable for large-batch SGD.
- Provide theoretical convergence analyses for Lars and Lamb in nonconvex settings.
- Empirically demonstrate Lamb’s superior performance on Bert and ResNet-50 across large batch regimes.
Proposed method
- Propose a general strategy: normalize updates layerwise to unit L2-norm and scale learning rates by a function of layer norm to stabilize large-batch training.
- Instantiate two algorithms under this strategy: Lars (momentum-based) and Lamb (Adam-based with layerwise normalization).
- Offer convergence analyses showing stationary-point convergence for nonconvex objectives under both Lars and Lamb.
- Evaluate on Bert (SQuAD, 2.5B+0.8B word corpora) and ImageNet/ResNet-50 with very large batch sizes and minimal hyperparameter tuning.
- Use square-root learning-rate scaling and linear warmup; employ re-warmup for multi-stage Bert training with mixed sequence lengths.
Experimental results
Research questions
- RQ1Can layerwise update normalization plus adaptive learning-rate scaling enable stable, efficient training with very large minibatches?
- RQ2Do Lamb and Lars provide theoretical convergence guarantees in nonconvex settings similar to SGD, and how do they compare empirically across tasks like Bert and ResNet-50?
- RQ3What batch sizes can Bert and ResNet-50 tolerate without loss of accuracy, and how much wall-clock speedup is achievable on TPUv3 Pods?
- RQ4Is Lamb more robust than Lars across diverse architectures and data scales (language models vs. vision models)?
Key findings
- Lamb achieves stable training for Bert with batch sizes up to 32K, maintaining or improving F1 on SQuAD compared with baseline.
- Using Lamb with mixed-batch training and re-warmup, Bert training time drops from about 3 days to 76 minutes on a TPUv3 Pod (with 64x scaling resources).
- Lamb delivers competitive or superior top-1 accuracy for ResNet-50 on ImageNet, outperforming Adam/AdamW and matching or surpassing momentum/Lars baselines at large batch sizes.
- Lars generally underperforms Lamb on Bert across tested batch sizes, while Lamb maintains high F1 scores as batch size increases (Table 1 and Table 2).
- Theoretical results show convergence to a stationary point for both Lars and Lamb in nonconvex settings, with Lamb offering favorable dependence on average layer Lipschitz constants (L_avg) compared to L_infty.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.