Skip to content

Commit 0b56822

Browse files
authored
feat: C++ runtime on Windows (#2806)
1 parent 70b5b12 commit 0b56822

File tree

15 files changed

+250
-102
lines changed

15 files changed

+250
-102
lines changed

.github/scripts/install-torch-tensorrt-windows.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
#!/usr/bin/env bash
21
set -eou pipefail
3-
# Source conda so it's available to the script environment
4-
source ${BUILD_ENV_FILE}
5-
export EXTRA_INDEX_URL="https://download.pytorch.org/whl/nightly/${CU_VERSION}"
2+
3+
TORCH_TORCHVISION=$(grep "^torch" ${PWD}/py/requirements.txt)
4+
INDEX_URL=https://download.pytorch.org/whl/${CHANNEL}/${CU_VERSION}
5+
PLATFORM=$(python -c "import sys; print(sys.platform)")
66

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

1011
# Install Torch-TensorRT
11-
${CONDA_RUN} pip install /opt/torch-tensorrt-builds/torch_tensorrt*.whl
12+
if [[ ${PLATFORM} == win32 ]]; then
13+
pip install ${RUNNER_ARTIFACT_DIR}/torch_tensorrt*.whl
14+
else
15+
pip install /opt/torch-tensorrt-builds/torch_tensorrt*.whl
16+
fi
1217

13-
echo -e "Running test script";
18+
echo -e "Running test script";

.github/workflows/build-test-linux.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ jobs:
8080
export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH
8181
pushd .
8282
cd tests/modules
83-
${CONDA_RUN} python hub.py
83+
python hub.py
8484
popd
8585
pushd .
8686
cd tests/py/ts
87-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_api_test_results.xml api/
88-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_models_test_results.xml models/
89-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_integrations_test_results.xml integrations/
87+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_api_test_results.xml api/
88+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_models_test_results.xml models/
89+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_integrations_test_results.xml integrations/
9090
popd
9191
9292
tests-py-dynamo-converters:
@@ -114,7 +114,7 @@ jobs:
114114
export USE_HOST_DEPS=1
115115
pushd .
116116
cd tests/py/dynamo
117-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/
117+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/
118118
popd
119119
120120
tests-py-dynamo-fe:
@@ -142,8 +142,8 @@ jobs:
142142
export USE_HOST_DEPS=1
143143
pushd .
144144
cd tests/py/dynamo
145-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_fe_test_results.xml --ir dynamo models/test_models_export.py
146-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/test_dyn_models.py
145+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_fe_test_results.xml --ir dynamo models/test_models_export.py
146+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/test_dyn_models.py
147147
popd
148148
149149
tests-py-dynamo-serde:
@@ -171,7 +171,7 @@ jobs:
171171
export USE_HOST_DEPS=1
172172
pushd .
173173
cd tests/py/dynamo
174-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py
174+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py
175175
popd
176176
177177
tests-py-torch-compile-be:
@@ -199,9 +199,9 @@ jobs:
199199
export USE_HOST_DEPS=1
200200
pushd .
201201
cd tests/py/dynamo
202-
${CONDA_RUN} python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/
203-
${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
204-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py
202+
python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/
203+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_comple_be_e2e_test_results.xml --ir torch_compile models/test_models.py
204+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py
205205
popd
206206
207207
tests-py-dynamo-core:
@@ -229,9 +229,9 @@ jobs:
229229
export USE_HOST_DEPS=1
230230
pushd .
231231
cd tests/py/dynamo
232-
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/
233-
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/
234-
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/
232+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/
233+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/
234+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/
235235
popd
236236
237237
tests-py-core:
@@ -259,7 +259,7 @@ jobs:
259259
export USE_HOST_DEPS=1
260260
pushd .
261261
cd tests/py/core
262-
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml .
262+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml .
263263
popd
264264
265265
concurrency:

.github/workflows/build-test-windows.yml

Lines changed: 110 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ jobs:
2424
with-rocm: false
2525
with-cpu: false
2626

27-
build:
27+
substitute-runner:
2828
needs: generate-matrix
29+
outputs:
30+
matrix: ${{ steps.substitute.outputs.matrix }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Substitute runner
34+
id: substitute
35+
run: |
36+
echo matrix="$(echo '${{ needs.generate-matrix.outputs.matrix }}' | sed -e 's/windows.8xlarge.nvidia.gpu/windows.g5.4xlarge.nvidia.gpu/g')" >> ${GITHUB_OUTPUT}
37+
38+
build:
39+
needs: substitute-runner
2940
permissions:
3041
id-token: write
3142
contents: read
@@ -35,6 +46,7 @@ jobs:
3546
include:
3647
- repository: pytorch/tensorrt
3748
pre-script: packaging/pre_build_script_windows.sh
49+
env-script: packaging/vc_env_helper.bat
3850
smoke-test-script: packaging/smoke_test_windows.py
3951
package-name: torch_tensorrt
4052
name: Build torch-tensorrt whl package
@@ -44,12 +56,44 @@ jobs:
4456
ref: ""
4557
test-infra-repository: pytorch/test-infra
4658
test-infra-ref: main
47-
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
59+
build-matrix: ${{ needs.substitute-runner.outputs.matrix }}
4860
pre-script: ${{ matrix.pre-script }}
61+
env-script: ${{ matrix.env-script }}
4962
smoke-test-script: ${{ matrix.smoke-test-script }}
5063
package-name: ${{ matrix.package-name }}
5164
trigger-event: ${{ github.event_name }}
5265

66+
tests-py-torchscript-fe:
67+
name: Test torchscript frontend [Python]
68+
needs: [generate-matrix, build]
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
include:
73+
- repository: pytorch/tensorrt
74+
package-name: torch_tensorrt
75+
uses: ./.github/workflows/windows-test.yml
76+
with:
77+
job-name: tests-py-torchscript-fe
78+
repository: ${{ matrix.repository }}
79+
ref: ""
80+
test-infra-repository: pytorch/test-infra
81+
test-infra-ref: main
82+
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
83+
pre-script: packaging/driver_upgrade.bat
84+
script: |
85+
export USE_HOST_DEPS=1
86+
pushd .
87+
cd tests/modules
88+
python hub.py
89+
popd
90+
pushd .
91+
cd tests/py/ts
92+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_api_test_results.xml api/
93+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_models_test_results.xml models/
94+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_integrations_test_results.xml integrations/
95+
popd
96+
5397
tests-py-dynamo-converters:
5498
name: Test dynamo converters [Python]
5599
needs: [generate-matrix, build]
@@ -62,7 +106,7 @@ jobs:
62106
uses: ./.github/workflows/windows-test.yml
63107
with:
64108
job-name: tests-py-dynamo-converters
65-
repository: "pytorch/tensorrt"
109+
repository: ${{ matrix.repository }}
66110
ref: ""
67111
test-infra-repository: pytorch/test-infra
68112
test-infra-ref: main
@@ -72,7 +116,7 @@ jobs:
72116
export USE_HOST_DEPS=1
73117
pushd .
74118
cd tests/py/dynamo
75-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/
119+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/
76120
popd
77121
78122
tests-py-dynamo-fe:
@@ -87,7 +131,33 @@ jobs:
87131
uses: ./.github/workflows/windows-test.yml
88132
with:
89133
job-name: tests-py-dynamo-fe
90-
repository: "pytorch/tensorrt"
134+
repository: ${{ matrix.repository }}
135+
ref: ""
136+
test-infra-repository: pytorch/test-infra
137+
test-infra-ref: main
138+
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
139+
pre-script: packaging/driver_upgrade.bat
140+
script: |
141+
export USE_HOST_DEPS=1
142+
pushd .
143+
cd tests/py/dynamo
144+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_fe_test_results.xml --ir dynamo models/test_models_export.py
145+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/test_dyn_models.py
146+
popd
147+
148+
tests-py-dynamo-serde:
149+
name: Test dynamo export serde [Python]
150+
needs: [generate-matrix, build]
151+
strategy:
152+
fail-fast: false
153+
matrix:
154+
include:
155+
- repository: pytorch/tensorrt
156+
package-name: torch_tensorrt
157+
uses: ./.github/workflows/windows-test.yml
158+
with:
159+
job-name: tests-py-dynamo-serde
160+
repository: ${{ matrix.repository }}
91161
ref: ""
92162
test-infra-repository: pytorch/test-infra
93163
test-infra-ref: main
@@ -97,8 +167,7 @@ jobs:
97167
export USE_HOST_DEPS=1
98168
pushd .
99169
cd tests/py/dynamo
100-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_fe_test_results.xml --ir dynamo models/test_models_export.py
101-
${CONDA_RUN} python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/test_dyn_models.py
170+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py
102171
popd
103172
104173
tests-py-torch-compile-be:
@@ -117,14 +186,15 @@ jobs:
117186
ref: ""
118187
test-infra-repository: pytorch/test-infra
119188
test-infra-ref: main
120-
pre-script: packaging/driver_upgrade.bat
121189
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
190+
pre-script: packaging/driver_upgrade.bat
122191
script: |
123192
export USE_HOST_DEPS=1
124193
pushd .
125194
cd tests/py/dynamo
126-
${CONDA_RUN} python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/
127-
${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
195+
python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/
196+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_comple_be_e2e_test_results.xml --ir torch_compile models/test_models.py
197+
python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py
128198
popd
129199
130200
tests-py-dynamo-core:
@@ -139,7 +209,7 @@ jobs:
139209
uses: ./.github/workflows/windows-test.yml
140210
with:
141211
job-name: tests-py-dynamo-core
142-
repository: "pytorch/tensorrt"
212+
repository: ${{ matrix.repository }}
143213
ref: ""
144214
test-infra-repository: pytorch/test-infra
145215
test-infra-ref: main
@@ -149,11 +219,36 @@ jobs:
149219
export USE_HOST_DEPS=1
150220
pushd .
151221
cd tests/py/dynamo
152-
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/
153-
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/
154-
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/
222+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/
223+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/
224+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/
225+
popd
226+
227+
tests-py-core:
228+
name: Test core [Python]
229+
needs: [generate-matrix, build]
230+
strategy:
231+
fail-fast: false
232+
matrix:
233+
include:
234+
- repository: pytorch/tensorrt
235+
package-name: torch_tensorrt
236+
uses: ./.github/workflows/windows-test.yml
237+
with:
238+
job-name: tests-py-core
239+
repository: ${{ matrix.repository }}
240+
ref: ""
241+
test-infra-repository: pytorch/test-infra
242+
test-infra-ref: main
243+
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
244+
pre-script: packaging/driver_upgrade.bat
245+
script: |
246+
export USE_HOST_DEPS=1
247+
pushd .
248+
cd tests/py/core
249+
python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml .
155250
popd
156251
157252
concurrency:
158253
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}
159-
cancel-in-progress: true
254+
cancel-in-progress: true

.github/workflows/windows-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
{
119119
echo "${SCRIPT}";
120120
} > "user_script"
121-
cat .github/scripts/install-torch-tensorrt-windows.sh user_script > exec_script
121+
cat .github/scripts/install-torch-tensorrt.sh user_script > exec_script
122122
- name: Run script
123123
uses: ./test-infra/.github/actions/run-script-with-cache
124124
with:

packaging/pre_build_script_windows.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
python -m pip install -U numpy packaging pyyaml setuptools wheel
1+
set -eou pipefail
22

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

6-
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
5+
# Install TRT from PyPI
6+
TRT_VERSION=$(python -c "import yaml; print(yaml.safe_load(open('dev_dep_versions.yml', 'r'))['__tensorrt_version__'])")
7+
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
78

89
choco install bazelisk -y
910

11+
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
12+
unzip -o TensorRT.zip -d C:/
13+
14+
export CUDA_HOME="$(echo ${CUDA_PATH} | sed -e 's#\\#\/#g')"
15+
1016
cat toolchains/ci_workspaces/WORKSPACE.win.release.tmpl | envsubst > WORKSPACE
1117

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

0 commit comments

Comments
 (0)