Skip to content

Commit 71b4aae

Browse files
committed
Merge branch 'develop' of https://github.com/xiaolei373/FastDeploy into add_error_log
2 parents cc1da7c + 3e8d4ab commit 71b4aae

File tree

212 files changed

+12524
-4404
lines changed

Some content is hidden

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

212 files changed

+12524
-4404
lines changed

.github/workflows/_base_test.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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+
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/server
161+
export URL=http://localhost:${FD_API_PORT}/v1/chat/completions
162+
export TEMPLATE=TOKEN_LOGPROB
163+
TEST_EXIT_CODE=0
164+
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
165+
curl -X POST http://0.0.0.0:${FLASK_PORT}/switch \
166+
-H "Content-Type: application/json" \
167+
-d "{\"--model\": \"/MODELDATA/ERNIE-4.5-0.3B-Paddle\", \"--early-stop-config\": \"{\\\"enable_early_stop\\\":true, \\\"window_size\\\":6, \\\"threshold\\\":0.93}\"}"
168+
curl -X POST http://localhost:${FLASK_PORT}/wait_for_infer?timeout=90
169+
python -m pytest -sv test_repetition_early_stop.py || TEST_EXIT_CODE=1
170+
popd
171+
echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> /workspace/FastDeploy/exit_code.env
172+
'
173+
if [ -f ./FastDeploy/exit_code.env ]; then
174+
source ./FastDeploy/exit_code.env
175+
cat ./FastDeploy/exit_code.env >> $GITHUB_ENV
176+
fi
177+
echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}"
178+
exit ${TEST_EXIT_CODE}

.github/workflows/_build_linux.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ jobs:
125125
export FASTDEPLOY_VERSION="${FASTDEPLOY_VERSION}.dev${DATE_ONLY}"
126126
fi
127127
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
128-
pip config set global.index-url http://pip.baidu.com/root/baidu/+simple/
129-
pip config set install.trusted-host pip.baidu.com
130-
pip config set global.extra-index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
128+
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
131129
132130
python -m pip install --upgrade pip
133131
python -m pip install -r requirements.txt

.github/workflows/_clone_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
branch_name=${{ github.ref_name }}
6969
target_path=paddle-github-action/BRANCH/FastDeploy/${branch_name}/${commit_id}
7070
fi
71-
wget -q --no-proxy --no-check-certificate https://paddle-qa.bj.bcebos.com/CodeSync/develop/PaddlePaddle/PaddleTest/tools/bos_tools.py
71+
wget -O bos_tools.py -q --no-proxy --no-check-certificate https://paddle-qa.bj.bcebos.com/CodeSync/develop/PaddlePaddle/PaddleTest/tools/bos_tools.py
7272
push_file=$(realpath bos_tools.py)
7373
python -m pip install bce-python-sdk==0.9.29
7474
ls

