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: C++ runtime on Windows #2806

Merged
merged 31 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5bcca38
feat: C++ runtime on Windows
HolyWu May 2, 2024
c6de545
Add cu124 for TRT_DOWNLOAD_LINK
HolyWu May 2, 2024
63c7e76
Update vc_env_helper.bat
HolyWu May 3, 2024
822265a
Add wheel-build-params
HolyWu May 3, 2024
0ef76e3
Migrate to G5 instance in test
HolyWu May 3, 2024
4b6f806
Use local file to actually run on G5 instance before merging
HolyWu May 4, 2024
e238acf
Migrate to G5 instance in build
HolyWu May 4, 2024
69bdbab
Update build_wheels_windows.yml
HolyWu May 4, 2024
f239353
Fix ABI incompatibility with pybind11
HolyWu May 4, 2024
ac8a92b
Fix FileNotFoundError on Windows in test_export_serde
HolyWu May 4, 2024
ed8afa8
Specify runner for test-infra's build_wheels_windows
HolyWu May 7, 2024
bbb3dab
Use env var instead of wheel-build-params for release flag
HolyWu May 8, 2024
9729183
Add -o option to unzip
HolyWu May 18, 2024
786fbc9
Use fixed version of transformers in tests
HolyWu May 22, 2024
411a223
Add test_dyn_models
HolyWu May 22, 2024
087b5cd
Use requirements.txt in tests
HolyWu May 24, 2024
d1497e6
Keep up with the changes in main
HolyWu May 30, 2024
339d3e9
Unify install-torch-tensorrt script for Linux and Windows
HolyWu May 30, 2024
3fb0b1e
Simply use TensorRT cuda 12.4 for building
HolyWu May 30, 2024
0e43822
Add trt-bindings and trt-libs to requirements
HolyWu May 30, 2024
60500c5
Use pypi.nvidia.com instead of pypi.ngc.nvidia.com for extra-index-url
HolyWu May 31, 2024
ac07bb1
Use windows.8xlarge.nvidia.gpu.nonephemeral runner in test
HolyWu May 31, 2024
c2a80c1
Sort packages in requirements alphabetically
HolyWu May 31, 2024
07c0ac9
Don't install NumPy 2.0 rc because it breaks CI
HolyWu May 31, 2024
d522edf
Remove redundant CONDA_RUN in tests
HolyWu May 31, 2024
aa31125
assertEquals is removed in Python 3.12
HolyWu Jun 1, 2024
6e876b8
Fix potential torchvision error due to dependency conflict
HolyWu Jun 1, 2024
19e2eed
Address review comment
HolyWu Jun 4, 2024
6ceda35
Use tempdir in test_export_serde
HolyWu Jun 12, 2024
11d0293
Add back CUDA version specialization for bindings and libs
HolyWu Jun 12, 2024
403ebc9
Move trt_bindings and trt_libs to pyproject.toml
HolyWu Jun 13, 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
13 changes: 0 additions & 13 deletions .github/scripts/install-torch-tensorrt-windows.sh

This file was deleted.

19 changes: 12 additions & 7 deletions .github/scripts/install-torch-tensorrt.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/usr/bin/env bash
set -eou pipefail
# Source conda so it's available to the script environment
source ${BUILD_ENV_FILE}
export EXTRA_INDEX_URL="https://download.pytorch.org/whl/nightly/${CU_VERSION}"

TORCH_TORCHVISION=$(grep "^torch" ${PWD}/py/requirements.txt)
INDEX_URL=https://download.pytorch.org/whl/${CHANNEL}/${CU_VERSION}
PLATFORM=$(python -c "import sys; print(sys.platform)")

# Install all the dependencies required for Torch-TensorRT
${CONDA_RUN} pip install --pre -r ${PWD}/tests/py/requirements.txt --use-deprecated=legacy-resolver --extra-index-url=${EXTRA_INDEX_URL}
pip install --pre ${TORCH_TORCHVISION} --index-url ${INDEX_URL}
pip install --pre -r ${PWD}/tests/py/requirements.txt --use-deprecated legacy-resolver

# Install Torch-TensorRT
${CONDA_RUN} pip install /opt/torch-tensorrt-builds/torch_tensorrt*.whl
if [[ ${PLATFORM} == win32 ]]; then
HolyWu marked this conversation as resolved.
Show resolved Hide resolved
pip install ${RUNNER_ARTIFACT_DIR}/torch_tensorrt*.whl
else
pip install /opt/torch-tensorrt-builds/torch_tensorrt*.whl
fi

echo -e "Running test script";
echo -e "Running test script";
30 changes: 15 additions & 15 deletions .github/workflows/build-test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ jobs:
export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH
pushd .
cd tests/modules
${CONDA_RUN} python hub.py
python hub.py
popd
pushd .
cd tests/py/ts
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_api_test_results.xml api/
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_models_test_results.xml models/
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_integrations_test_results.xml integrations/
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_api_test_results.xml api/
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_models_test_results.xml models/
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_integrations_test_results.xml integrations/
popd

tests-py-dynamo-converters:
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/
popd

