Qwen3.6-27B-int4 + DFlash 推测解码部署教程 vLLM

在 DGX Spark 上部署 27B INT4 量化模型,配合 DFlash 推测解码实现高性能推理

目录

  1. 概述
  2. 模型下载
  3. 启动服务
  4. 参数详解
  5. 性能实测
  6. 验证部署
  7. 踩坑记录
💡 本文介绍如何在 NVIDIA DGX Spark 上部署 Qwen3.6-27B-int4-AutoRound 模型,并结合 DFlash 推测解码(Speculative Decoding)加速推理。 使用本地模型路径而非 HuggingFace 在线加载,减少网络依赖。

1. 概述

2. 模型下载

两个模型都需要下载到本地 /model/ 目录:

主模型

huggingface-cli download Intel/Qwen3.6-27B-int4-AutoRound \
  --local-dir /model/Qwen3.6-27B-int4-AutoRound

约 18GB,包含 10 个 safetensors 分片。

DFlash 推测模型

huggingface-cli download z-lab/Qwen3.6-27B-DFlash \
  --local-dir /model/Qwen3.6-27B-DFlash

约 3.3GB,单个 model.safetensors 文件。⚠️ 该仓库为 gated repo,需先在 HuggingFace 申请访问权限。

💡 下载加速
如果 HuggingFace 直连速度慢,可使用国内镜像:
HF_ENDPOINT=https://hf-mirror.com huggingface-cli download ...
对于最后几 GB 卡住的情况,可切换到 wget -c 手动下载。

3. 启动服务

使用 DGX Spark 的 launch-cluster.sh 脚本启动 vLLM 容器:

cd ~/spark-vllm-docker
VLLM_SPARK_EXTRA_DOCKER_ARGS='-v /model:/model' \
./launch-cluster.sh -t vllm-node-tf5 --solo -d \
  -e VLLM_MARLIN_USE_ATOMIC_ADD=1 \
  exec vllm serve /model/Qwen3.6-27B-int4-AutoRound \
    --host 0.0.0.0 --port 30002 \
    --served-model-name vllm2 \
    --max-model-len 262144 \
    --max-num-batched-tokens 32768 \
    --gpu-memory-utilization 0.5 \
    --enable-auto-tool-choice \
    --reasoning-parser qwen3 \
    --tool-call-parser qwen3_xml \
    --enable-prefix-caching \
    --default-chat-template-kwargs '{"preserve_thinking":true}' \
    --speculative-config '{"method": "dflash", "model": "/model/Qwen3.6-27B-DFlash", "num_speculative_tokens": 15}' \
    --attention-backend flash_attn
⚠️ 卷挂载注意事项
launch-cluster.sh 不支持 -v 参数直接传入。需通过环境变量 VLLM_SPARK_EXTRA_DOCKER_ARGS 传递额外的 Docker 参数。
容器使用 host 网络模式,端口直接暴露在宿主机上。

4. 参数详解

参数说明
--port30002API 监听端口(host 网络模式)
--served-model-namevllm2对外模型 ID,客户端调用时使用
--max-model-len262144最大上下文长度 262K tokens
--gpu-memory-utilization0.5GPU 显存利用率 50%
--max-num-batched-tokens32768批处理 token 上限
--speculative-configDFlash, 15 tokens推测解码配置
--attention-backendflash_attnFlashAttention 加速
--enable-prefix-cachingtrue启用前缀缓存
--reasoning-parserqwen3思考过程解析器

5. 性能实测

在 NVIDIA DGX Spark(GB10 架构)上实测结果:

单并发测试

次数Tokens耗时速度
12005.23s38.2 tok/s
22005.00s40.0 tok/s
32005.00s40.0 tok/s
42006.08s32.9 tok/s
52005.12s39.0 tok/s

单并发平均:38.0 tok/s

并发 4 测试

请求耗时
请求17.89s
请求27.90s
请求38.02s
请求48.79s
批处理耗时8.80s
总吞吐90.9 tok/s

6. 验证部署

服务启动后,通过 API 检查模型是否就绪:

curl http://节点一:30002/v1/models

返回包含 "id": "vllm2" 即表示部署成功。

7. 踩坑记录

reasoning-parser 兼容性问题

⚠️ 内容返回 null
使用 --reasoning-parser qwen3 时,如果模型未输出 <think> 标签,content 字段可能为空,所有输出进入 reasoning 字段。
解决方法:去掉 --reasoning-parser qwen3--tool-call-parser qwen3_xml 参数,模型将直接输出内容到 content 字段。

HuggingFace 下载限速

HuggingFace 对单个大文件下载可能严重限速(低至 30KB/s)。应对策略:

launch-cluster.sh 卷挂载

该脚本不支持 -v 参数,必须通过环境变量 VLLM_SPARK_EXTRA_DOCKER_ARGS='-v /model:/model' 传递。

← 返回 DGX Spark 教程列表