|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# Test splitwise deployment |
| 5 | +# v0 requires prefill and decode in one node and it uses local scheduler |
| 6 | +# v1 supports prefill and decode in multi node and it uses splitwise scheduler |
| 7 | +# v2 supports prefill and decode in multi node and it uses router and local scheduler |
| 8 | + |
| 9 | +wait_for_health() { |
| 10 | + local server_port=$1 |
| 11 | + while true; do |
| 12 | + status_code=$(curl -s -o /dev/null -w "%{http_code}" "http://0.0.0.0:${server_port}/health" || echo "000") |
| 13 | + if [ "$status_code" -eq 200 ]; then |
| 14 | + break |
| 15 | + else |
| 16 | + echo "Service not ready. Retrying in 2s..." |
| 17 | + sleep 2 |
| 18 | + fi |
| 19 | + done |
| 20 | +} |
| 21 | + |
| 22 | +# prepare environment |
| 23 | +MODEL_NAME="PaddlePaddle/ERNIE-4.5-0.3B-Paddle" |
| 24 | +# MODEL_NAME="baidu/ERNIE-4.5-21B-A3B-Paddle" |
| 25 | + |
| 26 | +export FD_DEBUG=1 |
| 27 | +export ENABLE_V1_KVCACHE_SCHEDULER=0 |
| 28 | +export KVCACHE_GDRCOPY_FLUSH_ENABLE=1 |
| 29 | + |
| 30 | +SCRIPT_PATH=$(readlink -f "$0") |
| 31 | +SCRIPT_DIR=$(dirname "$SCRIPT_PATH") |
| 32 | +export $(bash ${SCRIPT_DIR}/../../scripts/get_rdma_nics.sh gpu) |
| 33 | +echo "KVCACHE_RDMA_NICS:${KVCACHE_RDMA_NICS}" |
| 34 | +if [ -z "${KVCACHE_RDMA_NICS}" ]; then |
| 35 | + echo "KVCACHE_RDMA_NICS is empty, please check the output of get_rdma_nics.sh" |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | + |
| 39 | +unset http_proxy && unset https_proxy |
| 40 | +rm -rf log_* |
| 41 | + |
| 42 | +# start redis |
| 43 | +if ! redis-cli ping &>/dev/null; then |
| 44 | + echo "Redis is not running. Starting redis-server..." |
| 45 | + redis-server --daemonize yes |
| 46 | + sleep 1 |
| 47 | +else |
| 48 | + echo "Redis is already running." |
| 49 | +fi |
| 50 | +sleep 1 |
| 51 | + |
| 52 | +# start prefill |
| 53 | +export CUDA_VISIBLE_DEVICES=0 |
| 54 | +export FD_LOG_DIR="log_prefill" |
| 55 | +mkdir -p ${FD_LOG_DIR} |
| 56 | + |
| 57 | +nohup python -m fastdeploy.entrypoints.openai.api_server \ |
| 58 | + --model ${MODEL_NAME} \ |
| 59 | + --port 8100 \ |
| 60 | + --metrics-port 8101 \ |
| 61 | + --engine-worker-queue-port 8102 \ |
| 62 | + --cache-queue-port 8103 \ |
| 63 | + --max-model-len 32768 \ |
| 64 | + --splitwise-role "prefill" \ |
| 65 | + --cache-transfer-protocol "rdma,ipc" \ |
| 66 | + --rdma-comm-ports 8104 \ |
| 67 | + --pd-comm-port 8105 \ |
| 68 | + --scheduler-name "splitwise" \ |
| 69 | + --scheduler-host "127.0.0.1" \ |
| 70 | + --scheduler-port 6379 \ |
| 71 | + --scheduler-ttl 9000 \ |
| 72 | + 2>&1 >${FD_LOG_DIR}/nohup & |
| 73 | +wait_for_health 8100 |
| 74 | + |
| 75 | +# start decode |
| 76 | +export CUDA_VISIBLE_DEVICES=1 |
| 77 | +export FD_LOG_DIR="log_decode" |
| 78 | +mkdir -p ${FD_LOG_DIR} |
| 79 | + |
| 80 | +nohup python -m fastdeploy.entrypoints.openai.api_server \ |
| 81 | + --model ${MODEL_NAME} \ |
| 82 | + --port 9000 \ |
| 83 | + --metrics-port 9001 \ |
| 84 | + --engine-worker-queue-port 9002 \ |
| 85 | + --cache-queue-port 9003 \ |
| 86 | + --max-model-len 32768 \ |
| 87 | + --splitwise-role "decode" \ |
| 88 | + --cache-transfer-protocol "rdma,ipc" \ |
| 89 | + --rdma-comm-ports 9004 \ |
| 90 | + --pd-comm-port 9005 \ |
| 91 | + --scheduler-name "splitwise" \ |
| 92 | + --scheduler-host "127.0.0.1" \ |
| 93 | + --scheduler-port 6379 \ |
| 94 | + --scheduler-ttl 9000 \ |
| 95 | + 2>&1 >${FD_LOG_DIR}/nohup & |
| 96 | +wait_for_health 9000 |
0 commit comments