Enhancing Stability for Large Language Models Training in Constrained Bandwidth Networks

Yun Dai, Tejas Dharamsi, Byron Hsu, Tao Song, Hamed Firooz

TL;DR

Training massive language models on commodity hardware often relies on ZeRO++ to overcome low-bandwidth bottlenecks, but this method frequently suffers from mysterious training crashes. This paper identifies the culprit as a low-level race condition in the hierarchical partitioning scheme and introduces a simple CUDA synchronization fix that restores stability, enabling robust training of 70B+ parameter models with up to a 98% speedup over standard data-parallel baselines.

What Problem Does This Paper Address?

Training Large Language Models (LLMs) with tens of billions of parameters is a memory and communication nightmare. While high-end clusters use specialized interconnects like NVLink or InfiniBand, many researchers and engineers are stuck with "commodity" hardware (like standard Ethernet), where inter-node communication is a major bottleneck.

To solve this, the ZeRO++ algorithm introduced hierarchical weight partitioning (hpZ). Instead of broadcasting weights across the entire cluster (which is slow), hpZ keeps a secondary copy of weights replicated on every node. This allows the system to use fast intra-node communication for the backward pass.

However, the authors discovered a critical flaw: when scaling to massive models like Falcon-40B or Llama-2-70B, the "stock" ZeRO++ implementation becomes unstable. The training loss often diverges or hits "Not-a-Number" (NaN) values, effectively killing the training run.

Methods

The researchers performed a deep dive into the ZeRO++ implementation and identified a race condition between two asynchronous operations:

  1. Memory Copy (Memcpy D2D): The process of partitioning weights into the secondary local copy.
  2. Collective Communication (AllGather): The operation that collects these partitioned weights for the backward pass.

Because ZeRO uses "prefetching"—enqueueing operations early to keep the GPU busy—the AllGather kernel was sometimes launching before the Memcpy had actually finished writing the data. This meant the model was performing calculations on uninitialized, "garbage" data.

The Fix: The authors proposed a modified algorithm (Algorithm 1) that introduces explicit CUDA synchronization points. By forcing the system to wait until the memory copy is guaranteed to be complete before enqueuing the AllGather operation, they eliminated the race condition entirely.

Figure 1. An end-to-end training step on a model with N layers with ZeRO++ qgZ and hpZ. Forward and backward pass on layer k is expanded. With ZeRO3 prefetch, the consequent AllGather kernel for the backward pass can be immediately enqueued while post-forward repartition is still in progress.

Datasets

The authors evaluated their fix by performing full-parameter fine-tuning on several prominent open-source LLMs:

  • Llama-2 (7B, 13B, and 70B variants)
  • Falcon-40B

For the fine-tuning task, they used the MMLU (Massive Multitask Language Understanding) dataset, a standard benchmark for measuring a model's knowledge across various subjects.

Key Insights and Ideas

  • Systems vs. Science: The instability in LLM training isn't always a mathematical or architectural problem; it can be a low-level systems engineering issue. A single missing synchronization point can render a multi-million dollar training run useless.
  • The Cost of Asynchrony: While asynchronous operations are vital for high throughput, they introduce non-deterministic behavior. The paper highlights that as models grow, these subtle timing issues become more likely to trigger failures.
  • Democratizing AI: By making ZeRO++ stable, the authors help level the playing field, allowing organizations without elite networking infrastructure to train state-of-the-art models efficiently.

Key Results

The modified algorithm successfully restored training stability across all tested models without significant performance penalties.

  • Stability: As shown in the table below, the original ZeRO++ ("with hpZ") failed on every large model tested, while the modified version was 100% stable. Table showing that modified hpZ restores stability where stock hpZ fails.
Table showing that modified hpZ restores stability where stock hpZ fails.
  • Throughput: The modified algorithm maintained the high efficiency of ZeRO++. For Falcon-40B, it achieved a 98% throughput improvement compared to the baseline without hierarchical partitioning. Even with the added synchronization overhead, the performance remained nearly identical to the (unstable) stock version. Table comparing throughput across different model sizes.
Table comparing throughput across different model sizes.
  • Convergence: The validation loss curves for the modified algorithm perfectly match the stable baselines, proving that the fix doesn't sacrifice model quality. Validation loss curves showing the stock version crashing (brown line) vs the stable modified version.
Figure 2. Validation loss convergence per optimization step with- out hpZ and with modified hpZ from Algorithm 1, tested on Llama- 2-7b for MMLU dataset. Brown curve demonstrates convergence issue in training without fix.

Limitations and Future Work

The paper focuses specifically on the interaction between ZeRO++ and CUDA-based GPU clusters. While the logic of the race condition is universal, the specific implementation of the fix is tied to the CUDA programming model.

The authors do not explore:

  • Training at the "trillion-parameter" scale, where other types of parallelism (like pipeline parallelism) are usually required.
  • Performance on non-NVIDIA hardware (e.g., AMD Instinct or Google TPUs), which may have different synchronization primitives.
  • The impact of this fix on extremely high-speed networks where the communication bottleneck is less severe.

Summary updated

BibTeX
@inproceedings{dai2024enhancing,
  author = {Yun Dai and Tejas Dharamsi and Byron Hsu and Tao Song and Hamed Firooz},
  title = {{Enhancing Stability for Large Language Models Training in Constrained Bandwidth Networks}},
  booktitle = {ES-FoMo-II @ ICML},
  year = {2024},
  url = {https://openreview.net/forum?id=aznJXs4zOO},
}
Figure