[Paper Review] Small Batch Size Training for Language Models: When Vanilla SGD Works, and Why Gradient Accumulation Is Wasteful
The paper shows that small batch sizes, including batch size one, can train language models stably and robustly, often matching or surpassing large-batch, optimizer-heavy approaches, and recommends against gradient accumulation.
Conventional wisdom dictates that small batch sizes make language model pretraining and fine-tuning unstable, motivating gradient accumulation, which trades off the number of optimizer steps for a proportional increase in batch size. While it is common to decrease the learning rate for smaller batch sizes, other hyperparameters are often held fixed. In this work, we revisit small batch sizes all the way down to batch size one, and we propose a rule for scaling Adam hyperparameters to small batch sizes. In particular, rather than holding the decay rate of the second moment fixed across batch sizes, we propose to hold its half-life fixed in terms of tokens. We find that small batch sizes (1) train stably, (2) are consistently more robust to hyperparameter choices, (3) achieve equal or better per-FLOP performance than larger batch sizes, and (4) notably enable stable language model training with vanilla SGD, even without momentum, despite storing no optimizer state. Building on these results, we provide practical recommendations for selecting a batch size and setting optimizer hyperparameters. We further recommend against gradient accumulation unless training on multiple devices with multiple model replicas. Finally, we show that a small batch size combined with an optimizer with a small state size can provide the performance benefits of full fine-tuning while maintaining a similar memory footprint to LoRA.
Motivation & Objective
- Investigate whether small batch sizes can stabilize language model training across pretraining and fine-tuning.
- Examine robustness of different optimizers and hyperparameters at varying batch sizes.
- Develop practical guidelines for scaling Adam hyperparameters and selecting batch sizes based on throughput and memory constraints.
- Explore memory and hardware considerations when choosing small batch sizes versus gradient accumulation.
Proposed method
- Perform comprehensive grid searches over SGD, Adam, Adafactor, and Muon across batch sizes from 1 to 4096.
- Tune learning rate and Adam decay factors (beta1, beta2) for each batch size to minimize validation loss.
- Introduce the concept of the second-moment half-life t2 and show scaling rules for beta2 based on token-based half-life.
- Compare vanilla SGD (no momentum) and memory-efficient optimizers like Adafactor in small-batch regimes.
- Validate scaling heuristics on larger models (GPT-2 124M and GPT-3 1.3B) and in fine-tuning scenarios.
- Assess memory implications and provide practical recommendations for memory-constrained training.
Experimental results
Research questions
- RQ1Can very small batch sizes (down to 1) train language models stably without momentum or complex optimizers?
- RQ2How should Adam hyperparameters be scaled with batch size to maintain performance at small batch sizes?
- RQ3Do small batch sizes offer robustness to hyperparameter misspecification compared to large batch sizes?
- RQ4What are the memory and hardware implications of using small batches versus gradient accumulation in language model training?
- RQ5Do findings extend to fine-tuning and larger model scales?
Key findings
- Small batch sizes consistently match or outperform large batches across optimizers when hyperparameters are scaled appropriately.
- Momentum is less necessary at small batch sizes, with vanilla SGD performing competitively.
- Scaling Adam by fixing the second-moment half-life in tokens (t2) yields better performance across batch sizes than fixing beta2.
- Gradient accumulation is often unnecessary and memory-inefficient compared to using small batches with simpler optimizers like Adafactor or SGD.
- For very large models, SGD with batch size 1 can match AdamW baselines with minimal tuning, and Adafactor provides a favorable memory-performance trade-off.
- The recommended practice is to use the smallest batch size that maximizes throughput and to avoid gradient accumulation except on multi-device setups.
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.