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

Hao Lin, Ke Wu, Jun Li, Wu-Jun Li · DOI

Abstract

Training modern foundation models requires complex distributed strategies. UniAP is the first framework to jointly optimize inter-layer (pipeline) and intra-layer (data, tensor, sharding) strategies using Mixed Integer Quadratic Programming (MIQP). By unifying these search spaces, UniAP achieves up to 3.8x throughput improvement and 107x faster optimization compared to existing hierarchical methods.

Introduction

Training large-scale models with billions of parameters necessitates distributing workloads across massive GPU clusters. Traditionally, this is handled via two distinct categories:

  1. Inter-layer Parallelism: Partitioning model layers into pipeline stages (Pipeline Parallelism).
  2. Intra-layer Parallelism: Distributing data or tensors within a single layer (e.g., Data, Tensor, or Fully Sharded Data Parallelism).

Existing Automatic Parallelism (AP) tools typically follow a hierarchical approach, optimizing these strategies sequentially. This "greedy" decomposition often fails to find the global optimum because inter- and intra-layer choices are deeply interdependent. Manual parallelism, while powerful, requires significant engineering effort and lacks flexibility across different hardware architectures.

Methodology: Unified Optimization

UniAP addresses the limitations of hierarchical search by treating the selection of parallel strategies as a single, unified mathematical optimization problem.

Comparison of automatic parallelism strategies: UniAP unifies the search space to find global optima.

The framework utilizes a three-step process:

  • Profiling & Cost Modeling: UniAP measures hardware-specific communication speeds and layer-wise computation/memory costs to build an accurate performance model.
  • MIQP Formulation: The problem is modeled as Mixed Integer Quadratic Programming. Binary variables represent layer placement and strategy selection, while constraints ensure memory safety (avoiding OOM errors) and model contiguity.
  • Unified Optimization Process (UOP): An off-the-shelf solver (e.g., Gurobi) navigates the massive search space. Unlike the dynamic programming used in previous tools, MIQP solvers leverage branch-and-bound techniques to find optimal solutions in seconds rather than hours.

Experimental Evaluation

The researchers evaluated UniAP on five prominent Transformer-based models, including BERT-Huge, T5-Large, Llama-7B/13B, ViT-Huge, and Swin-Huge. Testing occurred across diverse hardware environments, including NVIDIA V100, A100, and Hygon DCU clusters using datasets like English Wikipedia and ImageNet-1K.

Key Results

UniAP consistently outperformed state-of-the-art baselines like Galvatron and Alpa in almost every scenario.

Training throughput comparison across various models, showing UniAP's performance gains over isolated strategies.
  • Throughput Gains: UniAP achieved a 3.80x throughput increase for Llama-7B on A100 nodes. It effectively identifies when to use Pipeline Parallelism to minimize inter-device communication bottlenecks.
  • Optimization Efficiency: Strategy search time was reduced by up to 107x for BERT-Huge, enabling rapid re-optimization for changing hardware or batch sizes.
  • Reliability: While manual tuning often results in Out-of-Memory (OOM) errors (up to 87.5% failure rate for Llama-13B), UniAP robustly identifies valid, high-performance configurations.

Conclusion and Future Work

UniAP demonstrates that joint optimization of inter- and intra-layer parallelism is critical for maximizing the efficiency of large model training. While currently focused on homogeneous clusters, future work will extend the MIQP formulation to handle heterogeneous environments with varying hardware capacities. Additionally, exploring open-source solvers could further democratize access to this unified optimization approach.

Summary updated

BibTeX
@inproceedings{lin2025uniap,
  author = {Hao Lin and Ke Wu 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