From 0c25d9255bf55b6a81ab72cc50d74d29291fe1fc Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Tue, 16 Jul 2024 17:46:41 -0700 Subject: [PATCH] Lluo/auto release cherry pick main (#2992) --- .github/scripts/generate-release-matrix.py | 70 ++++++ .github/workflows/build-test-linux.yml | 2 +- .github/workflows/build-test-windows.yml | 2 +- .github/workflows/release-linux.yml | 130 ++++++++++ .github/workflows/release-wheel-linux.yml | 260 ++++++++++++++++++++ .github/workflows/release-wheel-windows.yml | 213 ++++++++++++++++ .github/workflows/release-windows.yml | 87 +++++++ 7 files changed, 762 insertions(+), 2 deletions(-) create mode 100644 .github/scripts/generate-release-matrix.py create mode 100644 .github/workflows/release-linux.yml create mode 100644 .github/workflows/release-wheel-linux.yml create mode 100644 .github/workflows/release-wheel-windows.yml create mode 100644 .github/workflows/release-windows.yml diff --git a/.github/scripts/generate-release-matrix.py b/.github/scripts/generate-release-matrix.py new file mode 100644 index 0000000000..e1b276184c --- /dev/null +++ b/.github/scripts/generate-release-matrix.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 + +import argparse +import json +import sys + +RELEASE_CUDA_VERSION = { + "wheel": ["cu124"], + "tarball": ["cu124"], +} +RELEASE_PYTHON_VERSION = { + "wheel": ["3.8", "3.9", "3.10", "3.11", "3.12"], + "tarball": ["3.10"], +} + +CXX11_TARBALL_CONTAINER_IMAGE = { + "cu124": "pytorch/libtorch-cxx11-builder:cuda12.4-main", +} + + +def main(args: list[str]) -> None: + parser = argparse.ArgumentParser() + parser.add_argument( + "--wheel_matrix", + help="wheel matrix", + type=str, + default="", + ) + parser.add_argument( + "--tarball_matrix", + help="tarball matrix", + type=str, + default="", + ) + options = parser.parse_args(args) + cuda_versions = [] + python_versions = [] + + if options.tarball_matrix != "": + cuda_versions = RELEASE_CUDA_VERSION["tarball"] + python_versions = RELEASE_PYTHON_VERSION["tarball"] + matrix_dict = json.loads(options.tarball_matrix) + elif options.wheel_matrix != "": + cuda_versions = RELEASE_CUDA_VERSION["wheel"] + python_versions = RELEASE_PYTHON_VERSION["wheel"] + matrix_dict = json.loads(options.wheel_matrix) + else: + raise Exception( + "Either --wheel_matrix or --tarball_matrix needs to be provided" + ) + + includes = matrix_dict["include"] + filtered_includes = [] + for item in includes: + if ( + item["desired_cuda"] in cuda_versions + and item["python_version"] in python_versions + ): + if options.tarball_matrix != "": + item["container_image"] = CXX11_TARBALL_CONTAINER_IMAGE[ + item["desired_cuda"] + ] + filtered_includes.append(item) + filtered_matrix_dict = {} + filtered_matrix_dict["include"] = filtered_includes + print(json.dumps(filtered_matrix_dict)) + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index b862673f0b..7476309266 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -200,7 +200,7 @@ jobs: pushd . cd tests/py/dynamo python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/ - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_comple_be_e2e_test_results.xml --ir torch_compile models/test_models.py + python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_complete_be_e2e_test_results.xml --ir torch_compile models/test_models.py python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py popd diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml index 1bdb52ae8a..b3f0352042 100644 --- a/.github/workflows/build-test-windows.yml +++ b/.github/workflows/build-test-windows.yml @@ -193,7 +193,7 @@ jobs: pushd . cd tests/py/dynamo python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/ - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_comple_be_e2e_test_results.xml --ir torch_compile models/test_models.py + python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_complete_be_e2e_test_results.xml --ir torch_compile models/test_models.py python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py popd diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml new file mode 100644 index 0000000000..53ed569725 --- /dev/null +++ b/.github/workflows/release-linux.yml @@ -0,0 +1,130 @@ +name: Release Linux wheels and tarball artifacts + +on: + push: + tags: + # NOTE: Binary build pipelines should only get triggered on release candidate builds + # Release candidate tags look like: v1.11.0-rc1 + - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ + workflow_dispatch: + +permissions: + id-token: write + contents: read + packages: write + +jobs: + generate-matrix: + uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main + if: ${{ contains(github.event.pull_request.labels.*.name, 'build-release-artifacts') || startsWith(github.event.ref, 'refs/tags/v') }} + with: + package-type: wheel + os: linux + test-infra-repository: pytorch/test-infra + test-infra-ref: main + with-rocm: false + with-cpu: false + + generate-release-tarball-matrix: + needs: [generate-matrix] + outputs: + matrix: ${{ steps.generate.outputs.matrix }} + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - uses: actions/checkout@v3 + with: + repository: pytorch/tensorrt + - name: Generate release matrix + id: generate + run: | + set -eou pipefail + MATRIX_BLOB=${{ toJSON(needs.generate-matrix.outputs.matrix) }} + MATRIX_BLOB="$(python3 .github/scripts/generate-release-matrix.py --tarball_matrix "${MATRIX_BLOB}")" + echo "${MATRIX_BLOB}" + echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}" + + release-cxx11-tarball-artifacts: + needs: [generate-release-tarball-matrix] + name: Release torch-tensorrt cxx11 tarball artifacts + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + env-var-script: packaging/env_vars.txt + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + cxx11-tarball-release: "true" + uses: ./.github/workflows/release-wheel-linux.yml + with: + repository: ${{ matrix.repository }} + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-release-tarball-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + env-var-script: ${{ matrix.env-var-script }} + post-script: ${{ matrix.post-script }} + package-name: ${{ matrix.package-name }} + smoke-test-script: ${{ matrix.smoke-test-script }} + trigger-event: ${{ github.event_name }} + cxx11-tarball-release: "true" + + generate-release-wheel-matrix: + needs: [generate-matrix] + outputs: + matrix: ${{ steps.generate.outputs.matrix }} + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - uses: actions/checkout@v3 + with: + repository: pytorch/tensorrt + - name: Generate release matrix + id: generate + run: | + set -eou pipefail + MATRIX_BLOB=${{ toJSON(needs.generate-matrix.outputs.matrix) }} + MATRIX_BLOB="$(python3 .github/scripts/generate-release-matrix.py --wheel_matrix "${MATRIX_BLOB}")" + echo "${MATRIX_BLOB}" + echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}" + + release-other-artifacts: + name: Release torch-tensorrt wheel and pre-cxx11 tarball artifacts + needs: [generate-release-wheel-matrix] + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + env-var-script: packaging/env_vars.txt + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + cxx11-tarball-release: "true" + uses: ./.github/workflows/release-wheel-linux.yml + with: + repository: ${{ matrix.repository }} + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-release-wheel-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + env-var-script: ${{ matrix.env-var-script }} + post-script: ${{ matrix.post-script }} + package-name: ${{ matrix.package-name }} + smoke-test-script: ${{ matrix.smoke-test-script }} + trigger-event: ${{ github.event_name }} + cxx11-tarball-release: "false" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} + cancel-in-progress: true \ No newline at end of file diff --git a/.github/workflows/release-wheel-linux.yml b/.github/workflows/release-wheel-linux.yml new file mode 100644 index 0000000000..3977b82336 --- /dev/null +++ b/.github/workflows/release-wheel-linux.yml @@ -0,0 +1,260 @@ +name: Build Release Wheel Artifacts on Linux + +on: + workflow_call: + inputs: + repository: + description: 'Repository to checkout, defaults to ""' + default: "" + type: string + ref: + description: 'Reference to checkout, defaults to "nightly"' + default: "nightly" + type: string + test-infra-repository: + description: "Test infra repository to use" + default: "pytorch/test-infra" + type: string + test-infra-ref: + description: "Test infra reference to use" + default: "" + type: string + build-matrix: + description: "Build matrix to utilize" + default: "" + type: string + pre-script: + description: "Pre script to run prior to build" + default: "" + type: string + post-script: + description: "Post script to run prior to build" + default: "" + type: string + smoke-test-script: + description: "Script for Smoke Test for a specific domain" + default: "" + type: string + env-var-script: + description: "Script that sets Domain-Specific Environment Variables" + default: "" + type: string + package-name: + description: "Name of the actual python package that is imported" + default: "" + type: string + trigger-event: + description: "Trigger Event in caller that determines whether or not to upload" + default: "" + type: string + cache-path: + description: "The path(s) on the runner to cache or restore. The path is relative to repository." + default: "" + type: string + cache-key: + description: "The key created when saving a cache and the key used to search for a cache." + default: "" + type: string + architecture: + description: Architecture to build for x86_64 for default Linux, or aarch64 for Linux aarch64 builds + required: false + type: string + default: x86_64 + submodules: + description: Works as stated in actions/checkout, but the default value is recursive + required: false + type: string + default: recursive + setup-miniconda: + description: Set to true if setup-miniconda is needed + required: false + type: boolean + default: true + cxx11-tarball-release: + description: "Flag whether this is the cxx11 tarball release" + required: true + type: string + default: "false" + +permissions: + id-token: write + contents: read + +jobs: + release: + strategy: + fail-fast: false + matrix: ${{ fromJSON(inputs.build-matrix) }} + env: + PYTHON_VERSION: ${{ matrix.python_version }} + PACKAGE_TYPE: wheel + REPOSITORY: ${{ inputs.repository }} + REF: ${{ inputs.ref }} + CU_VERSION: ${{ matrix.desired_cuda }} + UPLOAD_TO_BASE_BUCKET: ${{ matrix.upload_to_base_bucket }} + ARCH: ${{ inputs.architecture }} + name: release_${{ matrix.build_name }} + runs-on: ${{ matrix.validation_runner }} + container: + image: ${{ matrix.container_image }} + options: ${{ matrix.gpu_arch_type == 'cuda' && '--gpus all' || ' ' }} + # If a build is taking longer than 120 minutes on these runners we need + # to have a conversation + timeout-minutes: 120 + + steps: + - name: Clean workspace + shell: bash -l {0} + run: | + set -x + echo "::group::Cleanup debug output" + rm -rf "${GITHUB_WORKSPACE}" + mkdir -p "${GITHUB_WORKSPACE}" + if [[ "${{ inputs.architecture }}" = "aarch64" ]]; then + rm -rf "${RUNNER_TEMP}/*" + fi + echo "::endgroup::" + - uses: actions/checkout@v3 + with: + # Support the use case where we need to checkout someone's fork + repository: ${{ inputs.test-infra-repository }} + ref: ${{ inputs.test-infra-ref }} + path: test-infra + - uses: actions/checkout@v3 + if: ${{ env.ARCH == 'aarch64' }} + with: + # Support the use case where we need to checkout someone's fork + repository: "pytorch/builder" + ref: "main" + path: builder + - name: Set linux aarch64 CI + if: ${{ inputs.architecture == 'aarch64' }} + shell: bash -l {0} + env: + DESIRED_PYTHON: ${{ matrix.python_version }} + run: | + set +e + # TODO: This is temporary aarch64 setup script, this should be integrated into aarch64 docker. + ${GITHUB_WORKSPACE}/builder/aarch64_linux/aarch64_ci_setup.sh + echo "/opt/conda/bin" >> $GITHUB_PATH + set -e + - uses: ./test-infra/.github/actions/set-channel + - name: Set PYTORCH_VERSION + if: ${{ env.CHANNEL == 'test' }} + run: | + # When building RC, set the version to be the current candidate version, + # otherwise, leave it alone so nightly will pick up the latest + echo "PYTORCH_VERSION=${{ matrix.stable_version }}" >> "${GITHUB_ENV}" + - uses: ./test-infra/.github/actions/setup-binary-builds + env: + PLATFORM: ${{ inputs.architecture == 'aarch64' && 'linux-aarch64' || ''}} + with: + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref }} + submodules: ${{ inputs.submodules }} + setup-miniconda: ${{ inputs.setup-miniconda }} + python-version: ${{ env.PYTHON_VERSION }} + cuda-version: ${{ env.CU_VERSION }} + arch: ${{ env.ARCH }} + - name: Combine Env Var and Build Env Files + if: ${{ inputs.env-var-script != '' }} + working-directory: ${{ inputs.repository }} + shell: bash -l {0} + run: | + cat "${{ inputs.env-var-script }}" >> "${BUILD_ENV_FILE}" + - name: Install torch dependency + shell: bash -l {0} + run: | + set -x + # shellcheck disable=SC1090 + source "${BUILD_ENV_FILE}" + # shellcheck disable=SC2086 + ${CONDA_RUN} ${PIP_INSTALL_TORCH} + - name: Run Pre-Script with Caching + if: ${{ inputs.pre-script != '' }} + uses: ./test-infra/.github/actions/run-script-with-cache + with: + cache-path: ${{ inputs.cache-path }} + cache-key: ${{ inputs.cache-key }} + repository: ${{ inputs.repository }} + script: ${{ inputs.pre-script }} + - name: Build clean + working-directory: ${{ inputs.repository }} + shell: bash -l {0} + run: | + set -x + source "${BUILD_ENV_FILE}" + ${CONDA_RUN} python setup.py clean + - name: Build the wheel (bdist_wheel) + working-directory: ${{ inputs.repository }} + shell: bash -l {0} + run: | + set -x + source "${BUILD_ENV_FILE}" + + # BUILD_VERSION example: 2.4.0+cu121, we don't want the +cu121 part, so remove +cu121 + BUILD_VERSION=${BUILD_VERSION%+*} + TRT_VERSION=$(cat dev_dep_versions.yml | grep __tensorrt_version__ | sed 's/__tensorrt_version__: //g' | sed 's/"//g') + mkdir release + mkdir release/tarball + mkdir release/wheel + if [[ "${{ inputs.cxx11-tarball-release }}" == "true" ]]; then + bazel build //:libtorchtrt --compilation_mode opt --config=default + cp bazel-bin/libtorchtrt.tar.gz \ + release/tarball/libtorchtrt-${TORCHTRT_VERSION}-tensorrt${TENSORRT_VERSION}-cuda${CU_VERSION}-libtorch${PYTORCH_VERSION}-x86_64-linux.tar.gz + else + ${CONDA_RUN} python setup.py bdist_wheel --release + + cp bazel-bin/libtorchtrt.tar.gz \ + release/tarball/libtorchtrt-${BUILD_VERSION}-pre-cxx11-abi-tensorrt${TRT_VERSION}-cuda${CU_VERSION}-libtorch${BUILD_VERSION}-x86_64-linux.tar.gz + + ${CONDA_RUN} python -m pip install auditwheel + ${CONDA_RUN} python -m auditwheel repair \ + $(cat py/ci/soname_excludes.params) \ + --plat manylinux_2_34_x86_64 \ + dist/torch_tensorrt-*-linux_x86_64.whl + ${CONDA_RUN} python -m zipfile --list wheelhouse/torch_tensorrt-*_x86_64.whl + cp wheelhouse/torch_tensorrt-*_x86_64.whl release/wheel/ + fi + - name: Run Post-Script + if: ${{ inputs.post-script != '' }} + uses: ./test-infra/.github/actions/run-script-with-cache + with: + repository: ${{ inputs.repository }} + script: ${{ inputs.post-script }} + - name: Smoke Test + shell: bash -l {0} + env: + PACKAGE_NAME: ${{ inputs.package-name }} + SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }} + run: | + set -x + source "${BUILD_ENV_FILE}" + # TODO: add smoke test for the auditwheel tarball built + + # NB: Only upload to GitHub after passing smoke tests + - name: Upload wheel to GitHub + if: ${{ inputs.cxx11-tarball-release != 'true' }} + continue-on-error: true + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ inputs.repository }}/release/wheel/ + - name: Upload pre-cxx11 tarball to GitHub + if: ${{ inputs.cxx11-tarball-release != 'true' && env.PYTHON_VERSION == '3.10' }} + continue-on-error: true + uses: actions/upload-artifact@v3 + with: + name: pre-cxx11-tarball-${{ env.PYTHON_VERSION }}-${{ env.CU_VERSION }} + path: ${{ inputs.repository }}/release/tarball/ + - name: Upload cxx11 tarball to GitHub + if: ${{ inputs.cxx11-tarball-release == 'true' }} + continue-on-error: true + uses: actions/upload-artifact@v3 + with: + name: cxx11-tarball-${{ env.PYTHON_VERSION }}-${{ env.CU_VERSION }} + path: ${{ inputs.repository }}/release/tarball/ + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}-${{ inputs.cxx11-tarball-release }} + cancel-in-progress: true \ No newline at end of file diff --git a/.github/workflows/release-wheel-windows.yml b/.github/workflows/release-wheel-windows.yml new file mode 100644 index 0000000000..6a6c993502 --- /dev/null +++ b/.github/workflows/release-wheel-windows.yml @@ -0,0 +1,213 @@ +name: Build Release Wheel Artifacts on Windows + +on: + workflow_call: + inputs: + repository: + description: 'Repository to checkout, defaults to ""' + default: "" + type: string + ref: + description: 'Reference to checkout, defaults to "nightly"' + default: "nightly" + type: string + test-infra-repository: + description: "Test infra repository to use" + default: "pytorch/test-infra" + type: string + test-infra-ref: + description: "Test infra reference to use" + default: "" + type: string + build-matrix: + description: "Build matrix to utilize" + default: "" + type: string + pre-script: + description: "Pre script to run prior to build" + default: "" + type: string + env-script: + description: "Script to setup environment variables for the build" + default: "" + type: string + wheel-build-params: + description: "Additional parameters for bdist_wheel" + default: "" + type: string + post-script: + description: "Post script to run prior to build" + default: "" + type: string + smoke-test-script: + description: "Script for Smoke Test for a specific domain" + default: "" + type: string + package-name: + description: "Name of the actual python package that is imported" + default: "" + type: string + trigger-event: + description: "Trigger Event in caller that determines whether or not to upload" + default: "" + type: string + cache-path: + description: "The path(s) on the runner to cache or restore. The path is relative to repository." + default: "" + type: string + cache-key: + description: "The key created when saving a cache and the key used to search for a cache." + default: "" + type: string + submodules: + description: "Works as stated in actions/checkout, but the default value is recursive" + required: false + type: string + default: recursive + +permissions: + id-token: write + contents: read + +jobs: + build-release-wheel: + strategy: + fail-fast: false + matrix: ${{ fromJSON(inputs.build-matrix) }} + env: + PYTHON_VERSION: ${{ matrix.python_version }} + PACKAGE_TYPE: wheel + REPOSITORY: ${{ inputs.repository }} + REF: ${{ inputs.ref }} + CU_VERSION: ${{ matrix.desired_cuda }} + UPLOAD_TO_BASE_BUCKET: ${{ matrix.upload_to_base_bucket }} + name: ${{ matrix.build_name }} + runs-on: ${{ matrix.validation_runner }} + defaults: + run: + shell: bash -l {0} + # If a build is taking longer than 120 minutes on these runners we need + # to have a conversation + timeout-minutes: 120 + steps: + - uses: actions/checkout@v3 + with: + # Support the use case where we need to checkout someone's fork + repository: ${{ inputs.test-infra-repository }} + ref: ${{ inputs.test-infra-ref }} + path: test-infra + - uses: ./test-infra/.github/actions/setup-ssh + name: Setup SSH + with: + github-secret: ${{ secrets.GITHUB_TOKEN }} + activate-with-label: false + instructions: "SSH with rdesktop using ssh -L 3389:localhost:3389 %%username%%@%%hostname%%" + - name: Add Conda scripts to GitHub path + run: | + echo "C:/Jenkins/Miniconda3/Scripts" >> $GITHUB_PATH + - uses: ./test-infra/.github/actions/set-channel + - name: Set PYTORCH_VERSION + if: ${{ env.CHANNEL == 'test' }} + run: | + # When building RC, set the version to be the current candidate version, + # otherwise, leave it alone so nightly will pick up the latest + echo "PYTORCH_VERSION=${{ matrix.stable_version }}" >> "${GITHUB_ENV}" + - uses: ./test-infra/.github/actions/setup-binary-builds + with: + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref }} + submodules: ${{ inputs.submodules }} + setup-miniconda: false + python-version: ${{ env.PYTHON_VERSION }} + cuda-version: ${{ env.CU_VERSION }} + arch: ${{ env.ARCH }} + - name: Install torch dependency + run: | + source "${BUILD_ENV_FILE}" + # shellcheck disable=SC2086 + ${CONDA_RUN} ${PIP_INSTALL_TORCH} + - name: Run Pre-Script with Caching + if: ${{ inputs.pre-script != '' }} + uses: ./test-infra/.github/actions/run-script-with-cache + with: + cache-path: ${{ inputs.cache-path }} + cache-key: ${{ inputs.cache-key }} + repository: ${{ inputs.repository }} + script: ${{ inputs.pre-script }} + is_windows: 'enabled' + - name: Build clean + working-directory: ${{ inputs.repository }} + run: | + source "${BUILD_ENV_FILE}" + ${CONDA_RUN} python setup.py clean + - name: Build the wheel (bdist_wheel) + working-directory: ${{ inputs.repository }} + env: + ENV_SCRIPT: ${{ inputs.env-script }} + BUILD_PARAMS: ${{ inputs.wheel-build-params }} + run: | + set -x + source "${BUILD_ENV_FILE}" + + if [[ "$CU_VERSION" == "cpu" ]]; then + # CUDA and CPU are ABI compatible on the CPU-only parts, so strip + # in this case + export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')" + else + export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//')" + fi + + # BUILD_VERSION example: 2.4.0+cu121, we don't want the +cu121 part, so remove +cu121 + BUILD_VERSION=${BUILD_VERSION%+*} + + if [[ -z "${ENV_SCRIPT}" ]]; then + ${CONDA_RUN} python setup.py bdist_wheel + else + if [[ ! -f ${ENV_SCRIPT} ]]; then + echo "::error::Specified env-script file (${ENV_SCRIPT}) not found" + exit 1 + else + ${CONDA_RUN} ${ENV_SCRIPT} python setup.py bdist_wheel ${BUILD_PARAMS} + fi + fi + - name: Run post-script + working-directory: ${{ inputs.repository }} + env: + POST_SCRIPT: ${{ inputs.post-script }} + ENV_SCRIPT: ${{ inputs.env-script }} + if: ${{ inputs.post-script != '' }} + run: | + set -euxo pipefail + source "${BUILD_ENV_FILE}" + ${CONDA_RUN} ${ENV_SCRIPT} ${POST_SCRIPT} + - name: Smoke Test + env: + PACKAGE_NAME: ${{ inputs.package-name }} + SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }} + run: | + source "${BUILD_ENV_FILE}" + WHEEL_NAME=$(ls "${{ inputs.repository }}/dist/") + echo "$WHEEL_NAME" + ${CONDA_RUN} pip install "${{ inputs.repository }}/dist/$WHEEL_NAME" + if [[ ! -f "${{ inputs.repository }}"/${SMOKE_TEST_SCRIPT} ]]; then + echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} not found" + ${CONDA_RUN} python -c "import ${PACKAGE_NAME}; print('package version is ', ${PACKAGE_NAME}.__version__)" + else + echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} found" + ${CONDA_RUN} python "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT}" + fi + # NB: Only upload to GitHub after passing smoke tests + - name: Upload wheel to GitHub + continue-on-error: true + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ inputs.repository }}/dist/ + - uses: ./test-infra/.github/actions/teardown-windows + if: always() + name: Teardown Windows + + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} + cancel-in-progress: true diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml new file mode 100644 index 0000000000..6eed4f5206 --- /dev/null +++ b/.github/workflows/release-windows.yml @@ -0,0 +1,87 @@ +name: Release Windows wheels artifacts + +on: + push: + tags: + # NOTE: Binary build pipelines should only get triggered on release candidate builds + # Release candidate tags look like: v1.11.0-rc1 + - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ + workflow_dispatch: + +permissions: + id-token: write + contents: read + packages: write + +jobs: + generate-matrix: + uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main + if: ${{ contains(github.event.pull_request.labels.*.name, 'build-release-artifacts') || startsWith(github.event.ref, 'refs/tags/v') }} + with: + package-type: wheel + os: windows + test-infra-repository: pytorch/test-infra + test-infra-ref: main + with-rocm: false + with-cpu: false + + generate-release-matrix: + needs: [generate-matrix] + outputs: + matrix: ${{ steps.generate.outputs.matrix }} + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - uses: actions/checkout@v3 + with: + repository: pytorch/tensorrt + - name: Generate release matrix + id: generate + run: | + set -eou pipefail + MATRIX_BLOB=${{ toJSON(needs.generate-matrix.outputs.matrix) }} + MATRIX_BLOB="$(python3 .github/scripts/generate-release-matrix.py --wheel_matrix "${MATRIX_BLOB}")" + echo "${MATRIX_BLOB}" + echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}" + + substitute-runner: + needs: generate-release-matrix + outputs: + matrix: ${{ steps.substitute.outputs.matrix }} + runs-on: ubuntu-latest + steps: + - name: Substitute runner + id: substitute + run: | + echo matrix="$(echo '${{ needs.generate-release-matrix.outputs.matrix }}' | sed -e 's/windows.8xlarge.nvidia.gpu/windows.g5.4xlarge.nvidia.gpu/g')" >> ${GITHUB_OUTPUT} + + release-wheel-artifacts: + needs: substitute-runner + name: Release torch-tensorrt wheel artifacts + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + pre-script: packaging/pre_build_script_windows.sh + env-script: packaging/vc_env_helper.bat + smoke-test-script: packaging/smoke_test_windows.py + package-name: torch_tensorrt + uses: ./.github/workflows/release-wheel-windows.yml + with: + repository: ${{ matrix.repository }} + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.substitute-runner.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + env-script: ${{ matrix.env-script }} + smoke-test-script: ${{ matrix.smoke-test-script }} + package-name: ${{ matrix.package-name }} + + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} + cancel-in-progress: true \ No newline at end of file