Prefill-Decode 解耦 Llmdatadist 验证(Qwen2.5-VL)

Prefill-Decode 解耦 Llmdatadist 验证(Qwen2.5-VL)#

开始使用#

vLLM-Ascend 现已支持 Prefill-Decode(PD)解耦。本指南将以资源受限的场景为例,逐步介绍如何验证该功能。

以 Qwen2.5-VL-7B-Instruct 模型为例,在 1 台 Atlas 800T A2 服务器上,使用 vllm-ascend v0.11.0rc1(对应 vLLM v0.11.0)部署 “1P1D” 架构。假设服务器 IP 地址为 192.0.0.1。

验证通信环境#

验证流程#

  1. 单节点验证:

请按顺序执行以下命令,所有结果必须为 success,且状态必须为 UP

# Check the remote switch ports
for i in {0..7}; do hccn_tool -i $i -lldp -g | grep Ifname; done
# Get the link status of the Ethernet ports (UP or DOWN)
for i in {0..7}; do hccn_tool -i $i -link -g ; done
# Check the network health status
for i in {0..7}; do hccn_tool -i $i -net_health -g ; done
# View the network detected IP configuration
for i in {0..7}; do hccn_tool -i $i -netdetect -g ; done
# View gateway configuration
for i in {0..7}; do hccn_tool -i $i -gateway -g ; done
# View NPU network configuration
cat /etc/hccn.conf
  1. 获取 NPU IP 地址

for i in {0..7}; do hccn_tool -i $i -ip -g;done

生成 Ranktable#

Ranktable 是一个 JSON 文件,用于指定 Ascend NPU rank 与节点之间的映射关系。更多细节请参考 vllm-ascend 示例。以下命令仅供参考。

cd vllm-ascend/examples/disaggregate_prefill_v1/
bash gen_ranktable.sh --ips 192.0.0.1 \
  --npus-per-node  2 --network-card-name eth0 --prefill-device-cnt 1 --decode-device-cnt 1

如果需要运行 “2P1D”,请将 npus-per-node 设置为 3,并将 prefill-device-cnt 设置为 2。生成的 ranktable 文件位于 /vllm-workspace/vllm-ascend/examples/disaggregate_prefill_v1/ranktable.json。

参数

含义

--ips

每个节点的本地 IP 地址(Prefiller 节点需排在 Decoder 节点之前)

--npus-per-node

每个节点的 NPU 卡数量

--network-card-name

物理机使用的网卡名称

--prefill-device-cnt

用于 Prefill 的 NPU 卡数量

--decode-device-cnt

用于 Decode 的 NPU 卡数量

Prefiller / Decoder 部署#

我们可以分别在 Prefiller NPU 和 Decoder NPU 上运行以下脚本以启动服务。

export ASCEND_RT_VISIBLE_DEVICES=0
export HCCL_IF_IP=192.0.0.1 # node ip
export GLOO_SOCKET_IFNAME="eth0"  # network card name
export TP_SOCKET_IFNAME="eth0"
export HCCL_SOCKET_IFNAME="eth0"
export DISAGGREGATED_PREFILL_RANK_TABLE_PATH="/path/to/your/generated/ranktable.json"
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export VLLM_ASCEND_LLMDD_RPC_PORT=5959

vllm serve /model/Qwen2.5-VL-7B-Instruct  \
  --host 0.0.0.0 \
  --port 13700 \
  --tensor-parallel-size 1 \
  --no-enable-prefix-caching \
  --seed 1024 \
  --served-model-name qwen25vl \
  --max-model-len 40000  \
  --max-num-batched-tokens 40000  \
  --trust-remote-code \
  --gpu-memory-utilization 0.9  \
  --kv-transfer-config  \
  '{"kv_connector": "LLMDataDistCMgrConnector",
    "kv_buffer_device": "npu",
    "kv_role": "kv_producer",
    "kv_parallel_size": 1,
    "kv_port": "20001",
    "engine_id": "0",
    "kv_connector_module_path": "vllm_ascend.distributed.llmdatadist_c_mgr_connector"
  }'
export ASCEND_RT_VISIBLE_DEVICES=1
export HCCL_IF_IP=192.0.0.1  # node ip
export GLOO_SOCKET_IFNAME="eth0"  # network card name
export TP_SOCKET_IFNAME="eth0"
export HCCL_SOCKET_IFNAME="eth0"
export DISAGGREGATED_PREFILL_RANK_TABLE_PATH="/path/to/your/generated/ranktable.json"
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=10
export VLLM_ASCEND_LLMDD_RPC_PORT=5979

vllm serve /model/Qwen2.5-VL-7B-Instruct  \
  --host 0.0.0.0 \
  --port 13701 \
  --no-enable-prefix-caching \
  --tensor-parallel-size 1 \
  --seed 1024 \
  --served-model-name qwen25vl \
  --max-model-len 40000  \
  --max-num-batched-tokens 40000  \
  --trust-remote-code \
  --gpu-memory-utilization 0.9  \
  --kv-transfer-config  \
  '{"kv_connector": "LLMDataDistCMgrConnector",
  "kv_buffer_device": "npu",
  "kv_role": "kv_consumer",
  "kv_parallel_size": 1,
  "kv_port": "20001",
  "engine_id": "0",
  "kv_connector_module_path": "vllm_ascend.distributed.llmdatadist_c_mgr_connector"
  }'

如果需要运行 “2P1D”,请为每个 Prefill 进程分别设置不同的 ASCEND_RT_VISIBLE_DEVICES、VLLM_ASCEND_LLMDD_RPC_PORT 以及 port。

部署代理示例#

在与 Prefiller 服务实例相同的节点上运行一个代理服务器。代理程序可在仓库示例中获取:load_balance_proxy_server_example.py

python load_balance_proxy_server_example.py \
    --host 192.0.0.1 \
    --port 8080 \
    --prefiller-hosts 192.0.0.1 \
    --prefiller-port 13700 \
    --decoder-hosts 192.0.0.1 \
    --decoder-ports 13701

参数

含义

--port

代理服务端口

--prefiller-port

所有 Prefill 服务端口

--decoder-ports

所有 Decoder 服务端口

验证#

通过代理服务器提供的接口检查服务健康状态。

curl http://192.0.0.1:8080/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "qwen25vl",
        "messages": [
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": [
                {"type": "image_url", "image_url": {"url": "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/qwen.png"}},
                {"type": "text", "text": "What is the text in the illustrate?"}
            ]}
            ],
        "max_tokens": 100,
        "temperature": 0
    }'