Slapo: A Schedule Language for Progressive Optimization of Large Deep Learning Model Training

Hongzheng Chen, Cody Hao Yu, Shuai Zheng, Zhen Zhang, Zhiru Zhang, Yida Wang

TL;DR

Slapo is a new schedule language for PyTorch that decouples a model’s arithmetic definition from its execution optimizations. By providing a set of high-level primitives, it allows developers to progressively apply complex optimizations—like 3D parallelism and custom kernels—with minimal code changes, achieving up to 2.92× speedup over state-of-the-art frameworks like DeepSpeed and Megatron-LM.

What Problem Does This Paper Address?

Training large deep learning models (LLMs) is a constant tug-of-war between usability and performance.

On one side, frameworks like PyTorch offer great flexibility through dynamic graphs, but they often lack the aggressive optimizations needed for massive models. On the other side, performance-oriented frameworks (like Megatron-LM) require intrusive, manual code changes to implement optimizations like tensor parallelism or fused kernels. These manual changes make the code hard to maintain, difficult to generalize to new architectures, and a nightmare to debug.

Furthermore, existing deep learning compilers often "flatten" the model hierarchy during optimization, stripping away the structural information that developers use to understand and troubleshoot their models.

Methods

The authors introduce Slapo, a "Schedule LAnguage for Progressive Optimization." Inspired by hardware-centric compilers like Halide and TVM, Slapo separates what the model computes from how it is executed.

Key technical components include:

  • Schedule Primitives: A library of commands (e.g., .shard(), .replace(), .fuse(), .checkpoint()) that allow users to modify model behavior externally without touching the original source code.
  • Progressive Tracing: Unlike traditional compilers that try to trace the entire model at once (and often fail due to complex Python logic), Slapo uses a "trace-by-need" approach. It only converts specific sub-modules into static graphs for optimization while leaving the rest of the model in its native PyTorch state.
  • Structure-Preserving Hierarchy: Slapo maintains the original module hierarchy (e.g., bert.encoder.layer.0), making it easy for developers to locate and optimize specific parts of the model.
  • Auto-Tuning: A lightweight tuner that explores the "search space" of configurations (like batch sizes and activation checkpointing ratios) to find the most efficient setup for a specific hardware environment.
  • Verification: A differential testing tool that compares the optimized model against the vanilla version using random inputs to ensure numerical correctness.

Datasets (Models Evaluated)

The paper evaluates Slapo using a suite of popular large-scale models from the HuggingFace Hub and TorchVision:

  • Language Models: BERT, RoBERTa, GPT-2, GPT-3 (10B), OPT, T5, and LLaMA (7B).
  • Vision Models: WideResNet. Evaluation was performed on Amazon EC2 p3dn.24xlarge instances featuring NVIDIA V100 GPUs (32GB), scaled from a single machine (8 GPUs) up to 8 machines (64 GPUs).

Key Insights and Ideas

  • Decoupling is the "Aha!" Moment: By treating optimization as a separate "schedule" script, a single model definition can be optimized for different hardware (e.g., one GPU vs. a cluster) without rewriting the core logic.
  • The Power of "Progressive": You don't have to optimize everything at once. You can start with a vanilla model and incrementally add sharding or kernel fusion only where bottlenecks exist.
  • Usability as a First-Class Citizen: The authors demonstrate that complex distributed training setups that normally require thousands of lines of custom code can be implemented in roughly 20 lines of Slapo code.
  • Preserving the Mental Model: Because Slapo respects the original PyTorch module structure, the "optimized" model still looks and feels like the original model to the developer, significantly aiding debuggability.

Key Results

  • Throughput Gains: On a single node (8x V100), Slapo achieved up to 2.92× speedup compared to out-of-the-box performance.
  • Scaling Performance: In multi-node setups (up to 64 GPUs), Slapo outperformed DeepSpeed and Megatron-LM by up to 1.41× for models like GPT-10B.
  • Efficiency in Tuning: The Slapo auto-tuner identified optimal configurations 86% faster than an exhaustive search, exploring only 19% of the total candidate configurations.
  • Code Reduction: Implementing high-performance schedules for models like BERT or LLaMA required only 10–21 lines of code, compared to the massive manual refactoring required by traditional methods.

Limitations and Future Work

  • Architectural Regularity: Slapo currently shines on models with repetitive, regular structures (like Transformers). It may require more effort for highly irregular architectures.
  • Graph Partitioning: The current version does not automatically handle complex graph partitioning required for models like Graph Neural Networks (GNNs).
  • Future Direction: The authors plan to develop an auto-scheduler (similar to Ansor for TVM) that can automatically generate these schedule primitives without manual intervention, further lowering the barrier to high-performance training.

Summary updated

BibTeX
@inproceedings{chen2024slapo,
  author = {Hongzheng Chen and Cody Hao Yu and Shuai Zheng and Zhen Zhang and Zhiru Zhang and Yida Wang},
  title = {{Slapo: A Schedule Language for Progressive Optimization of Large Deep Learning Model Training}},
  booktitle = {ASPLOS},
  year = {2024},
  doi = {10.1145/3620665.3640399},
}
Figure