Analyzing the impact of the MPI allreduce in distributed training of convolutional neural networks

Adrián Castelló, Mar Catalán, Manuel F. Dolz, Enrique S. Quintana-Ortí, José Duato

Introduction

Distributed training of deep learning models often encounters a significant communication bottleneck during the gradient synchronization phase. In data-parallel training, multiple compute nodes process distinct portions of a data batch. To maintain model consistency, these nodes must synchronize their gradients using a communication primitive known as Allreduce. While high-level frameworks like TensorFlow and Horovod abstract these operations, they rely on underlying Message Passing Interface (MPI) libraries such as MPICH, OpenMPI, or IntelMPI. These libraries typically use a simple "AUTO" heuristic to select an internal Allreduce algorithm based on message size. However, these default choices are often suboptimal for the specific communication patterns of Convolutional Neural Networks (CNNs).

Methodology

The study employs a bottom-up approach to evaluate the performance of various Allreduce (ARD) algorithms.

Theoretical Modeling

The researchers first analyzed the theoretical costs—latency, bandwidth, and arithmetic—of five common algorithms: Recursive Doubling (RDB), Rabenseifner’s (RSA), Linear (LIN), Ring (RNG), and Segmented Ring (SRG).

Theoretical costs of different Allreduce algorithms.

Micro-benchmarking and Validation

Exhaustive evaluations were performed across MPICH 3.3.1, OpenMPI 4.1, and IntelMPI 2020 on an 8-node cluster equipped with Intel Xeon Gold CPUs and EDR Infiniband. Finally, these insights were validated in a real-world pipeline using TensorFlow 2.3.0 and Horovod 0.19, manually selecting the optimal algorithm for specific CNN models.

Experimental Setup

The performance was evaluated using standard computer vision datasets:

  • ImageNet: Used for AlexNet, ResNet50, and VGG11.
  • Cifar10: Used for ResNet110.

These models represent a spectrum of communication-to-computation ratios, from communication-bound (AlexNet) to compute-bound (VGG11).

Key Insights and Results

The experimental results highlight a significant gap between theoretical models and practical performance. While theory often assumes perfect overlap between communication and computation, real-world factors like software overhead and hardware buffer limits cause deviations.

Performance comparison of Allreduce algorithms across message sizes, node counts, and bandwidth parameters.

Suboptimal Defaults

The industry-standard "RSA" algorithm is rarely the best choice for messages larger than 32 MiB. For the large messages typical in deep learning, Ring (RNG) and Segmented Ring (SRG) algorithms consistently offer superior performance, yet they are frequently overlooked by "AUTO" selection heuristics.

Performance Gains

By manually selecting the "BEST" algorithm within a library, training throughput increased by 1.2x. When comparing the best configuration against the worst default library choice, speedups reached up to 2.8x. Notably, OpenMPI outperformed other implementations in most scenarios, particularly with non-power-of-two node counts.

Conclusion and Future Work

Optimizing the MPI Allreduce algorithm selection can yield substantial performance improvements in distributed CNN training, especially at smaller batch sizes where communication overhead is more prominent. Future research should address the limitations of this study by exploring GPU-accelerated environments (e.g., NVIDIA's NCCL) and scaling to hundreds or thousands of nodes to identify potential new bottlenecks at supercomputer scales.

Summary updated

BibTeX
@article{castello2023analyzing,
  author = {Adrián Castelló and Mar Catalán and Manuel F. Dolz and Enrique S. Quintana-Ortí and José Duato},
  title = {{Analyzing the impact of the MPI allreduce in distributed training of convolutional neural networks}},
  journal = {Computing},
  year = {2023},
  doi = {10.1007/s00607-021-01029-2},
}
Figure