【Hackathon 9th No.109】[CppExtension] 添加 fastdeploy_ops 目录到 package_data 以支持现代打包方式 (#5156)
Some checks failed
CE Compile Job / ce_job_pre_check (push) Has been cancelled
Deploy GitHub Pages / deploy (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
Publish Job / publish_pre_check (push) Has been cancelled
Publish Job / print_publish_pre_check_outputs (push) Has been cancelled
Publish Job / FD-Clone-Linux (push) Has been cancelled
Publish Job / Show Code Archive Output (push) Has been cancelled
Publish Job / BUILD_SM8090 (push) Has been cancelled
Publish Job / BUILD_SM8689 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8090 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8689 (push) Has been cancelled
Publish Job / Run FD Image Build (push) Has been cancelled
Publish Job / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
Publish Job / Run FastDeploy LogProb Tests (push) Has been cancelled
Publish Job / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
Publish Job / Run Base Tests (push) Has been cancelled
Publish Job / Run Accuracy Tests (push) Has been cancelled
Publish Job / Run Stable Tests (push) Has been cancelled
CI Images Build / FD-Clone-Linux (push) Has been cancelled
CI Images Build / Show Code Archive Output (push) Has been cancelled
CI Images Build / CI Images Build (push) Has been cancelled
CI Images Build / BUILD_SM8090 (push) Has been cancelled
CI Images Build / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
CI Images Build / Run FastDeploy LogProb Tests (push) Has been cancelled
CI Images Build / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
CI Images Build / Run Base Tests (push) Has been cancelled
CI Images Build / Publish Docker Images Pre Check (push) Has been cancelled

---------

Co-authored-by: YuBaoku <49938469+EmmonsCurse@users.noreply.github.com>
Co-authored-by: SigureMo <sigure.qaq@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
megemini
2025-11-22 01:32:06 +08:00
committed by GitHub
parent cceaba1c8d
commit c06cfe2447
11 changed files with 83 additions and 55 deletions

View File

@@ -143,7 +143,7 @@ jobs:
-v "${CACHE_DIR}/ConfigDir:/root/.config" \
-e TZ="Asia/Shanghai" \
--gpus '"device='"${DEVICES}"'"' ${docker_image} /bin/bash -xc '
python -m pip install paddlepaddle-gpu==3.3.0.dev20251118 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

View File

@@ -143,7 +143,7 @@ jobs:
-v "${CACHE_DIR}/ConfigDir:/root/.config" \
-e TZ="Asia/Shanghai" \
--gpus '"device='"${DEVICES}"'"' ${docker_image} /bin/bash -xc '
python -m pip install paddlepaddle-gpu==3.3.0.dev20251118 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

View File

@@ -155,7 +155,7 @@ jobs:
elif [[ "${PADDLEVERSION}" != "" ]];then
python -m pip install paddlepaddle-gpu==${PADDLEVERSION} -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
else
python -m pip install paddlepaddle-gpu==3.3.0.dev20251118 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
fi
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

View File

@@ -134,7 +134,7 @@ jobs:
-v "${CACHE_DIR}/ConfigDir:/root/.config" \
-e TZ="Asia/Shanghai" \
--gpus '"device='"${DEVICES}"'"' ${docker_image} /bin/bash -xc '
python -m pip install paddlepaddle-gpu==3.3.0.dev20251118 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

View File

@@ -154,7 +154,7 @@ jobs:
--gpus "\"device=${DEVICES}\"" ${docker_image} /bin/bash -c '
git config --global --add safe.directory /workspace/FastDeploy
cd FastDeploy
python -m pip install paddlepaddle-gpu==3.3.0.dev20251118 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
python -m pip install ${fd_wheel_url}
bash scripts/run_pre_ce.sh
'

View File

@@ -146,7 +146,7 @@ jobs:
-v "${CACHE_DIR}/ConfigDir:/root/.config" \
-e TZ="Asia/Shanghai" \
--gpus '"device='"${DEVICES}"'"' ${docker_image} /bin/bash -xc '
python -m pip install paddlepaddle-gpu==3.3.0.dev20251118 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

View File

@@ -175,7 +175,7 @@ jobs:
git config --global --add safe.directory /workspace/FastDeploy
cd FastDeploy
git diff origin/${BASE_REF}..HEAD --unified=0 > diff.txt
python -m pip install paddlepaddle-gpu==3.3.0.dev20251118 -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/
pip config set global.extra-index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python -m pip install -r scripts/unittest_requirement.txt

View File

@@ -77,47 +77,49 @@ function copy_ops(){
PY_VERSION="py${PY_MAIN_VERSION}.${PY_SUB_VERSION}"
SYSTEM_VERSION=`${python} -c "import platform; print(platform.system().lower())"`
PROCESSOR_VERSION=`${python} -c "import platform; print(platform.processor())"`
WHEEL_NAME="fastdeploy_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
WHEEL_CPU_NAME="fastdeploy_cpu_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
EGG_NAME="fastdeploy_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
EGG_CPU_NAME="fastdeploy_cpu_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
# Add compatibility for modern python packaging methods
WHEEL_MODERN_NAME="fastdeploy_ops"
WHEEL_MODERN_CPU_NAME="fastdeploy_cpu_ops"
LEGACY_PACKAGE_DIR="${OPS_TMP_DIR}/${EGG_NAME}"
MODERN_PACKAGE_DIR="${OPS_TMP_DIR}/fastdeploy_ops"
LEGACY_PACKAGE_DIR_CPU="${OPS_TMP_DIR}/${EGG_CPU_NAME}"
MODERN_PACKAGE_DIR_CPU="${OPS_TMP_DIR}/fastdeploy_cpu_ops"
# Handle GPU ops directories (WHEEL_MODERN_NAME and WHEEL_NAME)
if [ -d "./${OPS_TMP_DIR}/${WHEEL_MODERN_NAME}" ]; then
# Handle GPU ops directory compatibility between modern and legacy naming
if [ -d "${MODERN_PACKAGE_DIR}" ]; then
echo -e "${GREEN}[Info]${NONE} Ready to copy ops from modern directory ${WHEEL_MODERN_NAME} to target directory"
# Set WHEEL_NAME to empty string to ignore the directory path
WHEEL_NAME=""
TMP_PACKAGE_DIR="${OPS_TMP_DIR}"
# If modern directory doesn't exist, check for legacy directory, this branch should be removed in the future
elif [ -d "${LEGACY_PACKAGE_DIR}" ]; then
echo -e "${YELLOW}[Warning]${NONE} ${EGG_NAME} directory exists. This is a legacy packaging and distribution method."
TMP_PACKAGE_DIR="${LEGACY_PACKAGE_DIR}"
else
# If modern directory doesn't exist, check for deprecated directory
if [ -d "./${OPS_TMP_DIR}/${WHEEL_NAME}" ]; then
echo -e "${YELLOW}[Warning]${NONE} ${WHEEL_NAME} directory exists. This is a deprecated packaging and distribution method."
fi
echo -e "${RED}[Error]${NONE} Neither modern nor legacy directory for gpu ops found in ${OPS_TMP_DIR}"
fi
# Handle CPU ops directories (WHEEL_MODERN_CPU_NAME and WHEEL_CPU_NAME)
if [ -d "./${OPS_TMP_DIR}/${WHEEL_MODERN_CPU_NAME}" ]; then
# Handle CPU ops directory compatibility between modern and legacy naming
if [ -d "${MODERN_PACKAGE_DIR_CPU}" ]; then
echo -e "${GREEN}[Info]${NONE} Ready to copy ops from modern directory ${WHEEL_MODERN_CPU_NAME} to target directory"
# Set WHEEL_CPU_NAME to empty string to ignore the directory path
WHEEL_CPU_NAME=""
TMP_PACKAGE_DIR_BASE="${OPS_TMP_DIR}"
# If modern directory doesn't exist, check for legacy directory, this branch should be removed in the future
elif [ -d "${LEGACY_PACKAGE_DIR_CPU}" ]; then
echo -e "${YELLOW}[Warning]${NONE} ${EGG_CPU_NAME} directory exists. This is a legacy packaging and distribution method."
TMP_PACKAGE_DIR_BASE="${LEGACY_PACKAGE_DIR_CPU}"
else
# If modern directory doesn't exist, check for deprecated directory
if [ -d "./${OPS_TMP_DIR}/${WHEEL_CPU_NAME}" ]; then
echo -e "${YELLOW}[Warning]${NONE} ${WHEEL_CPU_NAME} directory exists. This is a deprecated packaging and distribution method."
fi
echo -e "${YELLOW}[Warning]${NONE} Neither modern nor legacy directory for cpu ops found in ${OPS_TMP_DIR}"
fi
is_rocm=`$python -c "import paddle; print(paddle.is_compiled_with_rocm())"`
if [ "$is_rocm" = "True" ]; then
DEVICE_TYPE="rocm"
cp -r ./${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/gpu
cp -r ${TMP_PACKAGE_DIR}/* ../fastdeploy/model_executor/ops/gpu
echo -e "ROCM ops have been copy to fastdeploy"
return
fi
is_cuda=`$python -c "import paddle; print(paddle.is_compiled_with_cuda())"`
if [ "$is_cuda" = "True" ]; then
DEVICE_TYPE="gpu"
cp -r ./${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/gpu
cp -r ${TMP_PACKAGE_DIR}/* ../fastdeploy/model_executor/ops/gpu
echo -e "CUDA ops have been copy to fastdeploy"
return
fi
@@ -125,7 +127,7 @@ function copy_ops(){
is_xpu=`$python -c "import paddle; print(paddle.is_compiled_with_xpu())"`
if [ "$is_xpu" = "True" ]; then
DEVICE_TYPE="xpu"
cp -r ./${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/xpu
cp -r ${TMP_PACKAGE_DIR}/* ../fastdeploy/model_executor/ops/xpu
echo -e "xpu ops have been copy to fastdeploy"
return
fi
@@ -133,7 +135,7 @@ function copy_ops(){
is_npu=`$python -c "import paddle; print(paddle.is_compiled_with_custom_device('npu'))"`
if [ "$is_npu" = "True" ]; then
DEVICE_TYPE="npu"
cp -r ${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/npu
cp -r ${TMP_PACKAGE_DIR}/* ../fastdeploy/model_executor/ops/npu
echo -e "npu ops have been copy to fastdeploy"
return
fi
@@ -141,7 +143,7 @@ function copy_ops(){
if_corex=`$python -c "import paddle; print(paddle.is_compiled_with_custom_device(\"iluvatar_gpu\"))"`
if [ "$if_corex" = "True" ]; then
DEVICE_TYPE="iluvatar-gpu"
cp -r ./${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/iluvatar
cp -r ${TMP_PACKAGE_DIR}/* ../fastdeploy/model_executor/ops/iluvatar
echo -e "Iluvatar ops have been copy to fastdeploy"
return
fi
@@ -149,7 +151,7 @@ function copy_ops(){
is_gcu=`$python -c "import paddle; print(paddle.is_compiled_with_custom_device('gcu'))"`
if [ "$is_gcu" = "True" ]; then
DEVICE_TYPE="gcu"
cp -r ${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/gcu
cp -r ${TMP_PACKAGE_DIR}/* ../fastdeploy/model_executor/ops/gcu
echo -e "gcu ops have been copy to fastdeploy"
return
fi
@@ -158,8 +160,8 @@ function copy_ops(){
if [ "$is_maca" = "True" ]; then
DEVICE_TYPE="metax_gpu"
mkdir -p ../fastdeploy/model_executor/ops/base
cp -r ./${OPS_TMP_DIR_BASE}/${WHEEL_BASE_NAME}/* ../fastdeploy/model_executor/ops/base
cp -r ./${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/gpu
cp -r ${OPS_TMP_DIR_BASE}/${WHEEL_BASE_NAME}/* ../fastdeploy/model_executor/ops/base
cp -r ${TMP_PACKAGE_DIR}/* ../fastdeploy/model_executor/ops/gpu
echo -e "MACA ops have been copy to fastdeploy"
return
fi
@@ -249,8 +251,14 @@ function extract_ops_from_precompiled_wheel() {
echo -e "${BLUE}[precompiled]${NONE} Copying GPU precompiled contents..."
mkdir -p "$DST_DIR"
cp -r "$SRC_DIR/deep_gemm" "$DST_DIR/" 2>/dev/null || true
cp -r "$SRC_DIR/fastdeploy_ops.py" "$DST_DIR/" 2>/dev/null || true
cp -f "$SRC_DIR/"fastdeploy_ops_*.so "$DST_DIR/" 2>/dev/null || true
# Check for modern Python packaging approach (fastdeploy_ops directory)
# If exists, copy the entire directory; otherwise, fall back to legacy method (individual files)
if [ -d "$SRC_DIR/fastdeploy_ops" ]; then
cp -r "$SRC_DIR/fastdeploy_ops" "$DST_DIR/" 2>/dev/null || true
else
cp -r "$SRC_DIR/fastdeploy_ops.py" "$DST_DIR/" 2>/dev/null || true
cp -f "$SRC_DIR/"fastdeploy_ops_*.so "$DST_DIR/" 2>/dev/null || true
fi
cp -f "$SRC_DIR/version.txt" "$DST_DIR/" 2>/dev/null || true
echo -e "${GREEN}[SUCCESS]${NONE} Installed FastDeploy using precompiled wheel."

View File

@@ -24,30 +24,39 @@ PY_SUB_VERSION=`${python} -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}'`
PY_VERSION="py${PY_MAIN_VERSION}.${PY_SUB_VERSION}"
SYSTEM_VERSION=`${python} -c "import platform; print(platform.system().lower())"`
PROCESSOR_VERSION=`${python} -c "import platform; print(platform.processor())"`
WHEEL_NAME="fastdeploy_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
EGG_NAME="fastdeploy_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
# Add compatibility for modern python packaging methods
WHEEL_MODERN_NAME="fastdeploy_ops"
LEGACY_PACKAGE_DIR="${OPS_TMP_DIR}/${EGG_NAME}"
MODERN_PACKAGE_DIR="${OPS_TMP_DIR}/fastdeploy_ops"
# Check if OPS_TMP_DIR exists, create it if it doesn't
if [ ! -d "${OPS_TMP_DIR}" ]; then
echo -e "${GREEN}[Info]${NONE} Creating directory ${OPS_TMP_DIR}"
mkdir -p "${OPS_TMP_DIR}"
fi
${python} setup_ops.py install --install-lib ${OPS_TMP_DIR}
# Handle directory compatibility between modern and legacy naming
if [ -d "./${OPS_TMP_DIR}/${WHEEL_MODERN_NAME}" ]; then
echo -e "${GREEN}[Info]${NONE} Ready to use ops from modern directory ${WHEEL_MODERN_NAME}"
if [ -d "${MODERN_PACKAGE_DIR}" ]; then
echo -e "${GREEN}[Info]${NONE} Ready to use ops from modern directory ${MODERN_PACKAGE_DIR}"
# Use modern directory name
TARGET_DIR="${OPS_TMP_DIR}/${WHEEL_MODERN_NAME}"
else
# If modern directory doesn't exist, check for legacy directory
if [ -d "./${OPS_TMP_DIR}/${WHEEL_NAME}" ]; then
echo -e "${YELLOW}[Warning]${NONE} ${WHEEL_NAME} directory exists. This is a deprecated packaging and distribution method."
else
echo -e "${RED}[Error]${NONE} Neither modern nor legacy directory found in ${OPS_TMP_DIR}"
fi
TMP_PACKAGE_DIR="${OPS_TMP_DIR}"
CUSTOM_OP_DLL_RPATH='$ORIGIN/../libs'
CUSTOM_OP_DLL_PATH="${MODERN_PACKAGE_DIR}/fastdeploy_ops_pd_.so"
# If modern directory doesn't exist, check for legacy directory, this branch should be removed in the future
elif [ -d "${LEGACY_PACKAGE_DIR}" ]; then
echo -e "${YELLOW}[Warning]${NONE} ${LEGACY_PACKAGE_DIR} directory exists. This is a deprecated packaging and distribution method."
# Use legacy directory name
TARGET_DIR="${OPS_TMP_DIR}/${WHEEL_NAME}"
TMP_PACKAGE_DIR="${LEGACY_PACKAGE_DIR}"
CUSTOM_OP_DLL_RPATH='$ORIGIN/libs'
CUSTOM_OP_DLL_PATH="${TMP_PACKAGE_DIR}/fastdeploy_ops_pd_.so"
else
echo -e "${RED}[Error]${NONE} Neither modern nor legacy directory for xpu ops found in ${OPS_TMP_DIR}"
fi
mkdir -p ${TARGET_DIR}/libs
cp ${XVLLM_PATH}/xft_blocks/so/libxft_blocks.so ${TARGET_DIR}/libs/
cp ${XVLLM_PATH}/infer_ops/so/libapiinfer.so ${TARGET_DIR}/libs/
patchelf --set-rpath '$ORIGIN/libs' ${TARGET_DIR}/fastdeploy_ops_pd_.so
mkdir -p ${TMP_PACKAGE_DIR}/libs
cp ${XVLLM_PATH}/xft_blocks/so/libxft_blocks.so ${TMP_PACKAGE_DIR}/libs/
cp ${XVLLM_PATH}/infer_ops/so/libapiinfer.so ${TMP_PACKAGE_DIR}/libs/
patchelf --set-rpath ${CUSTOM_OP_DLL_RPATH} ${CUSTOM_OP_DLL_PATH}

View File

@@ -42,7 +42,7 @@ echo "uninstall org"
python -m pip uninstall paddlepaddle-xpu -y
python -m pip uninstall fastdeploy-xpu -y
python -m pip install https://paddle-whl.bj.bcebos.com/nightly/xpu-p800/paddlepaddle-xpu/paddlepaddle_xpu-3.3.0.dev20251118-cp310-cp310-linux_x86_64.whl
python -m pip install paddlepaddle-xpu -i https://www.paddlepaddle.org.cn/packages/nightly/xpu-p800/
echo "build whl"
bash custom_ops/xpu_ops/download_dependencies.sh develop

View File

@@ -275,20 +275,31 @@ setup(
url="https://github.com/PaddlePaddle/FastDeploy",
packages=find_packages(),
package_dir={"fastdeploy": "fastdeploy/"},
# For deprecated method (egg-based installation), `.so` files are placed in the `model_executor/ops/XXX` directory.
# For modern method (PEP 517/518-based installation), `.so` files are placed in the `model_executor/ops/XXX/fastdeploy_ops` directory.
# Therefore, the `fastdeploy_ops` directory should be included for modern Python packaging.
package_data={
"fastdeploy": [
"model_executor/ops/gpu/*",
"model_executor/ops/gpu/fastdeploy_ops/*",
"model_executor/ops/gpu/deep_gemm/include/**/*",
"model_executor/ops/cpu/*",
"model_executor/ops/cpu/fastdeploy_cpu_ops/*",
"model_executor/ops/xpu/*",
"model_executor/ops/xpu/fastdeploy_ops/*",
"model_executor/ops/xpu/libs/*",
"model_executor/ops/xpu/fastdeploy_ops/libs/*",
"model_executor/ops/npu/*",
"model_executor/ops/npu/fastdeploy_ops/*",
"model_executor/ops/base/*",
"model_executor/ops/base/fastdeploy_ops/*",
"model_executor/ops/iluvatar/*",
"model_executor/ops/iluvatar/fastdeploy_ops/*",
"model_executor/models/*",
"model_executor/layers/*",
"input/ernie4_5_vl_processor/utils/*",
"model_executor/ops/gcu/*",
"model_executor/ops/gcu/fastdeploy_ops/*",
"version.txt",
]
},