|
| 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 | +function run_prefill_instance() { |
| 21 | + local model_name=$1 |
| 22 | + local tp_size=$2 |
| 23 | + local prefill_port=$3 |
| 24 | + local register_port=$4 |
| 25 | + local prefill_device_ips=$5 |
| 26 | + local decode_device_ips=$6 |
| 27 | + |
| 28 | + echo "================================" |
| 29 | + echo "Testing model: $model_name" |
| 30 | + echo "================================" |
| 31 | + # Start prefill instance |
| 32 | + |
| 33 | + KV_CONFIG=$(jq -n \ |
| 34 | + --arg kv_connector "AscendSimpleConnector" \ |
| 35 | + --arg kv_buffer_device "npu" \ |
| 36 | + --arg kv_role "kv_producer" \ |
| 37 | + --argjson kv_parallel_size 8 \ |
| 38 | + --arg kv_port 11001 \ |
| 39 | + --argjson prefill_device_ips "$prefill_device_ips" \ |
| 40 | + --argjson decode_device_ips "$decode_device_ips" \ |
| 41 | + --argjson llmdatadist_comm_port 26000 \ |
| 42 | + --arg proxy_ip "0.0.0.0" \ |
| 43 | + --argjson proxy_port "$register_port" \ |
| 44 | + --argjson http_port "$prefill_port" \ |
| 45 | + '{ |
| 46 | + "kv_connector": $kv_connector, |
| 47 | + "kv_buffer_device": $kv_buffer_device, |
| 48 | + "kv_role": $kv_role, |
| 49 | + "kv_parallel_size": $kv_parallel_size, |
| 50 | + "kv_port": $kv_port, |
| 51 | + "kv_connector_extra_config": { |
| 52 | + "prefill_device_ips": $prefill_device_ips, |
| 53 | + "decode_device_ips": $decode_device_ips, |
| 54 | + "llmdatadist_comm_port": $llmdatadist_comm_port, |
| 55 | + "proxy_ip": $proxy_ip, |
| 56 | + "proxy_port": $proxy_port, |
| 57 | + "http_port": $http_port |
| 58 | + } |
| 59 | + }') |
| 60 | + |
| 61 | + # start prefill instance |
| 62 | + ASCEND_RT_VISIBLE_DEVICES=0 vllm serve $model_name \ |
| 63 | + --host 0.0.0.0 \ |
| 64 | + --port $prefill_port \ |
| 65 | + --tensor-parallel-size $tp_size \ |
| 66 | + --served-model-name Deepseek \ |
| 67 | + --max-model-len 2000 \ |
| 68 | + --trust-remote-code \ |
| 69 | + --kv-transfer-config "$KV_CONFIG" & |
| 70 | +} |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +function run_decode_instance() { |
| 75 | + # Start decode instance |
| 76 | + local model_name=$1 |
| 77 | + local tp_size=$2 |
| 78 | + local decode_port=$3 |
| 79 | + local register_port=$4 |
| 80 | + local prefill_device_ips=$5 |
| 81 | + local decode_device_ips=$6 |
| 82 | + |
| 83 | + KV_CONFIG=$(jq -n \ |
| 84 | + --arg kv_connector "AscendSimpleConnector" \ |
| 85 | + --arg kv_buffer_device "npu" \ |
| 86 | + --arg kv_role "kv_consumer" \ |
| 87 | + --argjson kv_parallel_size 8 \ |
| 88 | + --arg kv_port 21001 \ |
| 89 | + --argjson prefill_device_ips "$prefill_device_ips" \ |
| 90 | + --argjson decode_device_ips "$decode_device_ips" \ |
| 91 | + --argjson llmdatadist_comm_port 26000 \ |
| 92 | + --arg proxy_ip "0.0.0.0" \ |
| 93 | + --argjson proxy_port "$register_port" \ |
| 94 | + --argjson http_port "$decode_port" \ |
| 95 | + '{ |
| 96 | + "kv_connector": $kv_connector, |
| 97 | + "kv_buffer_device": $kv_buffer_device, |
| 98 | + "kv_role": $kv_role, |
| 99 | + "kv_parallel_size": $kv_parallel_size, |
| 100 | + "kv_port": $kv_port, |
| 101 | + "kv_connector_extra_config": { |
| 102 | + "prefill_device_ips": $prefill_device_ips, |
| 103 | + "decode_device_ips": $decode_device_ips, |
| 104 | + "llmdatadist_comm_port": $llmdatadist_comm_port, |
| 105 | + "proxy_ip": $proxy_ip, |
| 106 | + "proxy_port": $proxy_port, |
| 107 | + "http_port": $http_port |
| 108 | + } |
| 109 | + }') |
| 110 | + |
| 111 | + # start decode instance |
| 112 | + ASCEND_RT_VISIBLE_DEVICES=1 vllm serve $model_name \ |
| 113 | + --host 0.0.0.0 \ |
| 114 | + --port $decode_port \ |
| 115 | + --tensor-parallel-size $tp_size \ |
| 116 | + --seed 1024 \ |
| 117 | + --served-model-name Deepseek \ |
| 118 | + --max-model-len 2000 \ |
| 119 | + --max-num-batched-tokens 2000 \ |
| 120 | + --trust-remote-code \ |
| 121 | + --gpu-memory-utilization 0.9 \ |
| 122 | + --kv-transfer-config "$KV_CONFIG" & |
| 123 | +} |
| 124 | + |
| 125 | +function run_proxy_server() { |
| 126 | + # Build the command for the proxy server with all the hosts and ports |
| 127 | + register_port=$1 |
| 128 | + proxy_port=$2 |
| 129 | + PROXY_CMD="python examples/disaggregated_prefill/p2p_disaggrefated_prefill_proxy.py --http-port $proxy_port --register-port $register_port" |
| 130 | + |
| 131 | + # Start the proxy server |
| 132 | + echo "Starting proxy server with command: $PROXY_CMD" |
| 133 | + $PROXY_CMD & |
| 134 | +} |
0 commit comments