SLAMB: Accelerated Large Batch Training with Sparse Communication

Hang Xu, Wenxuan Zhang, Jiawei Fei, Yuzhe Wu, Tingwen Xie, Jun Huang, Yuchen Xie, Mohamed Elhoseiny, Panos KalnisICML 2023

TL;DR

Distributed training of massive neural networks is often bottlenecked by the sheer volume of data exchanged between GPUs. This paper introduces SLAMB, a novel optimizer that combines large-batch training (LAMB) with sparse communication to drastically reduce this overhead. By transmitting up to 9 times less data, SLAMB achieves over 90% scaling efficiency on 1,024 GPUs and slashes training times without sacrificing model accuracy.

The Communication Bottleneck in Large-Batch Training

Training modern deep neural networks (like BERT or GPT) requires distributing the workload across hundreds or thousands of GPUs. To do this efficiently, practitioners use large batch sizes. The LAMB optimizer is the standard tool for this, as it adapts learning rates layer-by-layer to prevent the accuracy degradation typically caused by massive batches.

However, LAMB still requires GPUs to synchronize their full, massive gradient arrays at every step. This creates a severe communication bottleneck. Existing compression methods (like 1-bit LAMB) try to solve this by quantizing the data, but they require a long, uncompressed "warm-up" phase (often taking up nearly 20% of the total training time) before compression can safely kick in.

Furthermore, naively applying sparsification—sending only a small percentage of the gradient values—to LAMB causes the model to converge terribly. The authors set out to figure out why sparsification breaks LAMB and how to fix it, aiming for high compression from step one.

Training loss comparison at a 64K batch size, illustrating how naive sparsification (Random-k) degrades LAMB's convergence.

Introducing SLAMB

The authors propose SLAMB (Sparse Layer-wise Adaptive Moments optimizer for large Batch training). To make sparsification work with LAMB, they introduce three key novelties:

  • Momentum Masking & Local Error Compensation: Naively sparsifying gradients fails because LAMB's updates are dominated by historical momentum, not just the current gradient. SLAMB fixes this by applying a Random-$k$ mask to synchronize a sparse subset of the momentum itself. The unsynchronized parts are kept locally on each GPU to compensate for the "error" in future steps.
  • Element-wise Adaptive Rescaling: Because SLAMB only partially synchronizes updates, the local variance of the updates spikes. In standard LAMB, this would artificially shrink the scaling coefficients and stall learning. SLAMB introduces a "staleness vector" that tracks how often each parameter element is synchronized, dynamically rescaling the learning rate and scaling function for each specific element to keep convergence on track.
SLAMB successfully bridges the performance gap, tracking the standard LAMB optimizer much closer than naive Random-k sparsification.
  • Periodic Model Synchronization: Because local error compensation means each GPU has slightly different weights during training, SLAMB periodically synchronizes the actual model weights (e.g., every 100 steps) to prevent the local models from drifting too far apart.

Key Insights

  • Momentum is the real bottleneck for sparsification: If you only compress the current step's gradient in a momentum-heavy optimizer like LAMB, you are missing the forest for the trees. You have to compress and synchronize the momentum term directly.
  • Warm-ups are a massive drag on efficiency: Previous state-of-the-art methods like 1-bit LAMB are held back by their need for an uncompressed warm-up phase. Because SLAMB uses adaptive rescaling to handle the variance of sparse updates, it can apply a strict 10% compression ratio from the very first step, leading to vastly superior end-to-end speedups.
  • Staleness tracking saves adaptive optimizers: When you mess with the synchronization of an adaptive optimizer, you break its internal statistics. Tracking the "staleness" of each parameter allows the algorithm to mathematically correct for the bias introduced by sparse communication.

Experimental Results

The authors evaluated SLAMB across various datasets, including Wikipedia + BooksCorpus (BERT pre-training), SQuAD 1.1 (fine-tuning), ImageNet (Swin Transformer), and CIFAR-10 (ResNet110).

  • Massive Volume Reduction: SLAMB reduces communication volume by 9.1x compared to standard LAMB, and 2x compared to 1-bit LAMB.
  • End-to-End Speedups: Training a Swin Transformer on ImageNet using 128 V100 GPUs took 12.1 hours with standard LAMB and 7.28 hours with 1-bit LAMB. SLAMB finished the job in just 5.35 hours (a 2.2x speedup over the baseline).
  • Extreme Scalability: When training a massive 2.8B parameter BERT-XL model across 1,024 NVIDIA A100 GPUs, SLAMB achieved a remarkable 90.5% scaling efficiency (compared to just 53% for standard LAMB).
  • No Accuracy Loss: Across both language and vision tasks, SLAMB matched or slightly exceeded the final accuracy of the uncompressed LAMB baseline.

Limitations and Future Work

  • Memory Overhead: SLAMB requires additional GPU memory to store its staleness vectors and intermediate states (e.g., ~7.9GB vs LAMB's 5.6GB during BERT-Large training). For extremely large models, practitioners might need to rely on micro-batching to fit the optimizer states into memory.
  • Sparsifier Limitations: Currently, SLAMB only supports Random-$k$ sparsification. Adapting the algorithm to support Top-$k$ sparsification (sending the largest magnitude updates) might provide even better performance and is left for future work.

Summary updated

BibTeX
@inproceedings{xu2023slamb,
  author = {Hang Xu and Wenxuan Zhang and Jiawei Fei and Yuzhe Wu and Tingwen Xie and Jun Huang and Yuchen Xie and Mohamed Elhoseiny and Panos Kalnis},
  title = {{SLAMB: Accelerated Large Batch Training with Sparse Communication}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=cMmjBH5LqW},
}
Figure