Abstract
Training Large Language Models (LLMs) involves a complex "guessing game" to determine the most efficient parallel strategy across thousands of chips. This paper introduces an automatic planning algorithm that predicts training performance with 96.89% accuracy and prunes the search space by 99%. By utilizing a "white-box" simulation and mathematical pruning, the system identifies globally optimal configurations, significantly reducing the need for expensive trial-and-error.
The Challenge of 3D Parallelism
Training models with billions of parameters requires 3D Parallelism, a combination of three distinct strategies:
- Data Parallelism (DP): Distributing data batches across multiple workers.
- Tensor Parallelism (TP): Splitting individual layers or tensors across multiple chips.
- Pipeline Parallelism (PP): Partitioning the model's layers into stages, processed like an assembly line.
The primary difficulty lies in the interaction between these strategies. Suboptimal choices for the degree of parallelism or the micro-batch size can lead to significant "bubbles" (idle time) or communication bottlenecks. Traditionally, engineers have relied on empirical "rules of thumb," which often lead to wasted compute resources and increased costs.
Methods: White-Box Simulation and Pruning
The authors propose a two-step framework to automate the search for an optimal strategy.
1. Training Duration Simulation
Instead of treating training as a black box, the algorithm decomposes total training time ($T_T$) into four measurable components: computation, communication (e.g., All-Reduce, P2P), overlap (simultaneous computation and communication), and bubbles (idle time in pipeline schedules). By modeling these at the operator level, the system can simulate the performance of any parallel strategy in milliseconds.
2. Pruning and Searching
To handle the technically infinite search space, the authors apply mathematical constraints:
- Monotonicity of Global Batch Size ($G$): Larger global batches generally increase throughput, allowing $G$ to be treated as a boundary.
- Optimal Micro-batch Size ($b$): The authors prove that $b$ has a "sweet spot"—too small, and hardware utilization drops; too large, and pipeline bubbles increase.
- Memory Boundaries: Strategies that exceed memory limits for weights, optimizer states, or activations are instantly discarded.
Experimental Setup
The algorithm was evaluated using a cluster of 16 Ascend 910b NPUs (Huawei's AI chips) across two servers. The testing involved real-world LLM architectures, including Baichuan2-7b, Qwen-14b, and Aquila2-7b, integrated with the ModelLink distributed training framework.
Key Results and Insights
The proposed method demonstrated exceptional performance across several metrics:
- High Accuracy: The simulation achieved an average estimation accuracy of 96.89% for total training time.
- Efficiency: Pruning reduced the feasible search space by nearly 99%, enabling rapid identification of optimal strategies.
- The Micro-batch "Sweet Spot": Contrary to common practices of setting micro-batch size to 1 or the maximum memory limit, the results confirm a specific optimal value for $b$ that maximizes throughput.
- TP vs. PP Trade-offs: Experiments revealed that a Tensor Parallelism degree of 4 often outperformed the degree of 8 typically suggested by frameworks like Megatron-LM, highlighting the limitations of manual heuristics.
Conclusion and Future Work
This automatic planning algorithm provides a robust path toward optimizing LLM training. While currently focused on 3D parallelism on a 16-NPU cluster, future work aims to incorporate Sequence Parallelism, Optimizer Parallelism (ZeRO), and Mixture-of-Experts (MoE) strategies. Additionally, the authors plan to address communication jitter to improve prediction accuracy in larger, more chaotic network environments.
Summary updated