diff --git a/.github/workflows/release_packages.yml b/.github/workflows/release_packages.yml new file mode 100644 index 000000000..565f98615 --- /dev/null +++ b/.github/workflows/release_packages.yml @@ -0,0 +1,153 @@ +name: Release Packages + +on: + create: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + build-deb: + runs-on: [self-hosted, Linux, X64, spr, sg] + container: + image: registry-1.docker.io/dashinfer/dev-ubuntu-22.04-x86:v1 + defaults: + run: + shell: bash -l {0} + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + fetch-tags: true + + - name: Pull LFS + run: | + git lfs pull + + - name: Build deb package + run: | + TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1)) + VERSION_NUMBER=$(echo "$TAG_NAME" | sed 's/^v//') + source activate ds_py + AS_RELEASE_VERSION=$VERSION_NUMBER \ + AS_PLATFORM="x86" \ + AS_BUILD_PACKAGE=ON \ + bash build.sh + + - name: Upload deb package + uses: actions/upload-artifact@v3 + with: + name: dashinfer-deb + path: build/*.deb + + build-rpm: + strategy: + matrix: + os: [spr, yitian] + image: ["dev-centos7-x86:v1", "dev-alinux-arm:v1"] + exclude: + - os: spr + image: "dev-alinux-arm:v1" + - os: yitian + image: "dev-centos7-x86:v1" + runs-on: [self-hosted, Linux, "${{ matrix.os }}", sg] + container: + image: registry-1.docker.io/dashinfer/${{ matrix.image }} + defaults: + run: + shell: bash -l {0} + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + lfs: true + fetch-tags: true + + - name: Pull LFS + run: | + git lfs pull + + - name: Build rpm package + run: | + TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1)) + VERSION_NUMBER=$(echo "$TAG_NAME" | sed 's/^v//') + source /opt/rh/devtoolset-7/enable + source activate ds_py + AS_RELEASE_VERSION=$VERSION_NUMBER \ + AS_PLATFORM="x86" \ + AS_BUILD_PACKAGE=ON \ + bash build.sh + + - name: Upload rpm package + uses: actions/upload-artifact@v3 + with: + name: dashinfer-rpm-${{ matrix.os }} + path: build/*.rpm + + + build-wheels: + strategy: + matrix: + os: [spr, yitian] + image: ["dev-manylinux-x86:v1", "dev-manylinux-arm:v1"] + exclude: + - os: spr + image: "dev-manylinux-arm:v1" + - os: yitian + image: "dev-manylinux-x86:v1" + runs-on: [self-hosted, Linux, "${{ matrix.os }}", sg] + container: + image: registry-1.docker.io/dashinfer/${{ matrix.image }} + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + lfs: true + fetch-tags: true + + - name: Build manylinux wheels + run: | + TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1)) + VERSION_NUMBER=$(echo "$TAG_NAME" | sed 's/^v//') + AS_RELEASE_VERSION=$VERSION_NUMBER bash scripts/release/python_manylinux_build.sh + + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: python-manylinux-wheels-${{ matrix.os }} + path: python/wheelhouse/*-manylinux*.whl + + test: + strategy: + matrix: + os: [spr, yitian] + image: ["test-ubuntu-x86:v1", "test-centos-arm:v1"] + exclude: + - os: spr + image: "test-centos-arm:v1" + - os: yitian + image: "test-ubuntu-x86:v1" + runs-on: [self-hosted, Linux, "${{ matrix.os }}", sg] + container: + image: registry-1.docker.io/dashinfer/${{ matrix.image }} + volumes: + - /mnt/data0/models/modelscope:/github/home/.cache/modelscope + options: "--ipc=host --cap-add SYS_NICE --cap-add SYS_PTRACE" + needs: build-wheels + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Download wheels + uses: actions/download-artifact@v3 + with: + name: python-manylinux-wheels-${{ matrix.os }} + path: python/wheelhouse + + - name: Test manylinux wheels + run: | + TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1)) + VERSION_NUMBER=$(echo "$TAG_NAME" | sed 's/^v//') + AS_RELEASE_VERSION=$VERSION_NUMBER bash scripts/release/python_manylinux_test.sh + + + diff --git a/build.sh b/build.sh index 2aeecc34b..2a0ce257b 100755 --- a/build.sh +++ b/build.sh @@ -2,12 +2,29 @@ set -x clean="OFF" +# 捕获arch命令的输出 +architecture=$(arch) + +# 使用if-else结构进行条件判断 +if [ "${architecture}" == "aarch64" ]; then + export AS_PLATFORM=armclang +else + export AS_PLATFORM=x86 +fi + +if [ -z "$AS_PLATFORM" ]; +then + echo " please set AS_PLATFORM env, AS_PLATFORM can be x86 or armclang" + exit 1 +fi + # with_platform, to support x86/arm build -with_platform="${AS_PLATFORM:-x86}" +with_platform="${AS_PLATFORM}" build_type="${AS_BUILD_TYPE:-Release}" build_package="${AS_BUILD_PACKAGE:-OFF}" enable_glibcxx11_abi="${AS_CXX11_ABI:-ON}" # default enable cxx11 ABI + function clone_pull { GIT_URL=$1 DIRECTORY=$2 diff --git a/scripts/release/python_manylinux_build.sh b/scripts/release/python_manylinux_build.sh index 1745c45ac..5283b8f07 100755 --- a/scripts/release/python_manylinux_build.sh +++ b/scripts/release/python_manylinux_build.sh @@ -1,9 +1,17 @@ #!/bin/bash set -e -x +ALL_VERSION="3.8 3.9 3.10 3.11" +BUILD_VERSION=${@:-$ALL_VERSION} + +echo " going to build python wheels with version: ${BUILD_VERSION}" + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +REPO_ROOT=$( dirname -- "$( dirname -- "${SCRIPT_DIR}" )" ) + source activate ds_py +pushd $SCRIPT_DIR -repo_root=/root/workspace/DashInfer # 捕获arch命令的输出 architecture=$(arch) @@ -31,7 +39,7 @@ function repair_wheel { echo "Skipping non-platform wheel $wheel" else # TODO: add lib path to build lib path - auditwheel repair "$wheel" --plat "$PLAT" -w ${repo_root}/python/wheelhouse/ + auditwheel repair "$wheel" --plat "$PLAT" -w ${REPO_ROOT}/python/wheelhouse/ fi } @@ -49,9 +57,9 @@ build_wheel_for_python() { conda activate "$env_name" conda install pybind11 -y - pip install -r ${repo_root}/python/dev-requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ - python ${repo_root}/python/setup.py bdist_wheel - pip wheel ${repo_root}/python --no-deps -w ${repo_root}/python/wheelhouse/ --log wheel_log.txt + pip install -r ${REPO_ROOT}/python/dev-requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ + python ${REPO_ROOT}/python/setup.py bdist_wheel + pip wheel ${REPO_ROOT}/python --no-deps -w ${REPO_ROOT}/python/wheelhouse/ --log wheel_log.txt conda deactivate # conda remove --name "$env_name" --all -y @@ -59,16 +67,17 @@ build_wheel_for_python() { # rm -rf build -mkdir -p ${repo_root}/python/wheelhouse/ +mkdir -p ${REPO_ROOT}/python/wheelhouse/ + +for python_version in $BUILD_VERSION; do + build_wheel_for_python ${python_version} 2>&1 | tee whl_build_log_py${python_version//.}.txt +done -build_wheel_for_python 3.8 2>&1 | tee whl_build_log_py38.txt -build_wheel_for_python 3.9 2>&1 | tee whl_build_log_py39.txt -build_wheel_for_python 3.10 2>&1 | tee whl_build_log_py310.txt -build_wheel_for_python 3.11 2>&1 | tee whl_build_log_py311.txt # Bundle external shared libraries into the wheels -for whl in ${repo_root}/python/wheelhouse/*.whl; do +for whl in ${REPO_ROOT}/python/wheelhouse/*.whl; do repair_wheel "$whl" done echo "Build finished, please check in wheelhouse/* for manylinux whl package" +popd diff --git a/scripts/release/python_manylinux_test.sh b/scripts/release/python_manylinux_test.sh index 8f7ee3cb8..272eed6ca 100755 --- a/scripts/release/python_manylinux_test.sh +++ b/scripts/release/python_manylinux_test.sh @@ -1,9 +1,16 @@ #!/bin/bash set -e -x -source activate test_py +ALL_VERSION="3.8 3.9 3.10 3.11" +TEST_VERSION=${@:-$ALL_VERSION} + +echo " going to test with python version: ${TEST_VERSION}" -root_path=/root/workspace/DashInfer +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +REPO_ROOT=$( dirname -- "$( dirname -- "${SCRIPT_DIR}" )" ) + +source activate test_py +pushd $SCRIPT_DIR run_python_example() { local python_version=$1 @@ -27,29 +34,30 @@ run_python_example() { conda install -y pytorch-cpu -c pytorch fi - pip install -r ${root_path}/examples/python/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ - pip install ${root_path}/python/wheelhouse/dashinfer-${AS_RELEASE_VERSION}-cp${python_version//.}-cp${python_version//.}-manylinux*.whl + pip install -r ${REPO_ROOT}/examples/python/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ + pip install ${REPO_ROOT}/python/wheelhouse/dashinfer-${AS_RELEASE_VERSION}-cp${python_version//.}-cp${python_version//.}-manylinux*.whl - cd ${root_path}/examples/python/0_basic + cd ${REPO_ROOT}/examples/python/0_basic # python basic_example_chatglm2.py # python basic_example_chatglm3.py # python basic_example_llama2.py python basic_example_qwen_v10.py python basic_example_qwen_v15.py # python basic_example_qwen_v20.py - cd ${root_path} + cd ${REPO_ROOT} - cd ${root_path}/examples/python/1_performance + cd ${REPO_ROOT}/examples/python/1_performance # python performance_test_llama2.py --config_file config_llama2_7b.json --device_ids 0 1 # python performance_test_qwen_v15.py --device_ids 0 - python performance_test_qwen_v15.py --device_ids 0 1 - cd ${root_path} + python performance_test_qwen_v15.py + cd ${REPO_ROOT} conda deactivate # conda remove --name "$env_name" --all -y } -run_python_example 3.8 2>&1 | tee whl_test_log_py38.txt -run_python_example 3.9 2>&1 | tee whl_test_log_py39.txt -run_python_example 3.10 2>&1 | tee whl_test_log_py310.txt -run_python_example 3.11 2>&1 | tee whl_test_log_py311.txt +for python_version in $TEST_VERSION; do + run_python_example $python_version 2>&1 | tee whl_test_log_py${python_version//.}.txt +done + +popd