本文档记录 Qwen/Qwen-7B-Chat 在 vLLM-Ascend 0.18.0rc1 环境的快速部署与验证结果。Qwen-7B-Chat 是通义千问系列的 7B 参数对话模型,采用标准 MHA + RoPE + SwiGLU + RMSNorm 架构,vLLM 已原生支持 QWenLMHeadModel,无需额外代码修改即可在昇腾 NPU 上运行。
相关获取地址:
quay.io/ascend/vllm-ascend:v0.18.0rc1| 组件 | 版本 |
|---|---|
vllm-ascend | 0.18.0rc1 |
vllm | 0.18.0+empty |
transformers | 4.57.6 |
torch-npu | 2.9.0.post1+gitee7ba04 |
1 逻辑卡(Atlas 800 A2, 910B4, 32GB HBM)/opt/atomgit/models/Qwen/Qwen-7B-Chat8100启动前可先检查端口:
ss -lntp | grep ':8100 ' || true已验证通过的启动命令:
python3 -m vllm.entrypoints.openai.api_server \
--model /opt/atomgit/models/Qwen/Qwen-7B-Chat \
--dtype bfloat16 \
--tensor-parallel-size 1 \
--max-model-len 8192 \
--max-num-seqs 8 \
--port 8100 \
--trust-remote-code或使用 inference.py 脚本:
# 启动 API 服务
python3 inference.py --mode server --port 8100
# 离线推理
python3 inference.py --mode offline
# 客户端调用
python3 inference.py --mode client --prompt "你好,请介绍一下你自己。"基础检查:
# 健康检查
curl -sf http://127.0.0.1:8100/v1/models
# 中文对话
curl -sf http://127.0.0.1:8100/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "/opt/atomgit/models/Qwen/Qwen-7B-Chat",
"messages": [{"role": "user", "content": "你好,请用中文介绍一下你自己"}],
"temperature": 0.1,
"max_tokens": 256
}'
# 英文对话
curl -sf http://127.0.0.1:8100/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "/opt/atomgit/models/Qwen/Qwen-7B-Chat",
"messages": [{"role": "user", "content": "Hello, introduce yourself"}],
"temperature": 0.1,
"max_tokens": 256
}'验证结果:
/v1/models 返回 200/v1/chat/completions 返回 200测试条件:单卡 NPU(910B4),max-model-len=8192,max-num-seqs=8。
| 指标 | 数值 |
|---|---|
| 平均延迟 | 2.67 s |
| 平均吞吐 | 39.2 tok/s |
| 总体吞吐 | 38.4 tok/s |
使用关键词匹配方式对 5 项基础能力进行评测。
| 测试项 | 问题 | 期望关键词 | 结果 |
|---|---|---|---|
| 算术推理 | What is 2 + 2? | 4 | PASS |
| 知识问答 | What is the capital of France? | Paris | PASS |
| 中文知识 | 中国的首都是哪里? | 北京 | PASS |
| 翻译能力 | Translate 'hello' to Chinese. | 你好 | PASS |
| 代码生成 | Write a Python factorial function | def, factorial | PASS |
精度评测结果:5/5 通过(100%)
Qwen-7B-Chat 使用 QWenLMHeadModel 架构,vLLM 已原生支持,无需修改模型代码use_logn_attn 特性在 vLLM 实现中未使用,不影响推理精度tensor-parallel-size=1,如需多卡可调整为 2 或 4--max-model-len 8192 以适配 32GB HBM 显存