drizzlezyk commited on
Commit
54dd322
·
verified ·
1 Parent(s): 2b9837f

Upload inference/launch.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. inference/launch.sh +77 -0
inference/launch.sh ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4
+
5
+ export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
6
+ export VLLM_ENGINE_ITERATION_TIMEOUT_S=1000
7
+ timestamp=$(date +"%Y%m%d_%H%M%S")
8
+ export LOCAL_CKPT_DIR=${LOAD_CKPT_DIR:=../}
9
+ export LOCAL_CHAT_TEMPLATE_PATH=${CHAT_TEMPLATE_PATH:=$SCRIPT_DIR/chat_template_74B_1124.jinja}
10
+
11
+ if [[ ! -d ${OUTPUT_TEXT_DIR} ]]; then
12
+ export OUTPUT_TEXT_DIR=$PROJECT_DIR/outputs
13
+ mkdir -p ${OUTPUT_TEXT_DIR}
14
+ fi
15
+
16
+
17
+ apply_patch_to_package() {
18
+ local PACKAGE_NAME=$1
19
+ local PATCH_FILE=$2
20
+ local PACKAGE_DIR
21
+ echo "apply patch ${PATCH_FILE} to ${PACKAGE_NAME}..."
22
+
23
+ PACKAGE_DIR=$(python -m pip show "$PACKAGE_NAME" | grep 'Editable project location' | awk -F': ' '{print $2}')
24
+ (
25
+ cd "$PACKAGE_DIR" || exit 1
26
+
27
+ if git apply --reverse --check "$PATCH_FILE" >/dev/null 2>&1; then
28
+ echo "Patch for ${PACKAGE_NAME} already applied. Skipping."
29
+ return 0
30
+ fi
31
+
32
+ if git apply --check "$PATCH_FILE" >/dev/null 2>&1; then
33
+ git apply "$PATCH_FILE"
34
+ if [ $? -ne 0 ]; then
35
+ echo "Failed to apply patch to ${PACKAGE_NAME} due to git apply error."
36
+ exit 1
37
+ fi
38
+ else
39
+ echo "Failed to apply patch to ${PACKAGE_NAME}. Patch file is either incorrect or conflicts exist."
40
+ exit 1
41
+ fi
42
+ ) || exit 1
43
+ }
44
+
45
+ apply_patch_to_package "vllm-ascend" "$SCRIPT_DIR/vllm-ascend_v0.11.0rc0.patch"
46
+ apply_patch_to_package "vllm" "$SCRIPT_DIR/vllm_v0.11.0rc3.patch"
47
+
48
+ source /usr/local/Ascend/ascend-toolkit/latest/opp/vendors/omni_custom_ops/bin/set_env.bash
49
+
50
+ # 指定 HOST=127.0.0.1(本地主机)表示服务器只能从主设备访问。
51
+ # 指定 HOST=0.0.0.0 允许从同一网络上的其他设备甚至从互联网访问 vLLM 服务器,前提是网络配置正确(例如,防火墙规则、端口转发)。
52
+ HOST=xxx.xxx.xxx.xxx
53
+
54
+ # 拉起模型服务
55
+ python $SCRIPT_DIR/vllm_register.py \
56
+ --model $LOCAL_CKPT_DIR \
57
+ --served-model-name ${SERVED_MODEL_NAME:=pangu_7b} \
58
+ --tensor-parallel-size ${TENSOR_PARALLEL_SIZE:=8} \
59
+ --trust-remote-code \
60
+ --host ${HOST} \
61
+ --port ${PORT:=8000} \
62
+ --max-num-seqs ${MAX_NUM_SEQS:=256} \
63
+ --max-model-len ${MAX_MODEL_LEN:=131072} \
64
+ --tokenizer-mode "slow" \
65
+ --dtype bfloat16 \
66
+ --enable-log-requests \
67
+ --distributed-executor-backend mp \
68
+ --gpu-memory-utilization 0.9 \
69
+ --max-num-batched-tokens ${MAX_NUM_BATCHED_TOKENS:=4096} \
70
+ --no-enable-prefix-caching \
71
+ --reasoning-parser pangu \
72
+ --chat_template ${LOCAL_CHAT_TEMPLATE_PATH} \
73
+ --enable-auto-tool-choice \
74
+ --tool-call-parser pangu \
75
+ --trust-request-chat-template \
76
+ --enable_chunked_prefill \
77
+ --additional_config '{"ascend_scheduler_config":{"enabled":true,"enable_chunked_prefill":true,"chunked_prefill_enabled":true}}' | tee $OUTPUT_TEXT_DIR/inference.log