/vllm-workspace/vllm)/vllm-workspace/vllm-omni 分支release/v0.26.0)/vllm-workspace/vllm-ascend 分支dev-0.26.0rc2)/home/model/Qwen3-Omni-30B-A3B-Instruct(65.7GB bf16,15 个 safetensors 分片)/home/hwtest_0922/pcy/0924Qwen3-Omni-Test/qwen3_omni_moe_4npu.yaml/home/hwtest_0922/pcy/0924Qwen3-Omni-Test/run_qwen3_omni_instruct_kaixiang.sh#!/bin/bash
cname=vllm-ascend-v0.26.0rc2-openeuler-pcy
image=quay.io/ascend/vllm-ascend:v0.26.0rc2-openeuler
docker run -itd -u root \
--net=host \
--privileged=true \
--device=/dev/davinci_manager \
--device=/dev/devmm_svm \
--device=/dev/hisi_hdc \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-v /usr/bin/hccn_tool:/usr/bin/hccn_tool \
-v /etc/hccn.conf:/etc/hccn.conf \
-v /mnt:/mnt \
-v /tmp:/home \
--shm-size 1024g \
--name "${cname}" \
--ipc=host \
--hostname "${cname,,}" \
"${image}" \/bin/bash| Stage | 模型 | 设备 | 并行 | 权重 | KV Cache | 实测 HBM |
|---|---|---|---|---|---|---|
| stage0 Thinker | Qwen3-30B-A3B MoE + 音频编码器 + ViT | NPU 0,1,2,3 | TP4 + EP4 | 15.36GB/rank | 6.54GiB/rank(285,824 tokens) | 27.1GB/32GB |
| stage1 Talker | Qwen3-Omni-MoE Talker(3B MoE + code predictor) | NPU 4 | TP1 | 6,341MB | 18.57GiB(973,696 tokens) | 29.1GB/32GB |
| stage2 Code2Wav | 声码器 | NPU 5 | TP1 | 412MB | — | 4.0GB/32GB |
export http_proxy=http://10.2.1.246:3128
export https_proxy=http://10.2.1.246:3128
# 内部 pypi 镜像不可用(连 six 都装不上),经代理从 pypi.org 安装;
# 安装前用 pip install --dry-run 确认不影响既有 torch/torch_npu/transformers 等依赖:
pip install --index-url https://pypi.org/simple \
"aenum==3.1.16" "omegaconf>=2.3.0" "diffusers==0.38.0" "accelerate==1.12.0" \
"cache-dit==1.3.0" "torchsde>=0.2.6" "openai-whisper>=20250625" \
"imageio[ffmpeg]>=2.37.2" "x-transformers>=2.12.2" "prettytable>=3.8.0" \
"janus>=1.0.0" "gguf>=0.10.0"
pip install --index-url https://pypi.org/simple "onnxruntime-cann>=1.23.2"qwen3_omni_moe_4npu.yaml)# Qwen3-Omni-30B-A3B-Instruct deploy for this host (8x Ascend 910B4, 32GB HBM each).
#
# Memory math (measured from safetensors): thinker = 62.8GB bf16, talker ~7GB,
# code2wav ~0.5GB. TP2 (2x32GB=64GB) cannot hold the 62.8GB thinker plus KV
# cache, so stage0 uses TP4 across npu 0-3 (15.7GB weights/rank + encoders +
# KV fits the 0.9x32GB budget). Layout:
# stage0 thinker TP4 on npu 0,1,2,3 / stage1 talker on npu 4 / stage2 code2wav on npu 5.
# Based on vllm-omni/vllm_omni/deploy/qwen3_omni_moe.yaml; per-stage
# max_num_batched_tokens must stay >= --max-model-len (chunked prefill is
# disabled on omni stages).
async_chunk: true
connectors:
connector_of_shared_memory:
name: SharedMemoryConnector
extra:
initial_codec_chunk_frames: 4
codec_chunk_frames: 25
codec_left_context_frames: 25
stages:
- stage_id: 0
max_num_batched_tokens: 40960
max_num_seqs: 100
gpu_memory_utilization: 0.9
trust_remote_code: true
enable_prefix_caching: false
tensor_parallel_size: 4
enable_expert_parallel: true
devices: "0,1,2,3"
default_sampling_params:
temperature: 0.0
max_tokens: 2048
- stage_id: 1
max_num_batched_tokens: 40960
max_num_seqs: 100
gpu_memory_utilization: 0.9
trust_remote_code: true
enable_prefix_caching: false
devices: "4"
input_connectors:
from_stage_0: connector_of_shared_memory
default_sampling_params:
temperature: 0.9
top_k: 50
max_tokens: 4096
repetition_penalty: 1.05
- stage_id: 2
max_num_batched_tokens: 40960
max_num_seqs: 100
gpu_memory_utilization: 0.5
enforce_eager: false
trust_remote_code: true
enable_prefix_caching: false
enable_chunked_prefill: false
async_scheduling: false
devices: "5"
input_connectors:
from_stage_1: connector_of_shared_memory
default_sampling_params:
temperature: 0.0
top_p: 1.0
top_k: -1
max_tokens: 65536
repetition_penalty: 1.1
platforms:
npu:
stages:
- stage_id: 0
tensor_parallel_size: 4
enable_expert_parallel: true
compilation_config:
cudagraph_mode: PIECEWISE # Qwen3-Omni not FULL-cudagraph-safe on NPU
- stage_id: 1
compilation_config:
cudagraph_mode: PIECEWISE # code_predictor MaskedSelect / inner NPU graph replay
- stage_id: 2
compilation_config:
cudagraph_mode: PIECEWISE
(需要注意的是 max_num_batched_tokens: 40960 ≥ --max-model-len 40960,omni 阶段需要关 chunked prefill 的要求)。
export HCCL_BUFFSIZE=1024
export HCCL_OP_EXPANSION_MODE="AIV" # not needed on A2; drop if HCCL errors appear
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5
# Recommended by vllm-ascend Qwen3-Omni tutorial (A2):
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=1
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export MODEL_PATH="/home/model/Qwen3-Omni-30B-A3B-Instruct"
export DEPLOY_CONFIG="/home/hwtest_0922/pcy/0924Qwen3-Omni-Test/qwen3_omni_moe_4npu.yaml"
export LOGFILE="/home/hwtest_0922/pcy/0924Qwen3-Omni-Test/qwen3_omni_server.log"
vllm serve $MODEL_PATH \
--omni \
--deploy-config $DEPLOY_CONFIG \
--served-model-name qwen3-omni \
--trust-remote-code \
--max-model-len 40960 \
--distributed_executor_backend "mp" \
--no-enable-prefix-caching \
--allowed-local-media-path /home/hwtest_0922 \
--port 8000cd /home/hwtest_0922/pcy/0924Qwen3-Omni-Test
setsid nohup bash run_qwen3_omni_instruct_kaixiang.sh > qwen3_omni_server.log 2>&1 < /dev/null &05:05 启动
05:08:15 Stage 0 engine startup completed (thinker TP4 加载 15.36GB/rank + KV 6.54GiB/rank)
05:09:57 Stage 1 engine startup completed (talker 6341MB + KV 18.57GiB)
05:11:35 Stage 2 engine startup completed (code2wav 412MB)
05:11:xx Application startup completecurl -s -o /dev/null -w '%{http_code}' http://localhost:8000/health → 200
全量启动耗时约 6.5 分钟(权重从 tmpfs 读取,15 分片 ~10s;大头是三个阶段引擎的编译/图捕获)。
ERROR [__init__.py:72] Failed to load plugin vllm_omni_register_models
...
File "/vllm-workspace/vllm-omni/vllm_omni/patch.py", line 7, in <module>
from aenum import extend_enum
ModuleNotFoundError: No module named 'aenum'ModuleNotFoundError: No module named 'omegaconf'
(vllm_omni/config/yaml_util.py)。requirements/npu.txt(= common.txt + onnxruntime-cann + torchaudio)
声明的核心依赖没有安装(aenum、omegaconf、diffusers、accelerate、cache-dit、torchsde、
openai-whisper、imageio、x-transformers、prettytable、janus、gguf、onnxruntime-cann 等)。
内部 pypi 镜像 cache-service.nginx-pypi-cache.svc.cluster.local 不可用
(连 six 都报 "No matching distribution found"),直连 pypi.org 不通。http://10.2.1.246:3128,来自 ~/env.sh)从 pypi.org 安装。
全部安装前先 pip install --dry-run 模拟,确认只会新增包、
不升级/降级任何既有依赖(torch、torch_npu 2.10.0、transformers 5.14.1、torchaudio 2.10.0 等
均与官方 pin 一致,未动)。aenum 按 vllm-omni 的 pin 装 3.1.16。gpu_memory_utilization 0.9 预算(28.8GB)ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5。
EP 依据:官方教程明确该 MoE 模型多卡部署需 --enable-expert-parallel
(日志实测:[EP Rank x/4] Local/global number of experts: 32/128)。VLLM::StageEngineCoreProc_stage2_replica0
(pid 11598)仍以 init 为父进程存活,NPU5 占 8% HBM。kill 11598,确认 6 张卡 HBM 全部回到 8% 基线后再重启。/health 返回:HTTP 200curl -s --max-time 180 http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-omni",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "请描述这个视频的内容。"},
{"type": "video_url", "video_url": {"url": "file:///home/hwtest_0922/pcy/0924Qwen3-Omni-Test/draw.mp4"}}
]
}
],
"max_tokens": 1024
}' -o resp.jsonchoices[0].message.content(finish_reason=stop,
prompt_tokens=4336,completion_tokens=229):
好的,这是一个关于在平板电脑上进行数字绘画的视频。 视频内容描述如下:这是一个俯视视角的视频,展示了一位用户正在使用一支白色的触控笔 在一台平板电脑上绘制一把卡通风格的吉他……
choices[1].message.audio.data = base64 编码 WAV
(解码后 3,669,974 字节,文件头 RIFF…WAVE,audio.id=audio-1e18fc98b0f54013,
expires_at=1790313190;解码结果已存 audio_out.wav)。
说明:vllm-omni 将文字与音频拆在两个 choice 里——choices[0] 文字(audio 为 null),
choices[1] 音频。请求未带 modalities 参数时,服务端按引擎默认输出模态
(text+audio,见 vllm_omni/entrypoints/openai/serving_chat.py:590),无需额外参数。resp.json(4.9MB,文字+音频)audio_out.wav(解码出的音频)qwen3_omni_server.log(完整服务日志)音频转码脚本:
python3 -c "
import json, base64
d = json.load(open('resp.json'))
b64 = d['choices'][1]['message']['audio']['data']
open('audio_out.wav','wb').write(base64.b64decode(b64))
print('written audio_out.wav')
"使用VoiceBench数据集进行册数, 官方流程为: git clone https://github.com/MatthewCYM/VoiceBench cd VoiceBench pip install -r requirements.txt
下载voicebench数据集 pip install "huggingface_hub==0.25.2" huggingface-cli download hlt-lab/voicebench --repo-type dataset --local-dir /tmp/voicebench-test --resume-download
执行精度测试
python main.py
--model qwen3-omni
--data openbookqa
--split train
--modality audio
精度分数计算 export NLTK_ALLOW_PROXIED_URLOPEN=1
python evaluate.py
--src_file qwen3-omni-openbookqa-train-audio.jsonl
--evaluator mcq
输出如下所示: 2026-09-29 10:21:47.435 | INFO | main:main:18 - {'acc': 92.3076923076923, 'fail': 0.0}
openbookqa得分 92.3 官方得分 89.7 bbh 86.8 官方80.4
使用vllm omni 进行性能压测,测试条件:并发 8、不限速,发 100 个「32 token 文本 + 1 段音频(固定30s) → 生成 256 token 文本」的请求,做压力/吞吐测试。
vllm bench serve \
--omni \
--backend openai-chat-omni \
--base-url http://127.0.0.1:8000 \
--endpoint /v1/chat/completions \
--model qwen3-omni \
--tokenizer "$MODEL_PATH" \
--dataset-name random-mm \
--num-prompts 100 \
--request-rate inf \
--max-concurrency 8 \
--random-input-len 32 \
--random-output-len 256 \
--random-range-ratio 0 \
--random-mm-base-items-per-request 1 \
--random-mm-num-mm-items-range-ratio 0 \
--random-mm-limit-mm-per-prompt '{"audio":1}' \
--random-mm-bucket-config '{"(0,30,1)":1.0}' \
--ignore-eos \
--extra-body '{"modalities":["text"]}' \
--percentile-metrics ttft,tpot,itl,e2el \
--metric-percentiles 50,90,99 \
--save-result \
--result-dir ./bench_results \
--result-filename "audio-text-c8.json"性能测试结果如下
============ Serving Benchmark Result ============
Successful requests: 100
Failed requests: 0
Maximum request concurrency: 8
Benchmark duration (s): 161.58
Request throughput (req/s): 0.62
Peak concurrent requests: 16.00
----------------End-to-end Latency----------------
Mean E2EL (ms): 12473.96
Median E2EL (ms): 12463.35
P50 E2EL (ms): 12463.35
P90 E2EL (ms): 12842.63
P99 E2EL (ms): 13107.02
================== Text Result ===================
Total input tokens: 43200
Total generated tokens: 25600
Output token throughput (tok/s): 158.43
Peak output token throughput (tok/s): 208.00
Peak concurrent requests: 16.00
Total Token throughput (tok/s): 425.78
---------------Time to First Token----------------
Mean TTFT (ms): 1300.35
Median TTFT (ms): 1256.93
P50 TTFT (ms): 1256.93
P90 TTFT (ms): 1900.64
P99 TTFT (ms): 2118.68
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 43.82
Median TPOT (ms): 43.86
P50 TPOT (ms): 43.86
P90 TPOT (ms): 46.21
P99 TPOT (ms): 47.54
---------------Inter-token Latency----------------
Mean ITL (ms): 43.82
Median ITL (ms): 39.75
P50 ITL (ms): 39.75
P90 ITL (ms): 43.97
P99 ITL (ms): 259.69
==================================================