.github/workflows/_logprob_test_linux.yml

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,22 @@ jobs:
6262
MODEL_CACHE_DIR: ${{ inputs.MODEL_CACHE_DIR }}
6363
run: |
6464
runner_name="${{ runner.name }}"
65-
last_char="${runner_name: -1}"
65+
CARD_ID=$(echo "${runner_name}" | awk -F'-' '{print $NF}')
66+
DEVICES=$(echo "$CARD_ID" | fold -w1 | paste -sd,)
67+
DEVICE_PORT=$(echo "$DEVICES" | cut -d',' -f1)
6668
67-
if [[ "$last_char" =~ [0-7] ]]; then
68-
DEVICES="$last_char"
69-
else
70-
DEVICES="0"
71-
fi
72-
73-
FLASK_PORT=$((9160 + DEVICES * 100))
74-
FD_API_PORT=$((9180 + DEVICES * 100))
75-
FD_ENGINE_QUEUE_PORT=$((9150 + DEVICES * 100))
76-
FD_METRICS_PORT=$((9170 + DEVICES * 100))
69+
FLASK_PORT=$((42068 + DEVICE_PORT * 100))
70+
FD_API_PORT=$((42088 + DEVICE_PORT * 100))
71+
FD_ENGINE_QUEUE_PORT=$((42058 + DEVICE_PORT * 100))
72+
FD_METRICS_PORT=$((42078 + DEVICE_PORT * 100))
73+
echo "Test ENV Parameter:"
74+
echo "========================================================="
75+
echo "FLASK_PORT=${FLASK_PORT}"
76+
echo "FD_API_PORT=${FD_API_PORT}"
77+
echo "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}"
78+
echo "FD_METRICS_PORT=${FD_METRICS_PORT}"
79+
echo "DEVICES=${DEVICES}"
80+
echo "========================================================="
7781
7882
CACHE_DIR="${CACHE_DIR:-$(dirname "$(dirname "${{ github.workspace }}")")}"
7983
echo "CACHE_DIR is set to ${CACHE_DIR}"
@@ -85,9 +89,26 @@ jobs:
8589
exit 1
8690
fi
8791
88-
PARENT_DIR=$(dirname "$WORKSPACE")
92+
PORTS=($FLASK_PORT $FD_API_PORT $FD_ENGINE_QUEUE_PORT $FD_METRICS_PORT)
93+
LOG_FILE="./port_cleanup_$(date +%Y%m%d_%H%M%S).log"
94+
echo "==== LOG_FILE is ${LOG_FILE} ===="
95+
96+
echo "==== PORT CLEAN BEFORE TASK RUN ====" | tee -a $LOG_FILE
8997
90-
docker run --ipc=host --pid=host --net=host \
98+
for port in "${PORTS[@]}"; do
99+
PIDS=$(lsof -t -i :$port || true)
100+
if [ -n "$PIDS" ]; then
101+
echo "Port $port is occupied by PID(s): $PIDS" | tee -a $LOG_FILE
102+
echo "$PIDS" | xargs -r kill -9
103+
echo "Port $port cleared" | tee -a $LOG_FILE
104+
else
105+
echo "Port $port is free" | tee -a $LOG_FILE
106+
fi
107+
done
108+
109+
echo "==== PORT CLEAN COMPLETE ====" | tee -a $LOG_FILE
110+
111+
docker run --rm --ipc=host --pid=host --net=host \
91112
-v $(pwd):/workspace \
92113
-w /workspace \
93114
-e fastdeploy_wheel_url=${fastdeploy_wheel_url} \
@@ -100,13 +121,11 @@ jobs:
100121
-v "${CACHE_DIR}/.cache:/root/.cache" \
101122
-v "${CACHE_DIR}/ConfigDir:/root/.config" \
102123
-e TZ="Asia/Shanghai" \
103-
--gpus '"device='"${DEVICES}"'"' ${docker_image} /bin/bash -c '
104-
# python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
105-
python -m pip install paddlepaddle-gpu==3.0.0.dev20250729 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
124+
--gpus '"device='"${DEVICES}"'"' ${docker_image} /bin/bash -xc '
125+
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
126+
127+
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
106128
107-
pip config set global.index-url http://pip.baidu.com/root/baidu/+simple/
108-
pip config set install.trusted-host pip.baidu.com
109-
pip config set global.extra-index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
110129
python -m pip install ${fastdeploy_wheel_url}
111130
112131
wget https://paddle-qa.bj.bcebos.com/zhengtianyu/tools/llm-deploy-linux-amd64
@@ -124,6 +143,10 @@ jobs:
124143
-d "{\"--model\": \"/MODELDATA/ERNIE-4.5-0.3B-Paddle\"}"
125144
126145
curl -X POST http://localhost:${FLASK_PORT}/wait_for_infer?timeout=90
146+
curl -s -o /dev/null -w "%{http_code}" -m 2 "http://0.0.0.0:${FD_API_PORT}/health"
147+
curl -X POST "http://0.0.0.0:${FD_API_PORT}/v1/chat/completions" \
148+
-H "Content-Type: application/json" \
149+
-d "{\"messages\": [{\"role\": \"user\", \"content\": \"1+1=?\"}], \"logprobs\": true}"
127150
set +e
128151
rm -rf ./baseline_output
129152
cp -r baseline/ERNIE-4.5-0.3B-Paddle ./baseline_output

.github/workflows/_pre_ce_test.yml

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@ on:
2121
required: false
2222
type: string
2323
default: ""
24+
MODEL_CACHE_DIR:
25+
description: "Cache Dir Use"
26+
required: false
27+
type: string
28+
default: ""
2429

2530
concurrency:
2631
group: ${{ github.event.pull_request.number }}
2732
cancel-in-progress: true
2833

