README.md 2.47 KB
Newer Older
PanZezhong1725's avatar
PanZezhong1725 committed
1
# InfiniLM
PanZezhong's avatar
PanZezhong committed
2
3
4
5
6
7
8

本项目是基于 [`InfiniCore`](https://github.com/InfiniTensor/InfiniCore) 的推理引擎。

## 使用方式

- 编译并安装 `InfiniCore` 。注意根据提示设置好 `INFINI_ROOT` 环境变量(默认为 `$HOME/.infini`)。

PanZezhong1725's avatar
PanZezhong1725 committed
9
- 编译并安装 `InfiniLM`
PanZezhong's avatar
PanZezhong committed
10
11
12
13
14
15
16
17

```bash
xmake && xmake install
```

- 运行模型推理测试

```bash
zhuyue's avatar
zhuyue committed
18
python scripts/jiuge.py [--cpu | --nvidia | --cambricon | --ascend | --metax | --moore | --iluvatar | --kunlun | --hygon] path/to/model_dir [n_device]
PanZezhong's avatar
PanZezhong committed
19
20
21
22
23
```

- 部署模型推理服务

```bash
zhuyue's avatar
zhuyue committed
24
python scripts/launch_server.py --model-path MODEL_PATH [-h] [--dev {cpu,nvidia,cambricon,ascend,metax,moore,iluvatar,kunlun,hygon}] [--ndev NDEV] [--max-batch MAX_BATCH] [--max-tokens MAX_TOKENS]
PanZezhong's avatar
PanZezhong committed
25
26
27
28
29
```

- 测试模型推理服务性能

```bash
30
python scripts/test_perf.py
PanZezhong's avatar
PanZezhong committed
31
32
33
34
35
36
```

- 使用推理服务测试模型困惑度(Perplexity)

```bash
python scripts/test_ppl.py --model-path MODEL_PATH [--ndev NDEV] [--max-batch MAX_BATCH] [--max-tokens MAX_TOKENS]
PanZezhong's avatar
PanZezhong committed
37
```
38
39

## 使用方式(新版)
40
41
#### 一、编译并安装 `InfiniCore`
编译并安装 `InfiniCore`, 详情见 InfiniCore的 [`README`](https://github.com/InfiniTensor/InfiniCore) :
42

43
44
45
46
47
- 注意根据提示设置好 `INFINI_ROOT` 环境变量(默认为 `$HOME/.infini`
- 根据硬件平台,选择 xmake 构建配置
- 编译安装InfiniCore
- 安装 C++ 库
- 安装 Python 包
48

49

50
51
52
53
#### 二、编译并安装  `InfiniLM`
  - 克隆项目
  
    由于仓库中含有子模块,所以在克隆时请添加 `--recursive``--recurse-submodules`,如:
54

55
    ```shell
pengcheng888's avatar
pengcheng888 committed
56
    git clone --recursive https://github.com/InfiniTensor/InfiniLM.git
57
58
59
    ```

    或者在普通克隆后进行更新:
60

61
    ```shell
62
    git submodule update --init --recursive
63
64
    ```

65
66

  - 安装 InfiniLM Python 包
67
68
69
    ```bash
      pip install -e .
    ```
70

71
  - 单次推理测试
72
    - llama示例
73
74
75
76
77
78
79
    ```bash
    python examples/llama.py [--cpu | --nvidia | --metax | --moore | --iluvatar] --model_path=<path/to/model_dir>
    ```
    - 例如:
    ```bash
    python examples/llama.py --nvidia --model_path=/models/TinyLlama-1.1B-Chat-v1.0
    ```
80
81
82
83
84
85
86
87
88
89
  - 分布式推理测试
      - 9g示例
      ```bash
    python examples/jiuge.py [---nvidia] --model_path=<path/to/model_dir> --backend=cpp --tp=NDEV --batch_size=MAX_BATCH 
    ```
    
    - 例如: 9G7B模型,cpp后端,batch_size为16,4卡分布式
    ```bash
    python examples/jiuge.py --nvidia --model_path=/models/9G7B_MHA/ --backend=cpp --tp=4 --batch_size=16 
    ```