Skip to content

Commit 62bff9b

Browse files
authored
Merge pull request #35 from MooreThreads/update_vllm_demo_script
Update vllm demo script
2 parents 41d9d5a + 55d08fd commit 62bff9b

File tree

3 files changed

+84
-53
lines changed

3 files changed

+84
-53
lines changed

vllm/demo/model_url.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"DeepSeek-R1-Distill-Qwen-1.5B": "https://www.modelscope.cn/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B.git",
3+
"Qwen2.5-0.5B-Instruct": "https://www.modelscope.cn/Qwen/Qwen2.5-0.5B-Instruct.git"
4+
}

vllm/demo/run_server_ds_r1_dstl_qw1.5b.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

vllm/demo/run_vllm_serving.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
set -e
3+
4+
MODEL_NAME="$1"
5+
CONFIG_FILE="model_config.json"
6+
7+
if [ -z "$MODEL_NAME" ]; then
8+
echo "× Please provide the model name, for example:"
9+
echo " ./run_vllm_serving.sh DeepSeek-R1-Distill-Qwen-1.5B"
10+
exit 1
11+
fi
12+
13+
# 用 Python 解析 JSON 获取 URL
14+
MODEL_URL=$(python3 -c "
15+
import json
16+
config_file = '$CONFIG_FILE'
17+
model_name = '$MODEL_NAME'
18+
with open(config_file, 'r') as f:
19+
data = json.load(f)
20+
print(data.get(model_name, ''))
21+
")
22+
23+
if [ -z "$MODEL_URL" ]; then
24+
echo "× $MODEL_NAME is not supported yet, please refer to the website to try other models: https://docs.mthreads.com/mtt/mtt-doc-online/compability"
25+
exit 1
26+
fi
27+
28+
echo "√ 找到模型 URL: $MODEL_URL"
29+
30+
# 目录和日志路径
31+
CURRENT_DIR=$(pwd)
32+
MODEL_DIR="/data/mtt/models"
33+
CONVERTED_MODEL_DIR="/data/mtt/models_convert"
34+
LOG_FILE="/data/mtt/logs/model_server.log"
35+
MODEL_CHECK_FILE="$MODEL_DIR/$MODEL_NAME/model.safetensors"
36+
SUCCESS_MESSAGE="INFO: Started server process"
37+
38+
# 确保目录存在
39+
mkdir -p "$MODEL_DIR" "$CONVERTED_MODEL_DIR" "$(dirname "$LOG_FILE")"
40+
41+
# 检查模型是否已经存在
42+
if [ -f "$MODEL_CHECK_FILE" ]; then
43+
echo "√ The model file already exists. Skip the download step."
44+
else
45+
echo "⬇ The model file does not exist, start downloading the model..."
46+
cd "$MODEL_DIR"
47+
apt update && apt install -y git-lfs jq
48+
git lfs install
49+
git clone "$MODEL_URL" "$MODEL_NAME"
50+
echo "√ Model download completed."
51+
fi
52+
53+
# 权重转换
54+
cd "${CURRENT_DIR}/.."
55+
./convert_weight.sh "$MODEL_DIR/$MODEL_NAME" 1
56+
57+
# 启动 vLLM 服务器
58+
python -m vllm.entrypoints.openai.api_server \
59+
--model "$CONVERTED_MODEL_DIR/$MODEL_NAME-tp1-convert" \
60+
--trust-remote-code \
61+
--tensor-parallel-size 1 \
62+
-pp 1 \
63+
--block-size 64 \
64+
--max-model-len 2048 \
65+
--disable-log-stats \
66+
--disable-log-requests \
67+
--device "musa" \
68+
--served-model-name model-develop_test > "$LOG_FILE" 2>&1 &
69+
70+
pid=$!
71+
echo "Wait for the service to start..."
72+
while true; do
73+
if grep -q "$SUCCESS_MESSAGE" "$LOG_FILE"; then
74+
echo "√ Service has been started. If it does not work, check the log: $LOG_FILE"
75+
break
76+
else
77+
echo "Wait for the service to start..."
78+
sleep 5 # 每隔 5 秒检查日志文件
79+
fi
80+
done

0 commit comments

Comments
 (0)