Optimal Mini-Batch Size Selection for Fast Gradient Descent

Michael P. Perrone, Haidar Khan, Changhoan Kim, Anastasios Kyrillidis, Jerry Quinn, Valentina SalapuraarXiv 2019

Abstract

This paper presents a methodology for selecting the mini-batch size that minimizes Stochastic Gradient Descent (SGD) learning time for single and multiple learner problems. By decoupling algorithmic analysis issues from hardware and software implementation details, we reveal a robust empirical inverse law between mini-batch size and the average number of SGD updates required to converge to a specified error threshold. Combining this empirical inverse law with measured system performance, we create an accurate, closed-form model of average training time and show how this model can be used to identify quantifiable implications for both algorithmic and hardware aspects of machine learning. We demonstrate the inverse law empirically, on both image recognition (MNIST, CIFAR10 and CIFAR100) and machine translation (Europarl) tasks, and provide a theoretic justification via proving a novel bound on mini-batch SGD training.

Introduction

In deep learning, increasing the mini-batch size ($M$) is a common strategy to leverage hardware parallelism. However, this introduces a fundamental trade-off between hardware efficiency and algorithmic efficiency. While larger batches generally improve hardware throughput, they often require more total data samples to reach a target accuracy compared to smaller batches.

Standard practices like "weak scaling" (increasing batch size linearly with the number of processors) or "strong scaling" (keeping batch size fixed) do not necessarily minimize the total time to convergence ($T_C$). This paper addresses the challenge of identifying the "optimal" batch size that balances these competing forces by decoupling algorithmic behavior from hardware performance.

The Inverse Law of SGD Convergence

The authors model the total convergence time as the product of the number of updates and the time per update: $$T_C = N_{Update} \times T_{Update}$$

A key contribution of this work is the discovery of a robust empirical relationship for the algorithmic component: $$N_{Update} = N_\infty + \frac{\alpha}{M}$$

In this model, $N_\infty$ represents the fundamental limit of updates required even with a perfect gradient, while $\alpha$ represents the "noise sensitivity" of the algorithm. As shown in Figure 1, this inverse law provides an exceptionally close fit to experimental data across various architectures.

Empirical fit of the inverse law for CIFAR-10 using a ResNet architecture.

System Performance and Optimal Scaling

The hardware component, $T_{Update}$, is modeled based on the system's computation threshold ($M_T$) and communication overhead ($\delta$). By combining the algorithmic and hardware models, the authors derive a closed-form solution for the optimal $M$.

Key insights from this unified model include:

  • Optimal Batch Size for Single Learners: The optimal batch size is typically $M_T$, the "knee" of the hardware performance curve where peak efficiency is reached.
  • Distributed Scaling: In multi-learner ($P$) setups, the optimal batch size ($M_{Opt}$) may scale with $\sqrt{P}$ in certain communication-constrained regimes, rather than linearly as suggested by weak scaling.
  • Noise Sensitivity ($\alpha$): Harder problems (e.g., CIFAR-100 vs. MNIST) exhibit higher $\alpha$. A higher $\alpha$ indicates greater sensitivity to gradient noise, which paradoxically makes parallelization more effective because larger batches provide a more significant algorithmic benefit.

Empirical Validation and Limitations

The model was validated across image recognition tasks (MNIST, CIFAR-10, CIFAR-100) and machine translation (Europarl). While the inverse law proved universal for SGD, the authors noted limitations when applying it to adaptive optimizers like Adam.

The inverse law model applied to the Adam optimizer, showing a negative N_inf (N*), which suggests that adaptive learning rates require further theoretical refinement.

As seen in Figure 2, applying the model to Adam can result in non-physical parameters such as a negative $N_\infty$. Furthermore, the current study focuses on convergence time to a training error threshold and does not explicitly address the "generalization gap" often observed with very large batches.

Conclusion

By establishing a principled methodology to select mini-batch sizes, this work moves beyond heuristic scaling strategies. The decoupling of algorithmic noise sensitivity from hardware throughput allows for quantifiable design of both machine learning algorithms and the systems that run them.

Summary updated

BibTeX
@misc{perrone2019optimal,
  author = {Michael P. Perrone and Haidar Khan and Changhoan Kim and Anastasios Kyrillidis and Jerry Quinn and Valentina Salapura},
  title = {{Optimal Mini-Batch Size Selection for Fast Gradient Descent}},
  year = {2019},
  eprint = {1911.06459},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1911.06459},
}
Figure