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

4
5
   [![logo](https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/Colossal-AI_logo.png)](https://www.colossalai.org/)

binmakeswell's avatar
binmakeswell committed
6
   一个整合高效并行技术的 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-Examples"> 例程 </a> |   
binmakeswell's avatar
binmakeswell committed
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.yml/badge.svg)](https://github.com/hpcaitech/ColossalAI/actions/workflows/build.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
25
26
27


## 目录
<ul>
binmakeswell's avatar
binmakeswell committed
28
 <li><a href="#为何选择-Colossal-AI">为何选择 Colossal-AI</a> </li>
29
30
 <li><a href="#特点">特点</a> </li>
 <li>
31
   <a href="#并行样例展示">并行样例展示</a> 
32
33
34
35
36
   <ul>
     <li><a href="#ViT">ViT</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>
binmakeswell's avatar
binmakeswell committed
37
     <li><a href="#PaLM">PaLM</a></li>
38
39
   </ul>
 </li>
40
41
42
43
44
45
46
<li>
   <a href="#单GPU样例展示">单GPU样例展示</a> 
   <ul>
     <li><a href="#GPT-2-Single">GPT-2</a></li>
     <li><a href="#PaLM-Single">PaLM</a></li>
   </ul>
 </li>
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

 <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>
     <li><a href="#几行代码开启分布式训练">几行代码开启分布式训练</a></li>
     <li><a href="#构建一个简单的2维并行模型">构建一个简单的2维并行模型</a></li>
   </ul>
 <li><a href="#引用我们">引用我们</a></li>
</ul>
binmakeswell's avatar
binmakeswell committed
65

binmakeswell's avatar
binmakeswell committed
66
67
68
69
70
71
72
73
74
75
76
## 为何选择 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
77
78
## 特点

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

binmakeswell's avatar
binmakeswell committed
81
82
83
84
85
- 并行化策略
  - 数据并行
  - 流水线并行
  - 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
86
  - [零冗余优化器 (ZeRO)](https://arxiv.org/abs/1910.02054)
binmakeswell's avatar
binmakeswell committed
87
88
89
90
- 异构内存管理
  - [PatrickStar](https://arxiv.org/abs/2108.05818)
- 使用友好
  - 基于参数文件的并行化
91
92
<p align="right">(<a href="#top">返回顶端</a>)</p>

93
## 并行样例展示
binmakeswell's avatar
binmakeswell committed
94
### ViT
binmakeswell's avatar
binmakeswell committed
95
<p align="center">
96
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/ViT.png" width="450" />
binmakeswell's avatar
binmakeswell committed
97
</p>
98

99
- 14倍批大小和5倍训练速度(张量并行=64)
binmakeswell's avatar
binmakeswell committed
100

101
### GPT-3
binmakeswell's avatar
binmakeswell committed
102
<p align="center">
103
<img src="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/GPT3.png" width=700/>
binmakeswell's avatar
binmakeswell committed
104
</p>
binmakeswell's avatar
binmakeswell committed
105

106
- 释放 50% GPU 资源占用, 或 10.7% 加速
107
108

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

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

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

Sze-qq's avatar
Sze-qq committed
115
116
- 用相同的硬件条件训练24倍大的模型
- 超3倍的吞吐量 
binmakeswell's avatar
binmakeswell committed
117
118

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

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

binmakeswell's avatar
binmakeswell committed
123
124
125
### 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
126
127
请访问我们的[文档和教程](https://www.colossalai.org/)以了解详情。

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

130
## 单GPU样例展示
binmakeswell's avatar
binmakeswell committed
131

132
133
134
135
### 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
136

137
- 用相同的硬件条件训练20倍大的模型
binmakeswell's avatar
binmakeswell committed
138

139
140
141
142
### 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
143

144
145
146
147
148
149
150
- 用相同的硬件条件训练34倍大的模型

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

## 安装

### 从官方安装
binmakeswell's avatar
binmakeswell committed
151

binmakeswell's avatar
binmakeswell committed
152
您可以访问我们[下载](https://www.colossalai.org/download)页面来安装Colossal-AI,在这个页面上发布的版本都预编译了CUDA扩展。
binmakeswell's avatar
binmakeswell committed
153

154
155
156
### 从源安装

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

```shell
git clone https://github.com/hpcaitech/ColossalAI.git
cd ColossalAI
161
162

# install dependency
binmakeswell's avatar
binmakeswell committed
163
164
pip install -r requirements/requirements.txt

165
# install colossalai
binmakeswell's avatar
binmakeswell committed
166
167
168
pip install .
```

169
如果您不想安装和启用 CUDA 内核融合(使用融合优化器时强制安装):
binmakeswell's avatar
binmakeswell committed
170
171

```shell
172
NO_CUDA_EXT=1 pip install .
binmakeswell's avatar
binmakeswell committed
173
174
```

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

binmakeswell's avatar
binmakeswell committed
177
178
## 使用 Docker

binmakeswell's avatar
binmakeswell committed
179
运行以下命令从我们提供的 docker 文件中建立 docker 镜像。
binmakeswell's avatar
binmakeswell committed
180
181
182
183
184
185

```bash
cd ColossalAI
docker build -t colossalai ./docker
```

binmakeswell's avatar
binmakeswell committed
186
运行以下命令从以交互式启动 docker 镜像.
binmakeswell's avatar
binmakeswell committed
187
188
189
190
191

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

192
<p align="right">(<a href="#top">返回顶端</a>)</p>
binmakeswell's avatar
binmakeswell committed
193
194
195
196

## 社区
欢迎通过[论坛](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
197
[微信](https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/WeChat.png "qrcode")加入 Colossal-AI 社区,与我们分享你的建议和问题。
binmakeswell's avatar
binmakeswell committed
198
199


binmakeswell's avatar
binmakeswell committed
200
201
202
203
## 做出贡献

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

binmakeswell's avatar
binmakeswell committed
204
205
206
207
208
209
真诚感谢所有贡献者!

<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>

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

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

## 快速预览

214
### 几行代码开启分布式训练
binmakeswell's avatar
binmakeswell committed
215
216

```python
217
218
219
parallel = dict(
    pipeline=2,
    tensor=dict(mode='2.5d', depth = 1, size=4)
binmakeswell's avatar
binmakeswell committed
220
221
222
)
```

223
### 几行代码开启异构训练
binmakeswell's avatar
binmakeswell committed
224
225

```python
226
227
228
229
230
231
232
233
zero = dict(
    model_config=dict(
        tensor_placement_policy='auto',
        shard_strategy=TensorShardStrategy(),
        reuse_fp16_shard=True
    ),
    optimizer_config=dict(initial_scale=2**5, gpu_margin_mem_ratio=0.2)
)
binmakeswell's avatar
binmakeswell committed
234
235
```

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

238
## 引用我们
binmakeswell's avatar
binmakeswell committed
239
240
241
242
243
244
245
246
247

```
@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}
}
```
248

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