Scaling SGD Batch Size to 32K for ImageNet Training

Yang You, Igor Gitman, Boris Ginsburg

Abstract

Training deep learning models at scale requires leveraging massive parallelism, which necessitates increasing the mini-batch size. However, large-batch training often leads to optimization instability or a significant drop in final model accuracy. This paper introduces Layer-wise Adaptive Rate Scaling (LARS), a novel optimization algorithm that enables scaling batch sizes up to 32,000 for ResNet-50 and 8,000 for AlexNet on the ImageNet dataset without the typical loss in performance.

Introduction

To reduce training time, researchers employ data-parallelism, distributing large mini-batches across multiple GPUs. The standard approach to maintain convergence is linear learning rate scaling: if the batch size increases by a factor of $k$, the learning rate (LR) is also increased by $k$. However, extremely high learning rates often cause models to diverge during early training stages. Even with warm-up periods, models like AlexNet historically failed to maintain accuracy once batch sizes exceeded 2,000. LARS was developed to stabilize training for these massive batches, unlocking true hardware scalability.

Layer-wise Adaptive Rate Scaling (LARS)

Unlike standard SGD, which applies a single global learning rate to every layer, LARS calculates a local learning rate for each individual layer. The algorithm utilizes a "trust coefficient" ($\eta$) to scale the learning rate based on the ratio between the norm of the weights ($||w||$) and the norm of the gradients ($||\nabla L(w)||$) for each layer.

If a layer has large weights relative to its gradients, it can tolerate a higher learning rate. Conversely, if gradients are large relative to weights, the learning rate is scaled down to prevent drastic weight changes that cause instability. This differs from adaptive optimizers like Adam, which adapt per-weight; LARS adapts per-layer, preserving the global geometry of the optimization process.

Local learning rates for different layers and parameters in AlexNet-BN using LARS across various batch sizes.

Key Insights

Layer-wise Dynamics

The authors observed that the weight-to-gradient ratio varies wildly across a network. In AlexNet, the first convolutional layer might have a ratio of ~5.7, while the first fully connected layer reaches ~1345. A global learning rate is insufficient for these extremes. As shown in the figure above, LARS automatically adjusts the local learning rate for different layers (e.g., conv1 vs. conv5) and parameter types (weights vs. biases) to maintain stability.

Optimization vs. Generalization

A central question in large-batch training is whether performance drops are due to poor optimization (failure to minimize training loss) or poor generalization (finding a "sharp" minimum that fails on test data). For AlexNet, the authors demonstrated that the failure at large batches was primarily an optimization problem that LARS successfully addresses.

The gap between test and train loss for AlexNet with Batch Normalization, comparing small (512) and large (8192) batch sizes.

Experimental Results

The researchers evaluated LARS on the ImageNet (ILSVRC-2012) dataset using AlexNet and ResNet-50:

  • AlexNet: Using LARS and replacing Local Response Normalization with Batch Normalization (AlexNet-BN), they scaled the batch size to 8K and achieved 58% accuracy, matching the small-batch baseline. Without LARS, accuracy dropped to 44.8%.
  • ResNet-50: Training was successfully scaled to a batch size of 32K, achieving 72.3% top-1 accuracy, nearly matching the 73% baseline.

Conclusion and Future Work

LARS effectively bridges the gap between small and large-batch training, allowing for massive parallelization. However, scaling beyond 32K without accuracy loss remains a challenge. Additionally, while LARS automates local rates, users must still tune a global base learning rate and trust coefficient. Future work may focus on further closing the "generalization gap" that can still emerge at extreme scales.

Summary updated

BibTeX
@misc{you2017scaling,
  author = {Yang You and Igor Gitman and Boris Ginsburg},
  title = {{Scaling SGD Batch Size to 32K for ImageNet Training}},
  year = {2017},
  eprint = {1708.03888},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1708.03888},
}
Figure