https://github.com/awslabs/slapo
A schedule language for large model training
Science Score: 33.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
✓Committers with academic emails
1 of 4 committers (25.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.0%) to scientific vocabulary
Repository
A schedule language for large model training
Basic Info
- Host: GitHub
- Owner: awslabs
- License: apache-2.0
- Language: Python
- Default Branch: main
- Homepage: https://awslabs.github.io/slapo/
- Size: 7.17 MB
Statistics
- Stars: 149
- Watchers: 10
- Forks: 17
- Open Issues: 10
- Releases: 3
Metadata Files
README.md
Slapo: A Schedule Language for Large Model Training
Slapo is a schedule language for progressive optimization of large deep learning model training.
Large deep learning models demonstrate dominating model accuracy on a range of tasks in NLP and CV, but it is hard to train the model efficiently while preserving the usability. Slapo aims to address this tension through separation of concerns. Slapo decouples model execution from definition, enabling developers to use a set of schedule primitives to convert a PyTorch model for common model training optimizations without directly changing the model itself.
Slapo highlights the following features:
:rocket: Progressive optimization. Slapo incorporates a "trace by need" approach that only traces a desired module to be a static graph for compiler-based aggressive optimizations.
:building_construction: Structure-preserving scheduling. Slapo preserves the module hierarchy when constructing the schedule, so developers can easily locate the module and apply scheduling, which also facilitates the users to debug any performance and convergence issue.
:gear: Auto-tuning. Slapo provides a programming interface that allows developers to specify a set of tuneable knobs to form an efficient tuning space, which can then be explored by Slapo auto-tuner to realize the optimal configuration.
Getting Started
Installation
There are two approaches to install Slapo:
- Install from PYPI
bash
pip3 install slapo
- Install from source
bash
git clone https://github.com/awslabs/slapo.git slapo
cd slapo
pip3 install -e ".[dev]"
In addition, you can optionally install HuggingFace Transformers (>= v4.28.1) to retrieve models. Also, Slapo currently supports the following frameworks, so you can run the scheduled models on these frameworks if needed. * Megatron-LM >= 3.0.2 * DeepSpeed >= 0.7.7
Usage
Please see the examples folder for more details. Documentations will be released soon. ```python import slapo
Load a PyTorch model from HuggingFace Hub, TorchVision, etc.
from transformers import BertLMHeadModel, AutoConfig config = AutoConfig.from_pretrained("bert-large-uncased") bert = BertLMHeadModel(config)
Create a default schedule
sch = slapo.create_schedule(bert)
Apply primitives to optimize the model
Please refer to slapo/model_schedule/bert.py for details
sch["bert.encoder.layer.0"].primitve(...)
Build an optimized model
opt_model = slapo.build(sch)
Run the optimized model
inputs = ... outputs = opt_model(inputs) ```
Supported Primitives
To maximally reduce the risk introduced by tracers and compilers, we leverage progressive optimization to gradually apply primitives to a part of the model. We classify the primitives into two categories. The first type of primitives does not require tracing and can be directly applied to modules and parameters; the second type of primitives requires a static graph, and thus needs to apply the .trace() primitive first.
We provide the following primitives for dynamic graph optimizations:
| Feature | Primitive |
| :--: | :-- |
| Module replacement | s[op].replace(new_module) |
| Tensor parallelism | s[op].shard(param_name, axis) |
| Synchronization | s[op].sync(mode="fwd_pre/fwd_post/bwd_post", sync_op_or_fn, **kwargs) |
| Checkpointing | s[op].checkpoint() |
| Fork random number generator | s[op].fork_rng() |
| Annotate parameters | s[op].annotate(param_name, key, value) |
And the following primitives for static graph optimizations:
| Feature | Primitive |
| :--: | :-- |
| Module Tracing | s.trace(leaves, flatten) |
| Pattern matching | s.find(regex_or_pattern_fn) |
| Operator fusion | s[op].fuse(compiler, subgraph) |
| Layer decomposition | s[op].decompose() |
| Partial module replacement | s[op].replace(new_module, subgraph) |
| Partial gradient checkpointing | s[op].checkpoint(subgraph) |
| Pipeline parallelism | s[op].cut_pipeline_stage() |
You can look for all supported primitvies with the following API:
python
import slapo
print(slapo.list_primitives())
You could also check the description of each primitive on the fly:
python
import slapo
help(slapo.list_primitives(name_only=False)["shard"])
Auto-Tuning
We also provide a light-weight interface for auto-tuning, so the developers can (1) construct a polyhedral search space using our APIs, and (2) leverage Slapo auto-tuner to automatically search for the best training configuration.
```bash cd benchmark
Single device
The following script will trigger the tuning jobs for all the models
python3 tunesingledevice.py
Single node
python3 tunesinglenode.py ```
Benchmarking
We provide scripts to reproduce our results on a single AWS EC2 p3.16xlarge node with 8 * V100 GPUs. Please refer to benchmark for more details.
Publication
If you use Slapo in your project, please kindly cite our paper:
bibtex
@inproceedings{chen2024slapo,
title = {Slapo: A Schedule Language for Progressive Optimization of Large Deep Learning Model Training},
author = {Hongzheng Chen and Cody Hao Yu and Shuai Zheng and Zhen Zhang and Zhiru Zhang and Yida Wang},
booktitle = {Proceedings of the 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 2 (ASPLOS ’24)},
year = {2024}
}
License
Slapo is released under the Apache 2.0 license.
Owner
- Name: Amazon Web Services - Labs
- Login: awslabs
- Kind: organization
- Location: Seattle, WA
- Website: http://amazon.com/aws/
- Repositories: 914
- Profile: https://github.com/awslabs
AWS Labs
GitHub Events
Total
- Issues event: 1
- Watch event: 8
- Issue comment event: 6
- Fork event: 1
Last Year
- Issues event: 1
- Watch event: 8
- Issue comment event: 6
- Fork event: 1
Committers
Last synced: over 3 years ago
All Time
- Total Commits: 356
- Total Committers: 4
- Avg Commits per committer: 89.0
- Development Distribution Score (DDS): 0.303
Top Committers
| Name | Commits | |
|---|---|---|
| chhzh123 | h****6@c****u | 248 |
| Cody Yu | c****2@g****m | 92 |
| Shuai Zheng | s****c@u****m | 12 |
| Zhen Zhang | z****v@g****m | 4 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 18
- Total pull requests: 98
- Average time to close issues: 14 days
- Average time to close pull requests: 10 days
- Total issue authors: 6
- Total pull request authors: 8
- Average comments per issue: 1.28
- Average comments per pull request: 1.11
- Merged pull requests: 91
- Bot issues: 0
- Bot pull requests: 2
Past Year
- Issues: 1
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: about 5 hours
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- chhzh123 (6)
- comaniac (5)
- zarzen (4)
- keneoneth (1)
- szhengac (1)
- old0110 (1)
Pull Request Authors
- chhzh123 (40)
- comaniac (36)
- szhengac (9)
- zarzen (7)
- eric-haibin-lin (2)
- dependabot[bot] (2)
- liangfu (1)
- AdnaneKhan (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 158 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 2
pypi.org: slapo
Slapo: A Schedule Language for Progressive Optimization.
- Homepage: https://github.com/awslabs/slapo
- Documentation: https://slapo.readthedocs.io/
- License: apache-2.0
-
Latest release: 0.0.3
published over 3 years ago
Rankings
Maintainers (2)
Dependencies
- nvidia/cuda 11.7.1-cudnn8-devel-ubuntu18.04 build
- actions/checkout v2 composite
- actions/upload-artifact v2 composite
- actions/checkout v2 composite
- aws-actions/configure-aws-credentials v1 composite
- dawidd6/action-download-artifact v2 composite
- haya14busa/action-workflow_run-status v1 composite
- schneegans/dynamic-badges-action v1.1.0 composite
- actions/checkout v3 composite
- JamesIves/github-pages-deploy-action releases/v3 composite
- actions/checkout v3 composite
- actions/upload-artifact v1 composite
- ammaraskar/sphinx-action master composite
- Pygments >=2.13.0
- autodocsumm *
- matplotlib *
- sphinx >=4.5.0
- sphinx-book-theme *
- sphinx-copybutton *
- sphinx-gallery *
- sphinx_rtd_theme *
- sphinxcontrib-googleanalytics *
- transformers >=4.28.1
- packaging *
- psutil *