Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Python Runtime Windows Builds on TRT 10 #2764

Merged
merged 23 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
56fba7a
Fix C++ and Python building on Windows
HolyWu Feb 27, 2024
0588052
Switch to TRT 10 in installer
gs-olive Apr 19, 2024
b66b6f9
Installer flags
gs-olive Apr 19, 2024
ace1531
Add access to test indices Torch
gs-olive Apr 19, 2024
f642c8a
Add access to test indices Torch 2
gs-olive Apr 19, 2024
43a90ee
Add access to test indices Torch 3
gs-olive Apr 19, 2024
e8edf3a
Add access to test indices Torch 4
gs-olive Apr 19, 2024
20fb155
Add access to test indices Torch 5
gs-olive Apr 19, 2024
2482307
Add access to test indices Torch 6
gs-olive Apr 19, 2024
be605b6
Add access to test indices Torch 7
gs-olive Apr 19, 2024
9005523
TRT 10 build testing + Rebase
gs-olive Apr 20, 2024
dc9f0de
Missing tensorrt bindings
gs-olive Apr 22, 2024
422423c
Delete usused pre_build_script_driver_upgrade.sh
HolyWu Apr 20, 2024
53638c2
Clean up pre_build_script_windows.sh
HolyWu Apr 20, 2024
08afe82
cuDNN is not required by TRT 10
HolyWu Apr 20, 2024
bffcfb2
Install tensorrt-bindings and tensorrt-libs
HolyWu Apr 20, 2024
d70e46d
Temporarily install torch in test index
HolyWu Apr 20, 2024
c028b67
Install torch and tensorrt according to desired_cuda in matrix
HolyWu Apr 20, 2024
d14833f
Disable tests for Python-only runtime + Win unsupported ops
gs-olive Apr 22, 2024
a39801f
Fix tracing of generator in BERT model on Windows
gs-olive Apr 23, 2024
f8c300f
Clean up code changes
gs-olive Apr 23, 2024
0877ca1
Address review comments
gs-olive Apr 24, 2024
8ba63ea
Update job prompts for Windows
gs-olive Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ build --cxxopt="-fdiagnostics-color=always"
build --cxxopt='-std=c++17'
#build --linkopt="-Wl,--no-as-needed"

build:windows --cxxopt="/GS-" --cxxopt="/std:c++17" --cxxopt="/permissive-"
build:windows --cxxopt="/wd4244" --cxxopt="/wd4267" --cxxopt="/wd4819"
build:windows --features=windows_export_all_symbols

build:python --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
build:python --linkopt="-D_GLIBCXX_USE_CXX11_ABI=0"
Expand Down
14 changes: 14 additions & 0 deletions .github/scripts/install-torch-tensorrt-windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set -eou pipefail
source "${BUILD_ENV_FILE}"

# Install test index version of Torch and Torchvision
${CONDA_RUN} ${PIP_INSTALL_TORCH} torchvision
${CONDA_RUN} pip install pyyaml mpmath==1.3.0

# Install TRT 10 from PyPi
${CONDA_RUN} pip install tensorrt==10.0.0b6 tensorrt-${CU_VERSION::4}-bindings==10.0.0b6 tensorrt-${CU_VERSION::4}-libs==10.0.0b6 --extra-index-url https://pypi.nvidia.com

# Install pre-built Torch-TRT
${CONDA_RUN} pip install ${RUNNER_ARTIFACT_DIR}/torch_tensorrt*.whl

echo -e "Running test script";
159 changes: 159 additions & 0 deletions .github/workflows/build-test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Build and test Windows wheels

