Home

Awesome

Colossal-AI

<div id="top" align="center">

logo

Colossal-AI: Making large AI models cheaper, faster, and more accessible

<h3> <a href="https://arxiv.org/abs/2110.14883"> Paper </a> | <a href="https://www.colossalai.org/"> Documentation </a> | <a href="https://github.com/hpcaitech/ColossalAI/tree/main/examples"> Examples </a> | <a href="https://github.com/hpcaitech/ColossalAI/discussions"> Forum </a> | <a href="https://cloud.luchentech.com/">GPU Cloud Playground </a> | <a href="https://hpc-ai.com/blog"> Blog </a></h3>

GitHub Repo stars Build Documentation CodeFactor HuggingFace badge slack badge WeChat badge

| English | 中文 |

</div>

Get Started with Colossal-AI Without Setup

Access high-end, on-demand compute for your research instantly—no setup needed.

Sign up now and get $10 in credits!

Limited Academic Bonuses:

<div align="center"> <a href="https://hpc-ai.com/?utm_source=github&utm_medium=social&utm_campaign=promotion-colossalai"> <img src="https://github.com/hpcaitech/public_assets/blob/main/colossalai/img/2.gif" width="850" /> </a> </div>

Latest News

Table of Contents

<ul> <li><a href="#Why-Colossal-AI">Why Colossal-AI</a> </li> <li><a href="#Features">Features</a> </li> <li> <a href="#Colossal-AI-in-the-Real-World">Colossal-AI for Real World Applications</a> <ul> <li><a href="#Open-Sora">Open-Sora: Revealing Complete Model Parameters, Training Details, and Everything for Sora-like Video Generation Models</a></li> <li><a href="#Colossal-LLaMA-2">Colossal-LLaMA-2: One Half-Day of Training Using a Few Hundred Dollars Yields Similar Results to Mainstream Large Models, Open-Source and Commercial-Free Domain-Specific Llm Solution</a></li> <li><a href="#ColossalChat">ColossalChat: An Open-Source Solution for Cloning ChatGPT With a Complete RLHF Pipeline</a></li> <li><a href="#AIGC">AIGC: Acceleration of Stable Diffusion</a></li> <li><a href="#Biomedicine">Biomedicine: Acceleration of AlphaFold Protein Structure</a></li> </ul> </li> <li> <a href="#Parallel-Training-Demo">Parallel Training Demo</a> <ul> <li><a href="#LLaMA3">LLaMA 1/2/3 </a></li> <li><a href="#MoE">MoE</a></li> <li><a href="#GPT-3">GPT-3</a></li> <li><a href="#GPT-2">GPT-2</a></li> <li><a href="#BERT">BERT</a></li> <li><a href="#PaLM">PaLM</a></li> <li><a href="#OPT">OPT</a></li> <li><a href="#ViT">ViT</a></li> <li><a href="#Recommendation-System-Models">Recommendation System Models</a></li> </ul> </li> <li> <a href="#Single-GPU-Training-Demo">Single GPU Training Demo</a> <ul> <li><a href="#GPT-2-Single">GPT-2</a></li> <li><a href="#PaLM-Single">PaLM</a></li> </ul> </li> <li> <a href="#Inference">Inference</a> <ul> <li><a href="#Colossal-Inference">Colossal-Inference: Large AI Models Inference Speed Doubled</a></li> <li><a href="#Grok-1">Grok-1: 314B model of PyTorch + HuggingFace Inference</a></li> <li><a href="#SwiftInfer">SwiftInfer:Breaks the Length Limit of LLM for Multi-Round Conversations with 46% Acceleration</a></li> </ul> </li> <li> <a href="#Installation">Installation</a> <ul> <li><a href="#PyPI">PyPI</a></li> <li><a href="#Install-From-Source">Install From Source</a></li> </ul> </li> <li><a href="#Use-Docker">Use Docker</a></li> <li><a href="#Community">Community</a></li> <li><a href="#Contributing">Contributing</a></li> <li><a href="#Cite-Us">Cite Us</a></li> </ul>

