Skip to content

Commit 59b5641

Browse files
authored
Merge branch 'PaddlePaddle:develop' into develop
2 parents ac24227 + 5d13148 commit 59b5641

File tree

399 files changed

+25731
-7385
lines changed

Some content is hidden

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

399 files changed

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

.github/workflows/_base_test.yml

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

0 commit comments

Comments
 (0)