on:
pull_request:
push:
branches:
- main
- nightly
- release/*
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:

jobs:
generate-matrix:
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
with:
package-type: wheel
os: windows
test-infra-repository: pytorch/test-infra
test-infra-ref: main
with-rocm: false
with-cpu: false

build:
needs: generate-matrix
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix:
include:
- repository: pytorch/tensorrt
pre-script: packaging/pre_build_script_windows.sh
smoke-test-script: packaging/smoke_test_windows.py
package-name: torch_tensorrt
name: Build torch-tensorrt whl package
uses: pytorch/test-infra/.github/workflows/build_wheels_windows.yml@main
with:
repository: ${{ matrix.repository }}
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
pre-script: ${{ matrix.pre-script }}
smoke-test-script: ${{ matrix.smoke-test-script }}
package-name: ${{ matrix.package-name }}
trigger-event: ${{ github.event_name }}

tests-py-dynamo-converters:
name: Test dynamo converters [Python]
needs: [generate-matrix, build]
strategy:
fail-fast: false
matrix:
include:
- repository: pytorch/tensorrt
package-name: torch_tensorrt
uses: ./.github/workflows/windows-test.yml
with:
job-name: tests-py-dynamo-converters
repository: "pytorch/tensorrt"
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
pre-script: packaging/driver_upgrade.bat
script: |
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${CONDA_RUN} python -m pip install --pre pytest-xdist timm transformers parameterized expecttest==0.1.6 --use-deprecated=legacy-resolver
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/
popd

tests-py-dynamo-fe:
name: Test dynamo frontend [Python]
needs: [generate-matrix, build]
strategy:
fail-fast: false
matrix:
include:
- repository: pytorch/tensorrt
package-name: torch_tensorrt
uses: ./.github/workflows/windows-test.yml
with:
job-name: tests-py-dynamo-fe
repository: "pytorch/tensorrt"
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
pre-script: packaging/driver_upgrade.bat
script: |
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${CONDA_RUN} python -m pip install --pre pytest-xdist timm transformers parameterized expecttest==0.1.6 --use-deprecated=legacy-resolver
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_fe_test_results.xml --ir dynamo models/test_models_export.py
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/test_dyn_models.py
popd

tests-py-torch-compile-be:
name: Test torch compile backend [Python]
needs: [generate-matrix, build]
strategy:
fail-fast: false
matrix:
include:
- repository: pytorch/tensorrt
package-name: torch_tensorrt
uses: ./.github/workflows/windows-test.yml
with:
job-name: tests-py-torch-compile-be
repository: ${{ matrix.repository }}
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
pre-script: packaging/driver_upgrade.bat
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
script: |
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${CONDA_RUN} python -m pip install --pre pytest-xdist timm transformers parameterized expecttest==0.1.6 --use-deprecated=legacy-resolver
${CONDA_RUN} python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_comple_be_e2e_test_results.xml --ir torch_compile models/test_models.py
popd

tests-py-dynamo-core:
name: Test dynamo core [Python]
needs: [generate-matrix, build]
strategy:
fail-fast: false
matrix:
include:
- repository: pytorch/tensorrt
package-name: torch_tensorrt
uses: ./.github/workflows/windows-test.yml
with:
job-name: tests-py-dynamo-core
repository: "pytorch/tensorrt"
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
pre-script: packaging/driver_upgrade.bat
script: |
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${CONDA_RUN} python -m pip install --pre pytest-xdist timm transformers parameterized expecttest==0.1.6 --use-deprecated=legacy-resolver
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/
popd
140 changes: 140 additions & 0 deletions .github/workflows/windows-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Test 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
script:
description: 'Script to utilize'
default: "python setup.py bdist_wheel"
type: string
job-name:
description: "Name for the job, which is displayed in the GitHub UI"
default: "windows-job"
type: string
continue-on-error:
description: "Prevents a job from failing when a step fails. Set to true to allow a job to pass when exec script step fails."
default: false
type: boolean

jobs:
test:
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 }}
SCRIPT: ${{ inputs.script }}
PYTHONUTF8: 1
name: ${{ inputs.job-name }}-${{ matrix.desired_cuda }}
runs-on: windows.8xlarge.nvidia.gpu.nonephemeral
defaults:
run:
shell: bash -l {0}
# If a build is taking longer than 60 minutes on these runners we need
# to have a conversation
timeout-minutes: 60
steps:
- name: Clean workspace
run: |
echo "::group::Cleanup debug output"
rm -rfv "${GITHUB_WORKSPACE}"
mkdir -p "${GITHUB_WORKSPACE}"
echo "::endgroup::"
- name: Checkout repository (${{ inputs.test-infra-repository }}@${{ inputs.test-infra-ref }})
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
- name: Setup Windows
uses: ./test-infra/.github/actions/setup-windows
- name: Setup SSH
uses: ./test-infra/.github/actions/setup-ssh
with:
github-secret: ${{ github.token }}
- name: Add Conda scripts to GitHub path
run: |
echo "C:/Jenkins/Miniconda3/Scripts" >> $GITHUB_PATH
- uses: ./test-infra/.github/actions/set-channel
- uses: ./test-infra/.github/actions/setup-binary-builds
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
setup-miniconda: false
python-version: ${{ env.PYTHON_VERSION }}
cuda-version: ${{ env.CU_VERSION }}
arch: ${{ env.ARCH }}
- 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: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ runner.temp }}/artifacts/
- name: Pack script
continue-on-error: ${{ inputs.continue-on-error }}
working-directory: ${{ inputs.repository }}
env:
ALL_SECRETS: ${{ toJSON(secrets) }}
run: |
set -eou pipefail
source "${BUILD_ENV_FILE}"
{
echo "${SCRIPT}";
} > "user_script"
cat .github/scripts/install-torch-tensorrt-windows.sh user_script > exec_script
- name: Run script
uses: ./test-infra/.github/actions/run-script-with-cache
with:
repository: ${{ inputs.repository }}
script: exec_script
is_windows: 'enabled'
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@v0.3.0
with:
path: ${{ env.RUNNER_TEST_RESULTS_DIR }}
fail-on-empty: false
- name: Teardown Windows
if: ${{ always() }}
uses: ./test-infra/.github/actions/teardown-windows

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}
cancel-in-progress: true
4 changes: 2 additions & 2 deletions BUILD → BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pkg_tar(
pkg_tar(
name = "lib",
srcs = select({
":windows": ["//cpp/lib:torch_tensorrt.dll"],
":windows": ["//cpp/lib:torchtrt.dll"],
"//conditions:default": [
"//cpp/lib:libtorchtrt.so",
"//cpp/lib:libtorchtrt_plugins.so",
Expand All @@ -66,7 +66,7 @@ pkg_tar(
pkg_tar(
name = "lib_rt",
srcs = select({
":windows": ["//cpp/lib:torch_tensorrt_runtime.dll"],
":windows": ["//cpp/lib:torchtrt_runtime.dll"],
"//conditions:default": [
"//cpp/lib:libtorchtrt_runtime.so",
],
Expand Down
1 change: 1 addition & 0 deletions core/conversion/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cc_library(
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch"],
}),
alwayslink = True,
)

pkg_tar(
Expand Down
1 change: 1 addition & 0 deletions core/conversion/conversionctx/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cc_library(
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch"],
}),
alwayslink = True,
)

pkg_tar(
Expand Down
2 changes: 1 addition & 1 deletion core/conversion/converters/impl/activation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ auto acthardtanh TORCHTRT_UNUSED =

// Out_tensor of ParametricReLU shape is all 0, when slopes nDims is not equal to in nDims.
// Since make sure splopes nDims is equal to in nDims.
if (slopes.ndimension() == 1 and original_shape.nbDims != slopes.ndimension()) {
if (slopes.ndimension() == 1 && original_shape.nbDims != slopes.ndimension()) {
std::vector<int64_t> slopes_new_shape(original_shape.nbDims, 1);
auto first_inputs_allowed_formats = ctx->net->getInput(0)->getAllowedFormats();
for (size_t inputs_index = 1; inputs_index < ctx->num_inputs; inputs_index++) {
Expand Down
1 change: 1 addition & 0 deletions core/ir/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ cc_library(
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch"],
}),
alwayslink = True,
)

pkg_tar(
Expand Down
1 change: 1 addition & 0 deletions core/lowering/passes/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cc_library(
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch"],
}),
alwayslink = True,
)

pkg_tar(
Expand Down
Loading
Loading