跳转至

Qwen3-VL-235B-A22B-Instruct

简介

阿里云的通义千问视觉语言(Qwen-VL)系列包含一系列强大的大型视觉语言模型(LVLM),专为全面的多模态理解而设计。它们接受图像、文本和边界框作为输入,输出文本和检测框,支持图像检测、多模态对话和多图像推理等高级功能。

本文档将展示模型的主要验证步骤,包括支持的特性、特性配置、环境准备、NPU 部署、精度评估和性能评估。

本教程使用 vLLM-Ascend v0.11.0rc2 版本进行演示,以 Qwen3-VL-235B-A22B-Instruct 模型作为多 NPU 部署的示例。

支持的特性

请参阅支持的特性矩阵获取模型支持的特性列表。

请参阅特性指南获取特性的配置方法。

环境准备

模型权重

  • Qwen3-VL-235B-A22B-Instruct(BF16 版本):需要 1 个 Atlas 800 A3(64G × 16)节点,或 2 个 Atlas 800 A2(64G × 8)节点。下载模型权重

建议将模型权重下载到多节点共享目录,例如 /root/.cache/

验证多节点通信(可选)

如果要部署多节点环境,需要按照验证多节点通信环境验证多节点通信。

安装

例如,使用镜像 quay.io/ascend/vllm-ascend:v0.11.0rc2(适用于 Atlas 800 A2)和 quay.io/ascend/vllm-ascend:v0.11.0rc2-a3(适用于 Atlas 800 A3)。

根据您的机器类型选择镜像,并在节点上启动 Docker 镜像,请参考使用 Docker 安装

  # Update --device according to your device (Atlas A2: /dev/davinci[0-7] Atlas A3:/dev/davinci[0-15]).
  # Update the vllm-ascend image according to your environment.
  # Note you should download the weight to /root/.cache in advance.
  # Update the vllm-ascend image
  export IMAGE=m.daocloud.io/quay.io/ascend/vllm-ascend:v0.22.1rc1
  export NAME=vllm-ascend

  # Run the container using the defined variables
  # Note: If you are running bridge network with docker, please expose available ports for multiple nodes communication in advance
  docker run --rm \
  --name $NAME \
  --net=host \
  --privileged=true \
  --shm-size=500g \
  --device /dev/davinci0 \
  --device /dev/davinci1 \
  --device /dev/davinci2 \
  --device /dev/davinci3 \
  --device /dev/davinci4 \
  --device /dev/davinci5 \
  --device /dev/davinci6 \
  --device /dev/davinci7 \
  --device /dev/davinci_manager \
  --device /dev/devmm_svm \
  --device /dev/hisi_hdc \
  -v /usr/local/dcmi:/usr/local/dcmi \
  -v /usr/local/Ascend/driver/tools/hccn_tool:/usr/local/Ascend/driver/tools/hccn_tool \
  -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 \
  -it $IMAGE bash

You can build all from source.

If you want to deploy multi-node environment, you need to set up environment on each node.

Deployment

Assume you have Atlas 800 A3 (64G*16) nodes (or 2* A2), and want to deploy the Qwen3-VL-235B-A22B-Instruct 模型。

节点 0

#!/bin/sh
# Load model from ModelScope to speed up download
export VLLM_USE_MODELSCOPE=True
# To reduce memory fragmentation and avoid out of memory
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
# this obtained through ifconfig
# nic_name is the network interface name corresponding to local_ip of the current node
nic_name="xxxx"
local_ip="xxxx"

export HCCL_IF_IP=$local_ip
export GLOO_SOCKET_IFNAME=$nic_name
export TP_SOCKET_IFNAME=$nic_name
export HCCL_SOCKET_IFNAME=$nic_name
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=1
export HCCL_BUFFSIZE=1024
export TASK_QUEUE_ENABLE=1
export HCCL_OP_EXPANSION_MODE="AIV"

vllm serve Qwen/Qwen3-VL-235B-A22B-Instruct \
--host 0.0.0.0 \
--port 8000 \
--data-parallel-size 2 \
--api-server-count 2 \
--data-parallel-size-local 1 \
--data-parallel-address $local_ip \
--data-parallel-rpc-port 13389 \
--seed 1024 \
--served-model-name qwen3 \
--tensor-parallel-size 8 \
--enable-expert-parallel \
--max-num-seqs 16 \
--max-model-len 262144 \
--max-num-batched-tokens 4096 \
--trust-remote-code \
--gpu-memory-utilization 0.9 \

节点 1

#!/bin/sh
# Load model from ModelScope to speed up download
export VLLM_USE_MODELSCOPE=True
# To reduce memory fragmentation and avoid out of memory
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
# this is obtained through ifconfig
# nic_name is the network interface name corresponding to local_ip of the current node
nic_name="xxxx"
local_ip="xxxx"

# The value of node0_ip must be consistent with the value of local_ip set in node0 (master node)
node0_ip="xxxx"

export HCCL_IF_IP=$local_ip
export GLOO_SOCKET_IFNAME=$nic_name
export TP_SOCKET_IFNAME=$nic_name
export HCCL_SOCKET_IFNAME=$nic_name
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=1
export HCCL_BUFFSIZE=1024
export TASK_QUEUE_ENABLE=1
export HCCL_OP_EXPANSION_MODE="AIV"

