Fold3D: Rethinking and Parallelizing Computational and Communicational Tasks in the Training of Large DNN Models

Fanxin Li, Shixiong Zhao, Yuhao Qing, Xusheng Chen, Xiuxian Guan, Sen Wang, Gong Zhang, Heming CuiIEEE TPDS 2023

Introduction

Training massive AI models on standard cloud setups often leaves expensive GPUs sitting idle while waiting for data to sync across the network. This paper introduces FOLD3D, a novel 3D parallel training system that "folds" neural networks into segments to overlap heavy communication tasks with computation. By breaking the traditional first-in-first-out (FIFO) pipeline schedule, FOLD3D boosts training throughput by up to 42% on commodity GPU clusters.

The Serialization Problem in 3D Parallelism

Training Large Deep Neural Networks (DNNs) like GPT-3 requires splitting the model and the data across hundreds of GPUs using 3D Parallelism, which combines Data Parallelism (DP), Tensor Parallelism (TP), and Pipeline Parallelism (PP).

However, existing 3D parallel systems (such as Megatron and DeepSpeed) suffer from a significant serialization problem. They utilize a FIFO scheduling approach for pipeline micro-batches. Due to this strict ordering, the heavy network communication required to synchronize gradients across data replicas (DP.sync) cannot commence until the entire pipeline finishes its computation. On commodity clouds with standard networks (e.g., 100-200 Gbps), this massive data sync blocks the subsequent training step. Analysis shows that in state-of-the-art systems like Megatron, GPUs can remain idle for up to 44% of total training time while waiting for these communication tasks to conclude.

Methodology: AIAO Scheduling and Memory Management

To deserialize computation and communication, FOLD3D introduces a new scheduling paradigm paired with aggressive memory management:

Comparison of traditional FIFO scheduling vs. Fold3D's AIAO scheduling within a 3D parallel framework.

AIAO (All-In-All-Out) Scheduling

Instead of processing micro-batches strictly FIFO, FOLD3D "folds" (slices) the DNN into multiple segments. It groups the computational tasks for the same segment across all micro-batches. Once a segment's backward pass is complete, FOLD3D immediately launches the DP.sync for that specific segment. As GPUs proceed to compute the next segment, the heavy DP.sync communication occurs in the background, overlapping perfectly with computation.

Intra-Segment CPU Offloading

AIAO scheduling requires maintaining activation checkpoints in memory longer than FIFO scheduling, which typically leads to out-of-memory (OOM) errors. FOLD3D mitigates this by aggressively offloading these checkpoints to the host CPU's memory and prefetching them immediately before the backward pass.

Preemptive Communication Scheduling

Because FOLD3D overlaps different types of communication, latency-sensitive pipeline transfers (PP.sync) can be delayed by massive background data syncs (DP.sync). FOLD3D implements a preemptive scheduler that pauses DP.sync tasks to allow PP.sync tasks to pass through instantly.

Experimental Evaluation

The authors evaluated FOLD3D on five major Transformer-based architectures, including GPT-3 (ranging from 14B to 81B parameters), Turing-NLG, BERT, CPM, and T5, using large-scale datasets like OpenWebText and Wikipedia.

Key Results

FOLD3D demonstrates substantial performance improvements over existing baselines, including Megatron-SP, Megatron-PTD, DeepSpeed 3D, and DeepSpeed ZeRO3.

Aggregated throughput comparison across different GPU cluster sizes showing Fold3D's performance advantage.
  • Throughput Gains: FOLD3D achieved 25.2%–42.1% higher throughput than the baselines.
  • Elimination of Idle Time: For a GPT-3 18B model, FOLD3D reduced DP.sync time on the critical path by 69%–73%, effectively eliminating the 44% GPU idle time observed in Megatron.
  • Scalability: In weak scaling tests up to 256 NVIDIA A100 GPUs, FOLD3D maintained a consistent ~31% performance advantage over Megatron.
  • Memory Efficiency: CPU offloading and prefetching successfully managed extra memory requirements without impacting the computational critical path.

Discussion and Future Work

A key insight from this work is that optimal 1D scheduling does not necessarily translate to optimal 3D scheduling. While FIFO is mathematically optimal for pure pipeline parallelism, relaxing this constraint unlocks massive gains in the data parallelism dimension. Furthermore, FOLD3D proves that network bottlenecks can be hidden by restructuring the training loop's dependency graph.

Limitations: * Homogeneity: FOLD3D is designed for models with repeated, stacked blocks (e.g., Transformers) and is less suitable for heterogeneous architectures like ResNet. * CPU Memory: The offloading mechanism increases host CPU memory usage (e.g., an extra 8-17 GB per host). * Future Directions: Adapting AIAO scheduling for sparsely activated architectures like Mixture-of-Experts (MoE) remains a challenge due to asymmetric computational tasks.

Summary updated

BibTeX
@article{li2023fold,
  author = {Fanxin Li and Shixiong Zhao and Yuhao Qing and Xusheng Chen and Xiuxian Guan and Sen Wang and Gong Zhang and Heming Cui},
  title = {{Fold3D: Rethinking and Parallelizing Computational and Communicational Tasks in the Training of Large DNN Models}},
  journal = {IEEE Trans. Parallel Distributed Syst.},
  year = {2023},
  doi = {10.1109/tpds.2023.3247883},
}
Figure