Skip to content

Commit 5d170a9

Browse files
authored
Merge branch 'develop' into unify_config_part5
2 parents 32911cb + beec24f commit 5d170a9

File tree

144 files changed

+3544
-1005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+3544
-1005
lines changed

.github/workflows/_accuracy_test.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: Accuracy Test
2+
description: "Run Accuracy Tests"
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
DOCKER_IMAGE:
8+
description: "Build Images"
9+
required: true
10+
type: string
11+
default: "ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/paddleqa:cuda126-py310"
12+
FASTDEPLOY_ARCHIVE_URL:
13+
description: "URL of the compressed FastDeploy code archive."
14+
required: true
15+
type: string
16+
FASTDEPLOY_WHEEL_URL:
17+
description: "URL of the FastDeploy Wheel."
18+
required: true
19+
type: string
20+
CACHE_DIR:
21+
description: "Cache Dir Use"
22+
required: false
23+
type: string
24+
default: ""
25+
MODEL_CACHE_DIR:
26+
description: "Cache Dir Use"
27+
required: false
28+
type: string
29+
default: ""
30+
31+
jobs:
32+
accuracy_tests:
33+
runs-on: [self-hosted, GPU-h20-1Cards]
34+
steps:
35+
- name: Code Prepare
36+
shell: bash
37+
env:
38+
docker_image: ${{ inputs.DOCKER_IMAGE }}
39+
fd_archive_url: ${{ inputs.FASTDEPLOY_ARCHIVE_URL }}
40+
run: |
41+
set -x
42+
REPO="https://github.com/${{ github.repository }}.git"
43+
FULL_REPO="${{ github.repository }}"
44+
REPO_NAME="${FULL_REPO##*/}"
45+
BASE_BRANCH="${{ github.base_ref }}"
46+
47+
# Clean the repository directory before starting
48+
docker run --rm --net=host -v $(pwd):/workspace -w /workspace \
49+
-e "REPO_NAME=${REPO_NAME}" \
50+
${docker_image} /bin/bash -c '
51+
if [ -d ${REPO_NAME} ]; then
52+
echo "Directory ${REPO_NAME} exists, removing it..."
53+
rm -rf ${REPO_NAME}*
54+
fi
55+
'
56+
57+
wget -q ${fd_archive_url}
58+
tar -xf FastDeploy.tar.gz
59+
rm -rf FastDeploy.tar.gz
60+
cd FastDeploy
61+
git config --global user.name "FastDeployCI"
62+
git config --global user.email "fastdeploy_ci@example.com"
63+
git log -n 3 --oneline
64+
65+
- name: Run FastDeploy Base Tests
66+
shell: bash
67+
env:
68+
docker_image: ${{ inputs.DOCKER_IMAGE }}
69+
fastdeploy_wheel_url: ${{ inputs.FASTDEPLOY_WHEEL_URL }}
70+
CACHE_DIR: ${{ inputs.CACHE_DIR }}
71+
MODEL_CACHE_DIR: ${{ inputs.MODEL_CACHE_DIR }}
72+
run: |
73+
runner_name="${{ runner.name }}"
74+
CARD_ID=$(echo "${runner_name}" | awk -F'-' '{print $NF}')
75+
DEVICES=$(echo "$CARD_ID" | fold -w1 | paste -sd,)
76+
DEVICE_PORT=$(echo "$DEVICES" | cut -d',' -f1)
77+
78+
FLASK_PORT=$((42068 + DEVICE_PORT * 100))
79+
FD_API_PORT=$((42088 + DEVICE_PORT * 100))
80+
FD_ENGINE_QUEUE_PORT=$((42058 + DEVICE_PORT * 100))
81+
FD_METRICS_PORT=$((42078 + DEVICE_PORT * 100))
82+
echo "Test ENV Parameter:"
83+
echo "========================================================="
84+
echo "FLASK_PORT=${FLASK_PORT}"
85+
echo "FD_API_PORT=${FD_API_PORT}"
86+
echo "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}"
87+
echo "FD_METRICS_PORT=${FD_METRICS_PORT}"
88+
echo "DEVICES=${DEVICES}"
89+
echo "========================================================="
90+
91+
CACHE_DIR="${CACHE_DIR:-$(dirname "$(dirname "${{ github.workspace }}")")}"
92+
echo "CACHE_DIR is set to ${CACHE_DIR}"
93+
if [ ! -f "${CACHE_DIR}/gitconfig" ]; then
94+
touch "${CACHE_DIR}/gitconfig"
95+
fi
96+
if [ ! -d "${MODEL_CACHE_DIR}" ]; then
97+
echo "Error: MODEL_CACHE_DIR '${MODEL_CACHE_DIR}' does not exist."
98+
exit 1
99+
fi
100+
101+
PORTS=($FLASK_PORT $FD_API_PORT $FD_ENGINE_QUEUE_PORT $FD_METRICS_PORT)
102+
LOG_FILE="./port_cleanup_$(date +%Y%m%d_%H%M%S).log"
103+
echo "==== LOG_FILE is ${LOG_FILE} ===="
104+
105+
echo "==== PORT CLEAN BEFORE TASK RUN ====" | tee -a $LOG_FILE
106+
107+
for port in "${PORTS[@]}"; do
108+
PIDS=$(lsof -t -i :$port || true)
109+
if [ -n "$PIDS" ]; then
110+
echo "Port $port is occupied by PID(s): $PIDS" | tee -a $LOG_FILE
111+
echo "$PIDS" | xargs -r kill -9
112+
echo "Port $port cleared" | tee -a $LOG_FILE
113+
else
114+
echo "Port $port is free" | tee -a $LOG_FILE
115+
fi
116+
done
117+
118+
echo "==== PORT CLEAN COMPLETE ====" | tee -a $LOG_FILE
119+
120+
docker run --rm --ipc=host --pid=host --net=host \
121+
-v $(pwd):/workspace \
122+
-w /workspace \
123+
-e fastdeploy_wheel_url=${fastdeploy_wheel_url} \
124+
-e "FD_API_PORT=${FD_API_PORT}" \
125+
-e "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}" \
126+
-e "FD_METRICS_PORT=${FD_METRICS_PORT}" \
127+
-e "FLASK_PORT=${FLASK_PORT}" \
128+
-v "${MODEL_CACHE_DIR}:/MODELDATA" \
129+
-v "${CACHE_DIR}/gitconfig:/etc/gitconfig:ro" \
130+
-v "${CACHE_DIR}/.cache:/root/.cache" \
131+
-v "${CACHE_DIR}/ConfigDir:/root/.config" \
132+
-e TZ="Asia/Shanghai" \
133+
--gpus '"device='"${DEVICES}"'"' ${docker_image} /bin/bash -xc '
134+
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
135+
136+
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
137+
138+
python -m pip install ${fastdeploy_wheel_url}
139+
python -m pip install pytest
140+
141+
wget https://paddle-qa.bj.bcebos.com/zhengtianyu/tools/llm-deploy-linux-amd64
142+
chmod +x ./llm-deploy-linux-amd64
143+
./llm-deploy-linux-amd64 -python python3.10 \
144+
-model_name ERNIE-4.5-0.3B-Paddle \
145+
-model_path /MODELDATA \
146+
--skip install
147+
148+
git config --global --add safe.directory /workspace/FastDeploy
149+
cd FastDeploy
150+
pushd test/ce/deploy
151+
python3.10 deploy.py > dd.log 2>&1 &
152+
sleep 3
153+
curl -X POST http://0.0.0.0:${FLASK_PORT}/start \
154+
-H "Content-Type: application/json" \
155+
-d "{\"--model\": \"/MODELDATA/ERNIE-4.5-0.3B-Paddle\"}"
156+
157+
curl -X POST http://localhost:${FLASK_PORT}/wait_for_infer?timeout=90
158+
popd
159+
160+
pushd test/ce/accuracy_cases
161+
export URL=http://localhost:${FD_API_PORT}/v1/chat/completions
162+
export TEMPLATE=TOKEN_LOGPROB
163+
export MODEL_SIZE=0.3B
164+
TEST_EXIT_CODE=0
165+
python gsm8k.py || TEST_EXIT_CODE=1
166+
popd
167+
echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> /workspace/FastDeploy/exit_code.env
168+
'
169+
if [ -f ./FastDeploy/exit_code.env ]; then
170+
source ./FastDeploy/exit_code.env
171+
cat ./FastDeploy/exit_code.env >> $GITHUB_ENV
172+
fi
173+
echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}"
174+
exit ${TEST_EXIT_CODE}

