Making Asynchronous Stochastic Gradient Descent Work for Transformers

Alham Fikri Aji, Kenneth HeafieldarXiv 2019 · DOI

TL;DR

Transformers are notoriously difficult to train using asynchronous stochastic gradient descent (Async-SGD), often resulting in poor convergence or complete failure. This paper identifies gradient staleness—rather than just small batch sizes—as the primary culprit and introduces a "Global Accumulation" strategy that restores model quality while delivering a 1.36x speedup over traditional synchronous training.

What Problem Does This Paper Address?

In the world of distributed deep learning, there is a constant tug-of-war between Synchronous SGD (Sync-SGD) and Asynchronous SGD (Async-SGD).

  • Sync-SGD is the "safe" choice: workers calculate gradients and wait for everyone to finish before updating the model. It’s stable but slow because the fastest worker is always held back by the slowest (the "straggler" problem).
  • Async-SGD is the "fast" choice: workers push updates as soon as they are ready. There’s no waiting, but it introduces staleness—by the time a worker finishes its calculation, the central model parameters may have already been updated several times by other workers.

While Recurrent Neural Networks (RNNs) handle this staleness reasonably well, Transformers are famously fragile in asynchronous settings. Prior research noted that Transformers trained with Async-SGD yielded low-quality models, but didn't fully explain why. This paper sets out to diagnose the failure of Transformers in Async-SGD and find a way to make them work.

Methods

The authors conducted a series of ablation studies to decouple two factors: batch size and gradient staleness.

  1. Isolating Batch Size: They simulated large batches in asynchronous settings by having workers accumulate gradients locally before pushing.
  2. Isolating Staleness: They introduced "artificial staleness" into otherwise synchronous training to see how Transformers reacted to outdated information.
  3. Analyzing the Optimizer: They looked closely at how the Adam optimizer handles updates. Because Adam is scale-invariant (it normalizes updates based on historical gradient variance), applying two small, noisy updates sequentially is mathematically different—and often worse—than applying one summed update.

Based on these insights, they proposed Global Accumulation. In this hybrid approach, workers still compute gradients asynchronously (no waiting at a barrier), but the parameter server doesn't update the model immediately. Instead, it waits to receive $P$ gradients (where $P$ is the number of workers), sums them, and then performs a single update.

Datasets

The researchers evaluated their methods primarily on Neural Machine Translation (NMT) tasks:

  • WMT 2017 English-to-German (EN→DE): Used for the core analysis and ablation studies.
  • WMT 2018 English-to-Finnish (EN→FI) and English-to-Russian (EN→RU): Used to demonstrate that their findings generalize across different languages.
  • Evaluation: Performance was measured using BLEU scores, specifically via the sacreBLEU tool for standardized reporting.

Key Insights and Ideas

  • Transformers are "Staleness-Sensitive": Unlike RNNs, which are relatively robust, Transformers are highly sensitive to noisy, stale gradients. Even a small amount of staleness can cause the model to stay at 0 BLEU during training.
  • The Adam Factor: The paper provides a formal look at why Adam struggles with asynchronous updates. Summing gradients smooths out noise. When updates are applied individually (asynchronously), the noise increases the variance, causing Adam to "slow down" or move in the wrong direction.
  • Staleness > Batch Size: While larger batches help, they aren't enough to save Async-SGD. The experiment shown in Figure 2 demonstrates that even with a large effective batch size, high staleness significantly degrades convergence.
Figure 2: The impact of artificial staleness on Transformer convergence. Even with large batches, staleness 3 (typical for 4 GPUs) causes a major drop in quality.
  • The Sweet Spot: Global Accumulation acts as a middle ground. It eliminates the idle time of workers (speeding up training) while reducing the frequency of parameter updates (reducing staleness) and increasing the effective batch size.

Key Results

  • Restored Quality: Using 4x Global Accumulation, the authors achieved a BLEU score of 35.84 on EN-DE, slightly outperforming the Synchronous baseline (35.66) and vastly improving upon vanilla Asynchronous SGD (30.72).
  • Significant Speedup: The hybrid method reached near-convergence 1.36x faster than Synchronous SGD in a single-node, 4-GPU setup.
  • Learning Rate Robustness: Vanilla Async-SGD is extremely sensitive to learning rates; often, only very small rates work. Global Accumulation allows the use of higher learning rates, making the training process much more robust.
Figure 1: The effect of batch sizes on convergence of Transformer and RNN models.

Limitations and Future Work

  • Hardware Scale: The experiments were conducted on a single node with 4 GPUs. While the results are promising, the dynamics of staleness might change in massive multi-node clusters where network latency is higher.
  • Optimizer Specificity: The analysis focuses heavily on the Adam optimizer. While Adam is the standard for Transformers, it remains to be seen if these specific staleness effects apply identically to newer optimizers like Adafactor or Lamb.
  • Dynamic Accumulation: The authors suggest that future work could explore varying the accumulation count ($P$) dynamically based on real-time network conditions or training progress.

Summary updated

BibTeX
@misc{aji2019making,
  author = {Alham Fikri Aji and Kenneth Heafield},
  title = {{Making Asynchronous Stochastic Gradient Descent Work for Transformers}},
  year = {2019},
  eprint = {1906.03496},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1906.03496},
}
Figure