2934
jobs:
3035
run_ce_cases:
31-
runs-on: [self-hosted, GPU-L20-4Card]
36+
runs-on: [self-hosted, PRE_CE_RUN_2Card]
3237
steps:
3338
- name: Print current runner name
3439
run: |
@@ -67,38 +72,67 @@ jobs:
6772
env:
6873
docker_image: ${{ inputs.DOCKER_IMAGE }}
6974
fd_wheel_url: ${{ inputs.FASTDEPLOY_WHEEL_URL }}
75+
CACHE_DIR: ${{ inputs.CACHE_DIR }}
76+
MODEL_CACHE_DIR: ${{ inputs.MODEL_CACHE_DIR }}
7077
run: |
7178
runner_name="${{ runner.name }}"
72-
last_char="${runner_name: -1}"
79+
CARD_ID=$(echo "${runner_name}" | awk -F'-' '{print $NF}')
80+
DEVICES=$(echo "$CARD_ID" | fold -w1 | paste -sd,)
81+
DEVICE_PORT=$(echo "$DEVICES" | cut -d',' -f1)
82+
83+
FLASK_PORT=$((42068 + DEVICE_PORT * 100))
84+
FD_API_PORT=$((42088 + DEVICE_PORT * 100))
85+
FD_ENGINE_QUEUE_PORT=$((42058 + DEVICE_PORT * 100))
86+
FD_METRICS_PORT=$((42078 + DEVICE_PORT * 100))
87+
echo "Test ENV Parameter:"
88+
echo "========================================================="
89+
echo "FLASK_PORT=${FLASK_PORT}"
90+
echo "FD_API_PORT=${FD_API_PORT}"
91+
echo "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}"
92+
echo "FD_METRICS_PORT=${FD_METRICS_PORT}"
93+
echo "DEVICES=${DEVICES}"
94+
echo "========================================================="
7395
74-
if [ "${last_char}" = "1" ]; then
75-
gpu_id=2
76-
DEVICES="2,3"
77-
else
78-
gpu_id=0
79-
DEVICES="0,1"
96+
CACHE_DIR="${CACHE_DIR:-$(dirname "$(dirname "${{ github.workspace }}")")}"
97+
echo "CACHE_DIR is set to ${CACHE_DIR}"
98+
if [ ! -f "${CACHE_DIR}/gitconfig" ]; then
99+
touch "${CACHE_DIR}/gitconfig"
80100
fi
81-
FD_API_PORT=$((9180 + gpu_id * 100))
82-
FD_ENGINE_QUEUE_PORT=$((9150 + gpu_id * 100))
83-
FD_METRICS_PORT=$((9170 + gpu_id * 100))
84101
85-
PARENT_DIR=$(dirname "$WORKSPACE")
86-
echo "PARENT_DIR:$PARENT_DIR"
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+
87121
docker run --rm --net=host -v $(pwd):/workspace -w /workspace \
88-
-v "/ssd4/GithubActions/gitconfig:/etc/gitconfig:ro" \
89-
-v "/ssd4/GithubActions/ModelData:/ModelData:ro" \
90-
-v "/ssd4/GithubActions/CacheDir:/root/.cache" \
91-
-v "/ssd4/GithubActions/ConfigDir:/root/.config" \
122+
-v "${CACHE_DIR}/gitconfig:/etc/gitconfig:ro" \
123+
-v "${CACHE_DIR}/.cache:/root/.cache" \
124+
-v "${CACHE_DIR}/ConfigDir:/root/.config" \
125+
-v "${MODEL_CACHE_DIR}:/ModelData:ro" \
92126
-e "MODEL_PATH=/ModelData" \
93127
-e "FD_API_PORT=${FD_API_PORT}" \
94128
-e "FD_ENGINE_QUEUE_PORT=${FD_ENGINE_QUEUE_PORT}" \
95129
-e "FD_METRICS_PORT=${FD_METRICS_PORT}" \
130+
-e "FLASK_PORT=${FLASK_PORT}" \
96131
-e "fd_wheel_url=${fd_wheel_url}" \
97-
--gpus '"device='"${DEVICES}"'"' ${docker_image} /bin/bash -c '
132+
--gpus "\"device=${DEVICES}\"" ${docker_image} /bin/bash -c '
98133
git config --global --add safe.directory /workspace/FastDeploy
99134
cd FastDeploy
100-
# python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
101-
python -m pip install paddlepaddle-gpu==3.0.0.dev20250729 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
135+
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
102136
python -m pip install ${fd_wheel_url}
103137
bash scripts/run_pre_ce.sh
104138
'

0 commit comments

Comments
 (0)