Skip to content

Commit 11cfdf5

Browse files
添加XPU CI, test=model (#2701)
* 添加XPU CI, test=model * 添加XPU CI, test=model * 添加XPU CI, test=model * 添加XPU CI, test=model * 添加XPU CI, test=model * 添加XPU CI, test=model * 添加XPU CI, test=model * 添加XPU CI, test=model * 添加XPU CI, test=model
1 parent e7fa57e commit 11cfdf5

File tree

3 files changed

+207
-0
lines changed

3 files changed

+207
-0
lines changed

.github/workflows/ci_xpu.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CI_XPU
2+
3+
on:
4+
pull_request:
5+
branches: [ develop ]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.event.pull_request.number }}-xpu-ci
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build:
14+
runs-on: [self-hosted, XPU-P800-8Card]
15+
steps:
16+
- name: Print current runner name
17+
run: |
18+
echo "Current runner name: ${{ runner.name }}"
19+
# Because the system version is lower than 2.23, the checkout cannot be used.
20+
# - name: Checkout code
21+
# uses: actions/checkout@v4
22+
23+
- name: Code Checkout
24+
env:
25+
docker_image: ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/fastdeploy-xpu:2.0.0
26+
run: |
27+
REPO="https://github.com/${{ github.repository }}.git"
28+
FULL_REPO="${{ github.repository }}"
29+
REPO_NAME="${FULL_REPO##*/}"
30+
# Clean the repository directory before starting
31+
docker run --rm --net=host -v $(pwd):/workspace -w /workspace \
32+
-e "REPO_NAME=${REPO_NAME}" \
33+
${docker_image} /bin/bash -c '
34+
if [ -d ${REPO_NAME} ]; then
35+
echo "Directory ${REPO_NAME} exists, removing it..."
36+
rm -rf ${REPO_NAME}
37+
fi
38+
'
39+
git config --global user.name "FastDeployCI"
40+
git config --global user.email "fastdeploy_ci@example.com"
41+
git clone ${REPO} ${REPO_NAME}
42+
cd FastDeploy
43+
if [ "${{ github.event_name }}" = "pull_request" ]; then
44+
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr/${{ github.event.pull_request.number }}
45+
git merge pr/${{ github.event.pull_request.number }}
46+
git log -n 3 --oneline
47+
else
48+
git checkout ${{ github.sha }}
49+
git log -n 3 --oneline
50+
fi
51+
52+
- name: Run CI unittest
53+
env:
54+
docker_image: ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/fastdeploy-xpu:2.0.0
55+
run: |
56+
runner_name="${{ runner.name }}"
57+
last_char="${runner_name: -1}"
58+
59+
if [[ "$last_char" =~ [0-3] ]]; then
60+
gpu_id="$last_char"
61+
else
62+
gpu_id="0"
63+
fi
64+
FD_API_PORT=$((9180 + gpu_id * 100))
65+
FD_ENGINE_QUEUE_PORT=$((9150 + gpu_id * 100))
66+
FD_METRICS_PORT=$((9170 + gpu_id * 100))
67+
68+
PARENT_DIR=$(dirname "$WORKSPACE")
69+
echo "PARENT_DIR:$PARENT_DIR"
70+
docker run --rm --net=host --cap-add=SYS_PTRACE --privileged --shm-size=64G \
71+
-v $(pwd):/workspace -w /workspace \
72+
-v "/ssd3:/ssd3" \
73+
-e "MODEL_PATH=/ssd3/model" \
74+
-e "http_proxy=$(git config --global --get http.proxy)" \
75+
-e "https_proxy=$(git config --global --get https.proxy)" \
76+
-e "FD_API_PORT=${FD_API_PORT}" \
77+
-e "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}" \
78+
-e "FD_METRICS_PORT=${FD_METRICS_PORT}" \
79+
${docker_image} /bin/bash -c "
80+
git config --global --add safe.directory /workspace/FastDeploy
81+
cd FastDeploy
82+
bash scripts/run_ci_xpu.sh
83+
"