Why Colossal-AI

<div align="center"> <a href="https://youtu.be/KnXSfjqkKN0"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/JamesDemmel_Colossal-AI.png" width="600" /> </a>

Prof. James Demmel (UC Berkeley): Colossal-AI makes training AI models efficient, easy, and scalable.

</div> <p align="right">(<a href="#top">back to top</a>)</p>

Features

Colossal-AI provides a collection of parallel components for you. We aim to support you to write your distributed deep learning models just like how you write your model on your laptop. We provide user-friendly tools to kickstart distributed training and inference in a few lines.

<p align="right">(<a href="#top">back to top</a>)</p>

Colossal-AI in the Real World

Open-Sora

Open-Sora:Revealing Complete Model Parameters, Training Details, and Everything for Sora-like Video Generation Models [code] [blog] [Model weights] [Demo] [GPU Cloud Playground] [OpenSora Image]

<div align="center"> <a href="https://youtu.be/ilMQpU71ddI?si=J4JSPzZ03ycYmlki"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/applications/sora/opensora-v1.2.png" width="700" /> </a> </div> <p align="right">(<a href="#top">back to top</a>)</p>

Colossal-LLaMA-2

[GPU Cloud Playground] [LLaMA3 Image]

ModelBackboneTokens ConsumedMMLU (5-shot)CMMLU (5-shot)AGIEval (5-shot)GAOKAO (0-shot)CEval (5-shot)
Baichuan-7B-1.2T42.32 (42.30)44.53 (44.02)38.7236.7442.80
Baichuan-13B-Base-1.4T50.51 (51.60)55.73 (55.30)47.2051.4153.60
Baichuan2-7B-Base-2.6T46.97 (54.16)57.67 (57.07)45.7652.6054.00
Baichuan2-13B-Base-2.6T54.84 (59.17)62.62 (61.97)52.0858.2558.10
ChatGLM-6B-1.0T39.67 (40.63)41.17 (-)40.1036.5338.90
ChatGLM2-6B-1.4T44.74 (45.46)49.40 (-)46.3645.4951.70
InternLM-7B-1.6T46.70 (51.00)52.00 (-)44.7761.6452.80
Qwen-7B-2.2T54.29 (56.70)56.03 (58.80)52.4756.4259.60
Llama-2-7B-2.0T44.47 (45.30)32.97 (-)32.6025.46-
Linly-AI/Chinese-LLaMA-2-7B-hfLlama-2-7B1.0T37.4329.9232.0027.57-
wenge-research/yayi-7b-llama2Llama-2-7B-38.5631.5230.9925.95-
ziqingyang/chinese-llama-2-7bLlama-2-7B-33.8634.6934.5225.1834.2
TigerResearch/tigerbot-7b-baseLlama-2-7B0.3T43.7342.0437.6430.61-
LinkSoul/Chinese-Llama-2-7bLlama-2-7B-48.4138.3138.4527.72-
FlagAlpha/Atom-7BLlama-2-7B0.1T49.9641.1039.8333.00-
IDEA-CCNL/Ziya-LLaMA-13B-v1.1Llama-13B0.11T50.2540.9940.0430.54-
Colossal-LLaMA-2-7b-baseLlama-2-7B0.0085T53.0649.8951.4858.8250.2
Colossal-LLaMA-2-13b-baseLlama-2-13B0.025T56.4261.8054.6969.5360.3

ColossalChat

<div align="center"> <a href="https://www.youtube.com/watch?v=HcTiHzApHm0"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/applications/chat/ColossalChat%20YouTube.png" width="700" /> </a> </div>

ColossalChat: An open-source solution for cloning ChatGPT with a complete RLHF pipeline. [code] [blog] [demo] [tutorial]

<p id="ColossalChat-Speed" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/applications/chat/ColossalChat%20Speed.jpg" width=450/> </p> <p id="ColossalChat_scaling" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/applications/chatgpt/ChatGPT%20scaling.png" width=800/> </p> <p id="ColossalChat-1GPU" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/applications/chatgpt/ChatGPT-1GPU.jpg" width=450/> </p> <p id="ColossalChat-LoRA" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/applications/chatgpt/LoRA%20data.jpg" width=600/> </p> <p align="right">(<a href="#top">back to top</a>)</p>

