跳转至

Qwen-VL-Dense(Qwen3-VL-2B/4B/8B/32B)

1.简介

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

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

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

2.支持的特性

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

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

3.前提条件

3.1 模型权重

需要 1 个 Atlas 800I A2(64G × 8)节点中的 1 张卡或 1 个 Atlas 800 A3(64G × 16)节点中的 1 张卡:

需要 1 个 Atlas 800I A2(64G × 8)节点中的 2 张卡或 1 个 Atlas 800 A3(64G × 16)节点中的 2 张卡:

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

4.安装

4.1 Docker 镜像安装

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

A3 系列:

在每个节点上启动 Docker 镜像。

# Update the vllm-ascend image
export IMAGE=quay.io/ascend/vllm-ascend:v0.22.1rc1

docker run --rm \
--name vllm-ascend \
--shm-size=1g \
--device /dev/davinci0 \
--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 /root/.cache:/root/.cache \
-p 8000:8000 \
-it $IMAGE bash

安装验证:

启动容器后,运行以下命令验证安装:

docker ps | grep vllm-ascend

预期结果:容器列出且状态为 Up。您还可以在容器内验证 vllm-ascend 版本:

pip show vllm-ascend

预期结果:显示版本信息,与拉取的镜像版本一致。

4.2 源码安装

如果您不想使用 Docker 镜像,可以从源码构建。首先从源码安装 vLLM:

  1. 克隆并安装 vLLM:
git clone https://github.com/vllm-project/vllm.git
cd vllm
pip install -e .
  1. Clone and install the vLLM-Ascend repository:
git clone https://github.com/vllm-project/vllm-ascend.git
cd vllm-ascend
pip install -e .

安装验证:

pip show vllm vllm-ascend

预期结果:显示两个包的版本信息,确认安装成功。

Note

如果部署多节点环境,请在每个节点上设置环境。

更多详细信息,请参考安装指南

5.在线服务部署

5.1 单节点在线部署

运行 Docker 容器在单 NPU 上启动 vLLM 服务器:

vllm serve Qwen/Qwen3-VL-8B-Instruct \
--dtype bfloat16 \
--max_model_len 16384 \
--max-num-batched-tokens 16384

关键参数说明:

  • 添加 --max_model_len 选项以避免 Qwen3-VL-8B-Instruct 模型的最大序列长度(256000)大于 KV 缓存可存储的最大 token 数而导致的 值Error。不同 NPU 系列基于片上内存大小会有所不同。请根据您的 NPU 系列修改为合适的值。

如果服务启动成功,您将看到如下所示的信息:

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

6.功能验证

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

curl http://localhost:8000/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
    "model": "Qwen/Qwen3-VL-8B-Instruct",
    "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?"}
    ]}
    ]
    }'

预期结果:

服务返回 HTTP 200 OK。

{"id":"chatcmpl-d3270d4a16cb4b98936f71ee3016451f","object":"chat.completion","created":1764924127,"model":"Qwen/Qwen3-VL-8B-Instruct","choices":[{"index":0,"message":{"role":"assistant","content":"The text in the illustration is: **TONGYI Qwen**","refusal":null,"annotations":null,"audio":null,"function_call":null,"tool_calls":[],"reasoning_content":null},"logprobs":null,"finish_reason":"stop","stop_reason":null,"token_ids":null}],"service_tier":null,"system_fingerprint":null,"usage":{"prompt_tokens":107,"total_tokens":123,"completion_tokens":16,"prompt_tokens_details":null},"prompt_logprobs":null,"prompt_token_ids":null,"kv_transfer_params":null}

7.精度评估

使用 Language Model Evaluation Harness

以下模型的精度已在我们的 CI 监控范围内:

  • Qwen3-VL-8B-Instruct

mmmu_val 数据集为例,以离线模式运行 Qwen3-VL-8B-Instruct 的精度评估。

  1. 有关 ](../../developer_guide/evaluation/using_lm_eval.md) 安装的更多详细信息,请参考[使用 lm_eval 进行精度评估lm_eval

    pip install lm_eval
    
  2. Run lm_eval to execute the accuracy evaluation.

    lm_eval \
        --model vllm-vlm \
        --model_args pretrained=Qwen/Qwen3-VL-8B-Instruct,max_model_len=8192,gpu_memory_utilization=0.7 \
        --tasks mmmu_val \
        --batch_size 32 \
        --apply_chat_template \
        --trust_remote_code \
        --output_path ./results
    
  3. After execution, you can get the result, here is the result of Qwen3-VL-8B-Instruct in vllm-ascend:0.11.0rc3 for reference only.

    Tasks Value Stderr
    mmmu_val 0.5389 0.0159

8 Performance Evaluation

Using vLLM Benchmark

Refer to vLLM Benchmark for more details.

There are three vllm bench subcommands:

  • latency: Benchmark the latency of a single batch of requests.
  • serve: Benchmark the online serving throughput.
  • throughput: Benchmark offline inference throughput.

The performance evaluation must be conducted in an online mode. Take the serve 为例,运行如下代码。

vllm bench serve --model Qwen/Qwen3-VL-8B-Instruct  --dataset-name random --random-input 200 --num-prompts 200 --request-rate 1 --save-result --result-dir ./

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

9 性能调优

9.1 推荐配置

注意:以下配置在特定测试环境中验证,仅供参考。最佳配置取决于最大输入/输出长度、前缀缓存命中率、精度要求和部署机器比例等因素。建议根据实际情况参考第 9.2 节进行调优。

表 1:场景概览

场景 部署模式 *总 NPU 数 权重版本 关键考量
高吞吐量
(16K 上下文)
单节点混合 1 (A3) Qwen3-VL-8B-Instruct 对高分辨率文本输入使用 tp2
长上下文
(128K,无前缀缓存)
单节点混合 1 (A3) Qwen3-VL-8B-Instruct 对高分辨率文本输入使用 tp2
长上下文
(128K,有前缀缓存)
单节点混合 1 (A3) Qwen3-VL-8B-Instruct 对高分辨率文本输入使用 tp2
多模态
(1080P)
单节点混合 1 (A3) Qwen3-VL-8B-Instruct 对高分辨率视觉输入使用 tp2

*Total NPUs表示所有节点使用的 NPU 总数。1 个节点 = 1 台 Atlas 800 A3 服务器(64G × 16 NPU)。

表 2:详细节点配置

场景 配置 NPU 数 TP DP 最大模型长度 MTP 推测数 权重版本
高吞吐量/低延迟(16K) 服务器/单机 1 1 1 ~16K 3 Qwen3-VL-8B-Instruct
长上下文(128K,无缓存) 服务器/单机 1 1 1 128K 3 Qwen3-VL-8B-Instruct
长上下文(128K,有缓存) 服务器/单机 1 1 1 128K 3 Qwen3-VL-8B-Instruct
多模态(1080P) 服务器/单机 1 1 1 ~16K 3 Qwen3-VL-8B-Instruct

完整的启动命令和参数描述,请参考第 5 章中的部署示例。

Notice: max-model-len and max-num-seqs need to be set 准确率ording to the actual usage scenario. For other settings, please refer to the Deployment chapter.

9.2 调优指南

9.2.1 通用调优参考

调优方法请参考公共性能调优文档

详细的特性描述请参考特性指南

10 常见问题

For common environment, installation, and general parameter issues, please refer to the Public FAQ.