Skip to content

Commit 8e0f4df

Browse files
plusNew001suijiaxinrootroot
authored
[XPU] [CI] Xpu Ci Refactor (#5252)
* add xpu ci * add case * add case * fix ci bug * Update Docker image tag to 'latest' in CI workflow * Fix set -e usage in run_xpu_ci_pytest.sh * add pd case * add case * Configure pip to use Tsinghua mirror for dependencies Set the global pip index URL to Tsinghua mirror. * fix ci bug * fix bug * fix bug --------- Co-authored-by: suijiaxin <suijiaxin@Suis-MacBook-Pro.local> Co-authored-by: root <root@gajl-bbc-onlinec-com-1511964.gajl.baidu.com> Co-authored-by: root <root@gajl-bbc-onlinec-com-1511972.gajl.baidu.com>
1 parent 6b03f4f commit 8e0f4df

File tree

12 files changed

+1944
-1
lines changed

12 files changed

+1944
-1
lines changed

.github/workflows/ci_xpu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ jobs:
8282
${docker_image} /bin/bash -c "
8383
git config --global --add safe.directory /workspace/FastDeploy
8484
cd FastDeploy
85-
bash scripts/run_ci_xpu.sh
85+
bash scripts/run_xpu_ci_pytest.sh
8686
"

scripts/run_xpu_ci_pytest.sh

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#!/bin/bash
2+
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# XPU CI测试入口脚本 - 基于pytest框架
17+
#
18+
# 使用方法:
19+
# bash scripts/run_xpu_ci_pytest.sh
20+
#
21+
# 环境变量:
22+
# XPU_ID: XPU设备ID(0或1)
23+
# MODEL_PATH: 模型路径
24+
25+
set +e
26+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27+
echo "脚本目录: $DIR"
28+
29+
# ============ 环境准备阶段 ============
30+
31+
echo "============================环境准备============================"
32+
33+
# 安装lsof工具
34+
echo "安装lsof工具..."
35+
apt install -y lsof
36+
37+
# 设置XPU_VISIBLE_DEVICES
38+
if [[ "$XPU_ID" == "0" ]]; then
39+
export XPU_VISIBLE_DEVICES="0,1,2,3"
40+
else
41+
export XPU_VISIBLE_DEVICES="4,5,6,7"
42+
fi
43+
echo "XPU_VISIBLE_DEVICES=$XPU_VISIBLE_DEVICES"
44+
45+
# 下载和安装xre
46+
echo "下载和安装xre..."
47+
mkdir -p /workspace/deps
48+
cd /workspace/deps
49+
if [ ! -d "xre" ]; then
50+
wget -q https://klx-sdk-release-public.su.bcebos.com/xre/kl3-release/5.0.21.21/xre-Linux-x86_64-5.0.21.21.tar.gz
51+
tar -zxf xre-Linux-x86_64-5.0.21.21.tar.gz && mv xre-Linux-x86_64-5.0.21.21 xre
52+
fi
53+
cd -
54+
export PATH=/workspace/deps/xre/bin:$PATH
55+
56+
# 重启XPU卡
57+
echo "重启XPU卡..."
58+
xpu-smi -r -i $XPU_VISIBLE_DEVICES
59+
xpu-smi
60+
set -e
61+
# ============ Python环境配置 ============
62+
63+
echo "============================Python环境配置============================"
64+
65+
# 安装Python依赖
66+
echo "安装Python依赖..."
67+
python -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
68+
python -m pip install -r requirements.txt
69+
70+
# 卸载旧版本
71+
echo "卸载旧版本..."
72+
python -m pip uninstall paddlepaddle-xpu -y
73+
python -m pip uninstall fastdeploy-xpu -y
74+
75+
# 安装PaddlePaddle
76+
echo "安装PaddlePaddle..."
77+
python -m pip install https://paddle-whl.bj.bcebos.com/nightly/xpu-p800/paddlepaddle-xpu/paddlepaddle_xpu-3.3.0.dev20251123-cp310-cp310-linux_x86_64.whl
78+
79+
# ============ 编译项目 ============
80+
81+
echo "============================编译项目============================"
82+
bash custom_ops/xpu_ops/download_dependencies.sh develop
83+
export CLANG_PATH=$(pwd)/custom_ops/xpu_ops/third_party/xtdk
84+
export XVLLM_PATH=$(pwd)/custom_ops/xpu_ops/third_party/xvllm
85+
bash build.sh || exit 1
86+
87+
# ============ 安装测试依赖 ============
88+
89+
echo "============================安装测试依赖============================"
90+
python -m pip install openai -U
91+
python -m pip uninstall -y triton
92+
python -m pip install triton==3.3.0
93+
python -m pip install pytest
94+
python -m pip install pytest-timeout
95+
96+
# 清除代理设置
97+
unset http_proxy
98+
unset https_proxy
99+
unset no_proxy
100+
101+
# ============ 运行pytest测试 ============
102+
103+
echo "============================开始运行pytest测试============================"
104+
105+
# 切换到项目根目录(如果不在的话)
106+
cd "$(dirname "$DIR")"
107+
108+
# 运行pytest
109+
# -v: 详细输出
110+
# -s: 不捕获输出,直接显示print内容
111+
# --tb=short: 简短的traceback
112+
# --junit-xml: 生成junit格式的测试报告
113+
python -m pytest -v -s --tb=short tests/xpu_ci/
114+
115+
# 获取pytest退出码
116+
exit_code=$?
117+
118+
if [ $exit_code -eq 0 ]; then
119+
echo "============================所有测试通过!============================"
120+
else
121+
echo "============================测试失败,请检查日志!============================"
122+
exit $exit_code
123+
fi

tests/cov_pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ addopts =
77
--ignore=tests/operators/test_w4afp8_gemm.py
88
--ignore=tests/model_loader/test_w4a8_model.py
99
--ignore=tests/entrypoints/test_engine_client.py
10+
--ignore=tests/xpu_ci

0 commit comments

Comments
 (0)