tests-py-dynamo-fe:
Expand Down Expand Up @@ -142,8 +142,8 @@ jobs:
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${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
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_fe_test_results.xml --ir dynamo models/test_models_export.py
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/test_dyn_models.py
popd

tests-py-dynamo-serde:
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py
popd

tests-py-torch-compile-be:
Expand Down Expand Up @@ -199,9 +199,9 @@ jobs:
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${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
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py
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 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py
popd

tests-py-dynamo-core:
Expand Down Expand Up @@ -229,9 +229,9 @@ jobs:
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${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/
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/
popd

tests-py-core:
Expand Down Expand Up @@ -259,7 +259,7 @@ jobs:
export USE_HOST_DEPS=1
pushd .
cd tests/py/core
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml .
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml .
popd

concurrency:
Expand Down
125 changes: 110 additions & 15 deletions .github/workflows/build-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@ jobs:
with-rocm: false
with-cpu: false

build:
substitute-runner:
needs: generate-matrix
outputs:
matrix: ${{ steps.substitute.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- name: Substitute runner
id: substitute
run: |
echo matrix="$(echo '${{ needs.generate-matrix.outputs.matrix }}' | sed -e 's/windows.8xlarge.nvidia.gpu/windows.g5.4xlarge.nvidia.gpu/g')" >> ${GITHUB_OUTPUT}

build:
needs: substitute-runner
permissions:
id-token: write
contents: read
Expand All @@ -35,6 +46,7 @@ jobs:
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
name: Build torch-tensorrt whl package
Expand All @@ -44,12 +56,44 @@ jobs:
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
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 }}
trigger-event: ${{ github.event_name }}

tests-py-torchscript-fe:
name: Test torchscript 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-torchscript-fe
repository: ${{ matrix.repository }}
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/modules
python hub.py
popd
pushd .
cd tests/py/ts
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_api_test_results.xml api/
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_models_test_results.xml models/
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_integrations_test_results.xml integrations/
popd

tests-py-dynamo-converters:
name: Test dynamo converters [Python]
needs: [generate-matrix, build]
Expand All @@ -62,7 +106,7 @@ jobs:
uses: ./.github/workflows/windows-test.yml
with:
job-name: tests-py-dynamo-converters
repository: "pytorch/tensorrt"
repository: ${{ matrix.repository }}
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
Expand All @@ -72,7 +116,7 @@ jobs:
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/
popd

tests-py-dynamo-fe:
Expand All @@ -87,7 +131,33 @@ jobs:
uses: ./.github/workflows/windows-test.yml
with:
job-name: tests-py-dynamo-fe
repository: "pytorch/tensorrt"
repository: ${{ matrix.repository }}
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
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_fe_test_results.xml --ir dynamo models/test_models_export.py
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/test_dyn_models.py
popd

tests-py-dynamo-serde:
name: Test dynamo export serde [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-serde
repository: ${{ matrix.repository }}
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
Expand All @@ -97,8 +167,7 @@ jobs:
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${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
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py
popd

tests-py-torch-compile-be:
Expand All @@ -117,14 +186,15 @@ jobs:
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
pre-script: packaging/driver_upgrade.bat
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 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
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 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py
popd

tests-py-dynamo-core:
Expand All @@ -139,7 +209,7 @@ jobs:
uses: ./.github/workflows/windows-test.yml
with:
job-name: tests-py-dynamo-core
repository: "pytorch/tensorrt"
repository: ${{ matrix.repository }}
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
Expand All @@ -149,11 +219,36 @@ jobs:
export USE_HOST_DEPS=1
pushd .
cd tests/py/dynamo
${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/
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/
popd

tests-py-core:
name: Test 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-core
repository: ${{ matrix.repository }}
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/core
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml .
popd

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
cancel-in-progress: true
2 changes: 1 addition & 1 deletion .github/workflows/windows-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
{
echo "${SCRIPT}";
} > "user_script"
cat .github/scripts/install-torch-tensorrt-windows.sh user_script > exec_script
cat .github/scripts/install-torch-tensorrt.sh user_script > exec_script
- name: Run script
uses: ./test-infra/.github/actions/run-script-with-cache
with:
Expand Down
14 changes: 10 additions & 4 deletions packaging/pre_build_script_windows.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
python -m pip install -U numpy packaging pyyaml setuptools wheel
set -eou pipefail

# Install TRT from PyPi
TRT_VERSION=$(${CONDA_RUN} python -c "import yaml; print(yaml.safe_load(open('dev_dep_versions.yml', 'r'))['__tensorrt_version__'])")
pip install -U numpy packaging pyyaml setuptools wheel

python -m pip install tensorrt==${TRT_VERSION} tensorrt-${CU_VERSION::4}==${TRT_VERSION} tensorrt-${CU_VERSION::4}-bindings==${TRT_VERSION} tensorrt-${CU_VERSION::4}-libs==${TRT_VERSION} --extra-index-url https://pypi.nvidia.com
# Install TRT from PyPI
TRT_VERSION=$(python -c "import yaml; print(yaml.safe_load(open('dev_dep_versions.yml', 'r'))['__tensorrt_version__'])")
pip install tensorrt==${TRT_VERSION} tensorrt-${CU_VERSION::4}-bindings==${TRT_VERSION} tensorrt-${CU_VERSION::4}-libs==${TRT_VERSION} --extra-index-url https://pypi.nvidia.com

choco install bazelisk -y

curl -Lo TensorRT.zip https://developer.download.nvidia.com/compute/machine-learning/tensorrt/10.0.1/zip/TensorRT-10.0.1.6.Windows10.win10.cuda-12.4.zip
unzip -o TensorRT.zip -d C:/

export CUDA_HOME="$(echo ${CUDA_PATH} | sed -e 's#\\#\/#g')"

cat toolchains/ci_workspaces/WORKSPACE.win.release.tmpl | envsubst > WORKSPACE

echo "RELEASE=1" >> ${GITHUB_ENV}
Loading
Loading