README.md 6.36 KB
Newer Older
raojy's avatar
raojy committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Qwen3.6
## 论文
[Qwen3.6](https://qwen.ai/blog?id=qwen3.6)

## 模型简介

Qwen3.6-35B-A3B 是一款采用混合专家 (MoE) 架构并包含视觉编码器的多模态因果语言模型。总参数量为 35B,推理时激活参数量为 3B。此版本重点优化了智能体编程 (Agentic Coding) 的准确率,并引入了思维保留 (Thinking Preservation) 机制,特别适合长上下文和复杂的代码仓库开发任务。

<div align=center>
    <img src="./doc/qwen3.5_397b_a17b_infra.jpg"/>
</div>

## 环境依赖
| 软件 |                    版本                     |
| :------: |:-----------------------------------------:|
| DTK |                   26.04                   |
| python |                  3.10.12                  |
| transformers |            5.5.0               |
| vllm |      0.18.1+das.3266200.dtk2604     |
| triton |      3.4.0+git1ef59765      |
| torch |   2.10.0+das.opt1.dtk2604.20260325.g6b060a   |

当前仅支持定制镜像: harbor.sourcefind.cn:5443/dcu/admin/base/custom:vllm018-ubuntu22.04-dtk26.04-gemma4-0413

- 挂载地址`-v` 根据实际模型情况修改
```bash
docker run -it \
    --shm-size 200g \
    --network=host \
    --name qwen3.5 \
    --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/custom:vllm018-ubuntu22.04-dtk26.04-gemma4-0413 bash
```
更多镜像可前往[光源](https://sourcefind.cn/#/service-list)下载使用。

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

## 数据集
暂无

## 训练
暂无

## 推理
> 如果出现`ImportError: librocm_smi64.so.2: cannot open shaned object file: No such file or directory`报错,系机器hyhal版本较低所致,请进行升级。

### vllm
**mtp**功能需添加以下参数:
```
--speculative-config.method mtp  \
--speculative-config.num_speculative_tokens 2
```

#### 单机推理
```bash
## serve启动
vllm serve Qwen/Qwen3.5-35B-A3B \
    --port 8001 \
    --trust-remote-code \
    --dtype bfloat16 \
    --tensor-parallel-size 2 \
    --gpu-memory-utilization 0.925 \
    --default-chat-template-kwargs '{"enable_thinking": false}' \
    --reasoning-parser qwen3 \
    --enable-auto-tool-choice \
    --tool-call-parser qwen3_coder

## client访问
curl http://localhost:8001/v1/chat/completions   \
    -H "Content-Type: application/json"  \
    -d '{
        "model": "Qwen/Qwen3.5-35B-A3B",
        "messages": [
          {"role": "user", "content": "Type \"I love Qwen3.5\" backwards"}
        ],
        "temperature": 0.6
    }'
```

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

```bash
export ALLREDUCE_STREAM_WITH_COMPUTE=1
export VLLM_HOST_IP=x.x.x.x # 对应计算节点的IP,选择IB口SOCKET_IFNAME对应IP地址
export NCCL_SOCKET_IFNAME=ibxxxx
export GLOO_SOCKET_IFNAME=ibxxxx
export NCCL_IB_HCA=mlx5_x:1 # 环境中的IB网卡名字
unset NCCL_ALGO
export NCCL_MIN_NCHANNELS=16
export NCCL_MAX_NCHANNELS=16
export NCCL_NET_GDR_READ=1
export HIP_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export VLLM_RPC_TIMEOUT=1800000

# 海光CPU绑定核
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
```

2. 启动RAY集群
> x.x.x.x 对应第一步 VLLM_HOST_IP

```bash
# 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
```

3. 启动vllm server
```bash
## serve启动
vllm serve Qwen/Qwen3.5-397B-A17B \
    --port 8001 \
    --tensor-parallel-size 16 \
    --distributed-executor-backend ray \
    --trust-remote-code \
    --dtype bfloat16 \
    --gpu-memory-utilization 0.925 \
    --default-chat-template-kwargs '{"enable_thinking": false}' \
    --reasoning-parser qwen3 \
    --enable-auto-tool-choice \
    --tool-call-parser qwen3_coder

## client访问
curl http://localhost:8001/v1/chat/completions   \
    -H "Content-Type: application/json"  \
    -d '{
        "model": "Qwen/Qwen3.5-397B-A17B",
        "messages": [
          {"role": "user", "content": "Type \"I love Qwen3.5\" backwards"}
        ],
        "temperature": 0.6
    }'
```

## 效果展示
<div align=center>
    <img src="./doc/result-dcu.jpg"/>
</div>

### 精度
DCU与GPU精度一致,推理框架:vllm。

## 预训练权重
|  模型名称  | 权重大小 | DCU型号  | 最低卡数需求 |         下载地址          |
|:------:|:----:|:----------:|:------:|:---------------------:|
| Qwen3.5-397B-A17B | 397B | K100AI,BW1000 |   16   | [Hugging Face](https://huggingface.co/Qwen/Qwen3.5-397B-A17B) |
| Qwen3.5-397B-A17B-INT8 | 397B | BW1000 |   8   | [Modelscope](https://www.modelscope.cn/models/metax-tech/Qwen3.5-397B-A17B-W8A8) |
| Qwen3.5-122B-A10B | 122B | K100AI,BW1000 |   8   | [Hugging Face](https://huggingface.co/Qwen/Qwen3.5-122B-A10B) |
| Qwen3.5-35B-A3B | 35B | K100AI,BW1000 |   2   | [Hugging Face](https://huggingface.co/Qwen/Qwen3.5-35B-A3B) |
| Qwen3.5-27B | 27B | K100AI,BW1000 |   2   | [Hugging Face](https://huggingface.co/Qwen/Qwen3.5-27B) |
| Qwen3.5-9B | 9B | K100AI,BW1000 |   1   | [Hugging Face](https://huggingface.co/Qwen/Qwen3.5-9B) |
| Qwen3.5-4B | 4B | K100AI,BW1000 |   1   | [Hugging Face](https://huggingface.co/Qwen/Qwen3.5-4B) |
| Qwen3.5-2B | 2B | K100AI,BW1000 |   1   | [Hugging Face](https://huggingface.co/Qwen/Qwen3.5-2B) |
| Qwen3.5-0.8B | 0.8B | K100AI,BW1000 |   1   | [Hugging Face](https://huggingface.co/Qwen/Qwen3.5-0.8B) |

## 源码仓库及问题反馈
- https://developer.sourcefind.cn/codes/modelzoo/qwen3.5_vllm

## 参考资料
- https://github.com/QwenLM/Qwen3.5