scripts/run_ci_xpu.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3+
echo "$DIR"
4+
5+
#先kill一遍
6+
ps -efww | grep -E 'api_server' | grep -v grep | awk '{print $2}' | xargs kill -9 || true
7+
ps -efww | grep -E '8188' | grep -v grep | awk '{print $2}' | xargs kill -9 || true
8+
lsof -t -i :8188 | xargs kill -9 || true
9+
10+
export model_path=${MODEL_PATH}/data/eb45t_4_layer
11+
export CLANG_PATH=${MODEL_PATH}/data/xtdk
12+
export XVLLM_PATH=${MODEL_PATH}/data/xvllm
13+
14+
echo "pip requirements"
15+
python -m pip install -r requirements.txt
16+
echo "uninstall org"
17+
python -m pip uninstall paddlepaddle-xpu -y
18+
python -m pip uninstall fastdeploy-xpu -y
19+
python -m pip install paddlepaddle-xpu -i https://www.paddlepaddle.org.cn/packages/stable/xpu-p800/
20+
echo "build whl"
21+
bash build.sh || exit 1
22+
echo "pip others"
23+
python -m pip install openai -U
24+
python -m pip uninstall -y triton
25+
python -m pip install triton==3.3.0
26+
27+
unset http_proxy
28+
unset https_proxy
29+
unset no_proxy
30+
31+
# 起服务
32+
rm -rf log/*
33+
rm -f core*
34+
# pkill -9 python #流水线不执行这个
35+
#清空消息队列
36+
ipcrm --all=msg
37+
export XPU_VISIBLE_DEVICES="0,1,2,3"
38+
python -m fastdeploy.entrypoints.openai.api_server \
39+
--model ${model_path} \
40+
--port 8188 \
41+
--tensor-parallel-size 4 \
42+
--num-gpu-blocks-override 16384 \
43+
--max-model-len 32768 \
44+
--max-num-seqs 128 \
45+
--quantization wint4 > server.log 2>&1 &
46+
47+
sleep 60
48+
# 探活
49+
TIMEOUT=$((5 * 60))
50+
INTERVAL=10 # 检查间隔(秒)
51+
ENDPOINT="http://0.0.0.0:8188/health"
52+
START_TIME=$(date +%s) # 记录开始时间戳
53+
echo "开始服务健康检查,最长等待时间:${TIMEOUT}"
54+
while true; do
55+
# 计算已耗时
56+
CURRENT_TIME=$(date +%s)
57+
ELAPSED=$((CURRENT_TIME - START_TIME))
58+
59+
# 超时判断
60+
if [ $ELAPSED -ge $TIMEOUT ]; then
61+
echo -e "\n服务启动超时:经过 $((TIMEOUT/60)) 分钟服务仍未启动!"
62+
cat server.log
63+
cat log/workerlog.0
64+
exit 1
65+
fi
66+
67+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -m 2 "$ENDPOINT" || true)
68+
69+
if [ "$HTTP_CODE" = "200" ]; then
70+
echo -e "\n服务启动成功!耗时 ${ELAPSED}"
71+
break
72+
else
73+
sleep $INTERVAL
74+
fi
75+
done
76+
77+
cat server.log
78+
79+
# 执行服务化推理
80+
python test/ci_use/XPU_45T/run_45T.py
81+
exit_code=$?
82+
echo exit_code is ${exit_code}
83+
84+
ps -efww | grep -E 'api_server' | grep -v grep | awk '{print $2}' | xargs kill -9 || true
85+
ps -efww | grep -E '8188' | grep -v grep | awk '{print $2}' | xargs kill -9 || true
86+
lsof -t -i :8188 | xargs kill -9 || true
87+
88+
if [ ${exit_code} -ne 0 ]; then
89+
echo "log/workerlog.0"
90+
cat log/workerlog.0
91+
exit 1
92+
fi

test/ci_use/XPU_45T/run_45T.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import openai
16+
17+
ip = "0.0.0.0"
18+
service_http_port = "8188" # 服务配置的
19+
client = openai.Client(base_url=f"http://{ip}:{service_http_port}/v1", api_key="EMPTY_API_KEY")
20+
21+
# 非流式对话
22+
response = client.chat.completions.create(
23+
model="default",
24+
messages=[
25+
{"role": "user", "content": "你好,你是谁?"},
26+
],
27+
temperature=1,
28+
top_p=0,
29+
max_tokens=64,
30+
stream=False,
31+
)
32+
print(response)

0 commit comments

Comments
 (0)