Abstract: Scaling up deep neural networks has been proven effective in improving model quality, while it also brings ever-growing training challenges. This paper presents Whale, an automatic and hardware-aware distributed training framework for giant models. Whale generalizes the expression of parallelism with four primitives, which can define various parallel strategies, as well as flexible hybrid strategies including combination and nesting patterns. It allows users to build models at an arbitrary scale by adding a few annotations and automatically transforms the local model to a distributed implementation. Moreover, Whale is hardware-aware and highly efficient even when training on GPUs of mixed types, which meets the growing demand of heterogeneous training in industrial clusters. Whale sets a milestone for training the largest multimodal pretrained model M6. The success of M6 is achieved by Whale's design to decouple algorithm modeling from system implementations, i.e., algorithm developers can focus on model innovation, since it takes only three lines of code to scale the M6 model to trillions of parameters on a cluster of 480 GPUs.
Introduction: The "System Tax" of Giant Models
Training deep learning models has become an arms race of scale. As we move from millions of parameters to trillions, the primary bottleneck is no longer just algorithmic innovation but the "system tax." Distributing massive models across hundreds of GPUs typically requires researchers to act as low-level systems engineers, manually partitioning code and managing complex communication patterns.
Existing frameworks often struggle with the complexity of hybrid parallel strategies—where different parts of a model require different distribution methods (e.g., Data Parallelism for small layers and Model Parallelism for massive ones). Furthermore, industrial clusters are rarely uniform; they often contain a mix of different GPU generations. Standard frameworks struggle with this heterogeneity, leading to "stragglers" where fast GPUs sit idle waiting for slower ones to finish. Whale, developed by Alibaba and the National University of Singapore, aims to decouple model logic from system implementation, allowing researchers to scale models to the trillion-parameter mark with minimal code changes.
The Whale Framework: Primitives and TaskGraphs
Whale introduces a unified abstraction layer to bridge the gap between model code and distributed execution. It modularizes models into TaskGraphs (subsets of the model) and maps them to VirtualDevices (logical groups of GPUs), hiding the physical complexity of the cluster from the user.
To simplify scaling, Whale provides high-level primitives that users can use to annotate their code:
replicate(n): Instructs the system to use data parallelism across $n$ devices.split(n): Instructs the system to shard tensors (model parallelism) across $n$ devices.
The Whale Planner, a runtime engine, automatically rewrites the model's computation graph based on these annotations. A key innovation is the introduction of Bridge Layers, which automate the insertion of "glue" code to handle data movement (gathering, scattering, or re-sharding) between different parallel zones. This automation eliminates the manual, error-prone refactoring typically required for hybrid strategies.
Hardware-Aware Load Balancing
Unlike traditional frameworks that assume a uniform cluster, Whale treats hardware diversity as a scheduling problem. It profiles the cluster to identify the compute and memory capacity of each GPU type. In a heterogeneous environment—such as a mix of NVIDIA V100 and T4 GPUs—Whale dynamically adjusts the workload by assigning larger mini-batches to more powerful GPUs.
As shown in the comparison above, naive data parallelism results in significant idle cycles on faster GPUs (like the V100) as they wait for slower ones (like the T4) to synchronize. Whale’s hardware-aware approach balances the "FLOPs-per-second" across the cluster, ensuring all devices finish their tasks simultaneously and maximizing overall throughput.
Key Results and the M6 Milestone
The effectiveness of Whale was demonstrated through the training of the M6 (Multi-Modality to Multi-Modality Multitask Mega-transformer) model, which reached a staggering 10 trillion parameters. Whale enabled this scale on 512 GPUs with only four lines of code change.
- Scalability: The M6-10B model achieved 91% throughput scalability on 256 NVIDIA V100 GPUs.
- Hybrid Performance: In large-scale image classification (100K classes), Whale’s hybrid strategy outperformed standard data parallelism by 2.43x by reducing synchronization overhead by nearly 90%.
- Heterogeneous Gains: On mixed clusters of V100 and P100 GPUs, Whale provided a 1.2x to 1.4x speedup over standard TensorFlow distribution methods by effectively balancing the load.
Conclusion
Whale represents a significant step forward in democratizing giant model training. By decoupling algorithm modeling from system implementation and embracing hardware heterogeneity, it allows researchers to focus on innovation rather than infrastructure. While future work may involve automated "best effort" graph optimization to further reduce the user's decision burden, Whale has already set a new standard for efficiency and ease of use at the trillion-parameter scale.
Summary updated