DeepSeek-V4-Pro¶
1 引言¶
Note
本文档中提到的“PD 分离部署”仅作为示例/参考设计提供,用于演示以分离模式部署 Prefill 和 Decode 的基本流程。不建议在生产环境中使用。
对于客户侧的生产环境,推荐使用 MindIE Motor + vLLM-Ascend。
DeepSeek-V4 在 DeepSeek-V3 的基础上引入了多项关键升级:
- 流形约束超连接(mHC),用于增强传统的残差连接。
- 混合注意力架构,通过 Compress-4-Attention 和 Compress-128-Attention 大幅提升长上下文效率。对于混合专家(MoE)组件,仍采用 DeepSeekMoE 架构,仅做了细微调整。
DeepSeek-V4-Pro 是 DeepSeek-V4 的最大推理努力模式,显著提升了开源模型的知识能力,牢固确立了其作为当前最佳开源模型的地位。它在编程基准测试中取得了顶级性能,并在推理和智能体任务上显著缩小了与领先闭源模型的差距。
本文档将展示该模型的主要验证步骤,包括支持的特性、特性配置、环境准备、多节点部署、精度与性能评估。
本文档基于 vLLM-Ascend v0.30.0 版本编写。该版本支持此模型。
2 支持的特性¶
请参阅支持特性列表获取模型的支持特性矩阵。
请参阅特性指南获取特性的配置。
3 前提条件¶
3.1 模型权重¶
| 权重版本 | 硬件要求 | 下载链接 |
|---|---|---|
DeepSeek-V4-Pro-w4a8-mtp |
2 个 Atlas 800I A3(128GB × 8)节点或 4 个 Atlas 800I A2(64GB × 8)节点 | ModelScope |
DeepSeek-V4-Pro-0813-w4a8 |
2 个 Atlas 800I A3(128GB × 8)节点或 4 个 Atlas 800I A2(64GB × 8)节点 | ModelScope |
DeepSeek-V4-Pro-0813-w4a4c8 |
Ascend 950PR&950DT系列产品 | 使用 msmodelslim 在本地量化 |
DeepSeek-V4-Pro-0813 |
950DT products | ModelScope | Hugging Face |
-
DeepSeek-V4-Pro-0813-w4a8(量化后包含 DSpark 的官方发布版本):该权重包含 DSpark 草稿权重,因此无需单独的草稿模型路径。 -
DeepSeek-V4-Pro-0813:对于 Ascend 950DT系列产品,请使用 DeepSeek 在 Hugging Face 上发布的原始DeepSeek-V4-Pro-0813权重。Attention 权重使用 MXFP8,而 MoE 权重使用 MXFP4,采用 4 比特权重和 8 比特激活计算(W4A8)。无需进行昇腾特定的量化或权重转换。第 5.1 节中的混合部署示例和第 5.2 节中的 2P1D 示例均使用 Ascend 950DT系列产品(96GB × 8)及该权重。 -
DeepSeek-V4-Pro-0813-w4a4c8(W4A4 MXFP4 混合精度量化):关于超低位宽量化如何保持精度,请参见 W4A4C8 常见问题。
建议将模型权重下载到多节点的共享目录中,例如 /root/.cache/。
路径说明:将模型权重下载到您选择的目录并记录该目录。确保后续部署命令中的模型路径与该目录一致。
3.2 验证多节点通信(可选)¶
如果您想部署多节点环境,需要按照验证多节点通信环境验证多节点通信。
4 安装¶
4.1 Docker 镜像安装¶
根据您的机器类型选择镜像,并在节点上启动 docker 镜像,请参考使用 docker。
在每个节点上启动 docker 镜像。
export IMAGE=quay.io/ascend/vllm-ascend:v0.30.0-a5
export NAME=vllm-ascend
docker run --rm \
--name $NAME \
--net=host \
--shm-size=512g \
--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/hisi_hdc \
--device /dev/ummu \
--device /dev/uburma \
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v /etc/hccl_rootinfo.json:/etc/hccl_rootinfo.json \
-v /root/.cache:/root/.cache \
-v /usr/local/sbin:/usr/local/sbin \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /usr/local/sbin/npu-smi:/usr/local/sbin/npu-smi \
-itd $IMAGE bash
在每个节点上启动 docker 镜像。
export IMAGE=quay.io/ascend/vllm-ascend:v0.30.0-a3
docker run --rm \
--name vllm-ascend \
--shm-size=512g \
--net=host \
--privileged=true \
--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 \
-v /root/.cache:/root/.cache \
-it $IMAGE bash
在每个节点上启动 docker 镜像。
export IMAGE=quay.io/ascend/vllm-ascend:v0.30.0
docker run --rm \
--name vllm-ascend \
--shm-size=512g \
--net=host \
--privileged=true \
--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 \
-v /root/.cache:/root/.cache \
-it $IMAGE bash
docker 运行成功后,可以通过执行 docker ps 命令验证正在运行的容器服务。
4.2 源码安装¶
如果您不想像上面那样使用 docker 镜像,也可以从源码构建所有内容:
- 从源码安装
vllm-ascend,请参考安装。
如果您想部署多节点环境,需要在每个节点上设置环境。
5 在线服务部署¶
Note
A2/A3 示例假设模型权重存储在 /root/.cache/modelscope/hub/models/vllm-ascend/。Ascend 950DT系列产品的示例使用位于 /root/.cache/DeepSeek-V4-Pro-0813 的原始 DeepSeek-V4-Pro-0813 Hugging Face 权重。可根据实际环境修改这些路径。
建议将以下服务代码封装在 .sh 脚本文件中,并以 Bash 模式执行。
5.1 多节点在线部署¶
量化模型 DeepSeek-V4-Pro-w4a8-mtp 至少需要 2 个 Atlas 800I A3(128GB × 8)节点或 4 个 Atlas 800I A2(64GB × 8)节点。Ascend 950DT 混合部署示例使用 2 个节点(96GB × 8)及原始 Hugging Face 权重。请分别在各节点上运行以下脚本。
在两个节点上均使用原始 DeepSeek-V4-Pro-0813 权重。在两个节点上将 node0_ip 设置为 Node0 的服务 IP。每个节点承载一个 DP rank,其 8 个 NPU 运行 prefill 上下文并行(PCP8),因此引擎使用 DP2/TP1 并设置 --prefill-context-parallel-size 8。
节点0
# nic_name is the network interface that owns local_ip on the current node.
nic_name="xxx"
local_ip="xxx"
# node0_ip must be the local_ip of Node0 on every node.
node0_ip="xxxx"
export HCCL_IF_IP=$local_ip
export GLOO_SOCKET_IFNAME=$nic_name
export TP_SOCKET_IFNAME=$nic_name
export HCCL_SOCKET_IFNAME=$nic_name
export HCCL_BUFFSIZE=1024
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export HCCL_OP_EXPANSION_MODE=CCU_SCHED
export TASK_QUEUE_ENABLE=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export HCCL_EXEC_TIMEOUT=2040
export HCCL_CONNECT_TIMEOUT=1200
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_USE_FASTOKENS=1
vllm serve /root/.cache/DeepSeek-V4-Pro-0813 \
--host 0.0.0.0 \
--served-model-name dsv4 \
--port 8000 \
--data-parallel-size 2 \
--data-parallel-size-local 1 \
--data-parallel-address $node0_ip \
--data-parallel-rpc-port 6987 \
--tensor-parallel-size 1 \
--prefill-context-parallel-size 8 \
--enable-expert-parallel \
--seed 1024 \
--max-model-len 1048576 \
--max-num-batched-tokens 2048 \
--max-num-seqs 16 \
--async-scheduling \
--no-disable-hybrid-kv-cache-manager \
--model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \
--speculative-config '{"num_speculative_tokens":5,"method":"dspark"}' \
--trust-remote-code \
--block-size 32 \
--kv-cache-dtype fp8 \
--attention_config.indexer_kv_dtype fp8 \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--gpu-memory-utilization 0.95 \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{
"ascend_compilation_config":{
"enable_npugraph_ex":true,
"enable_static_kernel":false
},
"enable_cpu_binding":true,
"enable_fused_mc2":0,
"enable_shared_expert_dp":true,
"multistream_overlap_shared_expert":true
}'
节点1
使用与 Node0 相同的环境变量,并进行以下 DP 修改(起始 rank 为 1 且使用 --headless):
# nic_name is the network interface that owns local_ip on the current node.
nic_name="xxx"
local_ip="xxx"
# node0_ip must be the local_ip of Node0 on every node.
node0_ip="xxxx"
export HCCL_IF_IP=$local_ip
export GLOO_SOCKET_IFNAME=$nic_name
export TP_SOCKET_IFNAME=$nic_name
export HCCL_SOCKET_IFNAME=$nic_name
export HCCL_BUFFSIZE=1024
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export HCCL_OP_EXPANSION_MODE=CCU_SCHED
export TASK_QUEUE_ENABLE=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export HCCL_EXEC_TIMEOUT=2040
export HCCL_CONNECT_TIMEOUT=1200
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_USE_FASTOKENS=1
vllm serve /root/.cache/DeepSeek-V4-Pro-0813 \
--served-model-name dsv4 \
--data-parallel-size 2 \
--data-parallel-size-local 1 \
--data-parallel-start-rank 1 \
--data-parallel-address $node0_ip \
--data-parallel-rpc-port 6987 \
--tensor-parallel-size 1 \
--prefill-context-parallel-size 8 \
--enable-expert-parallel \
--seed 1024 \
--max-model-len 1048576 \
--max-num-batched-tokens 2048 \
--max-num-seqs 16 \
--async-scheduling \
--no-disable-hybrid-kv-cache-manager \
--model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \
--speculative-config '{"num_speculative_tokens":5,"method":"dspark"}' \
--trust-remote-code \
--block-size 32 \
--kv-cache-dtype fp8 \
--attention_config.indexer_kv_dtype fp8 \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--gpu-memory-utilization 0.95 \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{
"ascend_compilation_config":{
"enable_npugraph_ex":true,
"enable_static_kernel":false
},
"enable_cpu_binding":true,
"enable_fused_mc2":0,
"enable_shared_expert_dp":true,
"multistream_overlap_shared_expert":true
}' \
--headless
在两个节点上使用官方 DeepSeek-V4-Pro-0813-w4a8 检查点。该示例保持现有的 DP2/TP16 拓扑,仅更改与 DSpark 相关的参数和必需的运行时参数。
节点0
# nic_name is the network interface that owns local_ip on the current node.
nic_name="xxx"
local_ip="xxx"
# node0_ip must be the local_ip of Node0 on every node.
node0_ip="xxxx"
export HCCL_IF_IP=$local_ip
export GLOO_SOCKET_IFNAME=$nic_name
export TP_SOCKET_IFNAME=$nic_name
export HCCL_SOCKET_IFNAME=$nic_name
export HCCL_OP_EXPANSION_MODE="AIV"
export HCCL_BUFFSIZE=1024
export HCCL_CONNECT_TIMEOUT=1200
export HCCL_EXEC_TIMEOUT=2040
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export ASCEND_CONNECT_TIMEOUT=10000
export ASCEND_TRANSFER_TIMEOUT=10000
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export TASK_QUEUE_ENABLE=1
export VLLM_USE_V2_MODEL_RUNNER=1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
vllm serve /path/to/DeepSeek-V4-Pro-0813-w4a8 \
--host 0.0.0.0 \
--port 8000 \
--data-parallel-address $node0_ip \
--data-parallel-rpc-port 13399 \
--data-parallel-size 2 \
--data-parallel-size-local 1 \
--tensor-parallel-size 16 \
--enable-expert-parallel \
--served-model-name dsv4 \
--max-model-len 135000 \
--max-num-batched-tokens 4096 \
--max-num-seqs 16 \
--gpu-memory-utilization 0.9 \
--block-size 32 \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--attention_config.indexer_kv_dtype int8 \
--model-loader-extra-config='{"enable_multithread_load": true, "num_threads": 128}' \
--quantization ascend \
--speculative-config '{"num_speculative_tokens":5,"method":"dspark","enforce_eager":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{
"ascend_compilation_config": {
"enable_npugraph_ex": true,
"enable_static_kernel": false
},
"enable_cpu_binding": true,
"enable_flashcomm1": true,
"multistream_overlap_shared_expert": true
}'
节点1
使用与 Node0 相同的环境变量和命令,并进行以下 DP 更改:
nic_name="xxx"
local_ip="xxx"
node0_ip="xxxx"
export HCCL_IF_IP=$local_ip
export GLOO_SOCKET_IFNAME=$nic_name
export TP_SOCKET_IFNAME=$nic_name
export HCCL_SOCKET_IFNAME=$nic_name
export HCCL_OP_EXPANSION_MODE="AIV"
export HCCL_BUFFSIZE=1024
export HCCL_CONNECT_TIMEOUT=1200
export HCCL_EXEC_TIMEOUT=2040
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export ASCEND_CONNECT_TIMEOUT=10000
export ASCEND_TRANSFER_TIMEOUT=10000
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export TASK_QUEUE_ENABLE=1
export VLLM_USE_V2_MODEL_RUNNER=1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
vllm serve /path/to/DeepSeek-V4-Pro-0813-w4a8 \
--host 0.0.0.0 \
--port 8000 \
--headless \
--data-parallel-address $node0_ip \
--data-parallel-rpc-port 13399 \
--data-parallel-size 2 \
--data-parallel-size-local 1 \
--data-parallel-start-rank 1 \
--tensor-parallel-size 16 \
--enable-expert-parallel \
--served-model-name dsv4 \
--max-model-len 135000 \
--max-num-batched-tokens 4096 \
--max-num-seqs 16 \
--gpu-memory-utilization 0.9 \
--block-size 32 \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--attention_config.indexer_kv_dtype int8 \
--model-loader-extra-config='{"enable_multithread_load": true, "num_threads": 128}' \
--quantization ascend \
--speculative-config '{"num_speculative_tokens":5,"method":"dspark","enforce_eager":true}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--additional-config '{
"ascend_compilation_config": {
"enable_npugraph_ex": true,
"enable_static_kernel": false
},
"enable_cpu_binding": true,
"enable_flashcomm1": true,
"multistream_overlap_shared_expert": true
}'
在所有四个节点上使用 DeepSeek-V4-Pro-w4a8-mtp 权重。该示例保留现有的 DP4/TP8 拓扑,仅修改与 MTP 相关的参数及必需的运行时参数。
节点0
# nic_name is the network interface that owns local_ip on the current node.
nic_name="xxx"
local_ip="xxx"
# node0_ip must be the local_ip of Node0 on every node.
node0_ip="xxxx"
export HCCL_IF_IP=$local_ip
export GLOO_SOCKET_IFNAME=$nic_name
export TP_SOCKET_IFNAME=$nic_name
export HCCL_SOCKET_IFNAME=$nic_name
export HCCL_BUFFSIZE=512
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export ACL_OP_INIT_MODE=1
export VLLM_ENGINE_READY_TIMEOUT_S=3600
export HCCL_OP_EXPANSION_MODE="AIV"
export TASK_QUEUE_ENABLE=1
export HCCL_CONNECT_TIMEOUT=7200
export ASCEND_CONNECT_TIMEOUT=10000
export ASCEND_TRANSFER_TIMEOUT=10000
# Ensure the model path matches the directory recorded during download
vllm serve /root/.cache/modelscope/hub/models/vllm-ascend/DeepSeek-V4-Pro-w4a8-mtp \
--host 0.0.0.0 \
--port 8000 \
--data-parallel-address $node0_ip \
--data-parallel-size 4 \
--data-parallel-size-local 1 \
--tensor-parallel-size 8 \
--enable-expert-parallel \
--served-model-name dsv4 \
--max-model-len 135000 \
--max-num-batched-tokens 4096 \
--max-num-seqs 16 \
--gpu-memory-utilization 0.9 \
--block-size 128 \
--no-enable-prefix-caching \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--attention_config.indexer_kv_dtype int8 \
--model-loader-extra-config '{
"enable_multithread_load": true,
"num_threads": 128
}' \
--quantization ascend \
--speculative-config '{
"num_speculative_tokens": 1,
"method": "mtp",
"enforce_eager": true
}' \
--compilation-config '{
"cudagraph_mode":"FULL_DECODE_ONLY"
}' \
--additional-config '{
"ascend_compilation_config":{
"enable_npugraph_ex":true,
"enable_static_kernel":false
},
"enable_cpu_binding": true,
"enable_shared_expert_dp": true,
"enable_flashcomm1": true,
"multistream_overlap_shared_expert":true
}'
节点1-节点3
# nic_name is the network interface that owns local_ip on the current node.
nic_name="xxx"
local_ip="xxx"
# node0_ip must be the local_ip of Node0 on every node.
node0_ip="xxxx"
export HCCL_IF_IP=$local_ip
export GLOO_SOCKET_IFNAME=$nic_name
export TP_SOCKET_IFNAME=$nic_name
export HCCL_SOCKET_IFNAME=$nic_name
export HCCL_BUFFSIZE=512
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export ACL_OP_INIT_MODE=1
export VLLM_ENGINE_READY_TIMEOUT_S=3600
export HCCL_OP_EXPANSION_MODE="AIV"
export TASK_QUEUE_ENABLE=1
export HCCL_CONNECT_TIMEOUT=7200
export ASCEND_CONNECT_TIMEOUT=10000
export ASCEND_TRANSFER_TIMEOUT=10000
# Ensure the model path matches the directory recorded during download
vllm serve /root/.cache/modelscope/hub/models/vllm-ascend/DeepSeek-V4-Pro-w4a8-mtp \
--host 0.0.0.0 \
--port 8000 \
--headless \
--data-parallel-address $node0_ip \
--data-parallel-size 4 \
--data-parallel-size-local 1 \
--data-parallel-start-rank 1 \
--tensor-parallel-size 8 \
--enable-expert-parallel \
--served-model-name dsv4 \
--max-model-len 135000 \
--max-num-batched-tokens 4096 \
--max-num-seqs 16 \
--gpu-memory-utilization 0.9 \
--block-size 128 \
--no-enable-prefix-caching \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--attention_config.indexer_kv_dtype int8 \
--model-loader-extra-config '{
"enable_multithread_load": true,
"num_threads": 128
}' \
--quantization ascend \
--speculative-config '{
"num_speculative_tokens": 1,
"method": "mtp",
"enforce_eager": true
}' \
--compilation-config '{
"cudagraph_mode":"FULL_DECODE_ONLY"
}' \
--additional-config '{
"ascend_compilation_config":{
"enable_npugraph_ex":true,
"enable_static_kernel":false
},
"enable_cpu_binding": true,
"enable_shared_expert_dp": true,
"enable_flashcomm1": true,
"multistream_overlap_shared_expert":true
}'
关键参数说明:
--data-parallel-size设置全局数据并行 rank 数量,--data-parallel-size-local设置当前节点上的 DP rank 数量。--data-parallel-start-rank指定当前节点的起始数据并行 rank。在每个 headless 节点上设置唯一的值(例如 Node1 = 1)。在 Node0 上,即使起始 rank 为 0,也应省略--data-parallel-start-rank,以避免启用与 headless 远程引擎的混合负载均衡。--data-parallel-address指定数据并行主节点(Node0)的 IP 地址。所有节点上的该值必须保持一致。--data-parallel-rpc-port是 DP RPC 端口。所有节点使用相同的值,并确保该端口可用。--tensor-parallel-size设置每个 DP rank 内的张量并行大小。请根据部署拓扑和可用 NPU 将其与 DP 大小一起配置。--prefill-context-parallel-size在 Model Runner V2(MRv2)上配置 prefill 上下文并行(PCP),在 prefill 阶段将长 prompt 分散到多个 NPU 上。除了加速 prefill 之外,启用 PCP 还会在 PCP 组内对 o_proj 权重进行分片,即使--tensor-parallel-size为1也能提供部分张量并行。950DT DP 混合部署使用DP2/TP1和 PCP8,o_proj 权重分片也缓解了其内存压力。请勿将其与enable_dsa_cp组合使用,后者与 PCP 互斥,且 V2 模型运行器不支持。--enable-expert-parallel为 MoE 层启用专家并行。请勿在同一 MoE 层中混用 MoE 张量并行和专家并行。--headless(用于非主节点)禁用该节点上的 API server,因为只有主节点处理请求。--max-model-len指定最大上下文长度。示例值旨在使服务能够在文档所述的硬件和配置下启动。要调整此值,请查看启动日志Maximum concurrency for L tokens per request: Cx:L × C提供了在相同配置下增加上下文长度时 KV cache 容量的粗略参考。请使用所有 rank 中的最小估计值,对于 PD 分离部署,则使用 Prefill 和 Decode 两个池中的最小估计值。--max-num-seqs表示每个 DP 组允许处理的最大请求数。如果发送到服务的请求数超过此限制,多余的请求将保持等待状态,不会被调度。请注意,等待状态所花费的时间也会计入 TTFT 和 TPOT 等指标。因此,在测试性能时,通常建议--max-num-seqs*--data-parallel-size>= 实际总并发数。--max-num-batched-tokens是单个调度器步骤中处理的最大 token 数。较大的值可以提高 prefill 效率,但会消耗更多激活内存。--tokenizer-mode deepseek_v4、--tool-call-parser deepseek_v4、--enable-auto-tool-choice和--reasoning-parser deepseek_v4启用 DeepSeek-V4 tokenizer 行为、自动工具调用和推理输出解析。--no-enable-prefix-caching表示禁用前缀缓存。要启用它,请移除此选项。--block-size设置 KV cache 块大小。要启用实验性的 4k 前缀缓存命中支持,请将其从128改为32。--quantization ascend为 A2 和 A3 配置中使用的 W4A8 模型启用昇腾量化。950DT系列产品上使用的原始 DeepSeek-V4-Pro-0813 权重不需要此选项。--model-loader-extra-config='{"enable_multithread_load": true, "num_threads": 128}'选择多线程权重迭代器。enable_multithread_load必须是 JSON 布尔值,num_threads必须是正整数。--safetensors-load-strategy prefetch是一种替代方案,它在常规迭代器加载之前将 checkpoint 文件预热到操作系统页缓存中。请勿将其与多线程加载组合使用:当enable_multithread_load为true时,默认加载器会拒绝prefetch、eager或torchao。本文档中的示例仅使用多线程加载。--speculative-config配置投机解码。对于预览版 MTP checkpoint 使用mtp,对于DeepSeek-V4-Pro-0813checkpoint 使用dspark。对于 DSpark,请使用 checkpoint 声明的值;示例使用 5 个投机 token,所有 rank 必须使用相同的值。--kv-cache-dtype和--attention_config.indexer_kv_dtype设置 KV cache 数据类型。950DT 示例使用 FP8 KV cache,两个选项均设置为fp8。--no-disable-hybrid-kv-cache-manager保持混合 KV cache 管理器启用。DeepSeek-V4 部署需要此标志;否则,服务可能在启动期间 OOM。--async-scheduling启用异步调度,使调度器开销与模型执行重叠。--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}'在 decode 阶段启用完整的 ACL graph 执行。--additional-config启用昇腾特有的优化。enable_npugraph_ex启用增强的 ACL graph 执行,enable_static_kernel: false保持静态内核编译禁用,enable_cpu_binding启用昇腾原生 CPU 绑定,enable_shared_expert_dp为共享专家启用数据并行,multistream_overlap_shared_expert重叠共享专家计算以获得更好的 MoE 吞吐量。enable_fused_mc2: 0禁用 Fused MC2 dispatch/combine 路径。
常见问题提示:如果遇到问题,请参考公共FAQ进行故障排查。
服务验证:
curl http://<node0_ip>:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "dsv4",
"messages": [
{
"role": "user",
"content": "Who are you?"
}
],
"max_tokens": 256,
"temperature": 0
}'
预期结果:
服务返回HTTP 200 OK,并返回包含choices字段的JSON响应。
5.2 多节点 PD 分离部署¶
我们推荐使用 Mooncake 进行部署:Mooncake。
在标准部署模式下,Prefill(提示处理)和Decode(令牌生成)任务在同一组NPU上运行。PD(Prefill-Decode)分离通过将Prefill和Decode运行在专用节点组上(每组独立配置)来解决此问题。对于需要同时保证稳定延迟和高吞吐量的并发多用户工作负载的生产部署,建议采用此架构。
以下标签页介绍在 Ascend 950DT 节点(96GB × 8)、Atlas 800I A3 节点(128GB × 8)和 Atlas 800I A2 节点(64GB × 8)上的 PD 分离部署。
选择与部署硬件相匹配的标签页。
Ascend 950DT系列产品¶
本节介绍在 8 台 Ascend 950DT 节点(96GB × 8)上使用 DeepSeek-V4-Pro-0813 权重进行 2P1D 部署的方案。Prefill 侧(2P)运行 2 个 Prefill 实例,每个实例都是一个单一逻辑引擎,采用 DP1/TP1/PP2 配置,并通过 --prefill-context-parallel-size 8 分布在 2 个节点上(--nnodes 2):每个节点运行一个 PP stage。Decode 侧(1D)使用 4 个节点组成一个 Decode 池,包含 32 个 DP rank,采用 DP32/TP1 配置,每个 Decode 节点启动 8 个本地 DP rank。每个 Prefill 实例在 --kv-transfer-config 中声明 "prefill": {"dp_size": 1, "tp_size": 1, "pp_size": 2, "pp_layer_partition": "32,29"},而 Decode 侧声明 "decode": {"dp_size": 32, "tp_size": 1}。请为每个 Prefill 实例和 Decode 池分配唯一的 kv_port。
在开始之前,请将下面每个脚本中的 nic_name 和 local_ip 设置为当前节点的网卡名称和 IP 地址,然后再启动服务。
-
在每个 Decode 节点上准备脚本
launch_online_dp.py。Prefill 引擎在 Prefill 节点上由vllm serve直接启动,因此那里不需要此脚本。该启动器由所有硬件标签页共享,详见通用脚本与参数说明。 -
准备 Prefill 启动脚本。共有 2 个 Prefill 实例,每个实例都是一个分布在 2 个节点上的 PP2 引擎:主节点(
--node-rank 0)启动引擎及其 API server,而工作节点(--node-rank 1)通过--headless加入同一引擎。--master-addr必须指向主节点的服务 IP,以便工作节点能够加入跨节点进程组,并且两个节点必须使用相同的模型、TP、PP、PCP 和VLLM_PP_LAYER_PARTITION设置。--port $1从脚本的第一个命令行参数获取引擎端口,例如bash run_p_node0.sh 8000。-
在 Prefill 实例 1 的主节点上运行
run_p_node0.sh:#!/usr/bin/env bash # nic_name is the network interface that owns local_ip on the current node. nic_name="xxx" local_ip="xxx" # node0_ip must be the local_ip of the master node of this instance. node0_ip="xxxx" export HCCL_IF_IP=$local_ip export GLOO_SOCKET_IFNAME=$nic_name export TP_SOCKET_IFNAME=$nic_name export HCCL_SOCKET_IFNAME=$nic_name export HCCL_BUFFSIZE=1024 export OMP_PROC_BIND=false export OMP_NUM_THREADS=10 export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True export HCCL_OP_EXPANSION_MODE=CCU_SCHED export TASK_QUEUE_ENABLE=1 export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000 export HCCL_EXEC_TIMEOUT=2040 export HCCL_CONNECT_TIMEOUT=1200 export VLLM_USE_V2_MODEL_RUNNER=1 export VLLM_PP_LAYER_PARTITION="32,29" export VLLM_USE_FASTOKENS=1 export ASCEND_LOCAL_COMM_RES='{"version":"1.3"}' vllm serve /root/.cache/DeepSeek-V4-Pro-0813 \ --host 0.0.0.0 \ --served-model-name dsv4 \ --port $1 \ --nnodes 2 \ --node-rank 0 \ --master-addr $node0_ip \ --tensor-parallel-size 1 \ --prefill-context-parallel-size 8 \ --data-parallel-size 1 \ --pipeline-parallel-size 2 \ --enable-expert-parallel \ --seed 1024 \ --max-model-len 1048576 \ --max-num-batched-tokens 8192 \ --max-num-seqs 16 \ --no-disable-hybrid-kv-cache-manager \ --model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \ --speculative-config '{"num_speculative_tokens":5,"method":"dspark","enforce_eager":true}' \ --trust-remote-code \ --block-size 32 \ --kv-cache-dtype fp8 \ --attention_config.indexer_kv_dtype fp8 \ --tokenizer-mode deepseek_v4 \ --tool-call-parser deepseek_v4 \ --enable-auto-tool-choice \ --reasoning-parser deepseek_v4 \ --gpu-memory-utilization 0.94 \ --enforce-eager \ --additional-config '{"enable_cpu_binding":true,"enable_fused_mc2":0,"multistream_overlap_shared_expert":true,"enable_shared_expert_dp":true}' \ --kv-transfer-config '{ "kv_connector":"MooncakeConnectorV2", "kv_role":"kv_producer", "kv_port":"30000", "kv_connector_extra_config":{ "prefill":{"dp_size":1,"tp_size":1,"pp_size":2,"pp_layer_partition":"32,29"}, "decode":{"dp_size":32,"tp_size":1} } }' -
在 Prefill 实例 1 的工作节点上运行
run_p_node1.sh:使用与 Prefill 节点 0 相同的内容,但需做以下修改:将local_ip设置为本节点的 IP,保持node0_ip为主节点的服务 IP,将--node-rank改为1,并在vllm serve后追加--headless,使该节点仅运行其 PP stage 而不启动 API server。 -
Prefill 实例 2:以相同方式准备
run_p_node2.sh(主节点)和run_p_node3.sh(工作节点),但需做以下修改:将local_ip设置为各节点的 IP,将node0_ip设置为此实例自己的主节点 IP,并分配唯一的kv_port,例如"kv_port":"30200"。保持所有其他设置相同,以便两个 Prefill 实例向 Decode 池呈现相同的prefill拓扑。
-
-
在每个 Decode 节点上准备
run_dp_template.sh。launch_online_dp.py将可见设备、端口、DP 大小、DP rank、DP 地址、DP RPC 端口、TP 大小和 PCP 大小分别作为$1到$8传入;此模板忽略$8,因为 Decode 引擎不使用 PCP。#!/usr/bin/env bash # nic_name is the network interface that owns local_ip on the current node. nic_name="xxx" local_ip="xxx" 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 HCCL_BUFFSIZE=2048 export ASCEND_RT_VISIBLE_DEVICES=$1 export OMP_PROC_BIND=false export OMP_NUM_THREADS=10 export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True export TASK_QUEUE_ENABLE=1 export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000 export HCCL_EXEC_TIMEOUT=2040 export HCCL_CONNECT_TIMEOUT=1200 export VLLM_USE_V2_MODEL_RUNNER=1 export VLLM_USE_FASTOKENS=1 export ASCEND_LOCAL_COMM_RES='{"version":"1.3"}' vllm serve /root/.cache/DeepSeek-V4-Pro-0813 \ --host 0.0.0.0 \ --served-model-name dsv4 \ --port $2 \ --data-parallel-size $3 \ --data-parallel-rank $4 \ --data-parallel-address $5 \ --data-parallel-rpc-port $6 \ --tensor-parallel-size $7 \ --enable-expert-parallel \ --seed 1024 \ --max-model-len 1048576 \ --max-num-batched-tokens 512 \ --max-num-seqs 32 \ --async-scheduling \ --block-size 32 \ --kv-cache-dtype fp8 \ --attention_config.indexer_kv_dtype fp8 \ --no-enable-prefix-caching \ --no-disable-hybrid-kv-cache-manager \ --model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \ --trust-remote-code \ --tokenizer-mode deepseek_v4 \ --tool-call-parser deepseek_v4 \ --enable-auto-tool-choice \ --reasoning-parser deepseek_v4 \ --gpu-memory-utilization 0.92 \ --speculative-config '{"num_speculative_tokens":5,"method":"dspark","enforce_eager":false}' \ --compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \ --kv-transfer-config '{ "kv_connector":"MooncakeConnectorV2", "kv_role":"kv_consumer", "kv_port":"30100", "kv_connector_extra_config":{ "prefill":{"dp_size":1,"tp_size":1,"pp_size":2,"pp_layer_partition":"32,29"}, "decode":{"dp_size":32,"tp_size":1} } }' \ --additional-config '{ "ascend_compilation_config":{"enable_npugraph_ex":true,"enable_static_kernel":false}, "enable_cpu_binding":true, "multistream_overlap_shared_expert":true, "scheduler_config":{"recompute_scheduler_enable":true}, "enable_shared_expert_dp":true, "combine_quant_mode":4 }' -
启动服务。启动前请将每个脚本中的
local_ip设置为当前节点的 IP。对于每个 Prefill 实例,先启动主节点(--node-rank 0),再启动其工作节点。第一个参数是传递给--port $1的引擎端口。-
Prefill 实例 1,主节点:
-
Prefill 实例 1,工作节点(headless):
-
Prefill 实例 2,主节点:
-
Prefill 实例 2,工作节点(headless):
-
Decode节点0
-
Decode节点1
-
Decode节点2
-
Decode节点3
-
-
部署 P-D 分离代理。
请参考 Prefill-Decode 分离(Deepseek),注册上面启动的所有 Prefill 和 Decode 引擎端点。每个 Prefill 实例在其主节点的
8000端口上暴露一个 API server,每个 Decode 节点暴露8000到8007端口。使用 DP 主地址(上面的--dp-address,例如xx.xx.xx.5)作为 Decode 节点 0 的 IP。
关键参数说明:
--kv-cache-dtype fp8将 KV cache 数据类型设置为 FP8,--attention_config.indexer_kv_dtype fp8将索引侧 KV 数据类型设置为 FP8。P 侧和 D 侧必须使用相同的 KV 数据类型,以便传输的 KV cache 可直接复用。--pipeline-parallel-size 2/--nnodes 2/--node-rank/--master-addr将每个 Prefill 引擎(DP1/TP1/PP2)分布在 2 个节点上,每个节点运行一个 PP stage;工作节点(--node-rank 1)以 headless 模式运行,--master-addr是该实例主节点的服务 IP,用于跨节点进程组。VLLM_PP_LAYER_PARTITION="32,29"将 61 个目标层划分到 2 个 PP stage 上;必须在kv_connector_extra_config.prefill.pp_layer_partition中声明相同的划分。--prefill-context-parallel-size 8将 prompt 分散到每个 PP stage 的 8 个 NPU 上。--kv-transfer-config使用MooncakeConnectorV2进行 KV 传输;由于启用了流水线并行,此项为必需。--additional-config:enable_fused_mc2: 0禁用 Fused MC2,改为通过multistream_overlap_shared_expert: true将共享专家计算与 MoE 通信重叠,并通过enable_shared_expert_dp: true将共享专家放置在 DP rank 上;combine_quant_mode: 4强制 Decode 节点上的 MoE MC2 combine 阶段使用 FP8(MXFP float8_e4m3)通信量化。
A3 系列¶
本节展示在 Atlas 800I A3(128GB × 8)上部署一个 Prefill 池和一个 Decode 池的示例。该示例为每个池使用两个物理节点。
在所有节点上使用官方 DeepSeek-V4-Pro-0813-w4a8 权重。该权重已包含 DSpark 草稿权重,因此无需单独的草稿模型路径。请将下方的模型路径、IP 地址和网络接口名称替换为您环境中的实际值。
开始前,请:
-
在每个 Decode 节点上准备
launch_online_dp.py。该启动器由所有硬件标签页共享,详见通用脚本与参数说明。 -
准备 Prefill 启动脚本。本示例只有一个 Prefill 实例,即一个跨 2 个节点的 PP2 引擎:主节点(
--node-rank 0)启动引擎及其 API server,工作节点(--node-rank 1)通过--headless加入同一引擎。--master-addr必须指向主节点的服务 IP,以便工作节点加入跨节点进程组,且两个节点必须使用相同的模型、TP、PP、PCP 和VLLM_PP_LAYER_PARTITION设置。--port $1从脚本的第一个命令行参数获取引擎端口,例如bash run_p_node0.sh 8000。-
在主节点上运行
run_p_node0.sh:#!/usr/bin/env bash # nic_name is the network interface that owns local_ip on the current node. nic_name="xxx" local_ip="xxx" # node0_ip must be the local_ip of the master node of this instance. node0_ip="xxxx" export HCCL_IF_IP="$local_ip" export GLOO_SOCKET_IFNAME="$nic_name" export TP_SOCKET_IFNAME="$nic_name" export HCCL_SOCKET_IFNAME="$nic_name" export VLLM_USE_V2_MODEL_RUNNER=1 export HCCL_OP_EXPANSION_MODE="AIV" export HCCL_BUFFSIZE=1024 export HCCL_CONNECT_TIMEOUT=1200 export HCCL_EXEC_TIMEOUT=2040 export VLLM_RPC_TIMEOUT=3600000 export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000 export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True export VLLM_PP_LAYER_PARTITION="32,29" vllm serve /path/to/DeepSeek-V4-Pro-0813-w4a8 \ --tensor-parallel-size 2 \ --prefill-context-parallel-size 8 \ --host 0.0.0.0 \ --port $1 \ --nnodes 2 \ --node-rank 0 \ --master-addr $node0_ip \ --master-port 12321 \ --data-parallel-size 1 \ --pipeline-parallel-size 2 \ --decode-context-parallel-size 1 \ --served-model-name dsv4 \ --enable-expert-parallel \ --max-model-len 150000 \ --max-num-batched-tokens 4096 \ --max-num-seqs 16 \ --block-size 32 \ --gpu-memory-utilization 0.92 \ --enable-chunked-prefill \ --no-disable-hybrid-kv-cache-manager \ --enable-prefix-caching \ --enforce-eager \ --quantization ascend \ --tokenizer-mode deepseek_v4 \ --attention_config.indexer_kv_dtype int8 \ --tool-call-parser deepseek_v4 \ --enable-auto-tool-choice \ --reasoning-parser deepseek_v4 \ --trust-remote-code \ --seed 1024 \ --model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \ --speculative-config '{"method":"dspark","num_speculative_tokens":5,"enforce_eager":true}' \ --additional-config '{"enable_cpu_binding":true,"enable_flashcomm1":true,"enable_fused_mc2":1}' \ --kv-transfer-config \ '{ "kv_connector": "MooncakeConnectorV2", "kv_role": "kv_producer", "kv_port": 30000, "kv_connector_extra_config": { "prefill": {"dp_size": 1, "tp_size": 2, "pp_size": 2, "pcp_size": 8}, "decode": {"dp_size": 16, "tp_size": 2, "pp_size": 1, "pcp_size": 1} } }' -
在工作节点上运行
run_p_node1.sh:内容与run_p_node0.sh相同,但需做以下修改:将local_ip设置为本节点的 IP,保持node0_ip为主节点的服务 IP,将--node-rank改为1,在vllm serve后追加--headless,使该节点只运行其 PP stage 而不启动 API server,并分配一个唯一的kv_port,例如"kv_port":"30200"。
-
-
在两个 Decode 节点上准备
run_dp_template.sh,并将其放在与launch_online_dp.py相同的目录中。在每个节点上分别设置
local_ip和nic_name。启动器会提供可见设备、服务端口和并行参数。local_ip="xx.xx.xx.x" nic_name="xxxx" # NIC that owns 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 ASCEND_RT_VISIBLE_DEVICES="$1" export SERVICE_PORT="$2" export DP_SIZE="$3" export DP_RANK="$4" export DP_MASTER_IP="$5" export DP_RPC_PORT="$6" export TP_SIZE="$7" export PCP_SIZE="$8" export VLLM_USE_V2_MODEL_RUNNER=1 export HCCL_OP_EXPANSION_MODE="AIV" export HCCL_BUFFSIZE=1800 export HCCL_CONNECT_TIMEOUT=1200 export HCCL_EXEC_TIMEOUT=2040 export VLLM_RPC_TIMEOUT=3600000 export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000 export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True vllm serve /path/to/DeepSeek-V4-Pro-0813-w4a8 \ --host 0.0.0.0 \ --port "$SERVICE_PORT" \ --data-parallel-address "$DP_MASTER_IP" \ --data-parallel-rpc-port "$DP_RPC_PORT" \ --data-parallel-size "$DP_SIZE" \ --data-parallel-rank "$DP_RANK" \ --tensor-parallel-size "$TP_SIZE" \ --prefill-context-parallel-size "$PCP_SIZE" \ --decode-context-parallel-size 1 \ --served-model-name dsv4 \ --enable-expert-parallel \ --max-model-len 150000 \ --max-num-batched-tokens 180 \ --max-num-seqs 30 \ --block-size 32 \ --gpu-memory-utilization 0.95 \ --enable-chunked-prefill \ --no-disable-hybrid-kv-cache-manager \ --no-enable-prefix-caching \ --async-scheduling \ --compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \ --quantization ascend \ --tokenizer-mode deepseek_v4 \ --attention_config.indexer_kv_dtype int8 \ --tool-call-parser deepseek_v4 \ --enable-auto-tool-choice \ --reasoning-parser deepseek_v4 \ --trust-remote-code \ --seed 1024 \ --model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \ --speculative-config '{"method":"dspark","num_speculative_tokens":5}' \ --additional-config '{"enable_cpu_binding":true,"ascend_compilation_config":{"enable_npugraph_ex":true,"enable_static_kernel":false},"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true}}' \ --kv-transfer-config \ '{ "kv_connector": "MooncakeConnectorV2", "kv_role": "kv_consumer", "kv_port": 30100, "kv_connector_extra_config": { "prefill": {"dp_size": 1, "tp_size": 2, "pp_size": 2, "pcp_size": 8}, "decode": {"dp_size": 16, "tp_size": 2, "pp_size": 1, "pcp_size": 1} } }' -
在对应机器的独立终端中启动服务。请先启动 Prefill 主节点,再启动其工作节点;第一个参数是传递给
--port $1的引擎端口。-
Prefill 主节点
-
Prefill 工作节点:headless
-
Decode 节点 0
-
Decode 节点 1
-
-
部署 P-D 分离代理。
请参考Prefill-Decode分离 (Deepseek)部署P-D分离代理。
关键参数说明:
--kv-cache-dtype保持默认的 BF16 KV dtype,--attention_config.indexer_kv_dtype int8将 index 侧的 KV dtype 设置为 INT8。P 侧和 D 侧必须使用相同的 KV 数据类型,以便传输的 KV cache 可直接复用。--pipeline-parallel-size 2/--nnodes 2/--node-rank/--master-addr将 Prefill 引擎(DP1/TP2/PP2)分布到 2 个节点上,每个节点运行一个 PP stage;工作节点(--node-rank 1)以 headless 模式运行。- Prefill 侧设置
--prefill-context-parallel-size 8;Decode 侧向 launcher 传递--pcp-size 1,使 Decode 池不启用 PCP。请保持kv_connector_extra_config.prefill.pcp_size和decode.pcp_size与对应池的 PCP size 一致。 --kv-transfer-config使用MooncakeConnectorV2进行 KV 传输;由于启用了流水线并行,该配置是必需的。--additional-config:enable_flashcomm1: true和enable_fused_mc2: 1启用 Fused MC2 融合算子与 FlashComm,以加速 Prefill 节点上的通信。
A2 系列¶
本节展示在 Atlas 800I A2(64GB × 8)上部署一个 Prefill 池和一个 Decode 池的示例。该示例为每个池使用四个物理节点。
开始前,请:
-
在每个节点上准备脚本
launch_online_dp.py。该 launcher 由所有硬件标签页共用,详见通用脚本与参数说明。 -
在每个节点上准备脚本
run_dp_template.sh。-
Prefill节点(4个P节点共享同一脚本)
nic_name="xxxx" # change to your own nic name local_ip=xx.xx.xx.1/2/3/4 # change to your own ip export HCCL_OP_EXPANSION_MODE="AIV" export TASK_QUEUE_ENABLE=1 export VLLM_RPC_TIMEOUT=3600000 export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=30000 export HCCL_EXEC_TIMEOUT=204 export HCCL_CONNECT_TIMEOUT=6000 export HCCL_IF_IP=$local_ip export GLOO_SOCKET_IFNAME=$nic_name export TP_SOCKET_IFNAME=$nic_name export HCCL_SOCKET_IFNAME=$nic_name export OMP_PROC_BIND=false export OMP_NUM_THREADS=10 export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True export HCCL_BUFFSIZE=1024 export VLLM_USE_V2_MODEL_RUNNER=1 export ASCEND_RT_VISIBLE_DEVICES=$1 # Ensure the model path matches the directory recorded during download vllm serve /root/.cache/modelscope/hub/models/vllm-ascend/DeepSeek-V4-Pro-0813-w4a8 \ --host 0.0.0.0 \ --port $2 \ --data-parallel-address $5 \ --data-parallel-rpc-port $6 \ --data-parallel-size $3 \ --data-parallel-rank $4 \ --tensor-parallel-size $7 \ --enable-expert-parallel \ --seed 1024 \ --served-model-name dsv4 \ --max-model-len 150000 \ --max-num-batched-tokens 4096 \ --max-num-seqs 16 \ --gpu-memory-utilization 0.92 \ --block-size 32 \ --no-enable-prefix-caching \ --no-disable-hybrid-kv-cache-manager \ --tokenizer-mode deepseek_v4 \ --tool-call-parser deepseek_v4 \ --enable-auto-tool-choice \ --reasoning-parser deepseek_v4 \ --attention_config.indexer_kv_dtype int8 \ --model-loader-extra-config='{"enable_multithread_load": true, "num_threads": 128}' \ --trust-remote-code \ --quantization ascend \ --enforce-eager \ --speculative-config '{"num_speculative_tokens": 7, "method":"dspark", "enforce_eager": true}' \ --additional-config '{"enable_cpu_binding":true,"enable_shared_expert_dp":true,"enable_flashcomm1":true,"enable_fused_mc2":1}' \ --kv-transfer-config \ '{"kv_connector": "MooncakeHybridConnector", "kv_role": "kv_producer", "kv_port": "30000", "kv_connector_extra_config": { "prefill": { "dp_size": 4, "tp_size": 8 }, "decode": { "dp_size": 4, "tp_size": 8 } } }' -
Decode节点(4个D节点共享同一脚本)
nic_name="xxxx" # change to your own nic name local_ip=xx.xx.xx.5/6/7/8 # change to your own ip export HCCL_OP_EXPANSION_MODE="AIV" export TASK_QUEUE_ENABLE=1 export VLLM_RPC_TIMEOUT=3600000 export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=30000 export HCCL_EXEC_TIMEOUT=204 export HCCL_CONNECT_TIMEOUT=1200 export HCCL_IF_IP=$local_ip export GLOO_SOCKET_IFNAME=$nic_name export TP_SOCKET_IFNAME=$nic_name export HCCL_SOCKET_IFNAME=$nic_name export OMP_PROC_BIND=false export OMP_NUM_THREADS=10 export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True export HCCL_BUFFSIZE=1800 export VLLM_USE_V2_MODEL_RUNNER=1 export ASCEND_RT_VISIBLE_DEVICES=$1 # Ensure the model path matches the directory recorded during download vllm serve /root/.cache/modelscope/hub/models/vllm-ascend/DeepSeek-V4-Pro-0813-w4a8 \ --host 0.0.0.0 \ --port $2 \ --data-parallel-address $5 \ --data-parallel-rpc-port $6 \ --data-parallel-size $3 \ --data-parallel-rank $4 \ --tensor-parallel-size $7 \ --enable-expert-parallel \ --seed 1024 \ --served-model-name dsv4 \ --max-model-len 150000 \ --max-num-batched-tokens 256 \ --max-num-seqs 32 \ --async-scheduling \ --gpu-memory-utilization 0.92 \ --block-size 32 \ --no-enable-prefix-caching \ --no-disable-hybrid-kv-cache-manager \ --tokenizer-mode deepseek_v4 \ --tool-call-parser deepseek_v4 \ --enable-auto-tool-choice \ --reasoning-parser deepseek_v4 \ --attention_config.indexer_kv_dtype int8 \ --model-loader-extra-config='{"enable_multithread_load": true, "num_threads": 128}' \ --trust-remote-code \ --quantization ascend \ --speculative-config '{"num_speculative_tokens": 7, "method":"dspark", "enforce_eager": true}' \ --compilation-config '{"cudagraph_mode": "FULL_DECODE_ONLY"}' \ --additional-config '{"ascend_compilation_config":{"enable_npugraph_ex":true,"enable_static_kernel":false}, "enable_cpu_binding":true, "multistream_overlap_shared_expert":true, "scheduler_config":{"recompute_scheduler_enable":true}}' \ --kv-transfer-config \ '{"kv_connector": "MooncakeHybridConnector", "kv_role": "kv_consumer", "kv_port": "30100", "kv_connector_extra_config": { "prefill": { "dp_size": 4, "tp_size": 8 }, "decode": { "dp_size": 4, "tp_size": 8 } } }'
-
-
在每个节点上使用以下命令启动服务器。
-
Prefill节点0
-
Prefill节点1
-
Prefill节点2
-
Prefill节点3
-
Decode节点0
-
Decode节点1
-
Decode节点2
-
Decode节点3
-
-
部署P-D分离代理。
请参考Prefill-Decode分离 (Deepseek)部署P-D分离代理。
关键参数说明:
--kv-cache-dtype保持默认的 BF16 KV dtype,--attention_config.indexer_kv_dtype int8将 index 侧的 KV dtype 设置为 INT8。P 侧和 D 侧必须使用相同的 KV 数据类型,以便传输的 KV cache 可直接复用。- 由于未启用流水线并行,
--kv-transfer-config使用MooncakeHybridConnector进行 KV 传输。 --additional-config:enable_flashcomm1: true和enable_fused_mc2: 1启用 Fused MC2 融合算子与 FlashComm;Prefill 节点额外设置enable_shared_expert_dp: true。- 不设置
--prefill-context-parallel-size:由于每个 DP rank 已运行完整的TP8,因此不使用 PCP。
通用关键参数说明
--no-disable-hybrid-kv-cache-manager保持混合 KV cache manager 启用。DeepSeek-V4 KV Pool 部署需要此标志;否则服务可能在启动时 OOM。--enforce-eager强制 prefill 节点使用 eager 执行,而非图编译。--trust-remote-code允许加载模型仓库中的自定义代码。请仅使用可信的模型仓库。--kv-transfer-config配置 PD 分离场景下 prefill 生产者与 decode 消费者之间的 KV cache 传输。kv_connector_extra_config.prefill.dp_size/tp_size和decode.dp_size/tp_size必须与 prefill 侧和 decode 侧的实际并行布局一致。scheduler_config.recompute_scheduler_enable: true:启用重计算调度器。当 Decode 节点的 KV Cache 不足时,请求会被发送到 Prefill 进行 KV Cache 重计算。仅在 PD Decode 节点上启用;旧的顶层键已弃用。--speculative-config:Prefill 和 Decode 必须使用相同的 DSparknum_speculative_tokens值。请使用 checkpoint 声明的值;950DT 和 A3 示例使用5,而 A2 示例使用7。嵌套的enforce_eager作用于 DSpark draft 执行,而顶层的--enforce-eager使 Prefill 目标模型保持 eager 模式。ascend_compilation_config.enable_npugraph_ex: true在 Decode 侧启用扩展 NPU 图模式进行图编译(Prefill 则运行 eager 模式);enable_static_kernel: false保持动态 shape kernel,而非用于 aclgraph 执行的静态 shape kernel。--prefill-context-parallel-size在 Model Runner V2(MRv2)上配置 prefill 上下文并行(PCP),替代 MRv1 上使用的 DSA-CP 配置。启用 PCP 除了加速长上下文 prefill 外,还会在 PCP 组内分片 o_proj 权重,即使--tensor-parallel-size为1也能提供部分张量并行,从而缓解内存压力。各硬件标签页对 PCP 的配置方式不同,请参阅各标签页的说明。--quantization ascend为 A2 和 A3 配置中使用的 W4A8 模型启用昇腾量化。950DT 系列产品上使用的原始 DeepSeek-V4-Pro-0813 权重不需要此选项。
各硬件相关的参数差异列于上方各标签页中。
通用脚本与参数说明
上述三个硬件标签页共用同一个 launch_online_dp.py 启动脚本,如下所示。每个本地 DP 实例占用 TP × PCP 个 NPU;未指定 --pcp-size 时,PCP 默认为 1。
import argparse
import multiprocessing
import os
import subprocess
import sys
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--dp-size",
type=int,
required=True,
help="Data parallel size."
)
parser.add_argument(
"--tp-size",
type=int,
default=1,
help="Tensor parallel size."
)
parser.add_argument(
"--pcp-size",
type=int,
default=1,
help="Prefill context parallel size of each DP rank."
)
parser.add_argument(
"--dp-size-local",
type=int,
default=-1,
help="Local data parallel size."
)
parser.add_argument(
"--dp-rank-start",
type=int,
required=True,
help="Starting rank for data parallel."
)
parser.add_argument(
"--dp-address",
type=str,
required=True,
help="IP address for data parallel master node."
)
parser.add_argument(
"--dp-rpc-port",
type=str,
default="12321",
help="Port for data parallel master node."
)
parser.add_argument(
"--vllm-start-port",
type=int,
default=8000,
help="Starting port for the engine."
)
return parser.parse_args()
args = parse_args()
dp_size = args.dp_size
tp_size = args.tp_size
pcp_size = args.pcp_size
dp_size_local = args.dp_size_local
if dp_size_local == -1:
dp_size_local = dp_size
dp_rank_start = args.dp_rank_start
dp_address = args.dp_address
dp_rpc_port = args.dp_rpc_port
vllm_start_port = args.vllm_start_port
# Each local DP instance uses TP x PCP devices.
devices_per_dp_rank = tp_size * pcp_size
def run_command(visible_devices, dp_rank, vllm_engine_port):
command = [
"bash",
"./run_dp_template.sh",
visible_devices,
str(vllm_engine_port),
str(dp_size),
str(dp_rank),
dp_address,
dp_rpc_port,
str(tp_size),
str(pcp_size),
]
subprocess.run(command, check=True)
if __name__ == "__main__":
template_path = "./run_dp_template.sh"
if not os.path.exists(template_path):
print(f"Template file {template_path} does not exist.")
sys.exit(1)
processes = []
for i in range(dp_size_local):
dp_rank = dp_rank_start + i
vllm_engine_port = vllm_start_port + i
device_start = i * devices_per_dp_rank
device_end = (i + 1) * devices_per_dp_rank
visible_devices = ",".join(str(x) for x in range(device_start, device_end))
process = multiprocessing.Process(target=run_command,
args=(visible_devices, dp_rank,
vllm_engine_port))
processes.append(process)
process.start()
exit_code = 0
for process in processes:
process.join()
if process.exitcode != 0:
exit_code = 1
sys.exit(exit_code)
launch_online_dp.py 的参数说明:
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
--dp-size |
int | 是 | - | 数据并行大小(所有节点上 DP rank 的总数)。 |
--tp-size |
int | 否 | 1 | 每个 DP rank 内的张量并行大小。 |
--pcp-size |
int | 否 | 1 | 每个 DP rank 内的 Prefill 上下文并行大小;作为 $8 / PCP_SIZE 传递给 run_dp_template.sh。每个本地 DP 实例使用 TP × PCP 个设备。 |
--dp-size-local |
int | 否 | (与 --dp-size 相同) |
当前节点上的 DP rank 数量。若未设置,则默认为 --dp-size。 |
--dp-rank-start |
int | 是 | - | 本节点上数据并行 rank 的起始偏移量。 |
--dp-address |
str | 是 | - | 数据并行主节点的 IP 地址。 |
--dp-rpc-port |
str | 否 | 12321 | 数据并行主节点通信的 RPC 端口。 |
--vllm-start-port |
int | 否 | 8000 | 本节点上每个 vLLM 引擎实例的起始端口。 |
部署验证:
PD 分离服务完全启动且每个引擎都输出 Application startup complete 后,通过 Prefill 主节点上的代理端口发送请求,以验证 Prefill 与 Decode 节点能否正确协同工作。代理验证方法请参考 Prefill-Decode 分离(Deepseek)。
常见问题提示:如果遇到PD分离部署问题,请参考公共FAQ进行故障排查。
5.3 KV Cache Pool 部署¶
本节介绍在 PD 分离部署中增加 KV Cache Pool 以实现跨引擎 KV 复用的方案。各硬件系列使用适合其互联方式的池后端:A3 系列和 950DT 产品使用 MemCache 后端,A2 系列使用 Mooncake 后端。拓扑、连接器角色和池配置在各硬件标签页中说明;请仅应用所选平台的配置。
选择与部署硬件相匹配的标签页。
950DT 产品¶
本节在 5.2 节 的 2P1D 部署基础上,在同样的 8 个昇腾 950DT 节点(96GB × 8)和 DeepSeek-V4-Pro-0813 权重上增加 Memcache KV Cache Pool。MooncakeConnectorV2 仍负责将 KV cache 从 Prefill 传输到 Decode,而 AscendStoreConnector 将可复用的 KV cache 存入 Memcache,使共享相同前缀的请求可以跳过 Prefill 重算。两个连接器均配置为 MultiConnector 的子连接器。Prefill 通过 use_layerwise: true 和 layerwise_prefetch_layers: 3 启用分层 Memcache 访问;Decode 使用默认的非分层模式。
本示例使用内嵌 LocalService 模式:每个 vLLM 进程从 MMC_LOCAL_CONFIG_PATH 加载 mmc-local.conf 并自行加入池,因此无需独立的 Memcache 进程。启动 vLLM 之前,请安装 memfabric-hybrid 和 memcache-hybrid,并准备下面的配置文件。详情请参考 Memcache 后端指南。所有 Prefill 和 Decode 节点必须使用相同的 MetaService 端点。
准备 Memcache 服务¶
在运行 MetaService 的节点上创建 mmc-meta.conf:
ock.mmc.meta_service_url = tcp://<META_SERVICE_IP>:5000
ock.mmc.meta_service.config_store_url = tcp://<META_SERVICE_IP>:6000
ock.mmc.meta_service.metrics_url = http://<META_SERVICE_IP>:8000
ock.mmc.log_level = info
在所有 Prefill 和 Decode 节点上为内嵌于 vLLM 的 LocalService
创建 mmc-local.conf:
ock.mmc.meta_service_url = tcp://<META_SERVICE_IP>:5000
ock.mmc.local_service.config_store_url = tcp://<META_SERVICE_IP>:6000
ock.mmc.log_level = info
ock.mmc.local_service.world_size = 256
ock.mmc.local_service.protocol = device_urma
ock.mmc.local_service.dram.size = 40GB
ock.mmc.local_service.max.dram.size = 2048GB
950DT 产品的 Device UB 使用 device_urma;若使用 UBOE,则替换为 device_uboe。world_size 是池支持的最大 LocalService 数量,而不是本示例使用的 NPU 数量;在 LocalService 连接后修改该值需要重启 MetaService。max.dram.size 必须不小于任一 LocalService 贡献的最大 dram.size。由于本示例使用内嵌 LocalService 模式,dram.size 必须大于 0GB,且不启动独立的 LocalService 进程。
使用 mmc-meta.conf 启动 MetaService:
export MMC_META_CONFIG_PATH="<MEMCACHE_CONFIG_DIR>/mmc-meta.conf"
python -c "from memcache_hybrid import MetaService; MetaService.main()"
下面的启动脚本会导出 PYTHONHASHSEED=0 和 MMC_LOCAL_CONFIG_PATH。所有引擎的 PYTHONHASHSEED=0 必须保持一致。MMC_LOCAL_CONFIG_PATH 指向 mmc-local.conf 的绝对路径,例如 /usr/local/python3.12.13/lib/python3.12/site-packages/memcache_hybrid/config/mmc-local.conf;请修改为实际环境中的路径。
准备 Prefill 启动脚本¶
在 Decode 节点上复用 5.2 节 中的 launch_online_dp.py。Prefill 引擎仍由 vllm serve 直接启动,并带上池所需的环境变量和 MultiConnector 配置。
-
在 Prefill 实例 1 的主节点上运行
run_p_node0.sh:#!/usr/bin/env bash # nic_name is the network interface that owns local_ip on the current node. nic_name="xxx" local_ip="xxx" # node0_ip must be the local_ip of the master node of this instance. node0_ip="xxxx" export HCCL_IF_IP=$local_ip export GLOO_SOCKET_IFNAME=$nic_name export TP_SOCKET_IFNAME=$nic_name export HCCL_SOCKET_IFNAME=$nic_name export HCCL_BUFFSIZE=1024 export OMP_PROC_BIND=false export OMP_NUM_THREADS=10 export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True export HCCL_OP_EXPANSION_MODE=CCU_SCHED export TASK_QUEUE_ENABLE=1 export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000 export HCCL_EXEC_TIMEOUT=2040 export HCCL_CONNECT_TIMEOUT=1200 export VLLM_USE_V2_MODEL_RUNNER=1 export VLLM_PP_LAYER_PARTITION="32,29" export VLLM_USE_FASTOKENS=1 export ASCEND_LOCAL_COMM_RES='{"version":"1.3"}' # Parameters required by the Memcache KV Cache Pool. Change the config # path to the actual path of mmc-local.conf in your environment. export PYTHONHASHSEED=0 export MMC_LOCAL_CONFIG_PATH=/usr/local/python3.12.13/lib/python3.12/site-packages/memcache_hybrid/config/mmc-local.conf vllm serve /root/.cache/DeepSeek-V4-Pro-0813 \ --host 0.0.0.0 \ --served-model-name dsv4 \ --port $1 \ --nnodes 2 \ --node-rank 0 \ --master-addr $node0_ip \ --tensor-parallel-size 1 \ --prefill-context-parallel-size 8 \ --data-parallel-size 1 \ --pipeline-parallel-size 2 \ --enable-expert-parallel \ --seed 1024 \ --max-model-len 1048576 \ --max-num-batched-tokens 8192 \ --max-num-seqs 16 \ --no-disable-hybrid-kv-cache-manager \ --model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \ --speculative-config '{"num_speculative_tokens":5,"method":"dspark","enforce_eager":true}' \ --trust-remote-code \ --block-size 32 \ --kv-cache-dtype fp8 \ --attention_config.indexer_kv_dtype fp8 \ --enable-prefix-caching \ --tokenizer-mode deepseek_v4 \ --tool-call-parser deepseek_v4 \ --enable-auto-tool-choice \ --reasoning-parser deepseek_v4 \ --gpu-memory-utilization 0.94 \ --enforce-eager \ --additional-config '{"enable_cpu_binding":true,"enable_fused_mc2":0,"multistream_overlap_shared_expert":true,"enable_shared_expert_dp":true}' \ --kv-transfer-config '{ "kv_connector":"MultiConnector", "kv_role":"kv_producer", "kv_port":"30000", "engine_id":"0", "kv_connector_extra_config":{ "connectors":[ { "kv_connector":"MooncakeConnectorV2", "kv_role":"kv_producer", "kv_port":"30000", "kv_connector_extra_config":{ "prefill":{"dp_size":1,"tp_size":1,"pp_size":2,"pp_layer_partition":"32,29"}, "decode":{"dp_size":32,"tp_size":1} } }, { "kv_connector":"AscendStoreConnector", "kv_role":"kv_producer", "kv_connector_extra_config":{ "backend":"memcache", "use_layerwise":true, "layerwise_prefetch_layers":3 } } ] } }' -
Prefill 实例 1 的 worker 节点上的
run_p_node1.sh:内容与run_p_node0.sh相同,但需做以下修改:将local_ip设置为本节点 IP,node0_ip保持为主节点的服务 IP,将--node-rank改为1,并在vllm serve后追加--headless,使该节点只运行其 PP 阶段而不启动 API server。 -
Prefill 实例 2:以相同方式准备
run_p_node2.sh(主节点)和run_p_node3.sh(worker 节点),但需做以下修改:将local_ip设置为各节点的 IP,将node0_ip设置为本实例自己的主节点 IP,并为外层MultiConnector及其MooncakeConnectorV2子连接器分配唯一的kv_port,例如"kv_port":"30200"。其余设置保持完全一致,以便两个 Prefill 实例向 Decode 池呈现相同的prefill拓扑。
准备 Decode 启动脚本¶
在每个 Decode 节点上准备 run_dp_template.sh。与第 5.2 节相比,仅 Memcache 环境变量和 --kv-transfer-config 发生变化;launch_online_dp.py 仍将可见设备、端口、DP 大小、DP rank、DP 地址、DP RPC 端口、TP 大小和 PCP 大小作为 $1 到 $8 传入。
#!/usr/bin/env bash
# nic_name is the network interface that owns local_ip on the current node.
nic_name="xxx"
local_ip="xxx"
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 HCCL_BUFFSIZE=2048
export ASCEND_RT_VISIBLE_DEVICES=$1
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export TASK_QUEUE_ENABLE=1
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export HCCL_EXEC_TIMEOUT=2040
export HCCL_CONNECT_TIMEOUT=1200
export VLLM_USE_V2_MODEL_RUNNER=1
export VLLM_USE_FASTOKENS=1
export ASCEND_LOCAL_COMM_RES='{"version":"1.3"}'
# Parameters required by the Memcache KV Cache Pool. Change the config
# path to the actual path of mmc-local.conf in your environment.
export PYTHONHASHSEED=0
export MMC_LOCAL_CONFIG_PATH=/usr/local/python3.12.13/lib/python3.12/site-packages/memcache_hybrid/config/mmc-local.conf
vllm serve /root/.cache/DeepSeek-V4-Pro-0813 \
--host 0.0.0.0 \
--served-model-name dsv4 \
--port $2 \
--data-parallel-size $3 \
--data-parallel-rank $4 \
--data-parallel-address $5 \
--data-parallel-rpc-port $6 \
--tensor-parallel-size $7 \
--enable-expert-parallel \
--seed 1024 \
--max-model-len 1048576 \
--max-num-batched-tokens 512 \
--max-num-seqs 32 \
--async-scheduling \
--block-size 32 \
--kv-cache-dtype fp8 \
--attention_config.indexer_kv_dtype fp8 \
--no-enable-prefix-caching \
--no-disable-hybrid-kv-cache-manager \
--model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \
--trust-remote-code \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--gpu-memory-utilization 0.92 \
--speculative-config '{"num_speculative_tokens":5,"method":"dspark","enforce_eager":false}' \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--kv-transfer-config '{
"kv_connector":"MultiConnector",
"kv_role":"kv_consumer",
"kv_port":"30100",
"engine_id":"1",
"kv_connector_extra_config":{
"connectors":[
{
"kv_connector":"MooncakeConnectorV2",
"kv_role":"kv_consumer",
"kv_port":"30100",
"kv_connector_extra_config":{
"prefill":{"dp_size":1,"tp_size":1,"pp_size":2,"pp_layer_partition":"32,29"},
"decode":{"dp_size":32,"tp_size":1}
}
},
{
"kv_connector":"AscendStoreConnector",
"kv_role":"kv_consumer",
"kv_connector_extra_config":{
"backend":"memcache"
}
}
]
}
}' \
--additional-config '{
"ascend_compilation_config":{"enable_npugraph_ex":true,"enable_static_kernel":false},
"enable_cpu_binding":true,
"multistream_overlap_shared_expert":true,
"scheduler_config":{"recompute_scheduler_enable":true},
"enable_shared_expert_dp":true,
"combine_quant_mode":4
}'
启动与验证¶
首先启动 Memcache MetaService,因为每个内嵌的 LocalService 都会在引擎启动期间连接到它。Prefill 和 Decode 之间没有强制的启动顺序;请等待所有引擎都报告 Application startup complete 后再部署代理。
-
在包含
mmc-meta.conf的节点上启动 MetaService。等待其日志显示 Meta Service 已启动。 -
Prefill 节点。对于每个 Prefill 实例,先启动主节点(
--node-rank 0),再启动其工作节点。第一个参数是传给--port $1的引擎端口。-
Prefill 实例 1,主节点:
-
Prefill 实例 1,工作节点(headless):
-
Prefill 实例 2,主节点:
-
Prefill 实例 2,工作节点(headless):
-
-
Decode 节点。在包含
launch_online_dp.py和run_dp_template.sh的目录中运行每个命令:-
Decode 节点 0
-
Decode 节点 1
-
Decode 节点 2
-
Decode 节点 3
-
-
部署 P-D 分离代理。请参考 Prefill-Decode 分离(Deepseek),并按照与第 5.2 节相同的方式注册上面启动的所有 Prefill 和 Decode 引擎端点。
部署验证:
PD 分离服务完全启动后,通过代理发送一个请求,以验证 Prefill 和 Decode 节点能正确协同工作。然后再次发送相同的请求以验证 KV Cache Pool:检查 Prefill 日志中的 Memcache 查找、get、put 和缓存命中活动,并确认 Decode 日志仍显示正常的 Prefill 到 Decode 的 KV 传输。仅凭 HTTP 200 响应并不能确认池复用。详情请参考 KV Cache Pool 指南。
A3 系列¶
此配置在第 5.2 节的 Atlas 800I A3 部署基础上增加了
Memcache KV Cache Pool。MooncakeConnectorV2 将 KV cache 从 Prefill 传输到
Decode,并支持 Prefill 上使用的流水线并行。
AscendStoreConnector 将可复用的 KV cache 存储到 Memcache 中。两个连接器
都配置为 MultiConnector 的子连接器。
在所有节点上使用官方 DeepSeek-V4-Pro-0813-w4a8 checkpoint。此示例
使用 MRv2 和 DSpark。Prefill 通过
use_layerwise: true 和 layerwise_prefetch_layers: 3 启用分层 Memcache 访问;Decode 使用
use_layerwise: false。
在启动 vLLM 之前,请按照
Memcache 后端指南
安装 memfabric-hybrid 和 memcache-hybrid,配置
mmc-meta.conf、mmc-local.conf 和 mmc-local-standalone.conf,并启动
Memcache MetaService。
Prefill 和 Decode 节点必须使用相同的 MetaService 端点。
此示例使用分离式 Memcache 部署,以便池在 vLLM 加载模型之前预留主机 内存。请按下文所述准备一份 MetaService 配置和 两份 LocalService 配置。
准备 Memcache 服务¶
在运行 MetaService 的节点上创建 mmc-meta.conf:
ock.mmc.log_level = info
ock.mmc.meta_service_url = tcp://<META_SERVICE_IP>:5000
ock.mmc.meta_service.config_store_url = tcp://<META_SERVICE_IP>:6000
ock.mmc.meta_service.metrics_url = http://<META_SERVICE_IP>:7000
ock.mmc.evict_threshold_high = 70
ock.mmc.evict_threshold_low = 60
在所有 Prefill 和 Decode 节点上为内嵌于 vLLM 的 LocalService
创建 mmc-local.conf:
ock.mmc.meta_service_url = tcp://<META_SERVICE_IP>:5000
ock.mmc.local_service.config_store_url = tcp://<META_SERVICE_IP>:6000
ock.mmc.log_level = info
ock.mmc.local_service.world_size = 256
ock.mmc.local_service.protocol = device_sdma
ock.mmc.local_service.dram.size = 0GB
ock.mmc.local_service.max.dram.size = 1024GB
ock.mmc.local_service.storage.enabled = false
在所有四个节点上为独立的 Memcache 进程创建 mmc-local-standalone.conf。
它使用相同的端点、world size 和协议,但贡献池所使用的
主机 DRAM:
ock.mmc.meta_service_url = tcp://<META_SERVICE_IP>:5000
ock.mmc.local_service.config_store_url = tcp://<META_SERVICE_IP>:6000
ock.mmc.log_level = info
ock.mmc.local_service.world_size = 256
ock.mmc.local_service.protocol = device_sdma
ock.mmc.local_service.dram.size = 120GB
ock.mmc.local_service.max.dram.size = 1024GB
ock.mmc.local_service.storage.enabled = true
ubsio.disk.path = <DISK_PATH>
ubsio.mem.size_in_gb = 600
ubsio.standalone.device_count = 1
ubsio.standalone.force_new_disk = true
world_size 是能够加入池的 LocalService 的最大数量,而不是
DP 大小。在 LocalService 连接后更改它需要重启
MetaService。对于 A3 HCCS,推荐使用 device_sdma,它需要灵衢
计算网络 1.5 或更高版本。max.dram.size 必须至少等于任何 LocalService
贡献的最大 dram.size。
每个节点运行一个使用 store.init(0) 初始化的独立 LocalService。
其 120GB DRAM 贡献是按节点计算的,而不是按 NPU 计算的。
ubsio.standalone.device_count = 1 与此单个启用 DRAM 的进程相匹配。
由 ubsio.mem.size_in_gb 配置的 600GB 是用于 UBS IO 的独立主机内存池,
而不是存储设备容量。请为这两项分配以及操作系统和 vLLM
预留主机内存。
<DISK_PATH> 是本示例中使用的缓存设备路径。将 ubsio.disk.path 设置为
每个节点上专用的、未挂载的缓存设备。当
ubsio.standalone.force_new_disk = true 时,UBS IO 会在启动时在指定的块设备上重建其缓存布局和
元数据,从而使现有
缓存失效。
MetaService 的驱逐水位线为 70(高)和 60(低)。
使用 mmc-meta.conf 启动 MetaService:
export MMC_META_CONFIG_PATH="<MEMCACHE_CONFIG_DIR>/mmc-meta.conf"
python3 -c 'from memcache_hybrid import MetaService; MetaService.main()'
将以下脚本保存为所有 Prefill 和
Decode 节点上的 memcache_standalone.py:
import time
from memcache_hybrid import DistributedObjectStore
store = DistributedObjectStore()
result = store.init(0)
if result != 0:
raise RuntimeError(f"Failed to initialize Memcache: {result}")
print("Successfully initialized Memcache")
while True:
time.sleep(1)
在 MetaService 日志显示 Meta Service launched successfully 后,在所有 Prefill 和 Decode 节点上启动独立的
Memcache 进程。等待每个进程打印
Successfully initialized Memcache,以确认独立
初始化成功:
export MMC_LOCAL_CONFIG_PATH="<MEMCACHE_CONFIG_DIR>/mmc-local-standalone.conf"
python3 memcache_standalone.py
有关更多参数和容量约束,请参考 Memcache 与 vLLM 分离部署。
复用 5.2 节中的 launch_online_dp.py。在所有节点上将 MEMCACHE_INSTALL_PATH 设置为
pip show memcache_hybrid 报告的 Location,并将
MEMCACHE_CONFIG_DIR 设置为包含上述配置文件的绝对目录。
启动带池化的 Prefill 节点¶
准备 Prefill 启动脚本。这里有一个 Prefill 实例,即一个跨 2 个节点部署的 PP2 引擎:主节点(--node-rank 0)启动引擎及其 API 服务器,而工作节点(--node-rank 1)通过 --headless 加入同一个引擎。--master-addr 必须指向主节点的服务 IP,以便工作节点能够加入跨节点进程组,并且两个节点必须使用相同的模型、TP、PP、PCP 和 VLLM_PP_LAYER_PARTITION 设置。--port $1 从脚本的第一个命令行参数获取引擎端口,例如 bash run_p_node0.sh 8000。将 MEMCACHE_INSTALL_PATH 设置为 pip show memcache_hybrid 报告的 Location,并将 MEMCACHE_CONFIG_DIR 设置为两个节点上包含上述配置文件的绝对目录。
-
在主节点上运行
run_p_node0.sh:#!/usr/bin/env bash MEMCACHE_INSTALL_PATH="<MEMCACHE_INSTALL_PATH>" MEMCACHE_CONFIG_DIR="<MEMCACHE_CONFIG_DIR>" # nic_name is the network interface that owns local_ip on the current node. nic_name="xxx" local_ip="xxx" # node0_ip must be the local_ip of the master node of this instance. node0_ip="xxxx" export HCCL_IF_IP="$local_ip" export GLOO_SOCKET_IFNAME="$nic_name" export TP_SOCKET_IFNAME="$nic_name" export HCCL_SOCKET_IFNAME="$nic_name" # Parameters required by the Memcache KV Cache Pool. export PYTHONHASHSEED=0 export ACL_OP_INIT_MODE=1 export LD_LIBRARY_PATH="$MEMCACHE_INSTALL_PATH/memcache_hybrid/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}:/usr/local/lib/" export MMC_LOCAL_CONFIG_PATH="$MEMCACHE_CONFIG_DIR/mmc-local.conf" export VLLM_USE_V2_MODEL_RUNNER=1 export HCCL_OP_EXPANSION_MODE="AIV" export HCCL_BUFFSIZE=1024 export HCCL_CONNECT_TIMEOUT=1200 export HCCL_EXEC_TIMEOUT=2040 export VLLM_RPC_TIMEOUT=3600000 export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000 export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True export VLLM_PP_LAYER_PARTITION="32,29" vllm serve /path/to/DeepSeek-V4-Pro-0813-w4a8 \ --tensor-parallel-size 2 \ --prefill-context-parallel-size 8 \ --host 0.0.0.0 \ --port $1 \ --nnodes 2 \ --node-rank 0 \ --master-addr $node0_ip \ --master-port 12321 \ --data-parallel-size 1 \ --pipeline-parallel-size 2 \ --decode-context-parallel-size 1 \ --served-model-name dsv4 \ --enable-expert-parallel \ --max-model-len 150000 \ --max-num-batched-tokens 4096 \ --max-num-seqs 16 \ --block-size 32 \ --gpu-memory-utilization 0.92 \ --enable-chunked-prefill \ --no-disable-hybrid-kv-cache-manager \ --enable-prefix-caching \ --enforce-eager \ --quantization ascend \ --tokenizer-mode deepseek_v4 \ --attention_config.indexer_kv_dtype int8 \ --tool-call-parser deepseek_v4 \ --enable-auto-tool-choice \ --reasoning-parser deepseek_v4 \ --trust-remote-code \ --seed 1024 \ --model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \ --speculative-config '{"method":"dspark","num_speculative_tokens":5,"enforce_eager":true}' \ --additional-config '{"enable_cpu_binding":true,"enable_flashcomm1":true,"enable_fused_mc2":1}' \ --kv-transfer-config \ '{ "kv_connector": "MultiConnector", "kv_role": "kv_producer", "kv_port": 30000, "kv_connector_extra_config": { "connectors": [ { "kv_connector": "MooncakeConnectorV2", "kv_role": "kv_producer", "kv_port": 30000, "kv_connector_extra_config": { "prefill": { "dp_size": 1, "tp_size": 2, "pp_size": 2, "pcp_size": 8 }, "decode": { "dp_size": 16, "tp_size": 2, "pp_size": 1, "pcp_size": 1 } } }, { "kv_connector": "AscendStoreConnector", "kv_role": "kv_producer", "kv_connector_extra_config": { "lookup_rpc_port": "0", "backend": "memcache", "use_layerwise": true, "layerwise_prefetch_layers": 3 } } ] } }' -
在工作节点上运行
run_p_node1.sh:内容与run_p_node0.sh相同,但需做以下修改:将local_ip设置为本节点的 IP,保持node0_ip为主节点的服务 IP,将--node-rank改为1,在vllm serve后追加--headless,使该节点只运行其 PP stage 而不启动 API server,并分配一个唯一的kv_port,例如"kv_port":"30200"。
在 Decode 引擎就绪后,在对应机器上的独立终端中先启动 Prefill 主节点,再启动其
工作节点。第一个参数是传递给 --port $1 的引擎端口:
-
Prefill 主节点
-
Prefill 工作节点:headless
启动带池化的 Decode 节点¶
在两个 Decode 节点上,将以下脚本保存为 run_dp_template.sh,放在与 launch_online_dp.py
相同的目录中。根据本地环境设置 local_ip、nic_name、
MEMCACHE_INSTALL_PATH 和 MEMCACHE_CONFIG_DIR。
MEMCACHE_INSTALL_PATH="<MEMCACHE_INSTALL_PATH>"
MEMCACHE_CONFIG_DIR="<MEMCACHE_CONFIG_DIR>"
local_ip="xx.xx.xx.x"
nic_name="xxxx" # NIC that owns 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 ASCEND_RT_VISIBLE_DEVICES="$1"
export SERVICE_PORT="$2"
export DP_SIZE="$3"
export DP_RANK="$4"
export DP_MASTER_IP="$5"
export DP_RPC_PORT="$6"
export TP_SIZE="$7"
export PCP_SIZE="$8"
# Parameters required by the Memcache KV Cache Pool.
export PYTHONHASHSEED=0
export ACL_OP_INIT_MODE=1
export LD_LIBRARY_PATH="$MEMCACHE_INSTALL_PATH/memcache_hybrid/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}:/usr/local/lib/"
export MMC_LOCAL_CONFIG_PATH="$MEMCACHE_CONFIG_DIR/mmc-local.conf"
export VLLM_USE_V2_MODEL_RUNNER=1
export HCCL_OP_EXPANSION_MODE="AIV"
export HCCL_BUFFSIZE=2200
export HCCL_CONNECT_TIMEOUT=1200
export HCCL_EXEC_TIMEOUT=2040
export VLLM_RPC_TIMEOUT=3600000
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=3000
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
vllm serve /path/to/DeepSeek-V4-Pro-0813-w4a8 \
--host 0.0.0.0 \
--port "$SERVICE_PORT" \
--data-parallel-address "$DP_MASTER_IP" \
--data-parallel-rpc-port "$DP_RPC_PORT" \
--data-parallel-size "$DP_SIZE" \
--data-parallel-rank "$DP_RANK" \
--tensor-parallel-size "$TP_SIZE" \
--prefill-context-parallel-size "$PCP_SIZE" \
--decode-context-parallel-size 1 \
--served-model-name dsv4 \
--enable-expert-parallel \
--max-model-len 150000 \
--max-num-batched-tokens 180 \
--max-num-seqs 30 \
--block-size 32 \
--gpu-memory-utilization 0.95 \
--enable-chunked-prefill \
--no-disable-hybrid-kv-cache-manager \
--no-enable-prefix-caching \
--async-scheduling \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}' \
--quantization ascend \
--tokenizer-mode deepseek_v4 \
--attention_config.indexer_kv_dtype int8 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--trust-remote-code \
--seed 1024 \
--model-loader-extra-config '{"enable_multithread_load":true,"num_threads":128}' \
--speculative-config '{"method":"dspark","num_speculative_tokens":5}' \
--additional-config '{"enable_cpu_binding":true,"ascend_compilation_config":{"enable_npugraph_ex":true,"enable_static_kernel":false},"multistream_overlap_shared_expert":true,"scheduler_config":{"recompute_scheduler_enable":true}}' \
--kv-transfer-config \
'{
"kv_connector": "MultiConnector",
"kv_role": "kv_consumer",
"kv_port": 30100,
"kv_connector_extra_config": {
"connectors": [
{
"kv_connector": "MooncakeConnectorV2",
"kv_role": "kv_consumer",
"kv_port": 30100,
"kv_connector_extra_config": {
"prefill": {
"dp_size": 1,
"tp_size": 2,
"pp_size": 2,
"pcp_size": 8
},
"decode": {
"dp_size": 16,
"tp_size": 2,
"pp_size": 1,
"pcp_size": 1
}
}
},
{
"kv_connector": "AscendStoreConnector",
"kv_role": "kv_consumer",
"kv_connector_extra_config": {
"lookup_rpc_port": "0",
"backend": "memcache",
"use_layerwise": false
}
}
]
}
}'
在对应机器上的独立终端中启动 Decode 引擎:
# Decode node 0
python launch_online_dp.py --dp-size 16 --tp-size 2 --pcp-size 1 --dp-size-local 8 --dp-rank-start 0 --dp-address xx.xx.xx.3 --dp-rpc-port 12321 --vllm-start-port 8000
# Decode node 1
python launch_online_dp.py --dp-size 16 --tp-size 2 --pcp-size 1 --dp-size-local 8 --dp-rank-start 8 --dp-address xx.xx.xx.3 --dp-rpc-port 12321 --vllm-start-port 8000
启动与验证¶
按以下顺序启动各组件:
- Memcache MetaService。
- 所有四个节点上的独立 Memcache 进程。等待初始化成功。
- Decode 引擎。等待每个引擎报告
Application startup complete。 - 两个 Prefill 节点。等待 Prefill 服务就绪。
- 参考 Prefill-Decode 分离(Deepseek) 部署 P-D 分离代理。
使用可复用的前缀发送两次相同的请求。确认 Prefill 日志 显示 Memcache 查找、获取、写入和命中活动,并且 Decode 日志仍然 显示正常的 Prefill 到 Decode 的 KV 传输。
关键池化参数:
MultiConnector将通过MooncakeConnectorV2的 Prefill 到 Decode 传输与通过AscendStoreConnector的 KV 复用相结合。两个子连接器在 Prefill 上使用生产者角色,在 Decode 上使用消费者角色。backend: "memcache"选择 Memcache KV Cache Pool 后端。所有节点使用相同的 MetaService 端点。- Prefill 使用
use_layerwise: true和layerwise_prefetch_layers: 3。Decode 保持use_layerwise: false。
有关 Memcache 配置、容量调优和故障排查,请参考 KV Cache Pool 指南。
Atlas A2系列产品¶
此配置在 5.2 节中的 Atlas 800I A2 部署基础上,增加了
基于 Mooncake 后端的 KV Cache Pool。MooncakeHybridConnector 将 KV 缓存
从 Prefill 传输到 Decode,并通过
enable_tiered_storage 和 hbm_to_ram_threshold_ratio 控制 HBM 到主机内存的分层。
AscendStoreConnector 使用
tiered_pooling_mode: "async_bypass" 将可复用的 KV 缓存存储在 Mooncake 池中。两个连接器都配置为
MultiConnector 的子连接器。
在所有节点上使用官方 DeepSeek-V4-Pro-0813-w4a8 检查点。此示例
使用 MRv2 和 DSpark,并设置 num_speculative_tokens: 7。与 A3 示例不同,
池运行在 Mooncake 后端上,并且两个角色都保持 use_layerwise: false。
准备 Mooncake 服务¶
按照 Mooncake 后端指南
安装 Mooncake 软件(mooncake >= 0.3.11)。在每个 Prefill 和 Decode 节点上创建 mooncake.json;
所有节点必须将 master_server_address 指向
同一个 master:
{
"metadata_server": "P2PHANDSHAKE",
"protocol": "ascend",
"device_name": "",
"master_server_address": "<MASTER_IP>:50099",
"global_segment_size": "24GB",
"preferred_segment": false,
"prefer_alloc_in_same_node": true
}
在主节点上启动 mooncake_master:
mooncake_master \
--port 50099 \
--default_kv_lease_ttl 11000 \
--eviction_high_watermark_ratio 0.9 \
--eviction_ratio 0.1
在每个 Prefill 和 Decode 节点上,将 MOONCAKE_CONFIG_PATH 设置为
mooncake.json 的完整路径。下面的池化启动脚本使用
MOONCAKE_CONFIG_DIR 来设置该路径。
复用 5.2 节中的 launch_online_dp.py。
启动带池化的 Prefill 节点¶
在四个 Prefill 节点上将以下脚本保存为 run_dp_template.sh(它们
共享同一个脚本)。为当前节点设置 local_ip 和 nic_name,并将
MOONCAKE_CONFIG_DIR 设置为包含 mooncake.json 的绝对目录:
MOONCAKE_CONFIG_DIR="<MOONCAKE_CONFIG_DIR>"
local_ip=xx.xx.xx.1/2/3/4 # change to your own ip
nic_name="xxxx" # change to your own nic name
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_RPC_TIMEOUT=3600000
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=30000
export HCCL_EXEC_TIMEOUT=204
export HCCL_INTRA_ROCE_ENABLE=1
export PYTHONHASHSEED=0
export ASCEND_CONNECT_TIMEOUT=16000
export ASCEND_TRANSFER_TIMEOUT=10000
export HCCL_RDMA_TIMEOUT=17
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export HCCL_BUFFSIZE=1024
export TASK_QUEUE_ENABLE=1
export HCCL_OP_EXPANSION_MODE="AIV"
export ASCEND_RT_VISIBLE_DEVICES=$1
export VLLM_USE_V2_MODEL_RUNNER=1
export MOONCAKE_CONFIG_PATH="$MOONCAKE_CONFIG_DIR/mooncake.json"
vllm serve /path/to/DeepSeek-V4-Pro-0813-w4a8 \
--host 0.0.0.0 \
--port $2 \
--data-parallel-size $3 \
--data-parallel-rank $4 \
--data-parallel-address $5 \
--data-parallel-rpc-port $6 \
--tensor-parallel-size $7 \
--enable-expert-parallel \
--seed 1024 \
--served-model-name dsv4 \
--max-model-len 150000 \
--max-num-batched-tokens 4096 \
--max-num-seqs 16 \
--no-disable-hybrid-kv-cache-manager \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--model-loader-extra-config '{"enable_multithread_load": true, "num_threads": 128}' \
--trust-remote-code \
--gpu-memory-utilization 0.92 \
--quantization ascend \
--block-size 32 \
--enforce-eager \
--speculative-config '{"num_speculative_tokens": 7, "method": "dspark","enforce_eager": true}' \
--additional-config '{"enable_cpu_binding": true, "enable_fused_mc2": 1, "enable_flashcomm1":true}' \
--kv-transfer-config \
'{"kv_connector": "MultiConnector",
"kv_role": "kv_producer",
"kv_port": "30000",
"kv_connector_extra_config": {
"connectors": [
{
"kv_connector": "MooncakeHybridConnector",
"kv_role": "kv_producer",
"kv_port": "30000",
"kv_connector_extra_config": {
"prefill": {
"dp_size": 4,
"tp_size": 8
},
"decode": {
"dp_size": 4,
"tp_size": 8
},
"enable_tiered_storage": true,
"hbm_to_ram_threshold_ratio": 0.85
}
},
{
"kv_connector": "AscendStoreConnector",
"kv_role": "kv_producer",
"kv_connector_extra_config": {
"lookup_rpc_port": "0",
"backend": "mooncake",
"use_layerwise": false,
"tiered_pooling_mode": "async_bypass"
}
}
]
}
}'
在对应机器上启动 Prefill 引擎:
# Prefill node 0
python launch_online_dp.py --dp-size 4 --tp-size 8 --dp-size-local 1 --dp-rank-start 0 --dp-address xx.xx.xx.1 --dp-rpc-port 12321 --vllm-start-port 8000
# Prefill node 1
python launch_online_dp.py --dp-size 4 --tp-size 8 --dp-size-local 1 --dp-rank-start 1 --dp-address xx.xx.xx.1 --dp-rpc-port 12321 --vllm-start-port 8000
# Prefill node 2
python launch_online_dp.py --dp-size 4 --tp-size 8 --dp-size-local 1 --dp-rank-start 2 --dp-address xx.xx.xx.1 --dp-rpc-port 12321 --vllm-start-port 8000
# Prefill node 3
python launch_online_dp.py --dp-size 4 --tp-size 8 --dp-size-local 1 --dp-rank-start 3 --dp-address xx.xx.xx.1 --dp-rpc-port 12321 --vllm-start-port 8000
启动带池化的 Decode 节点¶
在四个 Decode 节点上将以下脚本保存为 run_dp_template.sh。根据本地环境
设置 local_ip、nic_name 和 MOONCAKE_CONFIG_DIR:
MOONCAKE_CONFIG_DIR="<MOONCAKE_CONFIG_DIR>"
local_ip=xx.xx.xx.5/6/7/8 # change to your own ip
nic_name="xxxx" # change to your own nic name
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 HCCL_OP_EXPANSION_MODE="AIV"
export VLLM_RPC_TIMEOUT=3600000
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=30000
export HCCL_EXEC_TIMEOUT=204
export HCCL_INTRA_ROCE_ENABLE=1
export PYTHONHASHSEED=0
export ASCEND_CONNECT_TIMEOUT=16000
export ASCEND_TRANSFER_TIMEOUT=10000
export HCCL_RDMA_TIMEOUT=17
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export HCCL_BUFFSIZE=1024
export TASK_QUEUE_ENABLE=1
export ASCEND_RT_VISIBLE_DEVICES=$1
export VLLM_USE_V2_MODEL_RUNNER=1
export MOONCAKE_CONFIG_PATH="$MOONCAKE_CONFIG_DIR/mooncake.json"
export HCCL_HOST_SOCKET_PORT_RANGE=auto
export HCCL_NPU_SOCKET_PORT_RANGE=auto
vllm serve /path/to/DeepSeek-V4-Pro-0813-w4a8 \
--host 0.0.0.0 \
--port $2 \
--data-parallel-size $3 \
--data-parallel-rank $4 \
--data-parallel-address $5 \
--data-parallel-rpc-port $6 \
--tensor-parallel-size $7 \
--enable-expert-parallel \
--seed 1024 \
--served-model-name dsv4 \
--max-model-len 150000 \
--max-num-batched-tokens 256 \
--max-num-seqs 32 \
--async-scheduling \
--block-size 32 \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--no-disable-hybrid-kv-cache-manager \
--model-loader-extra-config '{"enable_multithread_load": true, "num_threads": 128}' \
--trust-remote-code \
--speculative-config '{"num_speculative_tokens": 7,"method": "dspark","enforce_eager": true}' \
--gpu-memory-utilization 0.92 \
--quantization ascend \
--compilation-config '{"cudagraph_mode": "FULL_DECODE_ONLY"}' \
--kv-transfer-config \
'{"kv_connector": "MultiConnector",
"kv_role": "kv_consumer",
"kv_port": "30100",
"kv_connector_extra_config": {
"connectors": [
{
"kv_connector": "MooncakeHybridConnector",
"kv_role": "kv_consumer",
"kv_port": "30100",
"kv_connector_extra_config": {
"prefill": {
"dp_size": 4,
"tp_size": 8
},
"decode": {
"dp_size": 4,
"tp_size": 8
},
"enable_tiered_storage": true,
"hbm_to_ram_threshold_ratio": 0.85
}
},
{
"kv_connector": "AscendStoreConnector",
"kv_role": "kv_consumer",
"kv_connector_extra_config": {
"lookup_rpc_port": "0",
"backend": "mooncake",
"use_layerwise": false,
"tiered_pooling_mode": "async_bypass"
}
}
]
}
}' \
--additional-config '{
"ascend_compilation_config":{
"enable_npugraph_ex":true,
"enable_static_kernel":false
},
"enable_cpu_binding":true,
"multistream_overlap_shared_expert":true,
"scheduler_config":{"recompute_scheduler_enable":true}
}'
在对应机器上启动 Decode 引擎:
# Decode node 0
python launch_online_dp.py --dp-size 4 --tp-size 8 --dp-size-local 1 --dp-rank-start 0 --dp-address xx.xx.xx.2 --dp-rpc-port 12321 --vllm-start-port 8000
# Decode node 1
python launch_online_dp.py --dp-size 4 --tp-size 8 --dp-size-local 1 --dp-rank-start 1 --dp-address xx.xx.xx.2 --dp-rpc-port 12321 --vllm-start-port 8000
# Decode node 2
python launch_online_dp.py --dp-size 4 --tp-size 8 --dp-size-local 1 --dp-rank-start 2 --dp-address xx.xx.xx.2 --dp-rpc-port 12321 --vllm-start-port 8000
# Decode node 3
python launch_online_dp.py --dp-size 4 --tp-size 8 --dp-size-local 1 --dp-rank-start 3 --dp-address xx.xx.xx.2 --dp-rpc-port 12321 --vllm-start-port 8000
启动与验证¶
按以下顺序启动各组件:
- 主节点上的
mooncake_master。在启动引擎之前,等待其监听<MASTER_IP>:50099。 - 四个 Prefill 节点上的 Prefill 引擎。
- 四个 Decode 节点上的 Decode 引擎。
- 参考 Prefill-Decode 分离(Deepseek) 部署 P-D 分离代理。
使用可复用的前缀发送两次相同的请求。确认 vLLM 日志中显示 Mooncake 池和分层存储活动,并且 Decode 日志仍显示正常的 Prefill 到 Decode 的 KV 传输。
关键池化参数:
MultiConnector通过MooncakeHybridConnector组合 Prefill 到 Decode 的传输,并通过AscendStoreConnector实现 KV 复用。两个子连接器在 Prefill 上使用生产者角色,在 Decode 上使用消费者角色。backend: "mooncake"选择 Mooncake KV Cache Pool 后端。所有 Prefill 和 Decode 节点必须将master_server_address指向同一个 master。enable_tiered_storage: true与hbm_to_ram_threshold_ratio: 0.85控制传输连接器上的 HBM 到主机内存分层。AscendStoreConnector使用tiered_pooling_mode: "async_bypass",并且两个角色都保持use_layerwise: false—— 这与 A3 示例不同,A3 示例在 Prefill 上启用了分层 Memcache 访问。
有关 Mooncake 配置、容量调优和故障排查,请参阅 KV Cache Pool 指南。
6 功能验证¶
服务器启动后,您可以使用输入提示查询模型:
将 <node0_ip>:<port> 替换为提供请求服务的节点的 IP 地址和端口:对于 5.1 节中的混合部署,使用暴露 API server 的主节点(Node0);对于 5.2 节中的 PD 分离部署,则改用代理节点,因为所有请求都通过代理路由到 Prefill 和 Decode 池。
curl http://<node0_ip>:<port>/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "dsv4",
"messages": [
{
"role": "user",
"content": "Who are you?"
}
],
"max_tokens": 256,
"temperature": 0
}'
预期结果:
服务返回HTTP 200 OK,并返回包含choices字段的JSON响应。
7 精度评估¶
7.1 使用 AISBench¶
-
详情请参考使用AISBench。
-
执行后,即可获取结果。
| 数据集 | 版本 | 指标 | 模式 | vllm-api-general-chat | 备注 |
|---|---|---|---|---|---|
| GPQA | - | accuracy | gen | 89.90 | 2 Atlas 800I A3 (128GB × 8) |
| GPQA | - | accuracy | gen | 92.93 | 8 Ascend 950DT nodes (96GB × 8) |
| GSM8K | - | accuracy | gen | 96.21 | 2 Atlas 800I A3 (128GB × 8) |
| GSM8K | - | accuracy | gen | 97.54 | 950PR&950DT products, w4a4c8 |
注意:由于采样和运行时非确定性,数据集评估结果在多次运行之间会有所波动。当对数据集进行多次评估时,报告的是平均分数。
8 性能评估¶
8.1 使用 AISBench¶
详情请参考使用 AISBench 进行性能评估。
8.2 使用 vLLM Benchmark¶
更多详情请参考 vllm benchmark。
9 性能调优¶
9.1 推荐配置¶
注意:以下配置基于 第 5 节的部署示例和特定测试环境。它们仅供参考,并非全局最优。特别是长上下文配置,它是针对约 1M token 输入的推荐起点,必须根据实际输入/输出长度、前缀缓存命中率、并发数、内存使用情况和部署环境进行验证。进一步的调优请参阅 9.2 节。
表 1:场景概览¶
*Total NPUs表示所有节点使用的 NPU 总数。
| 场景 | 部署模式 | *NPU 总数 | 权重版本 | 关键考量 |
|---|---|---|---|---|
| 短序列 / 高吞吐 | 1P1D 部署(2 个 Prefill + 2 个 Decode A3 节点) | 64 (A3) | DeepSeek-V4-Pro-0813-w4a8 | Prefill 使用 DP1/TP2/PP2/PCP8,16 个序列;Decode 使用 DP16/TP2/PP1/PCP1,30 个序列和 180 个批处理 token。在 Prefill 上启用 Fused MC2 以优先保证吞吐。 |
| 长上下文(约 1M 输入,参考) | 1P1D 部署(2 个 Prefill + 2 个 Decode A3 节点) | 64(A3) | DeepSeek-V4-Pro-0813-w4a8 | 对于此单独的长上下文参考配置,两侧均使用 DP2/TP16,将两侧序列数均减少到 2,并将 Decode 批处理 token 数减少到 16,以便为 1M token 上下文预留内存。 |
| 长上下文(约 1M 输入) | 2P1D 部署(4 个 Prefill + 4 个 Decode Ascend 950DT 节点;每个 Prefill 实例跨 2 个节点) | 64 (Ascend 950DT) | DeepSeek-V4-Pro-0813 | 运行 2 个 Prefill 实例,每个实例为 DP1/TP1/PP2 引擎,跨 2 个节点使用 prefill 上下文并行(PCP8),以及一个 DP32/TP1 的 Decode 池。 |
表 2:详细节点配置¶
| 场景 | 配置 | NPU 数量 | TP | DP | 最大序列数 | 最大批处理 token 数 | 最大模型长度 | DSpark 推测数 | Fused MC2 | EP 开关 | FC | DSA-CP (MRv1) / PCP (MRv2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Short Sequence / High Throughput | Prefill Pool | 32 (2 A3 nodes) | 2 | 1 | 16 | 4096 | 150000 | 5 | On | On | On | PCP=8 |
| Short Sequence / High Throughput | Decode Pool | 32 (2 A3 nodes) | 2 | 16 | 30 | 180 | 150000 | 5 | Off | On | Off | PCP=1 |
| Long Context (~1M Input, Reference) | Prefill Pool | 32 (2 A3 nodes) | 16 | 2 | 2 | 4096 | 1048576 | 5 | Off | On | On | PCP=1 |
| Long Context (~1M Input, Reference) | Decode Pool | 32 (2 A3 nodes) | 16 | 2 | 2 | 16 | 1048576 | 5 | Off | On | Off | PCP=1 |
| Long Context (~1M Input) | Prefill Pool | 32 (4 950DT nodes, 2 instances) | 1 | 1 | 16 | 8192 | 1048576 | 5 | Off | Off | Off | PCP=8 |
| Long Context (~1M Input) | Decode Pool | 32 (4 950DT nodes) | 1 | 32 | 32 | 512 | 1048576 | 5 | Off | Off | Off | PCP=1 |
FC表示 FlashComm1。
DSA-CP (MRv1) / PCP (MRv2)根据 model runner 版本描述上下文并行:MRv1 使用enable_dsa_cp开关,而 MRv2 使用--prefill-context-parallel-size指定 PCP 大小。PCP=8表示八路上下文并行;PCP=1表示无上下文并行。对于长上下文 Prefill 参考配置,启用 FlashComm1 并禁用上下文并行(MRv1 上设置enable_dsa_cp: false,或 MRv2 上 PCP 大小为1)。950DT 系列产品的长上下文示例运行在 V2 model runner 上,并在 Prefill 上使用PCP=8;enable_dsa_cp与 PCP 互斥,因此在该场景下必须保持关闭。长上下文参考配置中禁用了 Fused MC2,因为它会增加内存使用量。如果内存充足且优先考虑更高性能,建议在 Prefill 上启用 Fused MC2。
--max-model-len 1048576是 prompt 和生成 token 的总上下文预算,而不是在 1M token prompt 之上额外的输出预算。如果内存不足,请减少--max-num-seqs或实际输入长度。完整的启动命令和参数说明,请参阅第 5 章中的部署示例。
9.2 调优指南¶
9.2.1 通用调优参考¶
调优方法请参考优化与调优。
请参阅特性矩阵获取详细的特性描述。
10 常见问题¶
对于常见的环境、安装和一般参数问题,请参考公共FAQ;本章仅涵盖模型特定问题。
问:W4A4C8 超低位宽量化权重如何保持精度?¶
答:对于 Ascend 950PR&950DT系列产品,DeepSeek-V4-Pro-0813 的 W4A4C8 权重使用 msmodelslim 进行量化。为了在如此低的位宽下保持精度,采用了混合精度策略:仅将参数数量占主导的模块量化为 4 bit,而对精度敏感的模块回退到更高精度或完全不量化。
| 模块 | 量化配置 |
|---|---|
| MoE FFN 路由专家 | W4A4 MXFP4 |
| Attention 线性层 | W8A8 MXFP8 |
| FFN 共享专家 | W8A8 MXFP8 |
Router 门控、compressor 投影(wgate/wkv)、indexer 投影以及 MTP 层 |
不量化(保持高精度) |
- 量化算法:权重和激活值采用 MXFP4/MXFP8 微缩放格式。每个张量被划分为 32 个元素的块,每个块共享一个缩放因子,该因子通过在混合校准数据集上进行对称 min-max 校准获得。分块缩放能够适应每个张量的局部动态范围,因此量化误差远低于均匀 INT4 量化。
- C8(FP8 KV cache):C8 是在推理过程中对 KV cache 应用的动态量化。在 Ascend 950PR&950DT系列产品 上,KV cache 被量化为 FP8(而非 INT8)。它与权重 checkpoint 中存储的参数无关,仅由服务配置控制。DeepSeek-V4-Flash 和 DeepSeek-V4-Pro 共享完全相同的 C8 方案:
- Attention KV cache(在 Ascend 950PR&950DT系列产品 上默认使用 FP8;可通过
--kv-cache-dtype bfloat16切换回 BF16):作为 K 和 V 的压缩 KV latent,按 64 元素 tile 动态量化为 FP8(E4M3),每个 tile 共享一个 E8M0 缩放因子;KV cache 的 RoPE 部分保持 BF16,Q 不进行量化。 - Indexer cache(通过
--attention_config.indexer_kv_dtype fp8启用):indexer 的 Q 和 K 首先通过 Hadamard 矩阵旋转以分散离群值,然后按 token 动态量化为 FP8(E4M3),每个 token 使用 FP32 缩放因子。
- Attention KV cache(在 Ascend 950PR&950DT系列产品 上默认使用 FP8;可通过
关于 W4A4C8 精度得分,请参阅精度评估。