Training a Large Language Model (LLM) is a massive engineering feat that requires orchestrating hundreds, sometimes thousands, of GPUs. To make this work, researchers use "3D parallelism"—a combination of Data, Tensor, and Pipeline parallelism. But how do you balance these three to get the most out of your expensive hardware?
In their paper, "Efficient Parallelization Layouts for Large-Scale Distributed Model Training," researchers from Aleph Alpha and the Hasso Plattner Institute provide a comprehensive map for this territory. By conducting a massive ablation study with modern optimizations like FlashAttention-2, they’ve distilled complex interactions into actionable rules of thumb for the next generation of AI engineers.
TL;DR
This paper presents a large-scale systematic study of 3D parallelism configurations, incorporating modern optimizations like FlashAttention-2 and sequence parallelism. The authors demonstrate that a micro-batch size of 1 is often the "sweet spot" for efficiency, helping them achieve a state-of-the-art 70.5% Model FLOPs Utilization (MFU) for a LLaMA 13B model.
What Problem Does This Paper Address?
The computational cost of training LLMs is skyrocketing. To fit models with 65B+ parameters into GPU memory, developers must shard the model across multiple dimensions. However, these choices—how many layers to pipeline, how to split tensors, and how many samples to process at once—interact in non-obvious ways.
Previous "best practices" were established before the release of game-changing optimizations like FlashAttention and sequence parallelism. This paper fills that gap, providing a modern benchmark for what "efficient training" actually looks like in 2024.
Methods
The authors used their in-house framework, AA-Scaling, to run a massive sweep on up to 256 NVIDIA A100 GPUs. They tested LLaMA models ranging from 13B to 65B parameters with sequence lengths of 2k and 8k.
The sweep explored the Cartesian product of several variables:
- Tensor Parallelism (TP): Splitting individual weight matrices.
- Pipeline Parallelism (PP): Splitting model layers across GPUs.
- Micro-batch Size (MBS): The number of samples processed before a gradient update.
- Activation Checkpointing: Trading compute for memory by re-calculating activations during the backward pass.
- Kernels: Comparing standard PyTorch, Megatron-LM, and FlashAttention-1/2, along with fused RMSNorm kernels.
Datasets
The study focused on training efficiency (throughput) rather than convergence or final model quality. They utilized the LLaMA architecture (13B, 30B, and 65B variants) as the primary benchmark, comparing their results against publicly reported numbers from MosaicML (MPT), Meta (LLaMA), and Megatron-DeepSpeed.
Key Insights and Ideas
- The "MBS=1" Rule: Surprisingly, a micro-batch size of 1 is often optimal. It minimizes memory usage, which allows researchers to avoid activation checkpointing (which adds ~33% compute overhead) and reduces "pipeline bubbles"—the idle time GPUs spend waiting for data from other stages.
- FlashAttention-2 is Non-Negotiable: The transition from FlashAttention-1 to version 2 improved MFU by 4 to 13 percentage points. As seen in Figure 1, FlashAttention-2 vastly outperforms native PyTorch and older Megatron kernels.
- Fused Kernels are "Free" Performance: Using a fused RMSNorm kernel provided a boost of up to 14 percentage points. This memory saving is so significant that it sometimes allows fitting a 13B model on a single GPU without any model parallelism.
- Pipeline > Tensor Parallelism: While older studies suggested an even split between TP and PP, this work found that for larger models, favoring pipeline parallelism (e.g., a TP=2, PP=8 layout for LLaMA 65B) is more efficient than an even split (TP=4, PP=4).
- Sequence Parallelism for the Big Leagues: For models over 30B parameters or long contexts (8k+), sequence parallelism provides a 2-6 percentage point improvement by sharding activations that tensor parallelism misses.
Key Results
The authors set new records for training efficiency across all tested model sizes:
- LLaMA 13B: Achieved 70.5% MFU, crushing the previous MPT 13B benchmark of 52.5%.
- LLaMA 65B: Achieved 59.6% MFU, significantly outperforming Meta’s original training efficiency of 49.4%.
- Long Context: For 8k sequence lengths, they outperformed MosaicML’s MPT models by 9–17 percentage points.
As shown in Figure 2, the authors highlight that avoiding activation checkpointing is a primary driver of these high MFU numbers.
Limitations and Future Work
- Hardware Specifics: The study is tailored to A100 GPUs. The authors note that newer hardware like the H100 (with FP8 support) or GH200 (with coherent memory) might change the optimal balance between compute and communication.
- ZeRO Stages: The experiments focused on ZeRO-1. Future work could investigate how ZeRO-3 or Fully Sharded Data Parallel (FSDP) interacts with these 3D layouts to save even more memory.
- Selective Checkpointing: While the authors generally avoided activation checkpointing, "selective" checkpointing (only recomputing specific parts of the block) remains a promising middle ground for extremely large models.
For those looking to dive into the raw numbers, the authors have released their full sweep data on GitHub.
Summary updated