Abstract
Scaling deep learning models to trillions of parameters requires sophisticated parallelization strategies that go beyond simple data parallelism. GSPMD (General and Scalable Parallelization for ML) is a compiler-based system that allows developers to write programs as if they were running on a single device. By utilizing a small number of sharding annotations, GSPMD automatically transforms the computation graph to execute across massive clusters. This approach unifies data, model, and pipeline parallelism into a single, efficient framework integrated into the XLA compiler.
Introduction
As neural networks grow in complexity and size, the traditional "one-size-fits-all" approach of data parallelism—splitting training data across devices—is no longer sufficient. Modern large-scale models require a combination of model parallelism (splitting weights), spatial partitioning (splitting large input tensors), and pipelining (distributing layers across time). Historically, implementing these strategies required manual, hardware-specific code rewrites, which are difficult to maintain and scale. GSPMD addresses this by providing an automated, general-purpose mechanism to scale "single-device" code to thousands of accelerators without sacrificing performance.
Methods: Tensor Sharding and Propagation
GSPMD is implemented as an extension to the XLA (Accelerated Linear Algebra) compiler. Its core innovation is a unified approach to tensor sharding.
The system operates on several key principles:
- Single Program Multiple Data (SPMD): GSPMD generates a single unified program that runs on all partitions. Each device uses its unique ID to determine which specific piece of data to process, significantly reducing compilation time for large clusters.
- Sharding Propagation: Users only need to annotate a tiny fraction of tensors (often less than 1%). GSPMD then uses a priority-based system to infer the partitioning for the rest of the graph, prioritizing element-wise operations to minimize cross-device communication.
- Unified Parallelism: By treating all tensor dimensions (batch, spatial, or feature) identically, GSPMD supports data, model, and spatial parallelism through the same mechanism. Pipeline parallelism is similarly integrated by adding a "stage" dimension to tensors.
- Halo Exchange: For operations like convolutions, GSPMD automatically manages "halo exchanges"—the data shuffling required to maintain mathematical correctness across device boundaries.
Evaluation and Models
The researchers evaluated GSPMD on a variety of production-grade models, demonstrating its versatility across different architectures:
- Dense Transformers: Scaled from 64 billion to 1 trillion parameters.
- Mixture-of-Experts (MoE): Sparse models where only specific "experts" are active per input.
- Conformer: A speech recognition model used to validate pipelining capabilities.
- 3D U-Net: A medical imaging model used to demonstrate spatial partitioning on high-resolution volumes.
Key Insights
A major breakthrough of GSPMD is the separation of concerns: it decouples the model logic from the parallelization strategy. Researchers can alter how a model is distributed across a cluster by changing a few lines of annotations rather than rewriting the model itself. In Transformer experiments, the authors found that annotating just 0.7% of the tensors (roughly 7 per layer) was sufficient for the compiler to correctly partition a trillion-parameter graph. Furthermore, by treating complex operators like Einsum recursively, GSPMD handles nested parallelism patterns without requiring a library of handwritten rules.
Results
GSPMD demonstrates exceptional performance and scalability:
- Efficiency: It achieved 50% to 62% compute utilization on up to 2,048 Cloud TPUv3 cores, a high benchmark for production workloads at this scale.
- Linear Scaling: For large Transformers, memory usage and performance scaled near-linearly with the number of devices.
- Spatial Speedup: On the 3D U-Net model, spatial partitioning enabled a 15.7x speedup on 16 devices, allowing the processing of high-resolution images that exceed the memory of a single accelerator.
Conclusion and Future Work
GSPMD provides a powerful, general-purpose framework for scaling ML models. While it currently requires minimal manual hints, future work may involve automated search algorithms to find optimal sharding strategies. Additionally, while highly effective on TPU architectures via XLA, expanding its reach to more heterogeneous hardware and pipeline configurations remains an area for growth.
Summary updated