README.md 5.65 KB
Newer Older
chenych's avatar
chenych committed
1
2
3
4
# DeepSeek-V3.2-Exp
## 论文
[DeepSeek_V3.2](./DeepSeek_V3_2.pdf)

chenych's avatar
chenych committed
5
6
7
## 模型简介
DeepSeek-V3.2-Exp模型是一个实验版本,作为迈向下一代架构的中间步骤,V3.2-Exp 在 V3.1-Terminus 的基础上引入了 DeepSeek 稀疏注意力机制,DeepSeek 稀疏注意力机制(DSA)首次实现了细粒度的稀疏注意力,在保持几乎相同的模型输出质量的同时,显著提高了长上下文训练和推理效率。

chenych's avatar
chenych committed
8
这个实验版本代表了deepseek团队对更高效变压器架构的持续研究,特别关注在处理扩展文本序列时提高计算效率。
chenych's avatar
chenych committed
9

chenych's avatar
chenych committed
10
11
12
<div align=center>
    <img src="./doc/arch.png"/>
</div>
chenych's avatar
chenych committed
13

chenych's avatar
chenych committed
14
15
16
17
18
19
20
21
## 环境依赖
| 软件 | 版本 |
| :------: | :------: |
| DTK | 26.04 |
| python | 3.10.12 |
| transformers | 4.57.6 |
| vllm | 0.11.0+das.opt1.rc2.dtk2604.20260128.g0bf89b0c |
| torch | 2.5.1+das.opt1.dtk2604.20260116.g78471bfd |
chenych's avatar
chenych committed
22

chenych's avatar
chenych committed
23
推荐使用镜像: harbor.sourcefind.cn:5443/dcu/admin/base/vllm:0.11.0-ubuntu22.04-dtk26.04-py3.10
chenych's avatar
chenych committed
24