.github/workflows/_build_linux.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@ on:
2222
description: "Enable nightly build mode (e.g. add date suffix to version)"
2323
required: false
2424
type: string
25-
default: "ON"
25+
default: "OFF"
2626
FD_VERSION:
2727
description: "FastDeploy Package Version"
2828
required: false
2929
type: string
3030
default: ""
31+
PADDLEVERSION:
32+
description: "Paddle Version Build Use"
33+
required: false
34+
type: string
35+
default: ""
36+
PADDLE_WHL_URL:
37+
description: "Paddle Wheel Package URL"
38+
required: false
39+
type: string
40+
default: ""
3141
UPLOAD:
3242
description: "Upload Package"
3343
required: false
@@ -85,6 +95,10 @@ jobs:
8595
compile_arch: ${{ inputs.COMPILE_ARCH }}
8696
fd_version: ${{ inputs.FD_VERSION }}
8797
CACHE_DIR: ${{ inputs.CACHE_DIR }}
98+
BRANCH_REF: ${{ github.ref_name }}
99+
PADDLEVERSION: ${{ inputs.PADDLEVERSION }}
100+
PADDLE_WHL_URL: ${{ inputs.PADDLE_WHL_URL }}
101+
WITH_NIGHTLY_BUILD: ${{ inputs.WITH_NIGHTLY_BUILD }}
88102
run: |
89103
set -x
90104
runner_name="${{ runner.name }}"
@@ -109,6 +123,9 @@ jobs:
109123
-e "COMPILE_ARCH=${compile_arch}" \
110124
-e "FD_VERSION=${fd_version}" \
111125
-e "WITH_NIGHTLY_BUILD=${WITH_NIGHTLY_BUILD}" \
126+
-e "PADDLEVERSION=${PADDLEVERSION}" \
127+
-e "PADDLE_WHL_URL=${PADDLE_WHL_URL}" \
128+
-e "BRANCH_REF=${BRANCH_REF}" \
112129
--gpus "\"device=${gpu_id}\"" ${docker_image} /bin/bash -c '
113130
if [[ -n "${FD_VERSION}" ]]; then
114131
export FASTDEPLOY_VERSION=${FD_VERSION}
@@ -124,7 +141,15 @@ jobs:
124141
echo "Date Only: $DATE_ONLY"
125142
export FASTDEPLOY_VERSION="${FASTDEPLOY_VERSION}.dev${DATE_ONLY}"
126143
fi
127-
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
144+
# 针对不同分支和tag使用不同的PaddlePaddle安装包
145+
if [[ "${PADDLE_WHL_URL}" != "" ]];then
146+
python -m pip install ${PADDLE_WHL_URL}
147+
elif [[ "${PADDLEVERSION}" != "" ]];then
148+
python -m pip install paddlepaddle-gpu==${PADDLEVERSION} -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
149+
else
150+
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
151+
fi
152+
128153
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
129154
130155
python -m pip install --upgrade pip

