UniAP: Unifying Inter- and Intra-Layer Automatic Parallelism by Mixed Integer Quadratic Programming

Hao Lin, Ke Wu, Jie Li, Jun Li, Wu-Jun Li

Introduction

Training Large Language Models (LLMs) with billions of parameters necessitates distributing workloads across massive GPU clusters. This distribution typically relies on two distinct strategies: inter-layer parallelism (e.g., pipeline parallelism) and intra-layer parallelism (e.g., data or tensor parallelism). Historically, these strategies have been treated as separate or hierarchical optimization problems. Existing Automatic Parallelism (AP) tools often determine a pipeline strategy first and then fit intra-layer strategies within its constraints. This greedy approach frequently misses the global optimum, leading to suboptimal training throughput or Out-of-Memory (OOM) errors.

UniAP's unified approach versus traditional hierarchical automatic parallelism.

UniAP addresses this by being the first framework to jointly optimize both inter- and intra-layer strategies. By treating them as a single unified optimization problem, UniAP achieves significantly higher training throughput and drastically reduces the time required to find optimal strategies.

Methodology: Unified Optimization via MIQP

The core innovation of UniAP is the Unified Optimization Process (UOP), which replaces heuristic searches with Mixed Integer Quadratic Programming (MIQP).

Profiling and Cost Modeling

UniAP begins by profiling the hardware environment to measure point-to-point communication speeds and all-reduce efficiency. Simultaneously, it profiles the target model to quantify the computation and memory requirements of each layer.

The MIQP Formulation

The search for an optimal parallel strategy is mathematically formulated as an MIQP problem. The objective is to minimize the total time per training iteration, subject to physical and logical constraints:

  • Memory Constraints: Ensuring the combined memory usage of all strategies does not exceed the capacity of any single GPU.
  • Contiguity Constraints: Ensuring layers are placed in a logical, sequential order across the pipeline stages.
  • Communication Constraints: Accounting for the overhead of data transfer between different parallelism domains.

By considering all layers and possible parallel combinations simultaneously, UniAP uses a solver (such as Gurobi) to find the mathematically optimal configuration.

Evaluation and Results

UniAP was evaluated using several Transformer-based models, including BERT-Huge, T5-Large, ViT-Huge, Swin-Huge, and Llama (7B and 13B), across diverse hardware clusters (NVIDIA V100, A100, and non-NVIDIA DCUs).

Training Throughput

UniAP consistently outperformed state-of-the-art methods like Galvatron and Alpa. For the Llama-7B model on an A100 node, UniAP achieved a 3.8x throughput increase. It also demonstrated superior reliability; while other methods often encountered OOM errors on large models like Swin-Huge, UniAP successfully identified valid, high-performance configurations.

Training throughput comparison across different models and strategies.

Optimization Efficiency

One of the most striking results is the speed of the strategy search. By leveraging MIQP solvers, UniAP reduced search time by up to 107x. For instance, finding a strategy for BERT-Huge took only 0.37 seconds with UniAP, compared to over 6 minutes with previous state-of-the-art tools.

Conclusion and Future Work

UniAP demonstrates that joint optimization of inter- and intra-layer parallelism is a "silver bullet" for LLM training efficiency. Its hardware-aware nature allows it to automatically adapt to different interconnect speeds, favoring communication-efficient strategies on slower networks.

Current limitations include a dependency on commercial solvers like Gurobi and a focus on static computation graphs. Future work will explore adapting UniAP for models with dynamic control flow and optimizing performance in heterogeneous hardware environments.

Summary updated

BibTeX
@inproceedings{lin2025uniap,
  author = {Hao Lin and Ke Wu and Jie Li and Jun Li and Wu-Jun Li},
  title = {{UniAP: Unifying Inter- and Intra-Layer Automatic Parallelism by Mixed Integer Quadratic Programming}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.01951},
}
Figure