diff --git a/.github/scripts/generate-release-matrix.py b/.github/scripts/generate-release-matrix.py index 4b232026de..9f740c2f4f 100644 --- a/.github/scripts/generate-release-matrix.py +++ b/.github/scripts/generate-release-matrix.py @@ -5,16 +5,17 @@ import sys RELEASE_CUDA_VERSION = { - "wheel": ["cu128"], - "tarball": ["cu128"], + "wheel": ["cu129"], + "tarball": ["cu129"], } RELEASE_PYTHON_VERSION = { - "wheel": ["3.9", "3.10", "3.11", "3.12", "3.13"], + "wheel": ["3.10", "3.11", "3.12", "3.13"], "tarball": ["3.11"], } +sbsa_container_image: str = "quay.io/pypa/manylinux_2_34_aarch64" CXX11_TARBALL_CONTAINER_IMAGE = { - "cu128": "pytorch/libtorch-cxx11-builder:cuda12.8-main", + "cu129": "pytorch/libtorch-cxx11-builder:cuda12.9-main", } @@ -56,10 +57,12 @@ def main(args: list[str]) -> None: 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"] - ] + if item["gpu_arch_type"] == "cuda-aarch64": + item["container_image"] = sbsa_container_image + # 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 diff --git a/.github/workflows/build-test-linux-aarch64-jetpack.yml b/.github/workflows/build-test-linux-aarch64-jetpack.yml index 9523872acf..ff827ad3f6 100644 --- a/.github/workflows/build-test-linux-aarch64-jetpack.yml +++ b/.github/workflows/build-test-linux-aarch64-jetpack.yml @@ -66,7 +66,7 @@ jobs: smoke-test-script: packaging/smoke_test_script.sh package-name: torch_tensorrt name: Build torch-tensorrt whl package for jetpack - uses: ./.github/workflows/build_wheels_linux.yml + uses: ./.github/workflows/build_linux.yml with: repository: ${{ matrix.repository }} ref: "" diff --git a/.github/workflows/build-test-linux-aarch64.yml b/.github/workflows/build-test-linux-aarch64.yml index a2b2a78db9..2604d18f92 100644 --- a/.github/workflows/build-test-linux-aarch64.yml +++ b/.github/workflows/build-test-linux-aarch64.yml @@ -63,7 +63,7 @@ jobs: smoke-test-script: packaging/smoke_test_script.sh package-name: torch_tensorrt name: Build torch-tensorrt whl package for SBSA - uses: ./.github/workflows/build_wheels_linux.yml + uses: ./.github/workflows/build_linux.yml with: repository: ${{ matrix.repository }} ref: "" diff --git a/.github/workflows/build-test-linux-x86_64.yml b/.github/workflows/build-test-linux-x86_64.yml index 3998eab0e7..b1630c03be 100644 --- a/.github/workflows/build-test-linux-x86_64.yml +++ b/.github/workflows/build-test-linux-x86_64.yml @@ -62,7 +62,7 @@ jobs: smoke-test-script: packaging/smoke_test_script.sh package-name: torch_tensorrt name: Build torch-tensorrt whl package for Linux x86_64 - uses: ./.github/workflows/build_wheels_linux.yml + uses: ./.github/workflows/build_linux.yml with: repository: ${{ matrix.repository }} ref: "" diff --git a/.github/workflows/build-test-linux-x86_64_rtx.yml b/.github/workflows/build-test-linux-x86_64_rtx.yml index 1f9b605584..67eecef0e9 100644 --- a/.github/workflows/build-test-linux-x86_64_rtx.yml +++ b/.github/workflows/build-test-linux-x86_64_rtx.yml @@ -61,7 +61,7 @@ jobs: smoke-test-script: packaging/smoke_test_script.sh package-name: torch_tensorrt name: RTX - Build torch-tensorrt-rtx whl package for Linux x86_64 - uses: ./.github/workflows/build_wheels_linux.yml + uses: ./.github/workflows/build_linux.yml with: repository: ${{ matrix.repository }} ref: "" diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml index ca39f8cb5f..39c3d20571 100644 --- a/.github/workflows/build-test-windows.yml +++ b/.github/workflows/build-test-windows.yml @@ -71,7 +71,7 @@ jobs: smoke-test-script: packaging/smoke_test_windows.py package-name: torch_tensorrt name: Build torch-tensorrt whl package for Windows - uses: ./.github/workflows/build_wheels_windows.yml + uses: ./.github/workflows/build_windows.yml with: repository: ${{ matrix.repository }} ref: "" diff --git a/.github/workflows/build-test-windows_rtx.yml b/.github/workflows/build-test-windows_rtx.yml index 137adb252c..88d347501d 100644 --- a/.github/workflows/build-test-windows_rtx.yml +++ b/.github/workflows/build-test-windows_rtx.yml @@ -71,7 +71,7 @@ jobs: smoke-test-script: packaging/smoke_test_windows.py package-name: torch_tensorrt name: RTX - Build torch-tensorrt-rtx whl package for Windows - uses: ./.github/workflows/build_wheels_windows.yml + uses: ./.github/workflows/build_windows.yml with: repository: ${{ matrix.repository }} ref: "" diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_linux.yml similarity index 85% rename from .github/workflows/build_wheels_linux.yml rename to .github/workflows/build_linux.yml index 4b95a90e86..32dd21de82 100644 --- a/.github/workflows/build_wheels_linux.yml +++ b/.github/workflows/build_linux.yml @@ -117,6 +117,16 @@ on: required: false default: false type: boolean + is-release-wheel: + description: Set to true if the build is for release wheel + required: false + default: false + type: boolean + is-release-tarball: + description: Set to true if the build is for release tarball + required: false + default: false + type: boolean secrets: PYPI_API_TOKEN: description: An optional token to upload to pypi @@ -265,22 +275,42 @@ jobs: export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')" ${CONDA_RUN} python setup.py clean echo "Successfully ran `python setup.py clean`" - if [[ "$BUILD_VERSION" != *"+"${CU_VERSION} ]]; then - BUILD_VERSION="${BUILD_VERSION}+${CU_VERSION}" + if [[ ${{ inputs.is-release-wheel }} == true || ${{ inputs.is-release-tarball }} == true ]]; then + # release version for upload to pypi + # BUILD_VERSION example: 2.4.0+cu121, we don't want the +cu121 part, so remove +cu121 + BUILD_VERSION=${BUILD_VERSION%+*} + if [[ ${{ inputs.is-release-tarball }} == true ]]; then + mkdir -p release/tarball + TRT_VERSION=$(cat dev_dep_versions.yml | grep __tensorrt_version__ | sed 's/__tensorrt_version__: //g' | sed 's/"//g') + bazel build //:libtorchtrt --compilation_mode opt --config=linux + cp bazel-bin/libtorchtrt.tar.gz \ + release/tarball/libtorchtrt-${BUILD_VERSION}-tensorrt${TRT_VERSION}-cuda${CU_VERSION:2}-libtorch${PYTORCH_VERSION}-x86_64-linux.tar.gz + return 0 + else + if [[ ${{ inputs.is-release-wheel }} == true ]]; then + param="--release" + fi + fi + else + # release version for upload to pytorch index + if [[ "$BUILD_VERSION" != *"+"${CU_VERSION} ]]; then + BUILD_VERSION="${BUILD_VERSION}+${CU_VERSION}" + fi fi + echo "BUILD_VERSION=$BUILD_VERSION" echo "USE_TRT_RTX=$USE_TRT_RTX" echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" if [[ ${{ inputs.use-rtx }} == true ]]; then echo "Building tensorrt-rtx wheel" - ${CONDA_RUN} python setup.py bdist_wheel --use-rtx + ${CONDA_RUN} python setup.py bdist_wheel ${param} --use-rtx else if [[ ${{ inputs.is-jetpack }} == true ]]; then echo "Building tensorrt wheel for jetpack" - ${CONDA_RUN} python setup.py bdist_wheel --jetpack + ${CONDA_RUN} python setup.py bdist_wheel ${param} --jetpack else echo "Building standard tensorrt wheel" - ${CONDA_RUN} python setup.py bdist_wheel + ${CONDA_RUN} python setup.py bdist_wheel ${param} fi fi - name: Repair Manylinux_2_28 Wheel @@ -289,7 +319,7 @@ jobs: PACKAGE_NAME: ${{ inputs.package-name }} SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }} # TODO: lan to verify whether manylinux repair is needed for jetpack - #if: ${{ inputs.is-jetpack == true }} + if: ${{ inputs.is-release-tarball == false }} run: | set -euxo pipefail source "${BUILD_ENV_FILE}" @@ -312,6 +342,7 @@ jobs: env: PACKAGE_NAME: ${{ inputs.package-name }} SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }} + if: ${{ inputs.is-release-tarball == false }} run: | set -euxo pipefail source "${BUILD_ENV_FILE}" @@ -348,18 +379,27 @@ jobs: # NB: Only upload to GitHub after passing smoke tests - name: Upload wheel to GitHub + if: ${{ inputs.is-release-tarball == false }} continue-on-error: true uses: actions/upload-artifact@v4 with: name: ${{ env.ARTIFACT_NAME }} path: ${{ inputs.repository }}/dist/ + - name: Upload cxx11 tarball to GitHub + if: ${{ inputs.is-release-tarball == true }} + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: cxx11-tarball-${{ env.PYTHON_VERSION }}-${{ env.CU_VERSION }} + path: ${{ inputs.repository }}/release/tarball/ upload: needs: build name: upload-wheel-${{ matrix.python_version }}-${{ matrix.desired_cuda }}-${{ matrix.gpu_arch_type }}-${{ inputs.is-jetpack }} uses: pytorch/test-infra/.github/workflows/_binary_upload.yml@main # if it is not jetpack nor rtx, then upload to pytorch index - if: ${{ inputs.is-jetpack == false && inputs.use-rtx == false }} + # if it is the release wheel or tarball, then skip upload to pytorch index + if: ${{ inputs.is-jetpack == false && inputs.use-rtx == false && inputs.is-release-wheel == false && inputs.is-release-tarball == false }} with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} @@ -373,5 +413,5 @@ jobs: PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{inputs.use-rtx}}-${{inputs.architecture}}-${{inputs.is-jetpack}}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{inputs.is-release-wheel}}-${{inputs.is-release-tarball}}-${{inputs.use-rtx}}-${{inputs.architecture}}-${{inputs.is-jetpack}}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_windows.yml similarity index 88% rename from .github/workflows/build_wheels_windows.yml rename to .github/workflows/build_windows.yml index 5c9e391cd6..6fbd343fdb 100644 --- a/.github/workflows/build_wheels_windows.yml +++ b/.github/workflows/build_windows.yml @@ -89,6 +89,16 @@ on: description: 'CPU architecture to build for' default: "x64" type: string + is-release-tarball: + description: Set to true if the build is for release tarball + required: false + default: false + type: boolean + is-release-wheel: + description: Set to true if the build is for release wheel + required: false + default: false + type: boolean permissions: id-token: write @@ -277,6 +287,20 @@ jobs: BUILD_PARAMS: ${{ inputs.wheel-build-params }} run: | source "${BUILD_ENV_FILE}" + if [[ ${{ inputs.is-release-wheel }} == true || ${{ inputs.is-release-tarball }} == true ]]; then + # release version for upload to pypi + # BUILD_VERSION example: 2.4.0+cu121, we don't want the +cu121 part, so remove +cu121 + BUILD_VERSION=${BUILD_VERSION%+*} + if [[ ${{ inputs.is-release-tarball }} == true ]]; then + mkdir -p release/tarball + TRT_VERSION=$(cat dev_dep_versions.yml | grep __tensorrt_version__ | sed 's/__tensorrt_version__: //g' | sed 's/"//g') + bazel build //:libtorchtrt --compilation_mode opt --config=windows + ls -lart bazel-bin/ + cp bazel-bin/libtorchtrt.zip\ + release/tarball/libtorchtrt-${BUILD_VERSION}-tensorrt${TRT_VERSION}-cuda${CU_VERSION:2}-libtorch${PYTORCH_VERSION}-x86_64-windows.zip + return 0 + fi + fi if [[ -z "${ENV_SCRIPT}" ]]; then ${CONDA_RUN} python setup.py bdist_wheel else @@ -311,7 +335,7 @@ jobs: source "${BUILD_ENV_FILE}" ${CONDA_RUN} ${ENV_SCRIPT} ${POST_SCRIPT} - name: Smoke Test X64 - if: inputs.architecture == 'x64' + if: ${{ inputs.architecture == 'x64' && inputs.is-release-tarball == false }} env: ENV_SCRIPT: ${{ inputs.env-script }} PACKAGE_NAME: ${{ inputs.package-name }} @@ -365,11 +389,19 @@ jobs: run: | echo "ARTIFACT_NAME=${REPOSITORY//\//_}_${REF//\//_}_${PYTHON_VERSION}_${CU_VERSION}_${ARCH}" >> "${GITHUB_ENV}" - name: Upload wheel to GitHub + if: ${{ inputs.is-release-tarball == false }} continue-on-error: true uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ${{ env.ARTIFACT_NAME }} path: ${{ inputs.repository }}/dist/ + - name: Upload zip artifact to GitHub + if: ${{ inputs.is-release-tarball == true }} + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: cxx11-zip-${{ env.PYTHON_VERSION }}-${{ env.CU_VERSION }} + path: ${{ inputs.repository }}/release/tarball/ - uses: ./test-infra/.github/actions/teardown-windows if: inputs.architecture == 'x64' name: Teardown Windows @@ -378,7 +410,8 @@ jobs: needs: build uses: pytorch/test-infra/.github/workflows/_binary_upload.yml@main # for tensorrt-rtx build, do not upload to pytorch indexat at all - if: ${{ inputs.use-rtx == false }} + # if it is the release wheel or tarball, then skip upload to pytorch index(release wheel are uploaded to pypi) + if: ${{ inputs.use-rtx == false && inputs.is-release-wheel == false && inputs.is-release-tarball == false }} with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} @@ -389,5 +422,5 @@ jobs: architecture: ${{ inputs.architecture }} concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ inputs.repository }}-${{ inputs.is-release-wheel }}-${{ inputs.is-release-tarball }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true \ No newline at end of file diff --git a/.github/workflows/release-linux-aarch64.yml b/.github/workflows/release-linux-aarch64.yml new file mode 100644 index 0000000000..065962ab3a --- /dev/null +++ b/.github/workflows/release-linux-aarch64.yml @@ -0,0 +1,132 @@ +name: Release aarch64 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-aarch64 + 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@v5 + with: + python-version: '3.11' + - uses: actions/checkout@v4 + 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 aarch64 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 + is-release-tarball: "true" + uses: ./.github/workflows/build_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 }} + is-release-tarball: true + architecture: "aarch64" + + generate-release-wheel-matrix: + needs: [generate-matrix] + outputs: + matrix: ${{ steps.generate.outputs.matrix }} + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - uses: actions/checkout@v4 + 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-wheel-artifacts: + name: Release aarch64 torch-tensorrt wheel 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 + is-release-wheel: true + uses: ./.github/workflows/build_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 }} + is-release-wheel: true + architecture: "aarch64" + +concurrency: + group: ${{ github.workflow }}-aarch64-${{ 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-linux.yml b/.github/workflows/release-linux-x86_64.yml similarity index 87% rename from .github/workflows/release-linux.yml rename to .github/workflows/release-linux-x86_64.yml index 2c4be0ec1d..fae96128c9 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux-x86_64.yml @@ -1,4 +1,4 @@ -name: Release Linux wheels and tarball artifacts +name: Release x86_64 Linux wheels and tarball artifacts on: push: @@ -48,7 +48,7 @@ jobs: release-cxx11-tarball-artifacts: needs: [generate-release-tarball-matrix] - name: Release torch-tensorrt cxx11 tarball artifacts + name: Release x86_64 torch-tensorrt cxx11 tarball artifacts strategy: fail-fast: false matrix: @@ -59,8 +59,8 @@ jobs: 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 + is-release-tarball: "true" + uses: ./.github/workflows/build_linux.yml with: repository: ${{ matrix.repository }} ref: "" @@ -73,7 +73,7 @@ jobs: package-name: ${{ matrix.package-name }} smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} - cxx11-tarball-release: "true" + is-release-tarball: true generate-release-wheel-matrix: needs: [generate-matrix] @@ -97,7 +97,7 @@ jobs: echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}" release-wheel-artifacts: - name: Release torch-tensorrt wheel artifacts + name: Release x86_64 torch-tensorrt wheel artifacts needs: [generate-release-wheel-matrix] strategy: fail-fast: false @@ -109,8 +109,8 @@ jobs: 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 + is-release-wheel: true + uses: ./.github/workflows/build_linux.yml with: repository: ${{ matrix.repository }} ref: "" @@ -123,8 +123,8 @@ jobs: package-name: ${{ matrix.package-name }} smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} - cxx11-tarball-release: "false" + is-release-wheel: true concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} + group: ${{ github.workflow }}-x86_64-${{ 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 deleted file mode 100644 index efd73f490f..0000000000 --- a/.github/workflows/release-wheel-linux.yml +++ /dev/null @@ -1,249 +0,0 @@ -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@v4 - 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@v4 - 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=linux - cp bazel-bin/libtorchtrt.tar.gz \ - release/tarball/libtorchtrt-${BUILD_VERSION}-tensorrt${TRT_VERSION}-cuda${CU_VERSION:2}-libtorch${PYTORCH_VERSION}-x86_64-linux.tar.gz - else - ${CONDA_RUN} python setup.py bdist_wheel --release - ${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@v4 - with: - name: ${{ env.ARTIFACT_NAME }} - path: ${{ inputs.repository }}/release/wheel/ - - name: Upload cxx11 tarball to GitHub - if: ${{ inputs.cxx11-tarball-release == 'true' }} - continue-on-error: true - uses: actions/upload-artifact@v4 - 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 deleted file mode 100644 index 2ea88bce9e..0000000000 --- a/.github/workflows/release-wheel-windows.yml +++ /dev/null @@ -1,213 +0,0 @@ -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@v4 - 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@v4 - 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 index 1a20eb7a71..fc70b83f96 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -25,7 +25,7 @@ jobs: with-rocm: false with-cpu: false - generate-release-matrix: + generate-release-zip-matrix: needs: [generate-matrix] outputs: matrix: ${{ steps.generate.outputs.matrix }} @@ -37,29 +37,74 @@ jobs: - uses: actions/checkout@v4 with: repository: pytorch/tensorrt - - name: Generate release matrix + - name: Generate release tarball 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}")" + MATRIX_BLOB="$(python3 .github/scripts/generate-release-matrix.py --tarball_matrix "${MATRIX_BLOB}")" echo "${MATRIX_BLOB}" - echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}" + substitute_matrix="$(echo "${MATRIX_BLOB}" | sed -e 's/windows.g4dn.xlarge/windows.g5.4xlarge.nvidia.gpu/g')" + + echo matrix="$(echo "${substitute_matrix}")" >> ${GITHUB_OUTPUT} + - substitute-runner: - needs: generate-release-matrix + generate-release-wheel-matrix: + needs: [generate-matrix] outputs: - matrix: ${{ steps.substitute.outputs.matrix }} + matrix: ${{ steps.generate.outputs.matrix }} runs-on: ubuntu-latest steps: - - name: Substitute runner - id: substitute + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - uses: actions/checkout@v4 + with: + repository: pytorch/tensorrt + - name: Generate release wheel matrix + id: generate run: | - echo matrix="$(echo '${{ needs.generate-release-matrix.outputs.matrix }}' | sed -e 's/windows.g4dn.xlarge/windows.g5.4xlarge.nvidia.gpu/g')" >> ${GITHUB_OUTPUT} + 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_BLOB}" + + substitute_matrix="$(echo "${MATRIX_BLOB}" | sed -e 's/windows.g4dn.xlarge/windows.g5.4xlarge.nvidia.gpu/g')" + echo "****substitute_matrix****" + echo "${substitute_matrix}" + echo "matrix=${substitute_matrix}" >> "${GITHUB_OUTPUT}" + + + release-cxx11-zip-artifacts: + needs: [generate-release-zip-matrix] + name: Release Windows torch-tensorrt cxx11 zip artifacts + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script_windows.sh + env-script: packaging/vc_env_helper.bat + smoke-test-script: packaging/smoke_test_windows.py + is-release-tarball: true + uses: ./.github/workflows/build_windows.yml + with: + repository: ${{ matrix.repository }} + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-release-zip-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + env-script: ${{ matrix.env-var-script }} + package-name: ${{ matrix.package-name }} + smoke-test-script: ${{ matrix.smoke-test-script }} + is-release-tarball: true release-wheel-artifacts: - needs: substitute-runner - name: Release torch-tensorrt wheel artifacts + needs: [generate-release-wheel-matrix] + name: Release Windows torch-tensorrt wheel artifacts strategy: fail-fast: false matrix: @@ -69,17 +114,19 @@ jobs: 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 + is-release-wheel: true + uses: ./.github/workflows/build_windows.yml with: repository: ${{ matrix.repository }} ref: "" test-infra-repository: pytorch/test-infra test-infra-ref: main - build-matrix: ${{ needs.substitute-runner.outputs.matrix }} + build-matrix: ${{ needs.generate-release-wheel-matrix.outputs.matrix }} pre-script: ${{ matrix.pre-script }} env-script: ${{ matrix.env-script }} smoke-test-script: ${{ matrix.smoke-test-script }} package-name: ${{ matrix.package-name }} + is-release-wheel: true concurrency: diff --git a/BUILD.bazel b/BUILD.bazel index 7a49d116b6..3d42625deb 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip") config_setting( name = "windows", @@ -43,6 +43,20 @@ pkg_tar( ], ) +pkg_zip( + name = "include_core_zip", + srcs = [ + "//core:include_zip", + "//core/plugins:impl_include_zip", + "//core/plugins:include_zip", + "//core/runtime:include_zip", + "//core/util:include_zip", + "//core/util/logging:include_zip", + ], + out = "include_core.zip", + package_dir = "include/torch_tensorrt", +) + pkg_tar( name = "include_rt", package_dir = "include/torch_tensorrt", @@ -51,6 +65,15 @@ pkg_tar( ], ) +pkg_zip( + name = "include_rt_zip", + srcs = [ + "//core/runtime:include", + ], + out = "include_rt.zip", + package_dir = "include/torch_tensorrt", +) + pkg_tar( name = "include", srcs = [ @@ -59,30 +82,49 @@ pkg_tar( package_dir = "include/torch_tensorrt/", ) +pkg_zip( + name = "include_zip", + srcs = [ + "//cpp:api_headers", + ], + out = "include.zip", + package_dir = "include/torch_tensorrt/", +) + +# Non-Windows tar target for lib pkg_tar( name = "lib", - srcs = select({ - ":rtx_win": ["//cpp/lib:torchtrt.dll"], - ":windows": ["//cpp/lib:torchtrt.dll"], - "//conditions:default": [ - "//cpp/lib:libtorchtrt.so", - "//cpp/lib:libtorchtrt_plugins.so", - "//cpp/lib:libtorchtrt_runtime.so", - ], - }), + srcs = [ + "//cpp/lib:libtorchtrt.so", + "//cpp/lib:libtorchtrt_plugins.so", + "//cpp/lib:libtorchtrt_runtime.so", + ], mode = "0755", package_dir = "lib/", ) +# Windows-specific zip target for lib +pkg_zip( + name = "lib_zip", + srcs = ["//cpp/lib:torchtrt.dll"], + out = "lib.zip", + mode = "0755", + package_dir = "lib/", +) + +# Non-Windows tar target for lib_rt pkg_tar( name = "lib_rt", - srcs = select({ - ":rtx_win": ["//cpp/lib:torchtrt_runtime.dll"], - ":windows": ["//cpp/lib:torchtrt_runtime.dll"], - "//conditions:default": [ - "//cpp/lib:libtorchtrt_runtime.so", - ], - }), + srcs = ["//cpp/lib:libtorchtrt_runtime.so"], + mode = "0755", + package_dir = "lib/", +) + +# Windows-specific zip target for lib_rt +pkg_zip( + name = "lib_rt_zip", + srcs = ["//cpp/lib:torchtrt_runtime.dll"], + out = "lib_rt.zip", mode = "0755", package_dir = "lib/", ) @@ -96,12 +138,28 @@ pkg_tar( package_dir = "bin/", ) +# Windows-specific zip target +pkg_zip( + name = "libtorchtrt_zip", + srcs = [ + ":include_core_zip", + ":include_zip", + ":lib_zip", + "//:LICENSE", + "//third_party/torch_tensorrt:BUILD", + ], + out = "libtorchtrt.zip", + package_dir = "torch_tensorrt", +) + +# tar target pkg_tar( - name = "libtorchtrt", + name = "libtorchtrt_tar", srcs = [ "//:LICENSE", "//third_party/torch_tensorrt:BUILD", ], + out = "libtorchtrt.tar.gz", extension = "tar.gz", package_dir = "torch_tensorrt", deps = [ @@ -115,12 +173,37 @@ pkg_tar( }), ) +# Main target that selects between zip and tar based on platform +alias( + name = "libtorchtrt", + actual = select({ + ":rtx_win": ":libtorchtrt_zip", + ":windows": ":libtorchtrt_zip", + "//conditions:default": ":libtorchtrt_tar", + }), +) + +# Windows-specific zip target for runtime +pkg_zip( + name = "libtorchtrt_runtime_zip", + srcs = [ + ":include_rt_zip", + ":lib_rt_zip", + "//:LICENSE", + "//third_party/torch_tensorrt:BUILD", + ], + out = "libtorchtrt_runtime.zip", + package_dir = "torch_tensorrt_runtime", +) + +# Non-Windows tar target for runtime pkg_tar( - name = "libtorchtrt_runtime", + name = "libtorchtrt_runtime_tar", srcs = [ "//:LICENSE", "//third_party/torch_tensorrt:BUILD", ], + out = "libtorchtrt_runtime.tar.gz", extension = "tar.gz", package_dir = "torch_tensorrt_runtime", deps = [ @@ -128,3 +211,13 @@ pkg_tar( ":lib_rt", ], ) + +# Main target that selects between zip and tar based on platform +alias( + name = "libtorchtrt_runtime", + actual = select({ + ":rtx_win": ":libtorchtrt_runtime_zip", + ":windows": ":libtorchtrt_runtime_zip", + "//conditions:default": ":libtorchtrt_runtime_tar", + }), +) diff --git a/core/BUILD b/core/BUILD index c6744c66c1..2cd415f881 100644 --- a/core/BUILD +++ b/core/BUILD @@ -1,5 +1,5 @@ load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip") package(default_visibility = ["//visibility:public"]) @@ -103,3 +103,12 @@ pkg_tar( ], package_dir = "core/", ) + +pkg_zip( + name = "include_zip", + srcs = [ + "compiler.h", + ], + out = "include.zip", + package_dir = "core/", +) diff --git a/core/plugins/BUILD b/core/plugins/BUILD index 00503552f2..37a9a47003 100644 --- a/core/plugins/BUILD +++ b/core/plugins/BUILD @@ -1,5 +1,5 @@ load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip") package(default_visibility = ["//visibility:public"]) @@ -115,17 +115,43 @@ cc_library( alwayslink = True, ) +filegroup( + name = "include_files", + srcs = ["plugins.h"], + visibility = ["//visibility:public"], +) + pkg_tar( name = "include", + srcs = [":include_files"], + package_dir = "core/plugins/", +) + +pkg_zip( + name = "include_zip", srcs = ["plugins.h"], + out = "include.zip", package_dir = "core/plugins/", ) -pkg_tar( - name = "impl_include", +filegroup( + name = "impl_include_files", srcs = [ "impl/interpolate_plugin.h", "impl/normalize_plugin.h", ], + visibility = ["//visibility:public"], +) + +pkg_tar( + name = "impl_include", + srcs = [":impl_include_files"], + package_dir = "core/plugins/impl", +) + +pkg_zip( + name = "impl_include_zip", + srcs = [":impl_include_files"], + out = "impl_include.zip", package_dir = "core/plugins/impl", ) diff --git a/core/runtime/BUILD b/core/runtime/BUILD index a573cfed78..95576aa18b 100644 --- a/core/runtime/BUILD +++ b/core/runtime/BUILD @@ -1,5 +1,5 @@ load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip") package(default_visibility = ["//visibility:public"]) @@ -100,8 +100,8 @@ cc_library( alwayslink = True, ) -pkg_tar( - name = "include", +filegroup( + name = "include_files", srcs = [ "Platform.h", "RTDevice.h", @@ -109,5 +109,18 @@ pkg_tar( "TRTEngineProfiler.h", "runtime.h", ], + visibility = ["//visibility:public"], +) + +pkg_tar( + name = "include", + srcs = [":include_files"], + package_dir = "core/runtime/", +) + +pkg_zip( + name = "include_zip", + srcs = [":include_files"], + out = "include.zip", package_dir = "core/runtime/", ) diff --git a/core/util/BUILD b/core/util/BUILD index 0ed97a5eda..8245e1c14a 100644 --- a/core/util/BUILD +++ b/core/util/BUILD @@ -1,5 +1,5 @@ load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip") package(default_visibility = ["//visibility:public"]) @@ -153,15 +153,28 @@ cc_library( alwayslink = True, ) -pkg_tar( - name = "include", +filegroup( + name = "include_files", srcs = [ - "//core/util:Exception.h", - "//core/util:build_info.h", - "//core/util:jit_util.h", - "//core/util:macros.h", - "//core/util:prelude.h", - "//core/util:trt_util.h", + "Exception.h", + "build_info.h", + "jit_util.h", + "macros.h", + "prelude.h", + "trt_util.h", ], + visibility = ["//visibility:public"], +) + +pkg_tar( + name = "include", + srcs = ["//core/util:include_files"], + package_dir = "core/util/", +) + +pkg_zip( + name = "include_zip", + srcs = ["//core/util:include_files"], + out = "include.zip", package_dir = "core/util/", ) diff --git a/core/util/logging/BUILD b/core/util/logging/BUILD index 1ac834b021..0d409df172 100644 --- a/core/util/logging/BUILD +++ b/core/util/logging/BUILD @@ -1,5 +1,5 @@ load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip") package(default_visibility = ["//visibility:public"]) @@ -85,3 +85,10 @@ pkg_tar( srcs = ["TorchTRTLogger.h"], package_dir = "core/util/logging", ) + +pkg_zip( + name = "include_zip", + srcs = ["TorchTRTLogger.h"], + out = "include.zip", + package_dir = "core/util/logging", +) diff --git a/third_party/libtorch/BUILD b/third_party/libtorch/BUILD index 46de7dd8d0..37309f7209 100644 --- a/third_party/libtorch/BUILD +++ b/third_party/libtorch/BUILD @@ -35,6 +35,7 @@ cc_library( [ "include/torch/**/*.h", ], + allow_empty = True, exclude = [ "include/torch/csrc/api/include/**/*.h", ],