.github/workflows/_pre_ce_test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ on:
2727
type: string
2828
default: ""
2929

30-
concurrency:
31-
group: ${{ github.event.pull_request.number }}
32-
cancel-in-progress: true
33-
3430
jobs:
3531
run_ce_cases:
3632
runs-on: [self-hosted, PRE_CE_RUN_2Card]

.github/workflows/_unit_test_coverage.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,13 @@ jobs:
7373
CACHE_DIR: ${{ inputs.CACHE_DIR }}
7474
BASE_REF: ${{ github.event.pull_request.base.ref }}
7575
MODEL_CACHE_DIR: ${{ inputs.MODEL_CACHE_DIR }}
76+
IS_PR: ${{ github.event_name == 'pull_request' }}
7677
run: |
77-
set -x
78+
if [[ "$IS_PR" == "true" ]]; then
79+
echo "Running on PR"
80+
else
81+
echo "Not a PR"
82+
fi
7883
runner_name="${{ runner.name }}"
7984
CARD_ID=$(echo "${runner_name}" | awk -F'-' '{print $NF}')
8085
DEVICES=$(echo "$CARD_ID" | fold -w1 | paste -sd,)
@@ -133,6 +138,7 @@ jobs:
133138
-e TZ="Asia/Shanghai" \
134139
-e "fd_wheel_url=${fd_wheel_url}" \
135140
-e "BASE_REF=${BASE_REF}" \
141+
-e "IS_PR=${IS_PR}" \
136142
--gpus "\"device=${DEVICES}\"" ${docker_image} /bin/bash -c '
137143
138144
git config --global --add safe.directory /workspace/FastDeploy
@@ -160,9 +166,13 @@ jobs:
160166
coverage combine coveragedata/
161167
coverage xml -o python_coverage_all.xml
162168
COVERAGE_EXIT_CODE=0
163-
diff-cover python_coverage_all.xml --diff-file=diff.txt --fail-under=80 --json-report diff_coverage.json || COVERAGE_EXIT_CODE=9
169+
if [[ "$IS_PR" == "true" ]]; then
170+
diff-cover python_coverage_all.xml --diff-file=diff.txt --fail-under=80 --json-report diff_coverage.json || COVERAGE_EXIT_CODE=9
171+
python scripts/generate_diff_coverage_xml.py diff.txt python_coverage_all.xml
172+
else
173+
echo "Not a PR, skipping diff-cover"
174+
fi
164175
echo "COVERAGE_EXIT_CODE=${COVERAGE_EXIT_CODE}" >> exit_code.env
165-
python scripts/generate_diff_coverage_xml.py diff.txt python_coverage_all.xml
166176
'
167177
if [ -f FastDeploy/exit_code.env ]; then
168178
cat FastDeploy/exit_code.env >> $GITHUB_ENV
@@ -205,6 +215,7 @@ jobs:
205215
- name: Check Unit Test Success
206216
shell: bash
207217
run: |
218+
cd FastDeploy
208219
if [ "$TEST_EXIT_CODE" -eq 8 ]; then
209220
filename=$(basename "$unittest_failed_url")
210221
if [ -z "${unittest_failed_url}" ]; then
@@ -223,8 +234,10 @@ jobs:
223234
echo "All tests passed"
224235
225236
- name: Verify Code Coverage Threshold (80%)
237+
if: ${{ github.event_name == 'pull_request' }}
226238
shell: bash
227239
run: |
240+
cd FastDeploy
228241
if [ "$COVERAGE_EXIT_CODE" -eq 9 ]; then
229242
echo "Coverage generation failed (exit code 9)"
230243
filename=$(basename "$diff_cov_result_json_url")

.github/workflows/pr_build_and_test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,13 @@ jobs:
7373
FASTDEPLOY_ARCHIVE_URL: ${{ needs.clone.outputs.repo_archive_url }}
7474
FASTDEPLOY_WHEEL_URL: ${{ needs.build.outputs.wheel_path }}
7575
MODEL_CACHE_DIR: "/ssd2/actions-runner/ModelData"
76+
77+
accuracy_test:
78+
name: Run Accuracy Tests
79+
needs: [clone,build]
80+
uses: ./.github/workflows/_accuracy_test.yml
81+
with:
82+
DOCKER_IMAGE: ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/paddleqa:fastdeploy-ciuse-cuda126-dailyupdate
83+
FASTDEPLOY_ARCHIVE_URL: ${{ needs.clone.outputs.repo_archive_url }}
84+
FASTDEPLOY_WHEEL_URL: ${{ needs.build.outputs.wheel_path }}
85+
MODEL_CACHE_DIR: "/ssd2/actions-runner/ModelData"

0 commit comments

Comments
 (0)