|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# This file is a part of the vllm-ascend project. |
| 18 | +# |
| 19 | + |
| 20 | + |
| 21 | +function cleanup_instances() { |
| 22 | + VLLM_PID=$(pgrep -f "vllm serve") |
| 23 | + _info "===> Try kill -2 ${VLLM_PID} to exit." |
| 24 | + kill -2 "$VLLM_PID" |
| 25 | + wait_for_exit "$VLLM_PID" |
| 26 | +} |
| 27 | + |
| 28 | + |
| 29 | +function run_prefill_instance() { |
| 30 | + local model_name=$1 |
| 31 | + local tp_size=$2 |
| 32 | + local prefill_port=$3 |
| 33 | + local register_port=$4 |
| 34 | + local prefill_device_ips=$5 |
| 35 | + local decode_device_ips=$6 |
| 36 | + |
| 37 | + echo "================================" |
| 38 | + echo "Testing model: $model_name" |
| 39 | + echo "================================" |
| 40 | + # Start prefill instance |
| 41 | + |
| 42 | + KV_CONFIG=$(jq -n \ |
| 43 | + --arg kv_connector "AscendSimpleConnector" \ |
| 44 | + --arg kv_buffer_device "npu" \ |
| 45 | + --arg kv_role "kv_producer" \ |
| 46 | + --argjson kv_parallel_size 8 \ |
| 47 | + --arg kv_port "11001" \ |
| 48 | + --argjson prefill_device_ips "$prefill_device_ips" \ |
| 49 | + --argjson decode_device_ips "$decode_device_ips" \ |
| 50 | + --argjson llmdatadist_comm_port "26000" \ |
| 51 | + --arg proxy_ip "0.0.0.0" \ |
| 52 | + --argjson proxy_port "$register_port" \ |
| 53 | + --argjson http_port "$prefill_port" \ |
| 54 | + '{ |
| 55 | + "kv_connector": $kv_connector, |
| 56 | + "kv_buffer_device": $kv_buffer_device, |
| 57 | + "kv_role": $kv_role, |
| 58 | + "kv_parallel_size": $kv_parallel_size, |
| 59 | + "kv_port": $kv_port, |
| 60 | + "kv_connector_extra_config": { |
| 61 | + "prefill_device_ips": $prefill_device_ips, |
| 62 | + "decode_device_ips": $decode_device_ips, |
| 63 | + "llmdatadist_comm_port": $llmdatadist_comm_port, |
| 64 | + "proxy_ip": $proxy_ip, |
| 65 | + "proxy_port": $proxy_port, |
| 66 | + "http_port": $http_port |
| 67 | + } |
| 68 | + }') |
| 69 | + |
| 70 | + # start prefill instance |
| 71 | + ASCEND_RT_VISIBLE_DEVICES=0 vllm serve $model_name \ |
| 72 | + --host 0.0.0.0 \ |
| 73 | + --port $prefill_port \ |
| 74 | + --tensor-parallel-size $tp_size \ |
| 75 | + --served-model-name Deepseek \ |
| 76 | + --max-model-len 2000 \ |
| 77 | + --trust-remote-code \ |
| 78 | + --kv-transfer-config "$KV_CONFIG" & |
| 79 | +} |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | +function run_decode_instance() { |
| 84 | + # Start decode instance |
| 85 | + local model_name=$1 |
| 86 | + local tp_size=$2 |
| 87 | + local decode_port=$3 |
| 88 | + local register_port=$4 |
| 89 | + local prefill_device_ips=$5 |
| 90 | + local decode_device_ips=$6 |
| 91 | + |
| 92 | + KV_CONFIG=$(jq -n \ |
| 93 | + --arg kv_connector "AscendSimpleConnector" \ |
| 94 | + --arg kv_buffer_device "npu" \ |
| 95 | + --arg kv_role "kv_consumer" \ |
| 96 | + --argjson kv_parallel_size 8 \ |
| 97 | + --arg kv_port "21001" \ |
| 98 | + --argjson prefill_device_ips "$prefill_device_ips" \ |
| 99 | + --argjson decode_device_ips "$decode_device_ips" \ |
| 100 | + --argjson llmdatadist_comm_port "26000" \ |
| 101 | + --arg proxy_ip "0.0.0.0" \ |
| 102 | + --argjson proxy_port "$register_port" \ |
| 103 | + --argjson http_port "$decode_port" \ |
| 104 | + '{ |
| 105 | + "kv_connector": $kv_connector, |
| 106 | + "kv_buffer_device": $kv_buffer_device, |
| 107 | + "kv_role": $kv_role, |
| 108 | + "kv_parallel_size": $kv_parallel_size, |
| 109 | + "kv_port": $kv_port, |
| 110 | + "kv_connector_extra_config": { |
| 111 | + "prefill_device_ips": $prefill_device_ips, |
| 112 | + "decode_device_ips": $decode_device_ips, |
| 113 | + "llmdatadist_comm_port": $llmdatadist_comm_port, |
| 114 | + "proxy_ip": $proxy_ip, |
| 115 | + "proxy_port": $proxy_port, |
| 116 | + "http_port": $http_port |
| 117 | + } |
| 118 | + }') |
| 119 | + |
| 120 | + # start decode instance |
| 121 | + ASCEND_RT_VISIBLE_DEVICES=1 vllm serve $model_name \ |
| 122 | + --host 0.0.0.0 \ |
| 123 | + --port $decode_port \ |
| 124 | + --tensor-parallel-size $tp_size \ |
| 125 | + --seed 1024 \ |
| 126 | + --served-model-name Deepseek \ |
| 127 | + --max-model-len 2000 \ |
| 128 | + --max-num-batched-tokens 2000 \ |
| 129 | + --trust-remote-code \ |
| 130 | + --gpu-memory-utilization 0.9 \ |
| 131 | + --kv-transfer-config "$KV_CONFIG" & |
| 132 | +} |
| 133 | + |
| 134 | +function run_proxy_server() { |
| 135 | + # Build the command for the proxy server with all the hosts and ports |
| 136 | + register_port=$1 |
| 137 | + proxy_port=$2 |
| 138 | + PROXY_CMD="python examples/disaggregated_prefill/p2p_disaggrefated_prefill_proxy.py --http-port $proxy_port --register-port $register_port" |
| 139 | + |
| 140 | + # Start the proxy server |
| 141 | + echo "Starting proxy server with command: $PROXY_CMD" |
| 142 | + $PROXY_CMD & |
| 143 | + |
| 144 | + # Wait for the proxy to start |
| 145 | + sleep 3 |
| 146 | +} |
0 commit comments