AIGC

Acceleration of AIGC (AI-Generated Content) models such as Stable Diffusion v1 and Stable Diffusion v2.

<p id="diffusion_train" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/Stable%20Diffusion%20v2.png" width=800/> </p> <p id="diffusion_demo" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/DreamBooth.png" width=800/> </p> <p id="inference-sd" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/Stable%20Diffusion%20Inference.jpg" width=800/> </p> <p align="right">(<a href="#top">back to top</a>)</p>

Biomedicine

Acceleration of AlphaFold Protein Structure

<p id="FastFold" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/FastFold.jpg" width=800/> </p> <p id="FastFold-Intel" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/data%20preprocessing%20with%20Intel.jpg" width=600/> </p> <p id="xTrimoMultimer" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/xTrimoMultimer_Table.jpg" width=800/> </p> <p align="right">(<a href="#top">back to top</a>)</p>

Parallel Training Demo

LLaMA3

<p align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/examples/images/LLaMA3-70B-H100.png" width=600/> </p>

LLaMA2

<p align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/llama2_pretraining.png" width=600/> </p>

LLaMA1

<p align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/examples/images/LLaMA_pretraining.png" width=600/> </p>

MoE

<p align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/examples/images/MOE_training.png" width=800/> </p>

GPT-3

<p align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/GPT3-v5.png" width=700/> </p>

GPT-2

<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/GPT2.png" width=800/> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/(updated)GPT-2.png" width=800>

BERT

<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/BERT.png" width=800/>

PaLM

OPT

<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/OPT_update.png" width=800/>

Please visit our documentation and examples for more details.

ViT

<p align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/ViT.png" width="450" /> </p>

Recommendation System Models

<p align="right">(<a href="#top">back to top</a>)</p>

Single GPU Training Demo

GPT-2

<p id="GPT-2-Single" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/GPT2-GPU1.png" width=450/> </p> <p id="GPT-2-NVME" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/GPT2-NVME.png" width=800/> </p>

PaLM

<p id="PaLM-Single" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/PaLM-GPU1.png" width=450/> </p> <p align="right">(<a href="#top">back to top</a>)</p>

Inference

Colossal-Inference

<p align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/inference/colossal-inference-v1-1.png" width=1000/> </p> <p align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/inference/colossal-inference-v1-2.png" width=1000/> </p>

Grok-1

<p id="Grok-1" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/examples/images/grok-1-inference.jpg" width=600/> </p>

[code] [blog] [HuggingFace Grok-1 PyTorch model weights] [ModelScope Grok-1 PyTorch model weights]

SwiftInfer

<p id="SwiftInfer" align="center"> <img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/SwiftInfer.jpg" width=800/> </p> <p align="right">(<a href="#top">back to top</a>)</p>

Installation

Requirements:

If you encounter any problem with installation, you may want to raise an issue in this repository.

Install from PyPI

You can easily install Colossal-AI with the following command. By default, we do not build PyTorch extensions during installation.

pip install colossalai

Note: only Linux is supported for now.

However, if you want to build the PyTorch extensions during installation, you can set BUILD_EXT=1.

BUILD_EXT=1 pip install colossalai

Otherwise, CUDA kernels will be built during runtime when you actually need them.

We also keep releasing the nightly version to PyPI every week. This allows you to access the unreleased features and bug fixes in the main branch. Installation can be made via

pip install colossalai-nightly

Download From Source

The version of Colossal-AI will be in line with the main branch of the repository. Feel free to raise an issue if you encounter any problems. :)

git clone https://github.com/hpcaitech/ColossalAI.git
cd ColossalAI

# install colossalai
pip install .

By default, we do not compile CUDA/C++ kernels. ColossalAI will build them during runtime. If you want to install and enable CUDA kernel fusion (compulsory installation when using fused optimizer):

BUILD_EXT=1 pip install .

