README-zh-Hans.md 15 KB
Newer Older
binmakeswell's avatar
binmakeswell committed
1
# Colossal-AI
2
<div id="top" align="center">
binmakeswell's avatar
binmakeswell committed
3

Sze-qq's avatar
Sze-qq committed
4
   [![logo](https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/colossal-ai_logo_vertical.png)](https://www.colossalai.org/)
5

binmakeswell's avatar
binmakeswell committed
6
   Colossal-AI: 一个面向大模型时代的通用深度学习系统
binmakeswell's avatar
binmakeswell committed
7

8
9
   <h3> <a href="https://arxiv.org/abs/2110.14883"> 论文 </a> |
   <a href="https://www.colossalai.org/"> 文档 </a> |
10
   <a href="https://github.com/hpcaitech/ColossalAI/tree/main/examples"> 例程 </a> |
11
   <a href="https://github.com/hpcaitech/ColossalAI/discussions"> 论坛 </a> |
12
   <a href="https://medium.com/@hpcaitech"> 博客 </a></h3>
binmakeswell's avatar
binmakeswell committed
13

Frank Lee's avatar
Frank Lee committed
14
   [![Build](https://github.com/hpcaitech/ColossalAI/actions/workflows/build_on_schedule.yml/badge.svg)](https://github.com/hpcaitech/ColossalAI/actions/workflows/build_on_schedule.yml)
binmakeswell's avatar
binmakeswell committed
15
   [![Documentation](https://readthedocs.org/projects/colossalai/badge/?version=latest)](https://colossalai.readthedocs.io/en/latest/?badge=latest)
16
   [![CodeFactor](https://www.codefactor.io/repository/github/hpcaitech/colossalai/badge)](https://www.codefactor.io/repository/github/hpcaitech/colossalai)
Frank Lee's avatar
Frank Lee committed
17
   [![HuggingFace badge](https://img.shields.io/badge/%F0%9F%A4%97HuggingFace-Join-yellow)](https://huggingface.co/hpcai-tech)
binmakeswell's avatar
binmakeswell committed
18
   [![slack badge](https://img.shields.io/badge/Slack-join-blueviolet?logo=slack&amp)](https://join.slack.com/t/colossalaiworkspace/shared_invite/zt-z7b26eeb-CBp7jouvu~r0~lcFzX832w)
19
   [![WeChat badge](https://img.shields.io/badge/微信-加入-green?logo=wechat&amp)](https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/WeChat.png)
binmakeswell's avatar
binmakeswell committed
20
21

   | [English](README.md) | [中文](README-zh-Hans.md) |
22

binmakeswell's avatar
binmakeswell committed
23
</div>
24

binmakeswell's avatar
binmakeswell committed
25
## 新闻
binmakeswell's avatar
binmakeswell committed
26
* [2023/01] [Hardware Savings Up to 46 Times for AIGC and  Automatic Parallelism](https://www.hpc-ai.tech/blog/colossal-ai-0-2-0)
binmakeswell's avatar
binmakeswell committed
27
28
29
30
* [2022/11] [Diffusion Pretraining and Hardware Fine-Tuning Can Be Almost 7X Cheaper](https://www.hpc-ai.tech/blog/diffusion-pretraining-and-hardware-fine-tuning-can-be-almost-7x-cheaper)
* [2022/10] [Use a Laptop to Analyze 90% of Proteins, With a Single-GPU Inference Sequence Exceeding 10,000](https://www.hpc-ai.tech/blog/use-a-laptop-to-analyze-90-of-proteins-with-a-single-gpu-inference-sequence-exceeding)
* [2022/10] [Embedding Training With 1% GPU Memory and 100 Times Less Budget for Super-Large Recommendation Model](https://www.hpc-ai.tech/blog/embedding-training-with-1-gpu-memory-and-10-times-less-budget-an-open-source-solution-for)
* [2022/09] [HPC-AI Tech Completes $6 Million Seed and Angel Round Fundraising](https://www.hpc-ai.tech/blog/hpc-ai-tech-completes-6-million-seed-and-angel-round-fundraising-led-by-bluerun-ventures-in-the)
binmakeswell's avatar
binmakeswell committed
31

32
33
34

## 目录
<ul>
binmakeswell's avatar
binmakeswell committed
35
 <li><a href="#为何选择-Colossal-AI">为何选择 Colossal-AI</a> </li>
36
37
 <li><a href="#特点">特点</a> </li>
 <li>
38
   <a href="#并行训练样例展示">并行训练样例展示</a>
39
40
41
42
   <ul>
     <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>
binmakeswell's avatar
binmakeswell committed
43
     <li><a href="#PaLM">PaLM</a></li>
binmakeswell's avatar
binmakeswell committed
44
     <li><a href="#OPT">OPT</a></li>
45
     <li><a href="#ViT">ViT</a></li>
46
     <li><a href="#推荐系统模型">推荐系统模型</a></li>
47
48
   </ul>
 </li>
49
<li>
50
   <a href="#单GPU训练样例展示">单GPU训练样例展示</a>
51
52
53
54
55
   <ul>
     <li><a href="#GPT-2-Single">GPT-2</a></li>
     <li><a href="#PaLM-Single">PaLM</a></li>
   </ul>
 </li>
binmakeswell's avatar
binmakeswell committed
56
<li>
57
   <a href="#推理-Energon-AI-样例展示">推理 (Energon-AI) 样例展示</a>
binmakeswell's avatar
binmakeswell committed
58
59
   <ul>
     <li><a href="#GPT-3-Inference">GPT-3</a></li>
binmakeswell's avatar
binmakeswell committed
60
     <li><a href="#OPT-Serving">1750亿参数OPT在线推理服务</a></li>
binmakeswell's avatar
binmakeswell committed
61
     <li><a href="#BLOOM-Inference">1760亿参数 BLOOM</a></li>
binmakeswell's avatar
binmakeswell committed
62
63
   </ul>
 </li>
64
<li>
65
   <a href="#Colossal-AI-in-the-Real-World">Colossal-AI 成功案例</a>
66
   <ul>
binmakeswell's avatar
binmakeswell committed
67
     <li><a href="#AIGC">AIGC: 加速 Stable Diffusion</a></li>
binmakeswell's avatar
binmakeswell committed
68
     <li><a href="#生物医药">生物医药: 加速AlphaFold蛋白质结构预测</a></li>
69
70
   </ul>
 </li>
71
72
73
74
75
76
77
78
79
80
81
82
 <li>
   <a href="#安装">安装</a>
   <ul>
     <li><a href="#PyPI">PyPI</a></li>
     <li><a href="#从源代码安装">从源代码安装</a></li>
   </ul>
 </li>
 <li><a href="#使用-Docker">使用 Docker</a></li>
 <li><a href="#社区">社区</a></li>
 <li><a href="#做出贡献">做出贡献</a></li>
 <li><a href="#引用我们">引用我们</a></li>
</ul>
binmakeswell's avatar
binmakeswell committed
83

binmakeswell's avatar
binmakeswell committed
84
85
86
87
88
89
90
91
92
93
94
## 为何选择 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>

   James Demmel 教授 (加州大学伯克利分校): Colossal-AI 让分布式训练高效、易用、可扩展。
</div>

<p align="right">(<a href="#top">返回顶端</a>)</p>

binmakeswell's avatar
binmakeswell committed
95
96
## 特点

binmakeswell's avatar
binmakeswell committed
97
Colossal-AI 为您提供了一系列并行组件。我们的目标是让您的分布式 AI 模型像构建普通的单 GPU 模型一样简单。我们提供的友好工具可以让您在几行代码内快速开始分布式训练和推理。
binmakeswell's avatar
binmakeswell committed
98

binmakeswell's avatar
binmakeswell committed
99
100
101
102
103
- 并行化策略
  - 数据并行
  - 流水线并行
  - 1维, [2维](https://arxiv.org/abs/2104.05343), [2.5维](https://arxiv.org/abs/2105.14500), [3维](https://arxiv.org/abs/2105.14450) 张量并行
  - [序列并行](https://arxiv.org/abs/2105.13120)
binmakeswell's avatar
binmakeswell committed
104
  - [零冗余优化器 (ZeRO)](https://arxiv.org/abs/1910.02054)
105
  - [自动并行](https://github.com/hpcaitech/ColossalAI/tree/main/examples/language/gpt/auto_parallel_with_gpt)
binmakeswell's avatar
binmakeswell committed
106
107
108
109
- 异构内存管理
  - [PatrickStar](https://arxiv.org/abs/2108.05818)
- 使用友好
  - 基于参数文件的并行化
binmakeswell's avatar
binmakeswell committed
110
111
- 推理
  - [Energon-AI](https://github.com/hpcaitech/EnergonAI)
112

113
114
<p align="right">(<a href="#top">返回顶端</a>)</p>

binmakeswell's avatar
binmakeswell committed
115
## 并行训练样例展示
116

binmakeswell's avatar
binmakeswell committed
117

118
### GPT-3
binmakeswell's avatar
binmakeswell committed
119
<p align="center">
Sze-qq's avatar
Sze-qq committed
120
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/GPT3-v5.png" width=700/>
binmakeswell's avatar
binmakeswell committed
121
</p>
binmakeswell's avatar
binmakeswell committed
122

123
- 释放 50% GPU 资源占用, 或 10.7% 加速
124
125

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

binmakeswell's avatar
binmakeswell committed
128
- 降低11倍 GPU 显存占用,或超线性扩展(张量并行)
129

Sze-qq's avatar
Sze-qq committed
130
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/(updated)GPT-2.png" width=800>
131

binmakeswell's avatar
binmakeswell committed
132
- 用相同的硬件训练24倍大的模型
133
- 超3倍的吞吐量
binmakeswell's avatar
binmakeswell committed
134
135

### BERT
136
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/BERT.png" width=800/>
binmakeswell's avatar
binmakeswell committed
137

138
- 2倍训练速度,或1.5倍序列长度
binmakeswell's avatar
binmakeswell committed
139

binmakeswell's avatar
binmakeswell committed
140
141
142
### PaLM
- [PaLM-colossalai](https://github.com/hpcaitech/PaLM-colossalai): 可扩展的谷歌 Pathways Language Model ([PaLM](https://ai.googleblog.com/2022/04/pathways-language-model-palm-scaling-to.html)) 实现。

binmakeswell's avatar
binmakeswell committed
143
### OPT
144
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/OPT_update.png" width=800/>
binmakeswell's avatar
binmakeswell committed
145
146

- [Open Pretrained Transformer (OPT)](https://github.com/facebookresearch/metaseq), 由Meta发布的1750亿语言模型,由于完全公开了预训练参数权重,因此促进了下游任务和应用部署的发展。
147
- 加速45%,仅用几行代码以低成本微调OPT。[[样例]](https://github.com/hpcaitech/ColossalAI-Examples/tree/main/language/opt) [[在线推理]](https://github.com/hpcaitech/ColossalAI-Documentation/blob/main/i18n/zh-Hans/docusaurus-plugin-content-docs/current/advanced_tutorials/opt_service.md)
binmakeswell's avatar
binmakeswell committed
148
149

请访问我们的 [文档](https://www.colossalai.org/)[例程](https://github.com/hpcaitech/ColossalAI-Examples) 以了解详情。
binmakeswell's avatar
binmakeswell committed
150

151
152
153
154
155
156
### ViT
<p align="center">
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/ViT.png" width="450" />
</p>

- 14倍批大小和5倍训练速度(张量并行=64)
157
158

### 推荐系统模型
159
- [Cached Embedding](https://github.com/hpcaitech/CachedEmbedding), 使用软件Cache实现Embeddings,用更少GPU显存训练更大的模型。
160
161


162
<p align="right">(<a href="#top">返回顶端</a>)</p>
binmakeswell's avatar
binmakeswell committed
163

binmakeswell's avatar
binmakeswell committed
164
## 单GPU训练样例展示
binmakeswell's avatar
binmakeswell committed
165

166
167
168
169
### 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>
binmakeswell's avatar
binmakeswell committed
170

binmakeswell's avatar
binmakeswell committed
171
- 用相同的硬件训练20倍大的模型
binmakeswell's avatar
binmakeswell committed
172

Jiarui Fang's avatar
Jiarui Fang committed
173
174
175
176
177
178
<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>

- 用相同的硬件训练120倍大的模型 (RTX 3080)

179
180
181
182
### 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>
binmakeswell's avatar
binmakeswell committed
183

binmakeswell's avatar
binmakeswell committed
184
185
- 用相同的硬件训练34倍大的模型

binmakeswell's avatar
binmakeswell committed
186
<p align="right">(<a href="#top">返回顶端</a>)</p>
binmakeswell's avatar
binmakeswell committed
187
188


binmakeswell's avatar
binmakeswell committed
189
## 推理 (Energon-AI) 样例展示
binmakeswell's avatar
binmakeswell committed
190
191
192
193
194
195

<p id="GPT-3-Inference" align="center">
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/inference_GPT-3.jpg" width=800/>
</p>

- [Energon-AI](https://github.com/hpcaitech/EnergonAI) :用相同的硬件推理加速50%
196

binmakeswell's avatar
binmakeswell committed
197
198
199
200
<p id="OPT-Serving" align="center">
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/OPT_serving.png" width=800/>
</p>

201
- [OPT推理服务](https://github.com/hpcaitech/ColossalAI-Documentation/blob/main/i18n/zh-Hans/docusaurus-plugin-content-docs/current/advanced_tutorials/opt_service.md): 无需注册,免费体验1750亿参数OPT在线推理服务
binmakeswell's avatar
binmakeswell committed
202

203
204
205
206
<p id="BLOOM-Inference" align="center">
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/BLOOM%20Inference.PNG" width=800/>
</p>

binmakeswell's avatar
binmakeswell committed
207
- [BLOOM](https://github.com/hpcaitech/EnergonAI/tree/main/examples/bloom): 降低1760亿参数BLOOM模型部署推理成本超10倍
binmakeswell's avatar
binmakeswell committed
208

binmakeswell's avatar
binmakeswell committed
209
<p align="right">(<a href="#top">返回顶端</a>)</p>
210

211
## Colossal-AI 成功案例
binmakeswell's avatar
binmakeswell committed
212
213

### AIGC
214
215
加速AIGC(AI内容生成)模型,如[Stable Diffusion v1](https://github.com/CompVis/stable-diffusion)[Stable Diffusion v2](https://github.com/Stability-AI/stablediffusion)

binmakeswell's avatar
binmakeswell committed
216
<p id="diffusion_train" align="center">
217
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/Stable%20Diffusion%20v2.png" width=800/>
binmakeswell's avatar
binmakeswell committed
218
219
</p>

220
- [训练](https://github.com/hpcaitech/ColossalAI/tree/main/examples/images/diffusion): 减少5.6倍显存消耗,硬件成本最高降低46倍(从A100到RTX3060)
binmakeswell's avatar
binmakeswell committed
221
222

<p id="diffusion_demo" align="center">
223
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/DreamBooth.png" width=800/>
binmakeswell's avatar
binmakeswell committed
224
225
</p>

226
- [DreamBooth微调](https://github.com/hpcaitech/ColossalAI/tree/main/examples/images/dreambooth): 仅需3-5张目标主题图像个性化微调
227
228
229
230
231

<p id="inference" align="center">
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/Stable%20Diffusion%20Inference.jpg" width=800/>
</p>

232
- [推理](https://github.com/hpcaitech/ColossalAI/tree/main/examples/images/diffusion): GPU推理显存消耗降低2.5倍
233
234


binmakeswell's avatar
binmakeswell committed
235
236
<p align="right">(<a href="#top">返回顶端</a>)</p>

binmakeswell's avatar
binmakeswell committed
237
238
239
240
241
242
243
244
245
### 生物医药

加速 [AlphaFold](https://alphafold.ebi.ac.uk/) 蛋白质结构预测

<p id="FastFold" align="center">
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/FastFold.jpg" width=800/>
</p>

- [FastFold](https://github.com/hpcaitech/FastFold): 加速AlphaFold训练与推理、数据前处理、推理序列长度超过10000残基
246
247
248
249
250
251

<p id="xTrimoMultimer" align="center">
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/xTrimoMultimer_Table.jpg" width=800/>
</p>

- [xTrimoMultimer](https://github.com/biomap-research/xTrimoMultimer): 11倍加速蛋白质单体与复合物结构预测
binmakeswell's avatar
binmakeswell committed
252

binmakeswell's avatar
binmakeswell committed
253
<p align="right">(<a href="#top">返回顶端</a>)</p>
binmakeswell's avatar
binmakeswell committed
254

255
256
## 安装

257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
### 从PyPI安装

您可以用下面的命令直接从PyPI上下载并安装Colossal-AI。我们默认不会安装PyTorch扩展包

```bash
pip install colossalai
```

但是,如果你想在安装时就直接构建PyTorch扩展,您可以设置环境变量`CUDA_EXT=1`.

```bash
CUDA_EXT=1 pip install colossalai
```

**否则,PyTorch扩展只会在你实际需要使用他们时在运行时里被构建。**

与此同时,我们也每周定时发布Nightly版本,这能让你提前体验到新的feature和bug fix。你可以通过以下命令安装Nightly版本。

```bash
pip install colossalai-nightly
```

279
### 从源码安装
280
281

> 此文档将与版本库的主分支保持一致。如果您遇到任何问题,欢迎给我们提 issue :)
binmakeswell's avatar
binmakeswell committed
282
283
284
285

```shell
git clone https://github.com/hpcaitech/ColossalAI.git
cd ColossalAI
286
287

# install dependency
binmakeswell's avatar
binmakeswell committed
288
289
pip install -r requirements/requirements.txt

290
# install colossalai
binmakeswell's avatar
binmakeswell committed
291
292
293
pip install .
```

294
我们默认在`pip install`时不安装PyTorch扩展,而是在运行时临时编译,如果你想要提前安装这些扩展的话(在使用融合优化器时会用到),可以使用一下命令。
binmakeswell's avatar
binmakeswell committed
295
296

```shell
297
CUDA_EXT=1 pip install .
binmakeswell's avatar
binmakeswell committed
298
299
```

300
301
<p align="right">(<a href="#top">返回顶端</a>)</p>

binmakeswell's avatar
binmakeswell committed
302
303
## 使用 Docker

304
305
306
307
308
309
### 从DockerHub获取镜像

您可以直接从我们的[DockerHub主页](https://hub.docker.com/r/hpcaitech/colossalai)获取最新的镜像,每一次发布我们都会自动上传最新的镜像。

### 本地构建镜像

binmakeswell's avatar
binmakeswell committed
310
运行以下命令从我们提供的 docker 文件中建立 docker 镜像。
binmakeswell's avatar
binmakeswell committed
311

312
313
314
> 在Dockerfile里编译Colossal-AI需要有GPU支持,您需要将Nvidia Docker Runtime设置为默认的Runtime。更多信息可以点击[这里](https://stackoverflow.com/questions/59691207/docker-build-with-nvidia-runtime)。
> 我们推荐从[项目主页](https://www.colossalai.org)直接下载Colossal-AI.

binmakeswell's avatar
binmakeswell committed
315
316
317
318
319
```bash
cd ColossalAI
docker build -t colossalai ./docker
```

binmakeswell's avatar
binmakeswell committed
320
运行以下命令从以交互式启动 docker 镜像.
binmakeswell's avatar
binmakeswell committed
321
322
323
324
325

```bash
docker run -ti --gpus all --rm --ipc=host colossalai bash
```

326
<p align="right">(<a href="#top">返回顶端</a>)</p>
binmakeswell's avatar
binmakeswell committed
327
328
329
330

## 社区
欢迎通过[论坛](https://github.com/hpcaitech/ColossalAI/discussions),
[Slack](https://join.slack.com/t/colossalaiworkspace/shared_invite/zt-z7b26eeb-CBp7jouvu~r0~lcFzX832w),
binmakeswell's avatar
binmakeswell committed
331
[微信](https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/WeChat.png "qrcode")加入 Colossal-AI 社区,与我们分享你的建议和问题。
binmakeswell's avatar
binmakeswell committed
332
333


binmakeswell's avatar
binmakeswell committed
334
335
336
337
## 做出贡献

欢迎为该项目做出贡献,请参阅[贡献指南](./CONTRIBUTING.md)

binmakeswell's avatar
binmakeswell committed
338
339
340
341
342
343
真诚感谢所有贡献者!

<a href="https://github.com/hpcaitech/ColossalAI/graphs/contributors"><img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/contributor_avatar.png" width="800px"></a>

*贡献者头像的展示顺序是随机的。*

344
<p align="right">(<a href="#top">返回顶端</a>)</p>
binmakeswell's avatar
binmakeswell committed
345
346


347
348
349
350
351
## CI/CD

我们使用[GitHub Actions](https://github.com/features/actions)来自动化大部分开发以及部署流程。如果想了解这些工作流是如何运行的,请查看这个[文档](.github/workflows/README.md).


352
## 引用我们
binmakeswell's avatar
binmakeswell committed
353
354
355
356
357
358
359
360
361

```
@article{bian2021colossal,
  title={Colossal-AI: A Unified Deep Learning System For Large-Scale Parallel Training},
  author={Bian, Zhengda and Liu, Hongxin and Wang, Boxiang and Huang, Haichen and Li, Yongbin and Wang, Chuanrui and Cui, Fan and You, Yang},
  journal={arXiv preprint arXiv:2110.14883},
  year={2021}
}
```
362

363
364
Colossal-AI 已被 [SC](https://sc22.supercomputing.org/), [AAAI](https://aaai.org/Conferences/AAAI-23/), [PPoPP](https://ppopp23.sigplan.org/) 等顶级会议录取为官方教程。

binmakeswell's avatar
binmakeswell committed
365
<p align="right">(<a href="#top">返回顶端</a>)</p>