Skip to content

Commit 50efa07

Browse files
authored
docs: Update readme (#91)
update README
1 parent 13da12b commit 50efa07

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
# DeepLinkExt
2+
该仓库用于在国产硬件适配大型模型训练和推理框架时,解决Torch尚不支持部分扩展算子的问题,如flash_attention和rms_norm。如果有相应的DIOPI实现,将直接采用;否则,将这些算子fallback为一系列小算子的组合来实现。
23

3-
基本思想仿照 cpp extension,不过会先在 python 层判断该融合算子的 diopi 实现没有(具体判断方法为,在 cpp 层进行 pybind 时,如果没有 diopi 实现,则不进行 pybind)。如果没有实现,则会在 python 层替换为 torch 的几个分离算子。
4-
5-
融合算子的 diopi 定义及实现放在 DIOPI 库里,本拓展库仅引用。
6-
7-
支持自动 patch InternLM 和 LightLLM 中用到的融合算子,将它们替换为 DIOPI 实现。
4+
DIOPI的具体内容请参考[DIOPI INTRODUCTION](https://deeplink.readthedocs.io/zh-cn/latest/doc/DIOPI/Introduction.html)
5+
目前支持的框架以及对应的算子可以查看[DeepLink/deeplink_ext](https://github.com/DeepLink-org/DeepLinkExt/tree/main/deeplink_ext).
86

97
## Install
8+
DeepLinkExt依赖deeplink.framework/dipu,需要先完成dipu的编译安装,具体请参考[dipu quick_start](https://deeplink.readthedocs.io/zh-cn/latest/doc/DIPU/quick_start.html)
9+
完成dipu的编译后,请参考如下代码,设置必要的环境变量。
10+
```bash
11+
export PYTHONPATH=$WORKDIR/deeplink.framework/dipu/:$PYTHONPATH
12+
export DIPU_ROOT=$WORKDIR/deeplink.framework/dipu/torch_dipu
13+
export DIOPI_PATH=$WORKDIR/deeplink.framework/dipu/third_party/DIOPI/proto
14+
export VENDOR_INCLUDE_DIRS=${PATH_TO_VENDOR_INCLUDE} # 底层软件栈的include路径,例如/usr/local/Ascend/ascend-toolkit/latest/include
15+
```
1016

11-
首先安装 DIPU,确保可以 `import torch_dipu`。然后在本目录下执行
12-
17+
完成上述准备工作后,使用如下命令即可安装DeepLinkExt
1318
```bash
19+
cd $WORKDIR/DeepLinkExt
1420
pip install -e .
1521
```
1622

1723
## Usage
18-
24+
以InternEvo、LightLLM大模型训练框架为例,参考如下代码,即可实现在训练/推理时使用DeepLinkExt的扩展算子。
1925
### InternEvo
20-
21-
适配版本 https://github.com/DeepLink-org/InternEvo/tree/deeplinkext
22-
23-
```python
24-
import deeplink_ext.patch_internlm
25-
import internlm
26-
```
27-
26+
DeepLinkExt已完全接入InternEvo,在完成DeepLinkExt的编译安装后,将其添加到PYTHONPATH,使用InternEvo进行训练即可。
2827
### LightLLM
29-
28+
对于LightLLM,在启动推理的脚本中,需要添加如下代码,即可实现使用DeepLinkExt扩展算子。
3029
```python
31-
import deeplink_ext.patch_lightllm
30+
import deeplink_ext.patch_lightllm.py
3231
import lightllm
33-
```
32+
```

0 commit comments

Comments
 (0)