For Users with CUDA 10.2, you can still build ColossalAI from source. However, you need to manually download the cub library and copy it to the corresponding directory.

# clone the repository
git clone https://github.com/hpcaitech/ColossalAI.git
cd ColossalAI

# download the cub library
wget https://github.com/NVIDIA/cub/archive/refs/tags/1.8.0.zip
unzip 1.8.0.zip
cp -r cub-1.8.0/cub/ colossalai/kernel/cuda_native/csrc/kernels/include/

# install
BUILD_EXT=1 pip install .
<p align="right">(<a href="#top">back to top</a>)</p>

Use Docker

Pull from DockerHub

You can directly pull the docker image from our DockerHub page. The image is automatically uploaded upon release.

Build On Your Own

Run the following command to build a docker image from Dockerfile provided.

Building Colossal-AI from scratch requires GPU support, you need to use Nvidia Docker Runtime as the default when doing docker build. More details can be found here. We recommend you install Colossal-AI from our project page directly.

cd ColossalAI
docker build -t colossalai ./docker

Run the following command to start the docker container in interactive mode.

docker run -ti --gpus all --rm --ipc=host colossalai bash
<p align="right">(<a href="#top">back to top</a>)</p>

Community

Join the Colossal-AI community on Forum, Slack, and WeChat(微信) to share your suggestions, feedback, and questions with our engineering team.

Contributing

Referring to the successful attempts of BLOOM and Stable Diffusion, any and all developers and partners with computing powers, datasets, models are welcome to join and build the Colossal-AI community, making efforts towards the era of big AI models!

You may contact us or participate in the following ways:

  1. Leaving a Star ⭐ to show your like and support. Thanks!
  2. Posting an issue, or submitting a PR on GitHub follow the guideline in Contributing
  3. Send your official proposal to email contact@hpcaitech.com

Thanks so much to all of our amazing contributors!

<a href="https://github.com/hpcaitech/ColossalAI/graphs/contributors"> <img src="https://contrib.rocks/image?repo=hpcaitech/ColossalAI" width="800px"/> </a> <p align="right">(<a href="#top">back to top</a>)</p>

CI/CD

We leverage the power of GitHub Actions to automate our development, release and deployment workflows. Please check out this documentation on how the automated workflows are operated.

Cite Us

This project is inspired by some related projects (some by our team and some by other organizations). We would like to credit these amazing projects as listed in the Reference List.

To cite this project, you can use the following BibTeX citation.

@inproceedings{10.1145/3605573.3605613,
author = {Li, Shenggui and Liu, Hongxin and Bian, Zhengda and Fang, Jiarui and Huang, Haichen and Liu, Yuliang and Wang, Boxiang and You, Yang},
title = {Colossal-AI: A Unified Deep Learning System For Large-Scale Parallel Training},
year = {2023},
isbn = {9798400708435},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3605573.3605613},
doi = {10.1145/3605573.3605613},
abstract = {The success of Transformer models has pushed the deep learning model scale to billions of parameters, but the memory limitation of a single GPU has led to an urgent need for training on multi-GPU clusters. However, the best practice for choosing the optimal parallel strategy is still lacking, as it requires domain expertise in both deep learning and parallel computing. The Colossal-AI system addressed the above challenge by introducing a unified interface to scale your sequential code of model training to distributed environments. It supports parallel training methods such as data, pipeline, tensor, and sequence parallelism and is integrated with heterogeneous training and zero redundancy optimizer. Compared to the baseline system, Colossal-AI can achieve up to 2.76 times training speedup on large-scale models.},
booktitle = {Proceedings of the 52nd International Conference on Parallel Processing},
pages = {766–775},
numpages = {10},
keywords = {datasets, gaze detection, text tagging, neural networks},
location = {Salt Lake City, UT, USA},
series = {ICPP '23}
}

Colossal-AI has been accepted as official tutorial by top conferences NeurIPS, SC, AAAI, PPoPP, CVPR, ISC, NVIDIA GTC ,etc.

<p align="right">(<a href="#top">back to top</a>)</p>