vllm serve Qwen/Qwen3-VL-235B-A22B-Instruct \
--host 0.0.0.0 \
--port 8000 \
--headless \
--data-parallel-size 2 \
--data-parallel-size-local 1 \
--data-parallel-start-rank 1 \
--data-parallel-address $node0_ip \
--data-parallel-rpc-port 13389 \
--seed 1024 \
--tensor-parallel-size 8 \
--served-model-name qwen3 \
--max-num-seqs 16 \
--max-model-len 262144 \
--max-num-batched-tokens 4096 \
--enable-expert-parallel \
--trust-remote-code \
--gpu-memory-utilization 0.9 \

参数解释如下:

  • --max-model-len 表示上下文长度,即单个请求的输入加输出的最大值。
  • --max-num-seqs 表示每个 DP 组允许处理的最大请求数。如果发送到服务的请求数超过此限制,超出部分将处于等待状态而不会被调度。请注意,等待状态所花费的时间也会计入 TTFT 和 TPOT 等指标中。因此,在测试性能时,通常建议 --max-num-seqs * --data-parallel-size >= 实际总并发数。
  • --max-num-batched-tokens 表示模型单步能处理的最大 token 数量。目前,vLLM v1 调度默认启用了 ChunkPrefill/SplitFuse,这意味着:
    • (1)如果请求的输入长度大于 --max-num-batched-tokens,将按照 --max-num-batched-tokens 拆分为多轮计算;
    • (2)解码请求优先调度,仅在有剩余容量时才调度预填充请求。
    • 通常,--max-num-batched-tokens 设置得越大,整体延迟越低,但对 GPU 内存(激活值占用)的压力越大。
  • --gpu-memory-utilization 表示 vLLM 将用于实际推理的 HBM 占比。其核心作用是计算可用的 kv_cache 大小。在预热阶段(vLLM 中称为 profile run),vLLM 会记录输入大小为 --max-num-batched-tokens 的推理过程中的峰值 GPU 内存使用量。然后按如下方式计算可用 kv_cache 大小:--gpu-memory-utilization * HBM 大小 - 峰值 GPU 内存使用量。因此,--gpu-memory-utilization 的值越大,可用的 kv_cache 就越多。然而,由于预热阶段的 GPU 内存使用量可能与实际推理时不同(例如由于 EP 负载不均),将 --gpu-memory-utilization 设置过高可能会导致实际推理时出现 OOM(内存不足)问题。默认值为 0.9
  • --enable-expert-parallel 表示启用 EP。请注意,vLLM 不支持 ETP 和 EP 混合的方式;即 MoE 只能使用纯 EP 或纯 TP。
  • --no-enable-prefix-caching 表示禁用前缀缓存。要启用前缀缓存,请移除该选项。
  • --quantization "ascend" 表示使用量化。要禁用量化,请移除该选项。
  • --compilation-config contains configurations related to the aclgraph graph 模式. The most significant configurations are "cudagraph_模式" and "cudagraph_capture_sizes", which have the following meanings: "cudagraph_模式": represents the specific graph 模式. Currently, "PIECEWISE" and "FULL_DECODE_ONLY" are supported. The graph 模式 is mainly used to reduce the cost of operator dispatch. Currently, "FULL_DECODE_ONLY" is recommended.
  • "cudagraph_capture_sizes":表示图模式的不同级别。默认值为 [1, 2, 4, 8, 16, 24, 32, 40, ..., --max-num-seqs]。在图模式下,不同级别的图输入是固定的,级别之间的输入会自动填充到下一级别。目前推荐使用默认设置。仅在少数场景下需要单独设置以获得最佳性能。
  • export VLLM_ASCEND_ENABLE_FLASHCOMM1=1 表示启用 Flashcomm1 优化。目前,该优化仅支持在 tp_size > 1 的场景下对 MoE 生效。

如果服务启动成功,节点 0 上将显示以下信息:

INFO:     Started server process [44610]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Started server process [44611]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

使用 Ray 的多节点部署

预填充-解码分离部署

功能验证

服务器启动后,您可以使用输入提示词查询模型:

curl http://<node0_ip>:<port>/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
    "model": "qwen3",
    "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": [
        {"type": "image_url", "image_url": {"url": "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/qwen.png"}},
        {"type": "text", "text": "What is the text in the illustration?"}
    ]}
    ]
    }'

精度评估

以下是两种精度评估方法。

使用 AISBench

  1. 详细信息请参考使用 AISBench 进行精度评估

  2. 执行后即可获得结果,以下是 Qwen3-VL-235B-A22B-Instructvllm-ascend:0.11.0rc2 上的结果,仅供参考。

数据集 版本 指标 模式 vllm-api-生成eral-chat
aime2024 - 准确率 生成 93

性能

使用 AISBench

详细信息请参考使用 AISBench 进行性能评估

使用 vLLM 基准测试

Qwen3-VL-235B-A22B-Instruct 为例运行性能评估。

更多详细信息请参考 vLLM 基准测试

有三个 vllm bench 子命令:

  • latency:基准测试单批次请求的延迟。
  • serve:基准测试在线服务的吞吐量。
  • throughput:基准测试离线推理的吞吐量。

serve 为例,运行如下代码。

export VLLM_USE_MODELSCOPE=True
vllm bench serve --model Qwen/Qwen3-VL-235B-A22B-Instruct  --dataset-name random --random-input 200 --num-prompts 200 --request-rate 1 --save-result --result-dir ./

大约几分钟后,即可获得性能评估结果。