diff --git a/.github/workflows/_accuracy_test.yml b/.github/workflows/_accuracy_test.yml index f5c2ad1cf..2dfd68aa9 100644 --- a/.github/workflows/_accuracy_test.yml +++ b/.github/workflows/_accuracy_test.yml @@ -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 diff --git a/.github/workflows/_base_test.yml b/.github/workflows/_base_test.yml index 3c30a8e23..6dbf1f6d2 100644 --- a/.github/workflows/_base_test.yml +++ b/.github/workflows/_base_test.yml @@ -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 diff --git a/.github/workflows/_build_linux.yml b/.github/workflows/_build_linux.yml index 06d55801e..495f3e3f0 100644 --- a/.github/workflows/_build_linux.yml +++ b/.github/workflows/_build_linux.yml @@ -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 diff --git a/.github/workflows/_logprob_test_linux.yml b/.github/workflows/_logprob_test_linux.yml index cdf985ae5..8ca3c7d7f 100644 --- a/.github/workflows/_logprob_test_linux.yml +++ b/.github/workflows/_logprob_test_linux.yml @@ -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 diff --git a/.github/workflows/_pre_ce_test.yml b/.github/workflows/_pre_ce_test.yml index f2841aa0b..4db325677 100644 --- a/.github/workflows/_pre_ce_test.yml +++ b/.github/workflows/_pre_ce_test.yml @@ -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 ' diff --git a/.github/workflows/_stable_test.yml b/.github/workflows/_stable_test.yml index b91056af7..f39b90767 100644 --- a/.github/workflows/_stable_test.yml +++ b/.github/workflows/_stable_test.yml @@ -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 diff --git a/.github/workflows/_unit_test_coverage.yml b/.github/workflows/_unit_test_coverage.yml index c24a5cfc8..fa19a781a 100644 --- a/.github/workflows/_unit_test_coverage.yml +++ b/.github/workflows/_unit_test_coverage.yml @@ -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 diff --git a/build.sh b/build.sh index e63dd9043..27f6d249f 100644 --- a/build.sh +++ b/build.sh @@ -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." diff --git a/custom_ops/xpu_ops/build.sh b/custom_ops/xpu_ops/build.sh index a141cf866..220f1974d 100755 --- a/custom_ops/xpu_ops/build.sh +++ b/custom_ops/xpu_ops/build.sh @@ -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} diff --git a/scripts/run_ci_xpu.sh b/scripts/run_ci_xpu.sh index 2672755d6..a756d818b 100644 --- a/scripts/run_ci_xpu.sh +++ b/scripts/run_ci_xpu.sh @@ -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 diff --git a/setup.py b/setup.py index 94cbdc817..8e6037aeb 100644 --- a/setup.py +++ b/setup.py @@ -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", ] },