Hydraulis: Balancing Large Transformer Model Training via Co-designing Parallel Strategies and Data Assignment

Haoyang Li, Fangcheng Fu, Sheng Lin, Hao Ge, Xuanyu Wang, Jiawen Niu, Jinbao Xue, Yangyu Tao, Di Wang, Jie Jiang, Bin Cui

TL;DR

Training massive AI models like Transformers is bottlenecked by uneven data distributions and static training strategies. Hydraulis introduces a novel system that dynamically co-designs parallel training strategies and data assignment to overcome these imbalances, leading to significant speedups of up to 2.66x.

What Problem Does This Paper Address?

Large Transformer models are revolutionizing AI, but training them is a monumental task. The sheer size of these models demands massive computational resources, and their effectiveness hinges on training with vast datasets. However, current training methods face two critical challenges that hinder performance:

  1. Data Sampling Imbalance: Real-world datasets, like CommonCrawl and GitHub, have a highly skewed distribution of sequence lengths. This means most sequences are short, while very long ones are rare. This imbalance creates inefficiencies because training setups are often optimized for the longest sequences, wasting resources on shorter ones. Furthermore, the maximum sequence length can fluctuate significantly between training iterations, making static strategies suboptimal.
  2. Data Packing Imbalance: To handle variable-length sequences efficiently, data is often "packed" into fixed-size chunks. While this helps with memory, the attention mechanism in Transformers has a quadratic time complexity with sequence length. This means even with packed data, the actual computation time can vary wildly depending on the original sequence lengths within a packed chunk, leading to imbalanced workloads across different parts of the training process.

Existing systems typically address these issues in isolation, using static parallel strategies and simple packing methods. This decoupled approach fails to leverage the inherent variability of data for performance gains.

Methods

Hydraulis tackles these challenges through a co-design approach, integrating parallel computing and data management:

  • Dynamic Heterogeneous Parallel Strategies: Instead of a single, static parallel configuration for all training pipelines (model replicas), Hydraulis employs dynamic strategies. This means different pipelines can use different parallel schemes (e.g., varying degrees of tensor, pipeline, or sequence parallelism) within the same training iteration. These strategies can also change between iterations, adapting to the specific data distribution of each mini-batch.
  • Optimization-Propagation Disaggregation: To enable these dynamic heterogeneous strategies, Hydraulis decouples the optimization phase (gradient synchronization and model updates) from the propagation phase (forward and backward passes). This allows for flexible communication patterns between these phases, supporting arbitrary parallel schemes without requiring them to be aligned. This is achieved through a novel "LNK" operator.
  • Two-Stage Sequence Assignment: To address data packing imbalances, Hydraulis uses a two-stage approach:
  • Sequence Dispatching: It first intelligently dispatches sequences of varying lengths to different pipelines to balance the workload across pipelines (inter-pipeline imbalance).
  • Sequence Packing: Then, within each pipeline, it meticulously packs sequences into micro-batches to balance the workload within the pipeline (intra-pipeline imbalance), considering both memory and computation time. This stage also estimates the latency of a given strategy for a mini-batch.
  • Data Distribution-Aware Strategy Proposal: To avoid exhaustively searching all possible strategies, Hydraulis analyzes the dataset's overall sequence length distribution beforehand. It uses dynamic programming to propose a set of promising candidate heterogeneous strategies that are likely to perform well across different data characteristics.

Datasets

The paper uses popular large language model training datasets:

  • CommonCrawl: A massive web crawl dataset.
  • GitHub: A dataset of code from GitHub repositories.

These datasets are noted for their highly variable sequence lengths, which are central to the problems addressed in the paper.

Key Insights and Ideas

  • Data Imbalance is a Feature, Not a Bug: The paper argues that the inherent variability in sequence lengths, often seen as a problem, can be leveraged for performance gains if training strategies are dynamic and adaptive.
  • Co-design is Crucial: Optimizing parallel strategies and data assignment in isolation is insufficient. Hydraulis demonstrates that jointly optimizing these aspects is key to unlocking significant efficiency improvements.
  • Heterogeneity is the Future: Static, homogeneous parallel strategies are a bottleneck. Dynamic, heterogeneous strategies that adapt to data characteristics are essential for efficient training of large models.
  • Decoupling for Flexibility: Separating optimization from propagation is a powerful technique that enables the use of diverse and dynamic parallel strategies, overcoming limitations of traditional synchronized training.

Key Results

  • Hydraulis achieves 1.32x to 2.66x improvement in throughput compared to state-of-the-art systems like Megatron-LM, DeepSpeed, and HotSPa.
  • The two-stage sequence assignment significantly reduces load imbalance across pipelines, with latency differences between ranks reduced to as low as 0.02-0.10x compared to 0.36-0.65x for Megatron-LM.
  • The dynamic heterogeneous strategies adapt to varying sequence lengths, leading to better GPU utilization and avoiding the overhead of static strategies optimized for worst-case scenarios.
  • The optimization-propagation disaggregation allows for overlap of communication and computation, further reducing latency.

Limitations and Future Work

  • Computational Cost of Strategy Proposal: While the strategy proposal is performed only once, its computational cost can increase with the number of GPUs, though it remains under 2 minutes.
  • Future Work: The authors plan to expand the strategy space by integrating more parallel methods (e.g., expert parallelism) and apply Hydraulis to other domains with significant sequence length variations, such as video processing. They also aim to explore its adaptability to broader applications.

Summary updated

BibTeX
@article{li2024hydraulis,
  author = {Haoyang Li and Fangcheng Fu and Sheng Lin and Hao Ge and Xuanyu Wang and Jiawen Niu and Jinbao Xue and Yangyu Tao and Di Wang and Jie Jiang and Bin Cui},
  title = {{Hydraulis: Balancing Large Transformer Model Training via Co-designing Parallel Strategies and Data Assignment}},
  journal = {Proc. ACM Manag. Data},
  year = {2024},
  url = {https://openreview.net/forum?id=JPdY5OZ31d},
}
Figure