Qwen3.8-Flash-Next¶
1 简介¶
Note
本文档中提到的“PD 分离部署”仅作为示例/参考设计提供,用于演示以分离模式部署 Prefill 和 Decode 的基本流程。不建议在生产环境中使用。
对于客户侧的生产环境,推荐使用 MindIE Motor + vLLM-Ascend。
Qwen3.8-Flash-Next 是一个多模态混合专家(MoE)模型,也是未来支撑 Qwen4 架构的实验性预览版本。其语言模型融合了门控 DeltaNet(GDN)与 Qwen 稀疏注意力(QSA)、门控残差连接、位置学习增强(PLE)以及原生多 Token 预测(MTP)头。
本教程涵盖在 Atlas A2系列产品、Atlas A3系列产品和 Ascend 950DT系列产品上的准备工作、部署、验证和评估,包括混部、PD 分离以及 MemCache 三级池化部署。
Qwen3.8-Flash-Next(实验特性)首次在 vllm-ascend:v0.26.0rc 中支持。示例使用 W4A8 权重(在 Ascend 950DT系列产品上使用 W4A8-MXFP)。为获得最佳性能,推荐使用 vLLM-Ascend v0.32.0rc(releases/v0.32.0rc)。
Warning
自动前缀缓存为实验特性。对于 Atlas A2系列产品和 Atlas A3系列产品的混部部署,请使用 --enable-prefix-caching --mamba-cache-mode align 启用,并针对目标上下文长度和并发量重新验证 NPU 内存容量。
2 支持的特性¶
3 前提条件¶
3.1 模型权重¶
| 权重版本 | 硬件要求 | 下载链接 |
|---|---|---|
Qwen3.8-Flash-Next-w8a8-mtp(量化版本) |
Atlas A3系列产品 | ModelScope |
Qwen3.8-Flash-Next-w4a8(量化版本) |
Atlas A2系列产品 / Atlas A3系列产品 | ModelScope |
Qwen3.8-Flash-Next-w4a8-mxfp(量化版本) |
Ascend 950DT系列产品 | ModelScope |
示例在 VLLM_USE_MODELSCOPE=True 时使用 ModelScope 模型 ID。PD 两个角色必须加载相同的权重。
4 安装¶
4.1 Docker 镜像安装¶
完整安装指南请参见使用 Docker。
请为目标硬件选择对应的镜像。
Note
在主机上运行 Docker。IMAGE 用于选择镜像;NAME 是 docker exec 使用的容器名称。镜像版本与文档发布版本保持一致;复制原始 Markdown 时请替换版本模板。
The image tag template follows the documentation build. For the recommended vLLM-Ascend 0.32 RC runtime, select the matching 0.32 RC image tag for your hardware if the rendered tag is from another release. This also applies to the pooling images in Section 4.3.
# Reuse the host model cache at /root/.cache.
export IMAGE=quay.io/ascend/vllm-ascend:v0.30.0-a2
export NAME=vllm-ascend
docker run --rm \
--name $NAME \
--net=host \
--shm-size=128g \
--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 \
-v /etc/hccn.conf:/etc/hccn.conf:ro \
-v /root/.cache:/root/.cache \
-it $IMAGE bash
# Reuse the host model cache at /root/.cache.
export IMAGE=quay.io/ascend/vllm-ascend:v0.30.0-a3
export NAME=vllm-ascend
docker run --rm \
--name $NAME \
--net=host \
--shm-size=128g \
--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/davinci8 \
--device /dev/davinci9 \
--device /dev/davinci10 \
--device /dev/davinci11 \
--device /dev/davinci12 \
--device /dev/davinci13 \
--device /dev/davinci14 \
--device /dev/davinci15 \
--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 \
-v /etc/hccn.conf:/etc/hccn.conf:ro \
-v /root/.cache:/root/.cache \
-it $IMAGE bash
# Reuse the host model cache at /root/.cache.
export IMAGE=quay.io/ascend/vllm-ascend:v0.30.0-a5
export NAME=vllm-ascend
docker run --rm \
--name $NAME \
--net=host \
--shm-size=500g \
--device /dev/davinci_manager \
--device /dev/hisi_hdc \
--device /dev/ummu \
--device /dev/uburma \
--device /dev/davinci0 \
--device /dev/davinci1 \
--device /dev/davinci2 \
--device /dev/davinci3 \
--device /dev/davinci4 \
--device /dev/davinci5 \
--device /dev/davinci6 \
--device /dev/davinci7 \
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
-v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \
-v /root/host:/root/host \
-v /usr/local/sbin:/usr/local/sbin \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /var/log/npu:/usr/slog \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /etc/hixlep:/etc/hixlep \
-v /root/.cache:/root/.cache \
-it $IMAGE bash
A2/A3 的 /etc/hccn.conf 挂载为 PD 示例提供通信配置;请确认主机上存在该文件,如果仅运行混部部署,可省略此挂载。
确保在服务 shell 中已初始化 CANN 和 ATB 环境。如果镜像未自动初始化,请从各自的安装目录 source 对应的 set_env.sh 脚本。然后验证 vLLM 和 vLLM-Ascend 能否正常导入:
4.2 源码安装¶
在 Atlas A2系列产品、Atlas A3系列产品或 Ascend 950DT系列产品上进行源码安装时,请遵循安装指南。
按照安装指南的说明,在服务 shell 中初始化 CANN 和 ATB 环境。对于多节点部署,请在每个节点上配置环境。
4.3 用于三级 PD 池化的 Docker¶
这些容器用于 MemCache 三级 PD 池化。其他部署模式使用第 4.1 节。容器权限遵循 MemCache Docker 示例。
在主机上准备存储,然后使用对应的硬件标签页为每台主机创建一个容器。按照第 5.5 节的说明在容器内启动服务。
对于 A2,请在每台主机上准备独立的 SSD 和配置目录。在 prefill 主机上运行 Prefill、MetaService 和 Proxy,在 decode 主机上运行 Decode,并使用共享的 MetaService 和 ConfigStore 端点。
A2 主机 HDK 要求
A2 三级池化要求两台主机上的 HDK 均为 25.5.1 或更高版本。HDK 安装在主机上,而非 Docker 镜像中。请在每台主机上运行 npu-smi info 检查版本;如果版本较低,请遵循 HDK 升级指南 升级,并在启动容器前再次检查。
在主机上准备 SSD 设备:
请选择一块专用设备,其上没有分区、挂载点、文件系统签名或需要保留的数据。不要使用系统盘。如果已有合适的设备,可跳过下面的 loop 文件命令。
如果没有专用磁盘而需要进行测试,请在现有 SSD 文件系统上选择一个全新的后备文件路径。将 LOOP_BACKING_SIZE 设置为此部署计划使用的容量(包含单位)。其父目录必须存在且有足够的可用空间:
export LOOP_BACKING_FILE="<ABSOLUTE_PATH_TO_NEW_BACKING_FILE>"
export LOOP_BACKING_SIZE="<BACKING_FILE_SIZE_WITH_UNIT>"
df -h "$(dirname "${LOOP_BACKING_FILE}")"
test ! -e "${LOOP_BACKING_FILE}" || exit 1
sudo fallocate -l "${LOOP_BACKING_SIZE}" "${LOOP_BACKING_FILE}"
sudo losetup --find --show --direct-io=on "${LOOP_BACKING_FILE}"
将 SSD_DEVICE_PATH 设置为 losetup 返回的设备,而不是后备文件路径。对于 A3 双设备示例,请先使用不同的后备文件准备第二个设备,然后再继续。使用专用磁盘时可跳过 loop 设备的创建。
复用现有池时,请保留其设备和后备文件;跳过新设备的创建和初始化。
准备个人配置目录和设备映射:
在用于 docker run 的主机终端中,将 MEMCACHE_CONFIG_DIR 设置为您的个人配置目录,将 SSD_DEVICE_PATH 设置为专用设备或 loop 设备:
export MEMCACHE_CONFIG_DIR="<ABSOLUTE_PERSONAL_CONFIG_DIR>"
export SSD_DEVICE_PATH="<ACTUAL_SSD_DEVICE_PATH>"
mkdir -p "${MEMCACHE_CONFIG_DIR}"
test -b "${SSD_DEVICE_PATH}" || exit 1
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS "${SSD_DEVICE_PATH}"
sudo blkid "${SSD_DEVICE_PATH}"
对于新建的存储池,只有在确认每个所选设备都没有文件系统签名或挂载点后才能继续;对于空白设备,blkid 通常不输出任何内容并返回非零状态。下方 Atlas A2系列产品和 Ascend 950DT系列产品的命令各映射一个设备;Atlas A3系列产品的示例映射两个设备。请在创建容器前准备好所有设备,并用 : 分隔它们对应的 ubsio.disk.path 条目。
Warning
在第 5.5 节中,MEMCACHE_FORCE_NEW_DISK 控制 ubsio.standalone.force_new_disk。将其设置为 true 会在启动时重新初始化缓存存储。请根据目标部署选择其值,并且仅使用专用缓存存储。
Note
在启动 Docker 之前设置 MEMCACHE_CONFIG_DIR。-e 将其值传入容器,-v 将该目录挂载到相同路径。第 5.5 节会将镜像模板复制到该目录,并使用这些个人文件。
在第 5.5 节中,将 MEMCACHE_SSD_PATHS 设置为由 --device 映射的设备路径。
在运行 Docker 之前,请确认所有主机设备和文件路径均存在。
Ascend 950DT系列产品通信前提条件
请按照 Ascend 950DT系列产品容器要求 和 MemCache 环境准备 准备通信环境。添加所选运行时和传输方式所需的通信文件挂载;容器要求中说明了何时可以省略 /lib/route.conf。
# Reuse the host model cache at /root/.cache.
export IMAGE=quay.io/ascend/vllm-ascend:v0.30.0-a2
export NAME=vllm-ascend-qwen38-pool
docker run --rm \
--name $NAME \
-e MEMCACHE_CONFIG_DIR \
--net=host \
--privileged=true \
--shm-size=128g \
--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 "${SSD_DEVICE_PATH}:${SSD_DEVICE_PATH}" \
--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 \
-v /etc/hccn.conf:/etc/hccn.conf:ro \
-v /root/.cache:/root/.cache \
-v "${MEMCACHE_CONFIG_DIR}:${MEMCACHE_CONFIG_DIR}" \
-it $IMAGE bash
第 5.5 节中的 A3 示例使用两个 SSD 设备。将 SSD_DEVICE_PATH 设置为第一个设备,将 SSD_DEVICE_PATH_2 设置为上面准备的第二个设备;在创建容器之前请检查两者。示例设备名称为 /dev/loop0 和 /dev/loop1,但请使用您主机上返回的实际名称。
export SSD_DEVICE_PATH_2="<SECOND_ACTUAL_SSD_DEVICE_PATH>"
test -b "${SSD_DEVICE_PATH_2}" || exit 1
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS "${SSD_DEVICE_PATH_2}"
sudo blkid "${SSD_DEVICE_PATH_2}"
# Reuse the host model cache at /root/.cache.
export IMAGE=quay.io/ascend/vllm-ascend:v0.30.0-a3
export NAME=vllm-ascend-qwen38-pool
docker run --rm \
--name $NAME \
-e MEMCACHE_CONFIG_DIR \
--net=host \
--privileged=true \
--shm-size=128g \
--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/davinci8 \
--device /dev/davinci9 \
--device /dev/davinci10 \
--device /dev/davinci11 \
--device /dev/davinci12 \
--device /dev/davinci13 \
--device /dev/davinci14 \
--device /dev/davinci15 \
--device /dev/davinci_manager \
--device "${SSD_DEVICE_PATH}:${SSD_DEVICE_PATH}" \
--device "${SSD_DEVICE_PATH_2}:${SSD_DEVICE_PATH_2}" \
--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 \
-v /etc/hccn.conf:/etc/hccn.conf:ro \
-v /root/.cache:/root/.cache \
-v "${MEMCACHE_CONFIG_DIR}:${MEMCACHE_CONFIG_DIR}" \
-it $IMAGE bash
# Reuse the host model cache at /root/.cache.
export IMAGE=quay.io/ascend/vllm-ascend:v0.30.0-a5
export NAME=vllm-ascend-qwen38-pool
docker run --rm \
--name $NAME \
-e MEMCACHE_CONFIG_DIR \
--net=host \
--privileged=true \
--shm-size=500g \
--device /dev/davinci_manager \
--device "${SSD_DEVICE_PATH}:${SSD_DEVICE_PATH}" \
--device /dev/hisi_hdc \
--device /dev/ummu \
--device /dev/uburma \
--device /dev/davinci0 \
--device /dev/davinci1 \
--device /dev/davinci2 \
--device /dev/davinci3 \
--device /dev/davinci4 \
--device /dev/davinci5 \
--device /dev/davinci6 \
--device /dev/davinci7 \
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
-v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \
-v /root/host:/root/host \
-v /usr/local/sbin:/usr/local/sbin \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /var/log/npu:/usr/slog \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /etc/hixlep:/etc/hixlep \
-v /etc/hccn.conf:/etc/hccn.conf:ro \
-v /usr/bin/urma_admin:/usr/bin/urma_admin:ro \
-v /root/.cache:/root/.cache \
-v "${MEMCACHE_CONFIG_DIR}:${MEMCACHE_CONFIG_DIR}" \
-it $IMAGE bash
保持容器运行。在主机上使用以下命令打开额外的服务终端:
使用由 NAME 设置的容器名称。新 shell 会继承 MEMCACHE_CONFIG_DIR;请在每个 shell 中重复第 5.5 节的库和服务导出。保持目录路径与容器的环境和挂载一致。
进入容器后,检查模型和存储依赖是否可用:
python -c "import vllm, vllm_ascend, mooncake, memcache_hybrid, memfabric_hybrid; print('Model and pool dependencies are available')"
在第 5.5 节中检查 MemCache 依赖版本。请将池 DRAM 和 UBS IO 内存与容器的 /dev/shm 限制(--shm-size)分开预算。
Ascend 950DT系列产品池化运行时
请使用支持 Qwen3.8-Flash-Next 和 MemCache 三级池化的运行时。按照第 4.1 节所述初始化 CANN/ATB。如果镜像不会自动初始化其仓库、自定义算子和模型库,请在每个服务 shell 中执行以下操作;请使用实际的容器路径,并用 : 分隔库目录。
export ASCEND_REPO="<VLLM_ASCEND_REPOSITORY_IN_CONTAINER>"
export MODEL_RUNTIME_LIB_DIRS="<MOONCAKE_TORCH_AND_TORCH_NPU_LIBRARY_DIRECTORIES>"
export PYTHONPATH="${ASCEND_REPO}${PYTHONPATH:+:${PYTHONPATH}}"
source "${ASCEND_REPO}/vllm_ascend/_cann_ops_custom/vendors/custom_transformer/bin/set_env.bash"
export LD_LIBRARY_PATH="${MODEL_RUNTIME_LIB_DIRS}:${LD_LIBRARY_PATH:-}"
使用当前活动环境的 Mooncake、Torch 和 torch_npu 库目录。MemCache/MemFabric 库路径在第 5.5 节中设置。
5 在线服务部署¶
5.1 单节点在线部署¶
Prefill 和 decode 在同一服务中运行。请选择下方的硬件标签页。
启动之前:
- 确保服务环境可以访问 ModelScope 以下载检查点。
- 在更改上下文长度、并发数或内存利用率之前,请确认可用的 NPU 内存。
通用设置:
- 三个示例均启用了 Model Runner V2、异步调度、专家并行、前缀缓存、decode 图捕获(
FULL_DECODE_ONLY)和三 token MTP。MTP 显式设置enforce_eager=false以允许图执行;设置为true会强制 MTP 使用 eager 执行。 cpu_offload=true将 Engram 嵌入表放在主机内存中;dp_shared_memory=false为 DP1 禁用共享。请使用具有受支持 n-gram 层且主机内存充足的检查点。- 已启用 CPU 绑定、FlashComm1、共享专家 DP 和共享专家重叠。共享专家 DP 需要专家并行且 TP > 1。
enable_fused_mc2=0禁用融合 MC2;norm/量化融合已禁用。 --mamba-cache-mode align为前缀缓存对齐 GDN 和 PLE 状态检查点。工具调用和推理解析见第 6 节。- 多模态请求需要视觉编码器;如需纯文本服务,请添加
--language-model-only。
此 W4A8 部署使用 TP8 × DP1,最大上下文长度为 131072 个 token,最多 8 个活动序列。
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_ENGINE_READY_TIMEOUT_S=4800
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 8088 \
--served-model-name qwen3.8-flash-next \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 8 \
--data-parallel-size 1 \
--enable-expert-parallel \
--max-model-len 131072 \
--max-num-seqs 8 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.93 \
--enable-prefix-caching \
--mamba-cache-mode align \
--async-scheduling \
--enable-auto-tool-choice \
--tool-call-parser qwen3_xml \
--reasoning-parser qwen3 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--additional-config '{"enable_cpu_binding":true,"enable_shared_expert_dp":true,"enable_fused_mc2":0,"enable_flashcomm1":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":false,"enable_super_kernel":false}}'
关键参数:
- TP8 × DP1 使用八个设备。已启用 NPU 图扩展;静态 kernel 和超级 kernel 已禁用。
此 W4A8 部署使用 TP8 × DP1,最大上下文长度为 131072 个 token,最多 8 个活动序列。
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_ENGINE_READY_TIMEOUT_S=4800
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 8088 \
--served-model-name qwen3.8-flash-next \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 8 \
--data-parallel-size 1 \
--enable-expert-parallel \
--max-model-len 131072 \
--max-num-seqs 8 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.93 \
--enable-prefix-caching \
--mamba-cache-mode align \
--async-scheduling \
--enable-auto-tool-choice \
--tool-call-parser qwen3_xml \
--reasoning-parser qwen3 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--additional-config '{"enable_cpu_binding":true,"enable_shared_expert_dp":true,"enable_fused_mc2":0,"enable_flashcomm1":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}'
关键参数:
- TP8 × DP1 使用八个设备。已启用 NPU 图扩展和静态 kernel;超级 kernel 已禁用。
此 W4A8-MXFP 部署使用 TP4 × DP1,最大上下文长度为 141312 个 token,最多 32 个活动序列。
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export TASK_QUEUE_ENABLE=1
export HCCL_BUFFSIZE=1024
export HCCL_NPU_SOCKET_PORT_RANGE=auto
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp \
--host 0.0.0.0 \
--port 8087 \
--served-model-name qwen3.8-flash-next-950-dt \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 4 \
--data-parallel-size 1 \
--max-model-len 141312 \
--max-num-seqs 32 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--enable-auto-tool-choice \
--tool-call-parser qwen3_xml \
--reasoning-parser qwen3 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_cpu_binding":true,"enable_shared_expert_dp":true,"enable_fused_mc2":0,"enable_flashcomm1":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}'
关键参数:
- TP4 × DP1 使用设备 0–3 和 W4A8-MXFP 检查点。NPU 图扩展和静态内核已启用;超级内核已禁用。
服务验证:
等待模型加载和图捕获完成,然后从服务主机检查服务。Atlas A2系列产品和 Atlas A3系列产品使用端口 8088,Ascend 950DT系列产品使用端口 8087:
响应中应列出已配置的模型名称。启动后,请使用第 6 节验证生成。
5.2 基础 PD 分离部署¶
按照第 4 节准备运行时,并遵循 Mooncake 安装指南。在不同终端中分别运行 P/D 命令,待其 API 就绪后再启动代理。
对于 Ascend 950DT系列产品,基础 PD、图文 10K 用例和长上下文用例使用 第 4.1 节 中相同的 Docker 容器设置,位于 950DT products 标签页下。
Note
在每个终端中设置 IP 和网卡变量;nic_name 必须拥有 local_ip。通信相关的环境变量导出使用这些值,no_proxy/NO_PROXY 用于让服务地址绕过 HTTP 代理。
This W4A8 deployment uses two eight-device A2 series hosts. Prefill runs on PREFILL_HOST and Decode runs on DECODE_HOST, each using devices 0–7. Prefill uses TP4 × PP2 × DP1, and Decode uses TP2 × DP4. Both roles load the same checkpoint; the proxy routes requests through one API endpoint per role (1P1D).
启动之前:
- 暴露所需设备,挂载
/etc/hccn.conf,并使用--shm-size=128g。为 Engram CPU 卸载和 DP 共享内存提供充足的主机内存。 - 在不同终端中分别运行 P 和 D。待两个 API 就绪后,在 prefill 主机上从 vLLM-Ascend 仓库根目录启动代理。
Prefill:
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
local_ip="${PREFILL_HOST}"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=8192
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25568 \
--served-model-name qwen38-flash-next-a2-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 4 \
--pipeline-parallel-size 2 \
--data-parallel-size 1 \
--max-model-len 141312 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--enforce-eager \
--additional-config '{"enable_shared_expert_dp":true,"enable_flashcomm1":true,"enable_prefill_mc2":true,"enable_fused_mc2":0,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":32600,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4,"pp_size":2},"decode":{"dp_size":4,"tp_size":2}}}'
Decode:
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
local_ip="${DECODE_HOST}"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25569 \
--served-model-name qwen38-flash-next-a2-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 4 \
--max-model-len 141312 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"enable_shared_expert_dp":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":32700,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4,"pp_size":2},"decode":{"dp_size":4,"tp_size":2}}}'
代理:
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
export no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host 0.0.0.0 --port 25570 \
--prefiller-hosts "${PREFILL_HOST}" --prefiller-ports 25568 \
--decoder-hosts "${DECODE_HOST}" --decoder-ports 25569
服务验证:
检查启动日志,确认 Prefill 使用 TP4 × PP2 × DP1,Decode 使用 TP2 × DP4 且 enable_static_kernel=true。在 prefill 主机上,检查两个 API 是否都列出 qwen38-flash-next-a2-pd:
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
curl --fail "http://${PREFILL_HOST}:25568/v1/models"
curl --fail "http://${DECODE_HOST}:25569/v1/models"
两项检查均成功后,在单独终端中启动代理,并验证完整的 PD 路径:
curl --fail "http://127.0.0.1:25570/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen38-flash-next-a2-pd",
"messages": [{"role": "user", "content": "Who are you?"}],
"max_tokens": 1024,
"temperature": 0
}'
如果请求失败,请检查 prefill、decode 和代理终端的输出。
This W4A8 PD deployment uses one 16-device A3 series host specified by local_ip. Prefill uses TP2 × PP4 × DP1 (EP2) on devices 0–7. Decode uses TP2 × DP4 (EP8) on devices 8–15. Both roles load the same checkpoint. The proxy routes requests through one Prefill API endpoint and one Decode API endpoint (1P1D); Decode runs four DP replicas behind its endpoint.
启动之前:
- 暴露所需设备,挂载
/etc/hccn.conf,并使用--shm-size=128g。为 Engram CPU 卸载和 DP 共享内存提供充足的主机内存。 - 在不同终端中分别运行 P 和 D。待两个 API 就绪后,在 prefill 主机上从 vLLM-Ascend 仓库根目录启动代理。
Prefill:
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=8192
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25568 \
--served-model-name qwen38-flash-next-a3-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--pipeline-parallel-size 4 \
--data-parallel-size 1 \
--max-model-len 262144 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--enforce-eager \
--additional-config '{"enable_shared_expert_dp":true,"enable_flashcomm1":true,"enable_prefill_mc2":true,"enable_fused_mc2":0,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":32600,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":2,"pp_size":4},"decode":{"dp_size":4,"tp_size":2}}}'
Decode:
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=8,9,10,11,12,13,14,15
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25569 \
--served-model-name qwen38-flash-next-a3-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 4 \
--max-model-len 262144 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"enable_shared_expert_dp":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":32700,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":2,"pp_size":4},"decode":{"dp_size":4,"tp_size":2}}}'
代理:
local_ip="<LOCAL_SERVICE_IP>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
export no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host 0.0.0.0 --port 25570 \
--prefiller-hosts "${local_ip}" --prefiller-ports 25568 \
--decoder-hosts "${local_ip}" --decoder-ports 25569
服务验证:
Check the startup logs for TP2 × PP4 × DP1 (EP2) on Prefill and TP2 × DP4 (EP8) with enable_static_kernel=true on Decode. From the serving host, check that both APIs list qwen38-flash-next-a3-pd:
两项检查均成功后,在单独终端中启动代理,并验证完整的 PD 路径:
curl --fail "http://127.0.0.1:25570/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen38-flash-next-a3-pd",
"messages": [{"role": "user", "content": "Who are you?"}],
"max_tokens": 1024,
"temperature": 0
}'
如果请求失败,请检查 prefill、decode 和代理终端的输出。
This W4A8-MXFP deployment uses eight devices on one 950DT products host. Prefill and Decode each use TP2 × DP2 (EP4), with one command per role managing both DP replicas behind a single API endpoint. MooncakeConnectorV2 transfers KV cache between the two roles.
| 设置 | Prefill | Decode |
|---|---|---|
| Visible devices | 0,1,2,3 | 4,5,6,7 |
| TP × PP × DP | 2 × 1 × 2 | 2 × 1 × 2 |
| EP | 4 | 4 |
| API port | 8088 | 8092 |
| DP RPC port | 13388 | 13389 |
| Mooncake 角色 / KV 基础端口 | kv_producer / 30000 |
kv_consumer / 30100 |
| Maximum context / sequences / batched tokens | 143360 / 64 / 4096 | 143360 / 64 / 4096 |
两个角色均加载 Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp。在每个命令块中将 local_ip 设置为服务主机地址,将 nic_name 设置为其网络接口。为 Engram CPU 卸载和共享内存提供充足的主机内存。
在不同终端中分别运行 Prefill 和 Decode。待两个 API 就绪后启动代理。端口 8087 也被同机部署示例使用,因此在启动此代理前请停止该服务。
这些命令保留了已验证运行时中的 VLLM_VERSION=0.32.0。该变量会覆盖 vLLM 版本检测;它不会安装或升级 vLLM。按第 4.1 节所述初始化 CANN/ATB。
Prefill:
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset CPLUS_INCLUDE_PATH CPATH C_INCLUDE_PATH
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
export VLLM_HOST_IP="${local_ip}"
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 VLLM_VERSION=0.32.0
export VLLM_RPC_TIMEOUT=3600000
export HCCL_EXEC_TIMEOUT=204
export HCCL_CONNECT_TIMEOUT=120
export VLLM_ASCEND_ENABLE_MLAPO=1
export VLLM_USE_V1=1
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export TASK_QUEUE_ENABLE=1
export HCCL_BUFFSIZE=8192
export HCCL_OP_EXPANSION_MODE=AIV
export ASCEND_BUFFER_POOL=0:0
export HCCL_IF_BASE_PORT=62000
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp \
--api-server-count 1 \
--host 0.0.0.0 \
--port 8088 \
--served-model-name qwen38-flash-next-950-dt-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 2 \
--data-parallel-address "${local_ip}" \
--data-parallel-rpc-port 13388 \
--max-model-len 143360 \
--max-num-seqs 64 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.90 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--enable-prefix-caching \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--async-scheduling \
--enable-expert-parallel \
--compilation-config '{"cudagraph_mode":"NONE"}' \
--additional-config '{"enable_cpu_binding":true,"enable_shared_expert_dp":true,"enable_fused_mc2":0,"enable_flashcomm1":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":false,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":30000,"kv_connector_extra_config":{"prefill":{"dp_size":2,"tp_size":2},"decode":{"dp_size":2,"tp_size":2}}}'
Decode:
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset CPLUS_INCLUDE_PATH CPATH C_INCLUDE_PATH
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
export VLLM_HOST_IP="${local_ip}"
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 VLLM_VERSION=0.32.0
export VLLM_RPC_TIMEOUT=3600000
export HCCL_EXEC_TIMEOUT=204
export HCCL_CONNECT_TIMEOUT=120
export VLLM_ASCEND_ENABLE_MLAPO=1
export VLLM_USE_V1=1
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=4,5,6,7
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export TASK_QUEUE_ENABLE=1
export HCCL_BUFFSIZE=8192
export HCCL_OP_EXPANSION_MODE=AIV
export ASCEND_BUFFER_POOL=0:0
export HCCL_IF_BASE_PORT=63000
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp \
--api-server-count 1 \
--host 0.0.0.0 \
--port 8092 \
--served-model-name qwen38-flash-next-950-dt-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 2 \
--data-parallel-address "${local_ip}" \
--data-parallel-rpc-port 13389 \
--max-model-len 143360 \
--max-num-seqs 64 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.90 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--enable-prefix-caching \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--async-scheduling \
--enable-expert-parallel \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_cpu_binding":true,"enable_shared_expert_dp":true,"enable_fused_mc2":0,"enable_flashcomm1":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false},"scheduler_config":{"recompute_scheduler_enable":true}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":30100,"kv_connector_extra_config":{"prefill":{"dp_size":2,"tp_size":2},"decode":{"dp_size":2,"tp_size":2}}}'
代理:
待两个模型 API 就绪后,从 vLLM-Ascend 仓库根目录运行以下命令:
local_ip="<LOCAL_SERVICE_IP>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host "${local_ip}" \
--port 8087 \
--prefiller-hosts "${local_ip}" \
--prefiller-ports 8088 \
--decoder-hosts "${local_ip}" \
--decoder-ports 8092
服务验证:
Check the startup logs for TP2 × DP2 (EP4) on each role, cudagraph_mode=NONE on Prefill, and FULL_DECODE_ONLY with static kernels on Decode. Check that both APIs list qwen38-flash-next-950-dt-pd before starting the proxy:
local_ip="<LOCAL_SERVICE_IP>"
curl --fail "http://${local_ip}:8088/v1/models"
curl --fail "http://${local_ip}:8092/v1/models"
代理开始监听后,验证完整的 PD 路径:
A2/A3 关键参数:
- A2 Prefill uses TP4 × PP2 × DP1 (EP4), and A3 Prefill uses TP2 × PP4 × DP1 (EP2). Both run in eager mode with
enable_prefill_mc2=trueand fused MC2 disabled. Check MC2 token limits before increasing the batch budget. - A2 and A3 Decode use TP2 × DP4 (EP8),
FULL_DECODE_ONLY, NPU graph extension, static kernels, and recompute scheduling; super kernels are disabled. - Both roles use three MTP draft tokens, with
enforce_eager=trueon P andfalseon D. Batch tokens are 8192; P/D HCCL buffers are 8192/512. - Engram CPU offload requires supported n-gram layers and sufficient host memory. P uses
dp_shared_memory=false; D usestrue. Shared-memory DP replicas must share a host and shared-memory namespace. - Both roles set prefix caching, Mamba cache mode
align, and Mamba state dtypebfloat16. Keep Mooncake TP/PP/DP declarations consistent with the model commands; clearVLLM_PP_LAYER_PARTITIONto use the default partition. - Prefill sets
enable_fused_mc2=0while enabling shared expert overlap.
Ascend 950DT系列产品关键参数:
- Each command starts TP2 × DP2 (EP4) on four devices.
--api-server-count 1exposes one API endpoint per role. Use distinct DP RPC ports for Prefill and Decode. - Model Runner V2, async scheduling, and expert parallelism are enabled.
- Engram uses CPU offload and DP shared memory. DP replicas must share the same host and shared-memory namespace.
- Both roles enable prefix caching with Mamba cache mode
alignand Mamba SSM cache dtypebfloat16. - Prefill uses
cudagraph_mode=NONEwith static kernels disabled. - Decode uses
FULL_DECODE_ONLY, static kernels, and recompute scheduling. MTP setsenforce_eager=falseto allow graph execution. - Both roles enable CPU binding, shared expert DP, FlashComm1, shared expert multistream overlap, and NPU graph extension. Fused MC2, norm/quantization fusion, and super kernels are disabled.
- Both roles use three MTP draft tokens and
VLLM_ENGINE_READY_TIMEOUT_S=4800for engine startup; model execution usesVLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000. - Both roles use
HCCL_BUFFSIZE=8192andASCEND_BUFFER_POOL=0:0. The validated configuration separates Prefill and Decode HCCL base ports (62000/63000) and NPU socket ranges (61400–61499/61500–61599). - Keep Mooncake DP2/TP2 declarations consistent with the services. The proxy connects to Prefill on port 8088 and Decode on port 8092. Keep the configured KV base ports at 30000 and 30100; the connector applies rank offsets internally.
5.3 图文 10K PD 分离部署¶
The 10K target is the processed input length, including text and image tokens. Keep the input plus requested output within the model length configured for your deployment.
For A2 and A3, make sure Mooncake is importable in both serving containers before running the environment setup. If needed, follow the Mooncake installation guide.
This W4A8 example uses two eight-device A2 series hosts. Prefill uses TP4 × PP2 × DP1 (EP4) on the Prefill host, and Decode uses TP2 × DP4 (EP8) on the Decode host. Each host uses devices 0–7. The proxy runs on the Prefill host and routes to one Prefill API and four Decode APIs, one per DP rank.
On both hosts, initialize the A2 container and runtime as described in Section 4.1. Use the same W4A8 checkpoint with the vision encoder and image processor on both hosts.
In each engine terminal, set PREFILL_HOST and DECODE_HOST to the two hosts' service IPs and nic_name to the local interface. Set local_ip="${PREFILL_HOST}" on Prefill and local_ip="${DECODE_HOST}" on Decode before applying the exports below.
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
local_ip="<THIS_HOST_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY all_proxy ALL_PROXY
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export VLLM_SERVER_DEV_MODE=1
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=2400
export VLLM_ASCEND_PLE_BACKEND=torch
Prefill:
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=4096
export VLLM_PP_LAYER_PARTITION=24,24
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25568 \
--served-model-name qwen38-flash-next-a2-pd \
--trust-remote-code \
--mm-encoder-tp-mode data \
--quantization ascend \
--tensor-parallel-size 4 \
--pipeline-parallel-size 2 \
--data-parallel-size 1 \
--data-parallel-size-local 1 \
--max-model-len 262144 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--no-enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--compilation-config '{"cudagraph_mode":"NONE"}' \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--additional-config '{"enable_shared_expert_dp":false,"enable_flashcomm1":true,"enable_prefill_mc2":true,"enable_fused_mc2":0,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":"34600","kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4,"pp_size":2,"pp_layer_partition":"24,24"},"decode":{"dp_size":4,"tp_size":2}}}'
Decode:
Start all four ranks in the same Decode container so they share the host memory namespace. Keep this terminal open while the ranks run.
| DP rank | Visible devices | API port |
|---|---|---|
| 0 | 0,1 | 25569 |
| 1 | 2,3 | 25579 |
| 2 | 4,5 | 25589 |
| 3 | 6,7 | 25599 |
unset VLLM_PP_LAYER_PARTITION
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
for rank in 0 1 2 3; do
first_device=$((rank * 2))
api_port=$((25569 + rank * 10))
kv_port=$((32700 + rank * 20))
ASCEND_RT_VISIBLE_DEVICES="${first_device},$((first_device + 1))" \
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port "${api_port}" \
--served-model-name qwen38-flash-next-a2-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 4 \
--data-parallel-size-local 1 \
--data-parallel-rank "${rank}" \
--data-parallel-address "${DECODE_HOST}" \
--data-parallel-rpc-port 29569 \
--max-model-len 262144 \
--max-num-seqs 32 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.90 \
--no-enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"enable_shared_expert_dp":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":"'"$kv_port"'","kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4,"pp_size":2,"pp_layer_partition":"24,24"},"decode":{"dp_size":4,"tp_size":2}}}' &
done
wait
代理:
On the Prefill host, check that all five model endpoints respond, then start the proxy from the vLLM-Ascend repository root.
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY all_proxy ALL_PROXY
export no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
curl --fail --noproxy '*' "http://${PREFILL_HOST}:25568/v1/models" || exit 1
for port in 25569 25579 25589 25599; do
curl --fail --noproxy '*' "http://${DECODE_HOST}:${port}/v1/models" || exit 1
done
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host 0.0.0.0 --port 25570 \
--prefiller-hosts "${PREFILL_HOST}" --prefiller-ports 25568 \
--decoder-hosts "${DECODE_HOST}" "${DECODE_HOST}" "${DECODE_HOST}" "${DECODE_HOST}" \
--decoder-ports 25569 25579 25589 25599
服务验证:
Send a 10K sample through the proxy. Replace <IMAGE_URL> with an image URL accessible to Prefill and Decode, and replace <TEXT_PROMPT> with the corresponding text. For local image files, mount the dataset at the same container path on both hosts and set --allowed-local-media-path to that directory in both engine commands.
curl --fail "http://127.0.0.1:25570/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{"model":"qwen38-flash-next-a2-pd","messages":[{"role":"user","content":[{"type":"image_url","image_url":{"url":"<IMAGE_URL>"}},{"type":"text","text":"<TEXT_PROMPT>"}]}],"max_tokens":1024,"temperature":0}'
预期返回 HTTP 200 以及针对图像和文本的回答。对照 10K 目标检查 usage.prompt_tokens,并确认没有图像处理、KV 传输或内存不足错误。
关键参数:
- Prefill uses a
24,24layer partition.--mm-encoder-tp-mode datadistributes complete images across the TP ranks for the vision encoder. The language model uses TP4 × PP2. - Decode enables static kernels and uses an API endpoint per DP rank.
- This case disables prefix caching on both roles. The Prefill/Decode batch token limits are 8192/4096, and both roles use
--max-model-len 262144.
This single-host W4A8 example uses TP4 × PP2 × DP1 (EP4) on devices 0–7 for Prefill and TP2 × DP4 (EP8) on devices 8–15 for Decode. The proxy routes to one Prefill API and four Decode APIs, one per DP rank.
Initialize the A3 container and runtime as described in Section 4.1. Use a W4A8 checkpoint with the vision encoder and image processor. Run the following environment setup in both the Prefill and Decode terminals. Set local_ip and nic_name to the serving host's address and interface.
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY all_proxy ALL_PROXY
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export VLLM_SERVER_DEV_MODE=1
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=2400
export VLLM_ASCEND_PLE_BACKEND=torch
Prefill:
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=4096
export VLLM_PP_LAYER_PARTITION=24,24
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25568 \
--served-model-name qwen38-flash-next-a3-pd \
--trust-remote-code \
--mm-encoder-tp-mode data \
--quantization ascend \
--tensor-parallel-size 4 \
--pipeline-parallel-size 2 \
--data-parallel-size 1 \
--data-parallel-size-local 1 \
--max-model-len 262144 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--no-enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--compilation-config '{"cudagraph_mode":"NONE"}' \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--additional-config '{"enable_shared_expert_dp":false,"enable_flashcomm1":true,"enable_prefill_mc2":true,"enable_fused_mc2":0,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":"34600","kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4,"pp_size":2,"pp_layer_partition":"24,24"},"decode":{"dp_size":4,"tp_size":2}}}'
Decode:
Start all four ranks in the same container so they share the host memory namespace. Keep this terminal open while the ranks run.
| DP rank | Visible devices | API port |
|---|---|---|
| 0 | 8,9 | 25569 |
| 1 | 10,11 | 25579 |
| 2 | 12,13 | 25589 |
| 3 | 14,15 | 25599 |
unset VLLM_PP_LAYER_PARTITION
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
for rank in 0 1 2 3; do
first_device=$((8 + rank * 2))
api_port=$((25569 + rank * 10))
kv_port=$((32700 + rank * 20))
ASCEND_RT_VISIBLE_DEVICES="${first_device},$((first_device + 1))" \
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port "${api_port}" \
--served-model-name qwen38-flash-next-a3-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 4 \
--data-parallel-size-local 1 \
--data-parallel-rank "${rank}" \
--data-parallel-address "${local_ip}" \
--data-parallel-rpc-port 29569 \
--max-model-len 262144 \
--max-num-seqs 32 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.90 \
--no-enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"enable_shared_expert_dp":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":"'"$kv_port"'","kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4,"pp_size":2,"pp_layer_partition":"24,24"},"decode":{"dp_size":4,"tp_size":2}}}' &
done
wait
代理:
Check that all five model endpoints respond, then start the proxy from the vLLM-Ascend repository root.
local_ip="<LOCAL_SERVICE_IP>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY all_proxy ALL_PROXY
export no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
for port in 25568 25569 25579 25589 25599; do
curl --fail --noproxy '*' "http://${local_ip}:${port}/v1/models" || exit 1
done
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host 0.0.0.0 --port 25570 \
--prefiller-hosts "${local_ip}" --prefiller-ports 25568 \
--decoder-hosts "${local_ip}" "${local_ip}" "${local_ip}" "${local_ip}" \
--decoder-ports 25569 25579 25589 25599
服务验证:
Send a 10K sample through the proxy. Replace <IMAGE_URL> with an image URL accessible to Prefill and Decode, and replace <TEXT_PROMPT> with the corresponding text. For local image files, mount the dataset in the serving container and set --allowed-local-media-path to the mounted directory in both engine commands.
curl --fail "http://127.0.0.1:25570/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{"model":"qwen38-flash-next-a3-pd","messages":[{"role":"user","content":[{"type":"image_url","image_url":{"url":"<IMAGE_URL>"}},{"type":"text","text":"<TEXT_PROMPT>"}]}],"max_tokens":1024,"temperature":0}'
预期返回 HTTP 200 以及针对图像和文本的回答。对照 10K 目标检查 usage.prompt_tokens,并确认没有图像处理、KV 传输或内存不足错误。
关键参数:
- Prefill uses a
24,24layer partition.--mm-encoder-tp-mode datadistributes complete images across the TP ranks for the vision encoder. The language model uses TP4 × PP2. - Decode enables static kernels and uses an API endpoint per DP rank. The 32-way concurrency in the MMMU-Pro benchmark is a client-side setting.
- This case disables prefix caching on both roles. The Prefill/Decode batch token limits are 8192/4096, and both roles use
--max-model-len 262144.
本案例使用与 5.2 节中基础 PD 示例相同的八设备 Ascend 950DT系列产品主机。对于图文 10K 验证,prefill 使用 TP2 × PP2 × DP1,层划分为 25,23,decode 使用 TP2 × DP2,位于一个 API 端点之后。两个角色均使用 8192 批处理 token 和 HCCL_BUFFSIZE=512。两个角色均启用前缀缓存;decode 还启用静态 kernel。
10K 目标是指处理后的输入长度,包括文本和图像 token。两个角色均保留 --max-model-len 143360;请确保输入加上请求的输出在此限制之内。使用 3.1 节中的 W4A8-MXFP checkpoint 及其视觉编码器和图像处理器。
按照 4 节所述初始化环境,并在单独的终端中运行 Prefill 和 Decode。两个角色均从 ModelScope 加载 Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp。
Prefill:
export VLLM_USE_MODELSCOPE=True
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_ASCEND_PLE_BACKEND=torch
export VLLM_PP_LAYER_PARTITION=25,23
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=512
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp \
--host 0.0.0.0 \
--port 8247 \
--served-model-name qwen38-megamoe-sp-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--pipeline-parallel-size 2 \
--data-parallel-size 1 \
--max-model-len 143360 \
--max-num-seqs 64 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.9 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--compilation-config '{"cudagraph_mode":"NONE"}' \
--additional-config '{"enable_shared_expert_dp":true,"enable_flashcomm1":true,"multistream_overlap_shared_expert":true,"enable_cpu_binding":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":32470,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":2,"pp_size":2,"pp_layer_partition":"25,23"},"decode":{"dp_size":2,"tp_size":2}}}'
Decode:
export VLLM_USE_MODELSCOPE=True
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_ASCEND_PLE_BACKEND=torch
unset VLLM_PP_LAYER_PARTITION
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
export ASCEND_RT_VISIBLE_DEVICES=4,5,6,7
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp \
--host 0.0.0.0 \
--port 8248 \
--served-model-name qwen38-megamoe-sp-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 2 \
--max-model-len 143360 \
--max-num-seqs 64 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.9 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_shared_expert_dp":true,"enable_flashcomm1":true,"multistream_overlap_shared_expert":true,"enable_cpu_binding":true,"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false},"enable_fused_mc2":0}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":32480,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":2,"pp_size":2,"pp_layer_partition":"25,23"},"decode":{"dp_size":2,"tp_size":2}}}'
代理:
两个模型 API 就绪后,从 vLLM-Ascend 仓库根目录运行代理:
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host "127.0.0.1" \
--port 8246 \
--prefiller-hosts "127.0.0.1" \
--prefiller-ports 8247 \
--decoder-hosts "127.0.0.1" \
--decoder-ports 8248
服务验证:
在启动日志中检查 P 的 TP2/PP2/DP1、D 的 TP2/DP2(含静态 kernel)以及 max_model_len=143360。通过代理发送一个 10K 样本,将 <IMAGE_URL> 和 <TEXT_PROMPT> 替换为可访问的图像及其文本:
curl --fail "http://127.0.0.1:8247/v1/models"
curl --fail "http://127.0.0.1:8248/v1/models"
curl --fail "http://127.0.0.1:8246/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{"model":"qwen38-megamoe-sp-pd","messages":[{"role":"user","content":[{"type":"image_url","image_url":{"url":"<IMAGE_URL>"}},{"type":"text","text":"<TEXT_PROMPT>"}]}],"max_tokens":1024,"temperature":0}'
预期返回 HTTP 200 以及针对图像和文本的回答。对照 10K 目标检查 usage.prompt_tokens,并确认没有图像处理、KV 传输或内存不足错误。
关键参数:
- Prefill partitions the layers across two pipeline stages with
VLLM_PP_LAYER_PARTITION=25,23. Keeppp_size=2andpp_layer_partition="25,23"in both Mooncake configurations consistent with this partition. - Decode uses TP2 × DP2 behind one API endpoint on port
8248; the proxy routes to that endpoint rather than separate DP-rank APIs. - Both roles enable prefix caching. Prefill disables graph capture and sets MTP
enforce_eager=true. Decode usesFULL_DECODE_ONLY, sets MTPenforce_eager=false, enables static kernels, and disables super kernels. - Both roles enable Engram CPU offload. Decode enables DP shared memory for its two replicas. Both roles use
HCCL_BUFFSIZE=512and setVLLM_ENGINE_READY_TIMEOUT_S=4800. Provide sufficient host memory and container shared memory for the deployment. VLLM_ASCEND_PLE_BACKENDonly applies to runtimes that implement it; an unknown-variable warning means it has no effect.
5.4 长上下文 PD 分离部署¶
This section extends the model context for PD separation on A2 series, A3 series, and 950DT products.
将原生 256K 上下文扩展到约 1M
检查点的原生上下文窗口为 256K(262144 个 token)。本长上下文用例需要在 Prefill 和 Decode 两者 上设置全部三项配置:如下所示的完整 YaRN --hf-overrides,其中 factor=4.0 且 original_max_position_embeddings=262144;export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1;以及 --max-model-len 1010000。请保持两个角色上的 YaRN 配置和最大模型长度一致;这三项设置均不可省略。
每个请求必须满足 输入 token 数 + 最大输出 token 数 <= max-model-len。在此配置下,总数不得超过 1,010,000 个 token。
The runtime must also size the Qwen4Exp MTP draft's position cache for the configured context length. The 0.32 RC branch applies the Qwen4Exp-specific fix in PR #21347. With main, use a compatible vLLM build with the upstream draft position-cache expansion, such as vLLM v0.33.0, and verify the long-context request on your target image.
On 950DT products, this case reuses ports 8247, 8248, and 8246 from the image-and-text case. Stop that deployment before starting this case.
This example uses two eight-device A2 series hosts. Prefill uses TP2 × PP4 × DP1 (EP2) on PREFILL_HOST, and Decode uses TP2 × DP4 (EP8) on DECODE_HOST. Each host uses devices 0–7. Set the two service addresses and the local network interface in the commands.
Prepare the A2 containers as in Section 5.2 and run each command on its designated host. Stop any deployment already using ports 25568, 25569, or 25570 on these hosts. After both model APIs are ready, run the proxy on the Prefill host from the vLLM-Ascend repository root.
Prefill:
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
local_ip="${PREFILL_HOST}"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=8192
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25568 \
--served-model-name qwen38-flash-next-a2-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--pipeline-parallel-size 4 \
--data-parallel-size 1 \
--max-model-len 1010000 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--enforce-eager \
--additional-config '{"enable_shared_expert_dp":true,"enable_flashcomm1":true,"enable_prefill_mc2":true,"enable_fused_mc2":0,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--hf-overrides '{"text_config":{"rope_parameters":{"mrope_interleaved":true,"mrope_section":[11,11,10],"rope_type":"yarn","rope_theta":10000000,"partial_rotary_factor":0.25,"factor":4.0,"original_max_position_embeddings":262144}}}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":32600,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":2,"pp_size":4},"decode":{"dp_size":4,"tp_size":2}}}'
Decode:
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
local_ip="${DECODE_HOST}"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25569 \
--served-model-name qwen38-flash-next-a2-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 4 \
--max-model-len 1010000 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"enable_shared_expert_dp":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--hf-overrides '{"text_config":{"rope_parameters":{"mrope_interleaved":true,"mrope_section":[11,11,10],"rope_type":"yarn","rope_theta":10000000,"partial_rotary_factor":0.25,"factor":4.0,"original_max_position_embeddings":262144}}}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":32700,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":2,"pp_size":4},"decode":{"dp_size":4,"tp_size":2}}}'
代理:
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
export no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host 0.0.0.0 --port 25570 \
--prefiller-hosts "${PREFILL_HOST}" --prefiller-ports 25568 \
--decoder-hosts "${DECODE_HOST}" --decoder-ports 25569
服务验证:
Confirm max_model_len=1010000 in both startup logs. Check the model APIs from the Prefill host.
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
curl --fail --noproxy '*' "http://${PREFILL_HOST}:25568/v1/models"
curl --fail --noproxy '*' "http://${DECODE_HOST}:25569/v1/models"
Start Proxy after both checks succeed. Prepare long-context-request.json with model set to qwen38-flash-next-a2-pd, the input in messages, and the requested output budget in max_tokens. Keep the input token count plus the maximum output token count within 1,010,000 tokens.
curl --fail "http://127.0.0.1:25570/v1/chat/completions" \
-H "Content-Type: application/json" \
--data-binary @long-context-request.json
Verify the response and compare usage.prompt_tokens with the test input.
This example uses one 16-device A3 series host. Prefill uses TP2 × PP4 × DP1 (EP2) on devices 0–7. Decode uses TP2 × DP4 (EP8) on devices 8–15. Set local_ip and nic_name in the commands for the serving host.
Prepare the container as in Section 5.2 and run Prefill and Decode in separate terminals. Stop any A3 deployment already using ports 25568, 25569, or 25570. After both model APIs are ready, run Proxy from the vLLM-Ascend repository root.
Prefill:
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=8192
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25568 \
--served-model-name qwen38-flash-next-a3-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--pipeline-parallel-size 4 \
--data-parallel-size 1 \
--max-model-len 1010000 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--enforce-eager \
--additional-config '{"enable_shared_expert_dp":true,"enable_flashcomm1":true,"enable_prefill_mc2":true,"enable_fused_mc2":0,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--hf-overrides '{"text_config":{"rope_parameters":{"mrope_interleaved":true,"mrope_section":[11,11,10],"rope_type":"yarn","rope_theta":10000000,"partial_rotary_factor":0.25,"factor":4.0,"original_max_position_embeddings":262144}}}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":32600,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":2,"pp_size":4},"decode":{"dp_size":4,"tp_size":2}}}'
Decode:
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=8,9,10,11,12,13,14,15
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25569 \
--served-model-name qwen38-flash-next-a3-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 4 \
--max-model-len 1010000 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"enable_shared_expert_dp":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--hf-overrides '{"text_config":{"rope_parameters":{"mrope_interleaved":true,"mrope_section":[11,11,10],"rope_type":"yarn","rope_theta":10000000,"partial_rotary_factor":0.25,"factor":4.0,"original_max_position_embeddings":262144}}}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":32700,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":2,"pp_size":4},"decode":{"dp_size":4,"tp_size":2}}}'
代理:
local_ip="<LOCAL_SERVICE_IP>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
export no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host 0.0.0.0 --port 25570 \
--prefiller-hosts "${local_ip}" --prefiller-ports 25568 \
--decoder-hosts "${local_ip}" --decoder-ports 25569
服务验证:
Check that both model APIs are ready and confirm max_model_len=1010000 in the startup logs.
Start Proxy after both checks succeed. Prepare long-context-request.json with model set to qwen38-flash-next-a3-pd, the input in messages, and the requested output budget in max_tokens. Keep the input token count plus the maximum output token count within 1,010,000 tokens.
curl --fail "http://127.0.0.1:25570/v1/chat/completions" \
-H "Content-Type: application/json" \
--data-binary @long-context-request.json
Verify the response and compare usage.prompt_tokens with the test input.
This case uses eight devices on a single 950DT products host, with TP4 × DP1 for both Prefill and Decode. Both roles set the maximum combined input and output length to 1,010,000 tokens, with up to 16 active sequences and 4096 batch tokens. Initialize the environment as described in Section 4 and run each role in a separate terminal.
Prefill:
unset CPLUS_INCLUDE_PATH CPATH C_INCLUDE_PATH
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
export VLLM_USE_MODELSCOPE=True
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=2400
export VLLM_ASCEND_PLE_BACKEND=torch
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=512
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp \
--host 0.0.0.0 \
--port 8247 \
--served-model-name qwen38-megamoe-sp-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 4 \
--pipeline-parallel-size 1 \
--data-parallel-size 1 \
--max-model-len 1010000 \
--max-num-seqs 16 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.9 \
--enable-prefix-caching \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--async-scheduling \
--enable-expert-parallel \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--compilation-config '{"cudagraph_mode":"NONE"}' \
--additional-config '{"enable_shared_expert_dp":true,"enable_flashcomm1":true,"enable_cpu_binding":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--hf-overrides '{"text_config":{"rope_parameters":{"mrope_interleaved":true,"mrope_section":[11,11,10],"rope_type":"yarn","rope_theta":10000000,"partial_rotary_factor":0.25,"factor":4.0,"original_max_position_embeddings":262144}}}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":"32470","kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4},"decode":{"dp_size":1,"tp_size":4}}}'
Decode:
unset CPLUS_INCLUDE_PATH CPATH C_INCLUDE_PATH
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
export VLLM_USE_MODELSCOPE=True
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_ASCEND_PLE_BACKEND=torch
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
export ASCEND_RT_VISIBLE_DEVICES=4,5,6,7
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp \
--host 0.0.0.0 \
--port 8248 \
--served-model-name qwen38-megamoe-sp-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 4 \
--data-parallel-size 1 \
--max-model-len 1010000 \
--max-num-seqs 16 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.9 \
--enable-prefix-caching \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--async-scheduling \
--enable-expert-parallel \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--hf-overrides '{"text_config":{"rope_parameters":{"mrope_interleaved":true,"mrope_section":[11,11,10],"rope_type":"yarn","rope_theta":10000000,"partial_rotary_factor":0.25,"factor":4.0,"original_max_position_embeddings":262144}}}' \
--kv-transfer-config '{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":"32480","kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4},"decode":{"dp_size":1,"tp_size":4}}}'
代理:
两个模型 API 就绪后,从 vLLM-Ascend 仓库根目录运行代理:
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host 0.0.0.0 \
--port 8246 \
--prefiller-hosts 127.0.0.1 \
--prefiller-ports 8247 \
--decoder-hosts 127.0.0.1 \
--decoder-ports 8248
服务验证:
检查两个角色的启动日志,确认均为 TP4 × DP1 且 max_model_len=1010000。准备 long-context-request.json 作为 chat-completion 请求,将 model 设置为 qwen38-megamoe-sp-pd,长输入放在 messages 中,并将 max_tokens 设置为所需的输出预算。确保处理后的输入加上输出预算不超过 1,010,000 个 token,然后运行:
curl --fail "http://127.0.0.1:8247/v1/models"
curl --fail "http://127.0.0.1:8248/v1/models"
curl --fail "http://127.0.0.1:8246/v1/chat/completions" \
-H "Content-Type: application/json" \
--data-binary @long-context-request.json
对照测试输入验证响应内容和 usage.prompt_tokens。仅 API 成功启动并不能验证长上下文推理。
关键参数:
- Both roles use TP4 × DP1 without pipeline parallelism. The Mooncake declarations use
tp_size=4anddp_size=1for both roles. - Both roles use Mamba cache mode
alignand Mamba SSM cache dtypebfloat16. - Prefill disables graph capture and sets MTP
enforce_eager=true. Decode usesFULL_DECODE_ONLY, sets MTPenforce_eager=false, and enables static kernels and recompute scheduling. - Both roles enable Engram CPU offload with
dp_shared_memory=falseand useHCCL_BUFFSIZE=512. The supplied configuration sets the engine-ready timeout to 2400 seconds on Prefill and 4800 seconds on Decode; the model-execution timeout is 3000 seconds on both roles. VLLM_ASCEND_PLE_BACKENDonly applies to runtimes that implement it; an unknown-variable warning means it has no effect.
5.5 基于 MemCache 三级 KV 缓存池的 PD 分离¶
MultiConnector combines Mooncake P-to-D transport with MemCache-backed KV caching in HBM, DRAM, and SSD. Each hardware tab contains its complete pooling Prefill and Decode commands. A2 uses the basic PD topology from Section 5.2. A3 uses a dedicated Prefill topology for the 128K/1K multi-prefix workload. This section does not cover colocated deployment, the image-and-text 10K case, or the long-context case.
开始之前:
在 4.3 节中准备容器、SSD 映射、配置目录和 A2 HDK 要求。在容器内运行以下内容。A3 HCCS 还需要灵衢计算网络 1.5 或更高版本;运行时依赖请参阅 MemCache 后端指南。
Use the same vLLM-Ascend release and compatible MemCache and MemFabric package versions across the pool. Verify cache reuse and SSD restore on the runtime you deploy.
两个软件包版本必须至少为 1.3.0。如果缺失,请安装兼容版本并重复 4.3 节中的导入检查:
使用上面报告的软件包 Location 设置库目录。在每个服务终端中运行这些导出命令,保留已初始化的模型运行时的库路径:
export MEMCACHE_LIB_DIR="<MEMCACHE_LIBRARY_DIRECTORY>"
export MEMFABRIC_LIB_DIR="<MEMFABRIC_LIBRARY_DIRECTORY>"
export PYTHON_LIB_DIR="$(python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')"
export LD_LIBRARY_PATH="${MEMCACHE_LIB_DIR}:${MEMFABRIC_LIB_DIR}:${PYTHON_LIB_DIR}:${LD_LIBRARY_PATH:-}"
MEMCACHE_LIB_DIR 和 MEMFABRIC_LIB_DIR 分别为对应软件包的 Location 加上 /memcache_hybrid/lib 和 /memfabric_hybrid/lib。在用于编辑配置的终端中设置模板目录:
使用所选镜像内置的模板:/usr/local/python3.11.10/lib/python3.11/site-packages/memcache_hybrid/config/ 仅为示例,实际路径随 Python 版本和安装位置而变化。将 MEMCACHE_TEMPLATE_DIR 设置为该目录,并将其中的文件复制到个人挂载的 MEMCACHE_CONFIG_DIR 中。在这些副本中仅编辑下面列出的键,保留其他模板条目;cp -n 不会改动已存在的个人文件。在 INI 示例中,将 <MEMCACHE_...> 替换为在对应硬件标签页中选择的实际值;配置文件不会展开 shell 变量。
在编辑配置之前,选择新建或已有资源池:
- 新建资源池: 按照对应硬件标签页中的 准备新资源池 操作,仅使用第 4.3 节中映射的设备。在编辑 INI 副本之前,确定所有端点和资源值。
- 已有资源池: 跳过下面的新资源池导出、模板复制、INI 编辑和 MetaService 启动步骤。使用已有资源池的 MetaService/ConfigStore 端点以及
MEMCACHE_CONFIG_DIR中已批准的 LocalService 文件(A2/A3:mmc-local.conf;Ascend 950DT系列产品:mmc-local-p.conf和mmc-local-d.conf)。保留其存储初始化策略;不要应用新资源池的force_new_disk=true示例。检查已有服务的实际端点,然后继续执行对应的服务环境和 P/D 命令。
dram.size 和 ubsio.mem.size_in_gb 按每个启用 DRAM 的 LocalService 计算;需将其总量与 Engram、vLLM 及操作系统内存一并纳入预算。world_size 是资源池容量;device_count 统计主机上启用 DRAM 的 LocalService 数量,而非 SSD 数量。LocalService 运行在 P/D worker 内部;ubsio.standalone.* 键不需要单独的进程。
Check host huge pages if pooling stalls
If a P or D worker stalls during MemCache DRAM initialization and the host kernel repeatedly reports alloc_contig_range ... PFNs busy, check the reserved 1 GiB HugeTLB pages on each affected host. The following example assumes NUMA nodes 0–7.
for n in 0 1 2 3 4 5 6 7; do
printf 'node%s: ' "$n"
cat "/sys/devices/system/node/node${n}/hugepages/hugepages-1048576kB/nr_hugepages"
done
To test with preallocated pages, run the following as root on the host before starting Prefill and Decode. Adjust the node IDs and page count for the available host memory. Writing 32 to nr_hugepages sets the target total to 32 pages per NUMA node (32 GiB per node, 256 GiB across eight nodes). Check the existing count before changing it and leave enough memory for MemCache, Engram, and vLLM.
for n in 0 1 2 3 4 5 6 7; do
echo 32 > "/sys/devices/system/node/node${n}/hugepages/hugepages-1048576kB/nr_hugepages"
done
Repeat the first command and confirm that each selected node reports the requested count. Recheck after a host reboot. Use the P/D startup logs and API checks to verify that the services are ready. Watchdog dumps and shared-memory broadcast wait messages can also occur while static kernels compile. Check the worker stack and kernel log before attributing the wait to huge-page allocation.
沿用第 5.2 节中的 A2 模型配置:Prefill 使用 TP4 × PP2 × DP1,Decode 使用 TP2 × DP4,分别运行在独立的八设备主机上。
准备新资源池:
在两台主机上准备 LocalService 文件,仅在 prefill 主机上准备 MetaService。在两台主机上设置相同的可达 MetaService/ConfigStore 端点和资源池 world_size;分别为每台主机选择存储值。
cp -n "${MEMCACHE_TEMPLATE_DIR}/mmc-local.conf" "${MEMCACHE_CONFIG_DIR}/mmc-local.conf"
export MEMCACHE_META_URL="tcp://<META_SERVICE_IP>:<META_SERVICE_PORT>"
export MEMCACHE_CONFIG_STORE_URL="tcp://<CONFIG_STORE_IP>:<CONFIG_STORE_PORT>"
仅在 prefill 主机上准备 MetaService:
cp -n "${MEMCACHE_TEMPLATE_DIR}/mmc-meta.conf" "${MEMCACHE_CONFIG_DIR}/mmc-meta.conf"
export MEMCACHE_METRICS_URL="http://<METRICS_IP>:<METRICS_PORT>"
export MEMCACHE_EVICT_HIGH="<HIGH_EVICTION_THRESHOLD_PERCENT>"
export MEMCACHE_EVICT_LOW="<LOW_EVICTION_THRESHOLD_PERCENT>"
在复制得到的 ${MEMCACHE_CONFIG_DIR}/mmc-meta.conf 中,编辑以下键:
ock.mmc.meta_service_url = <MEMCACHE_META_URL>
ock.mmc.meta_service.config_store_url = <MEMCACHE_CONFIG_STORE_URL>
ock.mmc.meta_service.metrics_url = <MEMCACHE_METRICS_URL>
ock.mmc.log_level = info
ock.mmc.evict_threshold_high = <MEMCACHE_EVICT_HIGH>
ock.mmc.evict_threshold_low = <MEMCACHE_EVICT_LOW>
根据各主机的部署配置和内存预算设置其存储值。使用第 4.3 节中映射的设备路径,多个设备之间用 : 分隔:
export MEMCACHE_SSD_PATHS="<MAPPED_SSD_DEVICE_PATHS_SEPARATED_BY_COLONS>"
export MEMCACHE_WORLD_SIZE="<POOL_LOCAL_SERVICE_CAPACITY>"
export MEMCACHE_DRAM_SIZE="<DRAM_SIZE_PER_LOCAL_SERVICE_WITH_UNIT>"
export MEMCACHE_MAX_DRAM_SIZE="<MAX_DRAM_SIZE_WITH_UNIT>"
export MEMCACHE_UBS_IO_MEM_GB="<UBS_IO_MEMORY_GB_PER_LOCAL_SERVICE>"
export MEMCACHE_DEVICE_COUNT="<DRAM_ENABLED_LOCAL_SERVICE_COUNT_ON_THIS_HOST>"
export MEMCACHE_FORCE_NEW_DISK="<true_OR_false_FOR_THIS_DEPLOYMENT>"
在复制得到的 ${MEMCACHE_CONFIG_DIR}/mmc-local.conf 中,编辑以下键:
ock.mmc.meta_service_url = <MEMCACHE_META_URL>
ock.mmc.local_service.config_store_url = <MEMCACHE_CONFIG_STORE_URL>
ock.mmc.log_level = info
ock.mmc.local_service.world_size = <MEMCACHE_WORLD_SIZE>
ock.mmc.local_service.protocol = device_rdma
ock.mmc.local_service.dram.size = <MEMCACHE_DRAM_SIZE>
ock.mmc.local_service.max.dram.size = <MEMCACHE_MAX_DRAM_SIZE>
ock.mmc.local_service.storage.enabled = true
ubsio.disk.path = <MEMCACHE_SSD_PATHS>
ubsio.mem.size_in_gb = <MEMCACHE_UBS_IO_MEM_GB>
ubsio.standalone.device_count = <MEMCACHE_DEVICE_COUNT>
ubsio.standalone.force_new_disk = <MEMCACHE_FORCE_NEW_DISK>
启动 MetaService:
除非资源池已在运行,否则在 prefill 主机上使用上述库导出启动 MetaService:
export MMC_META_CONFIG_PATH="${MEMCACHE_CONFIG_DIR}/mmc-meta.conf"
python -c "from memcache_hybrid import MetaService; MetaService.main()"
在其配置的端口开始监听后(ss -lntp),按照第 4 节初始化模型运行时,并在单独的终端中运行下面完整的 Prefill 和 Decode 命令。按上述说明在每个终端中设置库目录;MEMCACHE_CONFIG_DIR 是第 4.3 节中挂载的个人配置目录。
Prefill:
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
local_ip="${PREFILL_HOST}"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=8192
export MEMCACHE_LIB_DIR="<MEMCACHE_LIBRARY_DIRECTORY>"
export MEMFABRIC_LIB_DIR="<MEMFABRIC_LIBRARY_DIRECTORY>"
export PYTHON_LIB_DIR="$(python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')"
export LD_LIBRARY_PATH="${MEMCACHE_LIB_DIR}:${MEMFABRIC_LIB_DIR}:${PYTHON_LIB_DIR}:${LD_LIBRARY_PATH:-}"
export PYTHONHASHSEED=0
export MMC_LOCAL_CONFIG_PATH="${MEMCACHE_CONFIG_DIR}/mmc-local.conf"
unset ASCEND_ENABLE_USE_FABRIC_MEM ASCEND_GLOBAL_RESOURCE_CONFIG ASCEND_LOCAL_COMM_RES
export HCCL_INTRA_ROCE_ENABLE=1
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25568 \
--served-model-name qwen38-flash-next-a2-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 4 \
--pipeline-parallel-size 2 \
--data-parallel-size 1 \
--max-model-len 141312 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":false}' \
--enforce-eager \
--additional-config '{"enable_shared_expert_dp":true,"enable_flashcomm1":true,"enable_prefill_mc2":true,"enable_fused_mc2":0,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--kv-transfer-config '{"kv_connector":"MultiConnector","kv_role":"kv_producer","kv_connector_extra_config":{"connectors":[{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":32600,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4,"pp_size":2},"decode":{"dp_size":4,"tp_size":2}}},{"kv_connector":"AscendStoreConnector","kv_role":"kv_producer","kv_connector_extra_config":{"backend":"memcache","lookup_rpc_port":"qwen38_pool_p","use_layerwise":false}}]}}'
Decode:
PREFILL_HOST="<PREFILL_LOCAL_IP>"
DECODE_HOST="<DECODE_LOCAL_IP>"
local_ip="${DECODE_HOST}"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${PREFILL_HOST},${DECODE_HOST}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
export MEMCACHE_LIB_DIR="<MEMCACHE_LIBRARY_DIRECTORY>"
export MEMFABRIC_LIB_DIR="<MEMFABRIC_LIBRARY_DIRECTORY>"
export PYTHON_LIB_DIR="$(python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')"
export LD_LIBRARY_PATH="${MEMCACHE_LIB_DIR}:${MEMFABRIC_LIB_DIR}:${PYTHON_LIB_DIR}:${LD_LIBRARY_PATH:-}"
export PYTHONHASHSEED=0
export MMC_LOCAL_CONFIG_PATH="${MEMCACHE_CONFIG_DIR}/mmc-local.conf"
unset ASCEND_ENABLE_USE_FABRIC_MEM ASCEND_GLOBAL_RESOURCE_CONFIG ASCEND_LOCAL_COMM_RES
export HCCL_INTRA_ROCE_ENABLE=1
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25569 \
--served-model-name qwen38-flash-next-a2-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 4 \
--max-model-len 141312 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"enable_shared_expert_dp":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--kv-transfer-config '{"kv_connector":"MultiConnector","kv_role":"kv_consumer","kv_connector_extra_config":{"connectors":[{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":32700,"kv_connector_extra_config":{"prefill":{"dp_size":1,"tp_size":4,"pp_size":2},"decode":{"dp_size":4,"tp_size":2}}},{"kv_connector":"AscendStoreConnector","kv_role":"kv_consumer","kv_connector_extra_config":{"backend":"memcache","lookup_rpc_port":"qwen38_pool_d","use_layerwise":false}}]}}'
完成对应的第 5.2 节 API 检查并启动其 Proxy,然后执行下面的缓存复用检查。
The 128K/1K multi-prefix pooling example uses 16 devices, eight per role. Prefill uses TP2 × PP2 × DP2 (EP4) on devices 0–7, and Decode uses TP2 × DP4 (EP8) on devices 8–15. Both Mooncake configurations declare this topology. Both roles enable Engram CPU offload and DP shared memory.
准备新资源池:
以下值来自单主机 A3 配置:MetaService 与 P/D 共享主机网络,包含 16 个启用 DRAM 的 LocalService,以及第 4.3 节中已映射的两个 SSD 设备。在编辑下面任一 INI 文件之前,先选定这些值。对于已有资源池,按上述说明跳过此准备步骤。
export MEMCACHE_META_URL="tcp://127.0.0.1:15000"
export MEMCACHE_CONFIG_STORE_URL="tcp://127.0.0.1:16000"
export MEMCACHE_METRICS_URL="http://127.0.0.1:18000"
export MEMCACHE_EVICT_HIGH=70
export MEMCACHE_EVICT_LOW=60
export MEMCACHE_SSD_PATHS="/dev/loop0:/dev/loop1"
export MEMCACHE_WORLD_SIZE=256
export MEMCACHE_DRAM_SIZE=10GB
export MEMCACHE_MAX_DRAM_SIZE=1024GB
export MEMCACHE_UBS_IO_MEM_GB=10
export MEMCACHE_DEVICE_COUNT=16
export MEMCACHE_FORCE_NEW_DISK=true
将 /dev/loop0:/dev/loop1 替换为第 4.3 节中已映射的两个设备路径。这些新资源池值为每个 LocalService 分配 10GB 的 DRAM 和 10 GB 的 UBS IO;force_new_disk=true 会在启动时重新初始化 SSD 缓存存储。
After a host reboot, confirm that the backing filesystem is mounted and check the loop mappings with losetup -l. Identify any dedicated NVMe device by its serial number or WWN. If a device path changes, update both the Docker mapping and ubsio.disk.path. Run blockdev --getsize64 on each configured device inside the container before starting P and D. If MemCache initialization fails after model loading, check these devices even if MetaService is listening.
cp -n "${MEMCACHE_TEMPLATE_DIR}/mmc-meta.conf" "${MEMCACHE_CONFIG_DIR}/mmc-meta.conf"
cp -n "${MEMCACHE_TEMPLATE_DIR}/mmc-local.conf" "${MEMCACHE_CONFIG_DIR}/mmc-local.conf"
在复制得到的 ${MEMCACHE_CONFIG_DIR}/mmc-meta.conf 中,编辑以下键:
ock.mmc.meta_service_url = <MEMCACHE_META_URL>
ock.mmc.meta_service.config_store_url = <MEMCACHE_CONFIG_STORE_URL>
ock.mmc.meta_service.metrics_url = <MEMCACHE_METRICS_URL>
ock.mmc.log_level = info
ock.mmc.evict_threshold_high = <MEMCACHE_EVICT_HIGH>
ock.mmc.evict_threshold_low = <MEMCACHE_EVICT_LOW>
用选定的值填写两个 INI 文件;之后运行 export 不会更新这两个文件。
在复制得到的 ${MEMCACHE_CONFIG_DIR}/mmc-local.conf 中,编辑以下键:
ock.mmc.meta_service_url = <MEMCACHE_META_URL>
ock.mmc.local_service.config_store_url = <MEMCACHE_CONFIG_STORE_URL>
ock.mmc.log_level = info
ock.mmc.local_service.world_size = <MEMCACHE_WORLD_SIZE>
ock.mmc.local_service.protocol = device_sdma
ock.mmc.local_service.dram.size = <MEMCACHE_DRAM_SIZE>
ock.mmc.local_service.max.dram.size = <MEMCACHE_MAX_DRAM_SIZE>
ock.mmc.local_service.storage.enabled = true
ubsio.disk.path = <MEMCACHE_SSD_PATHS>
ubsio.mem.size_in_gb = <MEMCACHE_UBS_IO_MEM_GB>
ubsio.standalone.device_count = <MEMCACHE_DEVICE_COUNT>
ubsio.standalone.force_new_disk = <MEMCACHE_FORCE_NEW_DISK>
启动 MetaService:
除非资源池已在运行,否则在服务容器中使用上述库导出启动 MetaService:
export MMC_META_CONFIG_PATH="${MEMCACHE_CONFIG_DIR}/mmc-meta.conf"
python -c "from memcache_hybrid import MetaService; MetaService.main()"
在其配置的端口开始监听后(ss -lntp),按照第 4 节初始化模型运行时,并在单独的终端中运行下面完整的 Prefill 和 Decode 命令。按上述说明在每个终端中设置库目录;MEMCACHE_CONFIG_DIR 是第 4.3 节中挂载的个人配置目录。
Prefill:
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
export HCCL_BUFFSIZE=8192
export MEMCACHE_LIB_DIR="<MEMCACHE_LIBRARY_DIRECTORY>"
export MEMFABRIC_LIB_DIR="<MEMFABRIC_LIBRARY_DIRECTORY>"
export PYTHON_LIB_DIR="$(python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')"
export LD_LIBRARY_PATH="${MEMCACHE_LIB_DIR}:${MEMFABRIC_LIB_DIR}:${PYTHON_LIB_DIR}:${LD_LIBRARY_PATH:-}"
export PYTHONHASHSEED=0
export MMC_LOCAL_CONFIG_PATH="${MEMCACHE_CONFIG_DIR}/mmc-local.conf"
unset HCCL_INTRA_ROCE_ENABLE ASCEND_GLOBAL_RESOURCE_CONFIG ASCEND_LOCAL_COMM_RES
export ACL_OP_INIT_MODE=1
export ASCEND_ENABLE_USE_FABRIC_MEM=1
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25568 \
--served-model-name qwen38-flash-next-a3-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--pipeline-parallel-size 2 \
--data-parallel-size 2 \
--max-model-len 262144 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--enforce-eager \
--additional-config '{"enable_shared_expert_dp":true,"enable_flashcomm1":true,"enable_prefill_mc2":true,"enable_fused_mc2":0,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":true}' \
--kv-transfer-config '{"kv_connector":"MultiConnector","kv_role":"kv_producer","kv_connector_extra_config":{"connectors":[{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":32600,"kv_connector_extra_config":{"prefill":{"dp_size":2,"tp_size":2,"pp_size":2},"decode":{"dp_size":4,"tp_size":2}}},{"kv_connector":"AscendStoreConnector","kv_role":"kv_producer","kv_connector_extra_config":{"backend":"memcache","lookup_rpc_port":"qwen38_pool_p","use_layerwise":false}}]}}'
Decode:
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY
unset VLLM_PP_LAYER_PARTITION
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export VLLM_HOST_IP="${local_ip}"
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 no_proxy="localhost,127.0.0.1,${local_ip}"
export NO_PROXY="${no_proxy}"
export LD_LIBRARY_PATH="$(python -c 'import mooncake; print(next(iter(mooncake.__path__)))'):${LD_LIBRARY_PATH:-}"
export VLLM_USE_MODELSCOPE=True
export ASCEND_RT_VISIBLE_DEVICES=8,9,10,11,12,13,14,15
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
export HCCL_BUFFSIZE=512
export MEMCACHE_LIB_DIR="<MEMCACHE_LIBRARY_DIRECTORY>"
export MEMFABRIC_LIB_DIR="<MEMFABRIC_LIBRARY_DIRECTORY>"
export PYTHON_LIB_DIR="$(python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')"
export LD_LIBRARY_PATH="${MEMCACHE_LIB_DIR}:${MEMFABRIC_LIB_DIR}:${PYTHON_LIB_DIR}:${LD_LIBRARY_PATH:-}"
export PYTHONHASHSEED=0
export MMC_LOCAL_CONFIG_PATH="${MEMCACHE_CONFIG_DIR}/mmc-local.conf"
unset HCCL_INTRA_ROCE_ENABLE ASCEND_GLOBAL_RESOURCE_CONFIG ASCEND_LOCAL_COMM_RES
export ACL_OP_INIT_MODE=1
export ASCEND_ENABLE_USE_FABRIC_MEM=1
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--host 0.0.0.0 \
--port 25569 \
--served-model-name qwen38-flash-next-a3-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 4 \
--max-model-len 262144 \
--max-num-seqs 32 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--async-scheduling \
--enable-expert-parallel \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"enable_shared_expert_dp":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--kv-transfer-config '{"kv_connector":"MultiConnector","kv_role":"kv_consumer","kv_connector_extra_config":{"connectors":[{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":32700,"kv_connector_extra_config":{"prefill":{"dp_size":2,"tp_size":2,"pp_size":2},"decode":{"dp_size":4,"tp_size":2}}},{"kv_connector":"AscendStoreConnector","kv_role":"kv_consumer","kv_connector_extra_config":{"backend":"memcache","lookup_rpc_port":"qwen38_pool_d","use_layerwise":false}}]}}'
Check the startup logs for the Prefill and Decode topologies above. Use the A3 API checks and Proxy command from Section 5.2, then perform the cache-reuse checks below.
This single-host example uses TP2 × DP2 (EP4) per role, with Prefill on devices 0–3 and Decode on devices 4–7. Use the prepared runtime from Section 4.3 and the same W4A8-MXFP checkpoint for both roles. Both roles use Mamba cache mode align and Mamba SSM cache dtype bfloat16.
准备新资源池:
对于新资源池,使用所提供的 102 服务器配置中的以下值。其 MetaService 和 ConfigStore 使用 172.27.24.102,其专用的 500 GiB SSD 设备为 /dev/loop0。请根据目标部署替换地址和设备,并确保设备与第 4.3 节一致。对于已有资源池,跳过此准备步骤,并使用现有配置文件继续执行 设置服务环境。
local_ip="172.27.24.102"
export MEMCACHE_META_URL="tcp://${local_ip}:25250"
export MEMCACHE_CONFIG_STORE_URL="tcp://${local_ip}:25251"
export MEMCACHE_METRICS_URL="http://${local_ip}:25252"
export MEMCACHE_EVICT_HIGH=70
export MEMCACHE_EVICT_LOW=60
export MEMCACHE_SSD_PATHS="/dev/loop0"
cp -n "${MEMCACHE_TEMPLATE_DIR}/mmc-meta.conf" "${MEMCACHE_CONFIG_DIR}/mmc-meta.conf"
cp -n "${MEMCACHE_TEMPLATE_DIR}/mmc-local.conf" "${MEMCACHE_CONFIG_DIR}/mmc-local-p.conf"
cp -n "${MEMCACHE_TEMPLATE_DIR}/mmc-local.conf" "${MEMCACHE_CONFIG_DIR}/mmc-local-d.conf"
在复制得到的 ${MEMCACHE_CONFIG_DIR}/mmc-meta.conf 中,编辑以下键:
ock.mmc.meta_service_url = <MEMCACHE_META_URL>
ock.mmc.meta_service.config_store_url = <MEMCACHE_CONFIG_STORE_URL>
ock.mmc.meta_service.metrics_url = <MEMCACHE_METRICS_URL>
ock.mmc.log_level = info
ock.mmc.log_output_target = screen
ock.mmc.evict_threshold_high = <MEMCACHE_EVICT_HIGH>
ock.mmc.evict_threshold_low = <MEMCACHE_EVICT_LOW>
为两个 P/D LocalService 副本设置资源值:
export MEMCACHE_WORLD_SIZE=256
export MEMCACHE_DRAM_SIZE=10GB
export MEMCACHE_MAX_DRAM_SIZE=1024GB
export MEMCACHE_UBS_IO_MEM_GB=10
export MEMCACHE_DEVICE_COUNT=8
export MEMCACHE_FORCE_NEW_DISK=true
在复制得到的 ${MEMCACHE_CONFIG_DIR}/mmc-local-p.conf 和 ${MEMCACHE_CONFIG_DIR}/mmc-local-d.conf 中,编辑以下键:
ock.mmc.meta_service_url = <MEMCACHE_META_URL>
ock.mmc.local_service.config_store_url = <MEMCACHE_CONFIG_STORE_URL>
ock.mmc.log_level = info
ock.mmc.local_service.world_size = <MEMCACHE_WORLD_SIZE>
ock.mmc.local_service.protocol = device_urma
ock.mmc.local_service.dram.size = <MEMCACHE_DRAM_SIZE>
ock.mmc.local_service.max.dram.size = <MEMCACHE_MAX_DRAM_SIZE>
ock.mmc.local_service.storage.enabled = true
ubsio.disk.path = <MEMCACHE_SSD_PATHS>
ubsio.mem.size_in_gb = <MEMCACHE_UBS_IO_MEM_GB>
ubsio.standalone.device_count = <MEMCACHE_DEVICE_COUNT>
ubsio.standalone.force_new_disk = <MEMCACHE_FORCE_NEW_DISK>
八个内嵌的 LocalService 各贡献 10GB 的资源池 DRAM,并预留 10 GB 用于 UBS IO;无需单独的存储进程。force_new_disk=true 会在栈启动时重建 SSD 缓存,因此在缓存复用测试期间请保持栈持续运行。
设置服务环境:
在同一容器中分别打开 P、D 和 Proxy 终端,仅在创建新资源池时额外打开一个 MetaService 终端。按照第 4.3 节的说明初始化运行时,应用本节开头的库导出,并在每个终端中运行以下内容。
local_ip 是模型服务 IP;nic_name 是拥有该 IP 的 socket 网络接口。MetaService/ConfigStore URL 是独立的 TCP 控制端点,只需所有客户端均可访问即可;当所有进程共享主机网络时,使用 loopback 即可。device_urma 用于选择 UB 数据路径,并不会将 socket 接口变为 UB 接口。提供的示例对两者使用相同的主机 IP,但这并非通用要求。
local_ip="<LOCAL_SERVICE_IP>"
nic_name="<SERVICE_NETWORK_INTERFACE>"
unset ftp_proxy FTP_PROXY https_proxy HTTPS_PROXY http_proxy HTTP_PROXY ALL_PROXY all_proxy
unset HCCL_INTRA_ROCE_ENABLE ASCEND_ENABLE_USE_FABRIC_MEM ASCEND_GLOBAL_RESOURCE_CONFIG
unset ASCEND_RT_VISIBLE_DEVICES CUDA_VISIBLE_DEVICES MMC_LOCAL_CONFIG_PATH MMC_META_CONFIG_PATH
export ASCEND_LOCAL_COMM_RES='{"version":"1.3"}'
export VLLM_HOST_IP="${local_ip}"
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 NO_PROXY="localhost,127.0.0.1,${local_ip}"
export no_proxy="${NO_PROXY}"
export PYTHONHASHSEED=0
export VLLM_USE_MODELSCOPE=True
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export VLLM_ENGINE_READY_TIMEOUT_S=4800
export HCCL_BUFFSIZE=512
ulimit -l unlimited
ulimit -s 65536
启动 MetaService(仅新建资源池时):
复用正在运行的资源池时,请跳过此命令。
export MMC_META_CONFIG_PATH="${MEMCACHE_CONFIG_DIR}/mmc-meta.conf"
python -c "from memcache_hybrid import MetaService; MetaService.main()"
对于新建资源池,请等待 mmc-meta.conf 中配置的端口进入监听状态(ss -lntp);示例使用 25250、25251 和 25252。对于已有资源池,请改为检查其实际配置的端点。然后启动 Prefill。
Prefill:
在 Prefill 终端中,先应用第 5.5 节开头的库导出设置以及上方的 设置服务环境 代码块,然后运行以下命令。
export MMC_LOCAL_CONFIG_PATH="${MEMCACHE_CONFIG_DIR}/mmc-local-p.conf"
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
export HCCL_NPU_SOCKET_PORT_RANGE=61400-61499
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp \
--host 0.0.0.0 \
--port 8247 \
--served-model-name qwen38-megamoe-sp-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 2 \
--max-model-len 262144 \
--max-num-seqs 64 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.9 \
--enable-prefix-caching \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--async-scheduling \
--enable-expert-parallel \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"NONE"}' \
--additional-config '{"enable_cpu_binding":true,"enable_shared_expert_dp":true,"enable_fused_mc2":0,"enable_flashcomm1":true,"multistream_overlap_shared_expert":true,"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":false,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3}' \
--kv-transfer-config '{"kv_connector":"MultiConnector","kv_role":"kv_producer","kv_connector_extra_config":{"connectors":[{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_producer","kv_port":"32470","kv_connector_extra_config":{"prefill":{"dp_size":2,"tp_size":2},"decode":{"dp_size":2,"tp_size":2}}},{"kv_connector":"AscendStoreConnector","kv_role":"kv_producer","kv_connector_extra_config":{"backend":"memcache","lookup_rpc_port":"0","use_layerwise":false}}]}}' \
--enable-auto-tool-choice \
--tool-call-parser qwen3_coder \
--reasoning-parser qwen3 \
--data-parallel-address "${VLLM_HOST_IP}" \
--data-parallel-rpc-port 29770
等待端口 8247 上的 Prefill API 就绪,然后在新终端中启动 Decode。
Decode:
在 Decode 终端中,先应用第 5.5 节开头的库导出设置以及上方的 设置服务环境 代码块,然后运行以下命令。
export MMC_LOCAL_CONFIG_PATH="${MEMCACHE_CONFIG_DIR}/mmc-local-d.conf"
export ASCEND_RT_VISIBLE_DEVICES=4,5,6,7
export HCCL_NPU_SOCKET_PORT_RANGE=61500-61599
vllm serve Eco-Tech/Qwen3.8-Flash-Next-w4a8-mxfp \
--host 0.0.0.0 \
--port 8248 \
--served-model-name qwen38-megamoe-sp-pd \
--trust-remote-code \
--quantization ascend \
--tensor-parallel-size 2 \
--data-parallel-size 2 \
--max-model-len 262144 \
--max-num-seqs 64 \
--max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.9 \
--enable-prefix-caching \
--mamba-cache-mode align \
--mamba-ssm-cache-dtype bfloat16 \
--async-scheduling \
--enable-expert-parallel \
--engram-config '{"cpu_offload":true,"dp_shared_memory":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{"enable_flashcomm1":true,"enable_cpu_binding":true,"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true},"ascend_compilation_config":{"fuse_norm_quant":false,"enable_npugraph_ex":true,"enable_static_kernel":true,"enable_super_kernel":false}}' \
--speculative-config '{"method":"qwen3_5_mtp","num_speculative_tokens":3,"enforce_eager":false}' \
--kv-transfer-config '{"kv_connector":"MultiConnector","kv_role":"kv_consumer","kv_connector_extra_config":{"connectors":[{"kv_connector":"MooncakeConnectorV2","kv_role":"kv_consumer","kv_port":"32480","kv_connector_extra_config":{"prefill":{"dp_size":2,"tp_size":2},"decode":{"dp_size":2,"tp_size":2}}},{"kv_connector":"AscendStoreConnector","kv_role":"kv_consumer","kv_connector_extra_config":{"backend":"memcache","lookup_rpc_port":"1","use_layerwise":false}}]}}' \
--enable-auto-tool-choice \
--tool-call-parser qwen3_coder \
--reasoning-parser qwen3 \
--data-parallel-address "${VLLM_HOST_IP}" \
--data-parallel-rpc-port 29780
端口 8248 上的 Decode API 就绪后,在另一个终端中从 vLLM-Ascend 仓库根目录启动 Proxy。
代理:
python examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py \
--host 0.0.0.0 --port 8249 \
--prefiller-hosts "${VLLM_HOST_IP}" --prefiller-ports 8247 \
--decoder-hosts "${VLLM_HOST_IP}" --decoder-ports 8248 \
--workers 1
服务验证:
curl --fail "http://127.0.0.1:8249/v1/models"
curl --fail "http://127.0.0.1:8249/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{"model":"qwen38-megamoe-sp-pd","messages":[{"role":"user","content":"Who are you?"}],"max_tokens":1024,"temperature":0}'
测试配置将 Prefill 的 lookup_rpc_port 设置为 "0",将 Decode 的设置为 "1"。
验证三级缓存复用:
- 服务: 通过匹配的 proxy 运行第 5.2 节中针对 A2/A3 的 chat-completion 请求,或上文中的 950 DT 请求,并验证输出正确且 P-to-D 传输正常。
- 外部缓存: 发送具有共享前缀和不同后缀的请求;检查 MemCache 的查找、写入、读取和命中活动。仅本地前缀缓存命中并不能证明外部缓存复用。
- SSD 恢复: 将 DRAM 填充至超过驱逐水位线,确认发生 SSD 驱逐,然后再次请求已被驱逐的前缀,并验证 SSD 读取/恢复活动及输出正确。保持 MetaService 和 P/D 运行;仅 SSD 写入并不能证明恢复成功。
使用 MemCache、MemFabric 和 UBS IO 日志或可用的指标来检查这些结果;计数器名称取决于所安装的版本。
关键参数:
- 在各 worker 之间保持
PYTHONHASHSEED=0一致。lookup_rpc_port用于标识带有 DP 索引后缀的本地 IPC 端点;请使用不同的 P/D 标识符,并避免与其他资源池冲突。 - 保留
use_layerwise=false:Prefill 执行外部前缀查找和缓存写入,而 Decode 通过 P-to-D 连接器接收 KV/状态。
6 功能验证¶
通过 /v1/chat/completions 验证生成,使用与你的部署对应的 API 地址和模型名称:
| 部署方式 | API 地址 | 模型名称 |
|---|---|---|
| Atlas A2系列产品混部 | http://127.0.0.1:8088 |
qwen3.8-flash-next |
| Atlas A3系列产品混部 | http://127.0.0.1:8088 |
qwen3.8-flash-next |
| Ascend 950DT系列产品混部 | http://127.0.0.1:8087 |
qwen3.8-flash-next-950-dt |
| Atlas A2系列产品 PD proxy | http://127.0.0.1:25570 |
qwen38-flash-next-a2-pd |
| Atlas A3系列产品 PD proxy | http://127.0.0.1:25570 |
qwen38-flash-next-a3-pd |
| A2 series long-context PD proxy | http://127.0.0.1:25570 |
qwen38-flash-next-a2-pd |
| A3 series long-context PD proxy | http://127.0.0.1:25570 |
qwen38-flash-next-a3-pd |
| Ascend 950DT系列产品 PD proxy | http://<LOCAL_SERVICE_IP>:8087 |
qwen38-flash-next-950-dt-pd |
| Ascend 950DT系列产品图文 10K PD proxy | http://127.0.0.1:8246 |
qwen38-megamoe-sp-pd |
| Ascend 950DT系列产品长上下文 PD 代理 | http://127.0.0.1:8246 |
qwen38-megamoe-sp-pd |
| Ascend 950DT系列产品三级池化 PD proxy | http://127.0.0.1:8249 |
qwen38-megamoe-sp-pd |
对于 PD,请先完成第 5.2 节、第 5.3 节、第 5.4 节或第 5.5 节中相应的启动和代理检查。池化还需要完成第 5.5 节中的 SSD 驱逐/恢复检查。
6.1 基础对话补全¶
curl "http://127.0.0.1:8088/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-flash-next",
"messages": [
{"role": "user", "content": "Who are you?"}
],
"max_tokens": 1024,
"temperature": 0
}'
预期结果:服务返回 HTTP 200 OK,并在 choices[0].message.content 中给出生成的回答。
6.2 多模态对话补全¶
使用包含视觉编码器的 W4A8 权重来验证图文输入。将 <IMAGE_URL> 替换为服务环境可访问的图片 URL:
curl "http://127.0.0.1:8088/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-flash-next",
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "<IMAGE_URL>"
}
},
{
"type": "text",
"text": "Describe this image."
}
]
}
],
"max_tokens": 1024,
"temperature": 0
}'
预期结果:服务返回 HTTP 200 OK,并在 choices[0].message.content 中描述所提供的图片。
6.3 函数调用¶
要启用 Function Calling,请在混合部署(第 5.1 节)或基础 PD 分离(第 5.2 节)的模型命令中使用以下选项。对于 PD 分离,请将它们同时添加到 Prefill 和 Decode 命令中:
第 5.5 节中的 Ascend 950DT系列产品池化命令已通过 qwen3_coder 启用 Function Calling;验证此部署时请保留该解析器。
发送包含可用工具的请求,并将 tool_choice 设置为 auto:
curl "http://127.0.0.1:8088/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-flash-next",
"messages": [
{
"role": "user",
"content": "What is the weather in Beijing?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name"
}
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto",
"max_tokens": 1024,
"temperature": 0
}'
当模型选择该函数时,解析结果会出现在 choices[0].message.tool_calls 中。调用方必须执行该函数,并在后续消息中将结果发送回模型。
6.4 推理解析器与思考控制¶
推理解析需要以下启动选项。第 5.1 节中的混合部署示例已包含该选项;对于第 5.2 节中的基础 PD 分离,请将其同时添加到 Prefill 和 Decode 命令中:
Qwen3.8-Flash-Next 默认使用思考模式。如需显式请求推理,请将 enable_thinking 设置为 true(或省略该参数)。解析器会将推理内容与最终答案分开返回:
curl "http://127.0.0.1:8088/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-flash-next",
"messages": [
{
"role": "user",
"content": "Who are you?"
}
],
"max_tokens": 1024,
"temperature": 0,
"top_p": 1,
"chat_template_kwargs": {
"enable_thinking": true
}
}'
最终答案在 choices[0].message.content 中返回,而解析后的推理内容则单独在响应的 reasoning_content 字段中返回。
如需禁用思考并请求直接回答,请使用以下请求:
curl "http://127.0.0.1:8088/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-flash-next",
"messages": [
{
"role": "user",
"content": "Who are you?"
}
],
"max_tokens": 1024,
"temperature": 0,
"top_p": 1,
"chat_template_kwargs": {
"enable_thinking": false
}
}'
7 精度评估¶
7.1 使用 AISBench¶
请按照 使用 AISBench 进行评测。以下结果仅供参考。A3 结果来自 W8A8 TP8 × DP1 配置;请针对你使用的权重和部署配置验证精度。
| Hardware | Dataset | Metric | Score |
|---|---|---|---|
| A2 series | GPQA Diamond | Accuracy | 90.4 |
| A3 series | GPQA Diamond | Accuracy | 90.91 |
| 950DT products | GPQA Diamond | Accuracy | 91.2 |
8 性能评估¶
使用被测部署的端点和已服务模型名称。记录请求吞吐量、输出 token 吞吐量、首 token 时延(TTFT)和每输出 token 时延(TPOT)。在相同的输入/输出长度和请求并发度下比较各配置。
8.1 使用 AISBench¶
详情请参阅使用 AISBench 进行性能评估。
8.2 使用 vLLM Benchmark¶
服务就绪后,在另一个终端中运行此基础文本基准测试。该示例针对第 5.1 节中的 A2/A3 混部服务;对于其他部署,请使用 第 6 节 中的 API 地址和已服务模型名称,并为其 --model 使用匹配的权重文件。
export VLLM_USE_MODELSCOPE=True
vllm bench serve \
--backend openai-chat \
--base-url http://127.0.0.1:8088 \
--endpoint /v1/chat/completions \
--model Eco-Tech/Qwen3.8-Flash-Next-w4a8 \
--served-model-name qwen3.8-flash-next \
--dataset-name random \
--random-input-len 1024 \
--random-output-len 128 \
--num-prompts 100 \
--max-concurrency 8 \
--ignore-eos
确认所有请求均成功,然后从基准测试摘要中记录吞吐量、TTFT 和 TPOT。这些请求长度和并发数是起始示例;在比较不同部署时请使用相同的工作负载。更多详情请参阅 vLLM benchmark。
9 性能调优¶
9.1 推荐配置¶
Use the configuration for your hardware and deployment mode. The table summarizes the deployment configurations in Section 5; tune context length, concurrency, and memory utilization for the target workload.
| 硬件 | 部署 / 角色 | 设备数 | TP × PP × DP | 最大模型长度 | 最大序列数 | 批处理 token 数 |
|---|---|---|---|---|---|---|
| A2 series | Colocated | 0–7 | 8 × 1 × 1 | 131072 | 8 | 4096 |
| A3 series | Colocated | 0–7 | 8 × 1 × 1 | 131072 | 8 | 4096 |
| 950DT products | Colocated | 0–3 | 4 × 1 × 1 | 141312 | 32 | 4096 |
| A2 series | Prefill | 0–7 on prefill host | 4 × 2 × 1 | 141312 | 32 | 8192 |
| A3 series | Prefill (basic PD) | 0–7 | 2 × 4 × 1 (EP2) | 262144 | 32 | 8192 |
| 950DT products | Prefill (basic PD) | 0–3 | 2 × 1 × 2 (EP4) | 143360 | 64 | 4096 |
| A2 series | Decode | 0–7 on decode host | 2 × 1 × 4 | 141312 | 32 | 8192 |
| A3 series | Decode (basic PD) | 8–15 | 2 × 1 × 4 (EP8) | 262144 | 32 | 8192 |
| 950DT products | Decode (basic PD) | 4–7 | 2 × 1 × 2 (EP4) | 143360 | 64 | 4096 |
| A2 series | Prefill (image-and-text 10K) | 0–7 on prefill host | 4 × 2 × 1 (EP4) | 262144 | 32 | 8192 |
| A3 series | Prefill (image-and-text 10K) | 0–7 | 4 × 2 × 1 (EP4) | 262144 | 32 | 8192 |
| 950DT products | Prefill (image-and-text 10K) | 0–3 | 2 × 2 × 1 | 143360 | 64 | 8192 |
| A2 series | Decode (image-and-text 10K) | 0–7 on decode host | 2 × 1 × 4 (EP8) | 262144 | 32 | 4096 |
| A3 series | Decode (image-and-text 10K) | 8–15 | 2 × 1 × 4 (EP8) | 262144 | 32 | 4096 |
| 950DT products | Decode (image-and-text 10K) | 4–7 | 2 × 1 × 2 | 143360 | 64 | 8192 |
| A2 series | Prefill (long-context) | 0–7 on prefill host | 2 × 4 × 1 (EP2) | 1010000 | 32 | 8192 |
| A3 series | Prefill (long-context) | 0–7 | 2 × 4 × 1 (EP2) | 1010000 | 32 | 8192 |
| 950DT products | Prefill (long-context) | 0–3 | 4 × 1 × 1 | 1010000 | 16 | 4096 |
| A2 series | Decode (long-context) | 0–7 on decode host | 2 × 1 × 4 (EP8) | 1010000 | 32 | 8192 |
| A3 series | Decode (long-context) | 8–15 | 2 × 1 × 4 (EP8) | 1010000 | 32 | 8192 |
| 950DT products | Decode (long-context) | 4–7 | 4 × 1 × 1 | 1010000 | 16 | 4096 |
| A3 series | Prefill (128K/1K three-tier pooling) | 0–7 | 2 × 2 × 2 (EP4) | 262144 | 32 | 8192 |
| A3 series | Decode (128K/1K three-tier pooling) | 8–15 | 2 × 1 × 4 (EP8) | 262144 | 32 | 8192 |
| 950DT products | Prefill (three-tier pooling) | 0–3 | 2 × 1 × 2 (EP4) | 262144 | 64 | 4096 |
| 950DT products | Decode (three-tier pooling) | 4–7 | 2 × 1 × 2 (EP4) | 262144 | 64 | 4096 |
请为您的硬件配对相应的 P/D 行。A2 使用两台八设备主机;A3 使用一台 16 设备主机。A2/A3 Prefill 设置 --enforce-eager;Ascend 950DT系列产品 Prefill 设置 cudagraph_mode=NONE。所有 PD Decode 示例均使用 FULL_DECODE_ONLY 并启用静态 kernel。
For MemCache three-tier pooling, A2 uses the basic PD token budgets above. Use the dedicated pooling rows for A3 and 950DT products and the corresponding commands in Section 5.5. Both 950DT products roles use HCCL_BUFFSIZE=512. Pool and UBS IO memory must be budgeted separately from Engram CPU offload.
9.2 调优指南¶
调优方法请参阅 公开性能调优文档,功能说明请参阅 特性矩阵。
9.2.1 使用 msmodeling 进行工具辅助调优¶
MindStudio-Modeling(msmodeling)利用实测结果及其知识库来调优服务与基准测试参数。
操作说明请参阅 Optix-for-PD-disaggregation。
9.3 Model Runner V2 解码提交¶
当目标模型和 MTP 注意力实现支持时,Model Runner V2 会在 decode 期间自动减少 CPU 同步;无需额外的配置开关。精确的 token 计数和状态保留在设备上。不支持的配置仍保留精确的 CPU 同步;运行时兼容性检查会选择相应行为。
10 常见问题¶
关于常见的环境、安装和参数问题,请参阅公开常见问题。