ATP: Adaptive Tensor Parallelism for Foundation Models

Shenggan Cheng, Ziming Liu, Jiangsu Du, Yang YouarXiv 2023

Abstract

Foundation models have impressive performance and generalization capabilities across a wide range of applications. The increasing size of the models introduces great challenges for the training. Tensor parallelism is a critical technique that is currently used in almost all foundation model training and has a significant impact on overall training performance. However, current tensor parallelism in machine learning frameworks misses optimization opportunities in fitting various interconnection topologies. In this work, we present ATP, an adaptive tensor parallelism framework for foundation models, which can automatically select the optimal parallel strategy on different interconnections. We propose column- and row-first tensor parallelism based on 2D device meshes and construct a search space. Combined with the hierarchical communication matrix, ATP can identify the optimal strategy in the search space. We also propose chunk-based overlapping to reduce communication overhead. Our evaluations show ATP consistently outperforms the state-of-the-art approaches for various model sizes and interconnects, achieving end-to-end training performance improvements of up to 37-64% on specific interconnects. Based on our theoretical model, the communication overhead of ATP decreases with scaling, indicating a qualitative leap forward.

Introduction

Training foundation models like GPT-3 or BERT is a Herculean task that requires orchestrating hundreds or thousands of GPUs. To fit these massive models into memory, researchers use Tensor Parallelism (TP)—splitting individual layers of a neural network across multiple devices. However, most current frameworks treat all GPU connections as equal. In reality, a cluster is a messy hierarchy of ultra-fast wires (like NVLink) and significantly slower ones (like PCIe or standard Ethernet).

Hierarchical interconnects in a server with NVLink and PCIe switches.

Current tools, such as Megatron-LM, typically use a "one-size-fits-all" strategy that assumes a high-bandwidth, uniform interconnect. But real-world hardware is hierarchical. For example, two GPUs in the same box might communicate very fast, but talking to a GPU in the next rack is much slower. If a framework forces a "slow" link to participate in a high-frequency data swap, the entire training process crawls to the speed of that slowest link. ATP (Adaptive Tensor Parallelism) addresses this by automatically selecting the most efficient way to split large AI models across GPUs based on their specific hardware connections.

Methodology

ATP introduces three main innovations to solve the communication bottleneck:

2D Device Meshes and TP Strategies

Instead of treating GPUs as a simple list, ATP organizes them into a 2D grid, or mesh. It introduces "column-first" and "row-first" tensor parallelism, providing more flexibility in how the mathematical workload is distributed across that grid.

2D Device Mesh and sharding strategies (column-wise and row-wise) used in ATP.

Hierarchical Communication Matrix

This is the "brain" of ATP. It is a mathematical model describing the exact bandwidth of every link in the system (e.g., NVLink vs. PCIe vs. InfiniBand). ATP uses this matrix to simulate different splitting strategies and automatically pick the one that minimizes the time spent waiting for data.

Chunk-based Overlapping

Standard TP is synchronous—the GPU performs computation, then waits for the network to finish, then resumes computation. ATP breaks the data into "chunks." While the network is busy sending the results of one chunk, the GPU is already processing the next, effectively overlapping computation and communication.

Experimental Setup

The authors evaluated ATP using four different sizes of GPT-style models, ranging from 0.048B to 1.728B parameters per layer (labeled M1 to M4). These were tested across four hardware interconnect configurations (IC1 to IC4), ranging from PCIe-only setups to high-end NVSwitch and InfiniBand clusters.

Results and Discussion

ATP consistently outperformed state-of-the-art approaches:

  • Massive Gains on PCIe: On systems without high-speed NVLink (IC1), ATP achieved a 37% to 64% speedup, which is significant for researchers working on commodity hardware.
  • Solid Gains on High-End Gear: Even on top-tier NVLink systems (IC2/IC3), ATP provided a ~10% improvement, largely due to its chunk-based overlapping.
  • Multi-Node Efficiency: On InfiniBand clusters (IC4), ATP showed a 4% improvement for the largest models, proving it remains relevant at massive scale.

A key insight from the research is the "Slowest Link Trap": standard all-reduce operations are often held back by the single slowest connection in a ring. ATP avoids this by grouping communication so that the heaviest data transfers happen over the fastest wires. Furthermore, theoretical models show that as the number of GPUs scales, ATP’s communication overhead actually decreases relative to total compute, whereas standard methods often see overhead growth.

Conclusion

ATP represents a significant step forward in making foundation model training "topology-aware." By using a search space and a cost model, it can adapt to unbalanced hardware setups that manual optimization might miss. While current evaluations focus on Transformer architectures, future work could extend ATP to other models like GNNs or CNNs. The authors suggest that future hardware should be designed with these hierarchical bottlenecks in mind, potentially leading to software-hardware co-design.

Summary updated

BibTeX
@misc{cheng2023atp,
  author = {Shenggan Cheng and Ziming Liu and Jiangsu Du and Yang You},
  title = {{ATP: Adaptive Tensor Parallelism for Foundation Models}},
  year = {2023},
  eprint = {2301.08658},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2301.08658},
}
Figure