chenych's avatar
chenych committed
25
- 挂载地址`-v` 根据实际模型情况修改
chenych's avatar
chenych committed
26
```bash
chenych's avatar
chenych committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
docker run -it \
    --shm-size 200g \
    --network=host \
    --name deepseek-v32 \
    --privileged \
    --device=/dev/kfd \
    --device=/dev/dri \
    --device=/dev/mkfd \
    --group-add video \
    --cap-add=SYS_PTRACE \
    --security-opt seccomp=unconfined \
    -u root \
    -v /opt/hyhal/:/opt/hyhal/:ro \
    -v /path/your_code_data/:/path/your_code_data/ \
    harbor.sourcefind.cn:5443/dcu/admin/base/vllm:0.11.0-ubuntu22.04-dtk26.04-py3.10 bash
chenych's avatar
chenych committed
42
```
chenych's avatar
chenych committed
43
更多镜像可前往[光源](https://sourcefind.cn/#/service-list)下载使用。
chenych's avatar
chenych committed
44
45
46
47
48
49
50
51
52
53

关于本项目DCU显卡所需的特殊深度学习库可从[光合](https://developer.sourcefind.cn/tool/)开发者社区下载安装。

## 数据集


## 训练
暂无

## 推理
chenych's avatar
chenych committed
54
55
样例模型:[DeepSeek-V3.2-Exp](https://huggingface.co/deepseek-ai/DeepSeek-V3.2-Exp)

chenych's avatar
chenych committed
56
首先将模型转换成bf16格式,转换命令如下:
chenych's avatar
chenych committed
57
58
```bash
# fp8转bf16
chenych's avatar
chenych committed
59
python inference/fp8_cast_bf16.py --input-fp8-hf-path /path/to/DeepSeek-V3.2-Exp --output-bf16-hf-path /path/to/DeepSeek-V3.2-Exp-bf16
chenych's avatar
chenych committed
60
61
# 拷贝config文件
cp inference/config.json /path/to/DeepSeek-V3.2-Exp-bf16
chenych's avatar
chenych committed
62
```
chenych's avatar
chenych committed
63
转换完成后,将原模型中的 `generation_config.json`, `tokenizer_config.json`, `tokenizer.json`拷贝到`/path/to/DeepSeek-V3.2-Exp-bf16`中。
chenych's avatar
chenych committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

### vllm推理方法
#### server 多机
1. 加入环境变量
> 请注意:
> 每个节点上的环境变量都写到.sh文件中,保存后各个计算节点分别source `.sh` 文件
>
> VLLM_HOST_IP:节点本地通信口ip,尽量选择IB网卡的IP,**避免出现rccl超时问题**
>
> NCCL_SOCKET_IFNAME和GLOO_SOCKET_IFNAME:节点本地通信网口ip对应的名称
>
> 通信口和ip查询方法:ifconfig
>
> IB口状态查询:ibstat  !!!一定要active激活状态才可用,各个节点要保持统一

<div align=center>
    <img src="./doc/ip_bw.png"/>
</div>

```bash
export ALLREDUCE_STREAM_WITH_COMPUTE=1
export VLLM_HOST_IP=x.x.x.x # 对应计算节点的IP,建议选择IB口SOCKET_IFNAME对应IP地址
chenych's avatar
chenych committed
86
87
export HIP_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HSA_FORCE_FINE_GRAIN_PCIE=1
chenych's avatar
chenych committed
88
89
export NCCL_SOCKET_IFNAME=ibxxxx
export GLOO_SOCKET_IFNAME=ibxxxx
chenych's avatar
chenych committed
90
export NCCL_IB_HCA=mlx5_0:1
chenych's avatar
chenych committed
91
unset NCCL_ALGO
chenych's avatar
chenych committed
92
export NCCL_IB_DISABLE=0
chenych's avatar
chenych committed
93
export NCCL_MAX_NCHANNELS=16
chenych's avatar
chenych committed
94
export NCCL_MIN_NCHANNELS=16
chenych's avatar
chenych committed
95
export NCCL_NET_GDR_READ=1
chenych's avatar
chenych committed
96
97
98
99
100
101
102
103
export NCCL_DEBUG=INFO
export NCCL_MIN_P2P_NCHANNELS=16
export NCCL_NCHANNELS_PER_PEER=16
export HIP_USE_GRAPH_QUEUE_POOL=1
export VLLM_ENABLE_MOE_FUSED_GATE=0
export VLLM_ENFORCE_EAGER_BS_THRESHOLD=44
export VLLM_RPC_TIMEOUT=1800000
export VLLM_USE_FLASH_MLA=1
chenych's avatar
chenych committed
104

chenych's avatar
chenych committed
105
# 海光CPU绑定核,intel cpu可不加
chenych's avatar
chenych committed
106
107
108
109
110
111
112
113
114
export VLLM_NUMA_BIND=1
export VLLM_RANK0_NUMA=0
export VLLM_RANK1_NUMA=1
export VLLM_RANK2_NUMA=2
export VLLM_RANK3_NUMA=3
export VLLM_RANK4_NUMA=4
export VLLM_RANK5_NUMA=5
export VLLM_RANK6_NUMA=6
export VLLM_RANK7_NUMA=7
chenych's avatar
chenych committed
115

chenych's avatar
chenych committed
116
```
chenych's avatar
chenych committed
117

chenych's avatar
chenych committed
118
119
120
2. 启动RAY集群
> x.x.x.x 对应第一步 Master节点的 VLLM_HOST_IP

chenych's avatar
chenych committed
121
```bash
chenych's avatar
chenych committed
122
123
124
125
# head节点执行
ray start --head --node-ip-address=x.x.x.x --port=6379 --num-gpus=8 --num-cpus=32
# worker节点执行
ray start --address='x.x.x.x:6379' --num-gpus=8 --num-cpus=32
chenych's avatar
chenych committed
126
127
```

chenych's avatar
chenych committed
128
129
130
3. 启动vllm server
> intel cpu 需要加参数:`--enforce-eager`

chenych's avatar
chenych committed
131
```bash
chenych's avatar
chenych committed
132
vllm serve /path/to/DeepSeek-V3.2-Exp-bf16 \
chenych's avatar
chenych committed
133
134
135
136
    --trust-remote-code \
    --distributed-executor-backend ray \
    --dtype bfloat16 \
    --tensor-parallel-size 32 \
chenych's avatar
chenych committed
137
    --max-model-len 32768 \
chenych's avatar
chenych committed
138
139
    --no-enable-chunked-prefill \
    --no-enable-prefix-caching \
chenych's avatar
chenych committed
140
    --port 8001
chenych's avatar
chenych committed
141
142
```

chenych's avatar
chenych committed
143
144
启动完成后可通过以下方式访问:
```bash
chenych's avatar
chenych committed
145
146
curl http://127.0.0.1:8001/v1/chat/completions   \
    -H "Content-Type: application/json"  \
chenych's avatar
chenych committed
147
    -d '{
chenych's avatar
chenych committed
148
        "model": "ds32",
chenych's avatar
chenych committed
149
150
151
        "messages": [
            {
                "role": "user",
chenych's avatar
chenych committed
152
                "content": "请介绍下你自己。"
chenych's avatar
chenych committed
153
154
            }
        ],
chenych's avatar
chenych committed
155
156
157
158
159
160
        "max_tokens": 1024,
        "temperature": 0.7,
        "chat_template_kwargs": {
            "thinking": false
        }
    }'
chenych's avatar
chenych committed
161
```
chenych's avatar
add  
chenych committed
162

chenych's avatar
chenych committed
163
## 效果展示
chenych's avatar
chenych committed
164
<div align=center>
chenych's avatar
chenych committed
165
    <img src="./doc/results_dcu.png"/>
chenych's avatar
chenych committed
166
</div>
chenych's avatar
chenych committed
167
168

### 精度
chenych's avatar
chenych committed
169
DCU与GPU精度一致,推理框架:vllm。
chenych's avatar
chenych committed
170
171

## 预训练权重
chenych's avatar
chenych committed
172
173
174
175
| 模型名称  | 权重大小  | DCU型号  | 最低卡数需求 |下载地址|
|:-----:|:----------:|:----------:|:---------------------:|:----------:|
| DeepSeek-V3.2-Exp  | 685B | BW1000 | 32 | [Hugging Face](https://huggingface.co/deepseek-ai/DeepSeek-V3.2-Exp) |
| DeepSeek-V3.2-Exp-Base  | 685B | BW1000 | 32 | [Hugging Face](https://huggingface.co/deepseek-ai/DeepSeek-V3.2-Exp-Base) |
chenych's avatar
chenych committed
176
177

## 源码仓库及问题反馈
chenych's avatar
chenych committed
178
- https://developer.sourcefind.cn/codes/modelzoo/deepseek-v3.2-exp_vllm
chenych's avatar
chenych committed
179
180
181
182

## 参考资料
- https://huggingface.co/deepseek-ai/DeepSeek-V3.2-Exp
- https://github.com/deepseek-ai/DeepSeek-V3.2-Exp