Adaptive Batch Size Schedules for Distributed Training of Language Models with Data and Model Parallelism

Tim Tsz-Kit Lau, Weijian Li, Chenwei Xu, Han Liu, Mladen Kolar

TL;DR

Training large language models with large batch sizes speeds up hardware throughput but often harms generalization—a problem typically managed via handcrafted, static batch-size warmup schedules. This paper introduces DDP-Norm and FSDP-Norm, theoretically grounded adaptive batch-size schedules for distributed data and model parallelism that dynamically scale batch sizes based on gradient noise. The authors provide non-convex convergence guarantees for the Adam optimizer and show that their method beats static and heuristic batch schedules on Llama models up to 3 billion parameters.

What Problem Does This Paper Address?

In deep learning, large-batch training efficiently saturates GPU compute and memory, but suffers from a well-known generalization gap: smaller batches introduce stochastic gradient noise that helps optimizers escape sharp local minima and reach flatter, better-generalizing solutions.

To cope with this, current LLM pretraining relies on heuristic batch size ramp-up schedules (e.g., Llama 3 and GPT-3 linearly increase batch sizes across early tokens). However, these schedules are rigid, hand-crafted, and blind to the actual dynamics of training. While adaptive sampling techniques (like the "norm test") exist to grow batch sizes based on gradient variance, they historically assume single-GPU setups where per-sample gradients can be calculated. In modern distributed regimes using Distributed Data Parallel (DDP) or Fully Sharded Data Parallel (FSDP), computing per-sample gradients causes unacceptable computational and memory overhead.

Methods

The authors bridge adaptive batch sizing with distributed training paradigms:

  • Distributed Norm Test (DDP-Norm & FSDP-Norm): The classical norm test scales batch size $b_k$ when gradient variance exceeds a fraction $\eta^2$ of the squared gradient norm. Instead of calculating costly per-sample gradients, the authors construct a variance estimator across the minibatch gradients already calculated across $J$ distributed workers: $$\frac{1}{b_k \cdot J} \sum_{j=1}^J \|\nabla \mathcal{L}_{B_{k,j}}(w_k) - \nabla \mathcal{L}_{B_k}(w_k)\|^2 \le \eta^2 \|\nabla \mathcal{L}_{B_k}(w_k)\|^2$$
  • Integration with PyTorch FSDP: To scale past single-GPU memory limits to billions of parameters, they implement the schedule directly inside PyTorch FSDP, coordinating microbatch sizes, gradient accumulation steps, and sharded parameter states via collective communications (reduce-scatter and all-gather).
  • Theoretical Analysis for Adam: Extending previous guarantees limited to SGD or AdaGrad, the authors prove a convergence rate of $\sum_{k=1}^K \mathbb{E}[\|\nabla \mathcal{L}(w_k)\|] \le \tilde{\mathcal{O}}(\sqrt{K})$ for Adam under coordinate-wise expected strong growth conditions on smooth non-convex objectives.

Datasets

  • C4 (Colossal Clean Crawled Corpus): Pretraining corpus tokenized using the Llama 2 tokenizer (vocabulary size: 32,000).
  • No new benchmarks were introduced; models were evaluated on training loss and validation perplexity/loss on held-out C4 splits.

Key Insights and Ideas

  • Inter-worker gradient variance as an efficient proxy: By computing variance over worker-level minibatch gradients rather than individual sample gradients, the test requires only one additional all-reduce communication without requiring memory-heavy autograd tricks.
  • Dynamic batch growth mirrors natural optimization needs: The schedule automatically keeps batch sizes smaller in early training when stochastic noise aids exploration, then increases to maximum batch sizes later for stability and high hardware throughput.
  • Robustness against loss spikes: Adaptively growing batch sizes naturally dampened the magnitude of loss spikes commonly observed during constant large-batch training.

Key Results

The authors evaluated decoder-only transformer models of varying scales on 4$\times$ NVIDIA L40S or A100 GPUs:

Model Scheme Steps Avg Batch Size Val Loss
MicroLlama (300M) Constant ($b_k=8192$) 245 8192 6.192
Heuristic Warmup (2.5-2.5-95%) 269 7439 4.604
DDP-Norm ($\eta=0.2$) 254 7878 4.720
DDP-Norm ($\eta=0.25$) 843 2373 3.361
TinyLlama (1.1B) Constant ($b_k=8192$) 245 8192 4.893
Heuristic Warmup 269 7439 4.367
FSDP-Norm ($\eta=0.085$) 274 7312 4.256
OpenLlama (3B) Constant ($b_k=8192$) 245 8192 5.104
Heuristic Warmup 269 7439 4.781
FSDP-Norm ($\eta=0.15$) 259 7726 4.554

In all configurations, the adaptive schedule achieved lower validation losses than constant large batches with nearly identical wall-clock training times, while matching or outperforming hand-tuned stage-wise warmup schedules without requiring manual schedule tuning.

Limitations and Future Work

  • Proof Assumptions vs. Practice: The convergence analysis covers standard Adam with coordinate-wise variance tests, but omits decoupled weight decay (AdamW), gradient clipping, and learning rate decay schedules used in the actual experiments.
  • Proof-of-Concept Scale: Models were trained for 2 million sequences (a few billion tokens) as a feasibility demonstration; models were not fully pretrained to evaluate performance on downstream NLP benchmarks.
  • Parallelism Scope: The current implementation is built on FSDP and DDP (2D parallelism). Scaling beyond 7B+ parameters will require extending the schedule to 3D/4D parallelism (tensor, pipeline, and context parallelism via toolkits like Megatron-LM or Picotron).

Summary updated

BibTeX
@inproceedings{lau2025adaptive,
  author = {Tim Tsz-Kit Lau and Weijian Li and Chenwei Xu and Han Liu and Mladen Kolar},
  title = {{Adaptive Batch Size Schedules for Distributed Training of Language Models with Data and Model Parallelism}},
  booktitle = {CPAL (Proceedings Track)},
  year = {2025},
  url = {https://openreview.net/forum?id=pi2TiX7er9},
}

Loading related content...

Figure