Skip to content

Commit 22cfa2b

Browse files
committed
Merge branch 'main' into lluo/add_fail_fast
2 parents 6d37407 + bfedc3c commit 22cfa2b

File tree

49 files changed

+718
-261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+718
-261
lines changed

.github/scripts/filter-matrix.py

Lines changed: 85 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,62 @@
44
import json
55
import os
66
import sys
7-
from typing import List
7+
from typing import Any, Dict, List
88

99
# currently we don't support python 3.13t due to tensorrt does not support 3.13t
1010
disabled_python_versions: List[str] = ["3.13t"]
1111

12+
# jetpack 6.2 only officially supports python 3.10 and cu126
13+
jetpack_python_versions: List[str] = ["3.10"]
14+
jetpack_cuda_versions: List[str] = ["cu126"]
15+
16+
jetpack_container_image: str = "nvcr.io/nvidia/l4t-jetpack:r36.4.0"
17+
sbsa_container_image: str = "quay.io/pypa/manylinux_2_34_aarch64"
18+
19+
20+
def validate_matrix(matrix_dict: Dict[str, Any]) -> None:
21+
"""Validate the structure of the input matrix."""
22+
if not isinstance(matrix_dict, dict):
23+
raise ValueError("Matrix must be a dictionary")
24+
if "include" not in matrix_dict:
25+
raise ValueError("Matrix must contain 'include' key")
26+
if not isinstance(matrix_dict["include"], list):
27+
raise ValueError("Matrix 'include' must be a list")
28+
29+
30+
def filter_matrix_item(
31+
item: Dict[str, Any],
32+
is_jetpack: bool,
33+
limit_pr_builds: bool,
34+
) -> bool:
35+
"""Filter a single matrix item based on the build type and requirements."""
36+
if item["python_version"] in disabled_python_versions:
37+
# Skipping disabled Python version
38+
return False
39+
40+
if is_jetpack:
41+
if limit_pr_builds:
42+
# pr build,matrix passed from test-infra is cu128, python 3.9, change to cu126, python 3.10
43+
item["desired_cuda"] = "cu126"
44+
item["python_version"] = "3.10"
45+
item["container_image"] = jetpack_container_image
46+
return True
47+
else:
48+
# nightly/main build, matrix passed from test-infra is cu128, all python versions, change to cu126, python 3.10
49+
if item["python_version"] in jetpack_python_versions:
50+
item["desired_cuda"] = "cu126"
51+
item["container_image"] = jetpack_container_image
52+
return True
53+
return False
54+
else:
55+
if item["gpu_arch_type"] == "cuda-aarch64":
56+
# pytorch image:pytorch/manylinuxaarch64-builder:cuda12.8 comes with glibc2.28
57+
# however, TensorRT requires glibc2.31 on aarch64 platform
58+
# TODO: in future, if pytorch supports aarch64 with glibc2.31, we should switch to use the pytorch image
59+
item["container_image"] = sbsa_container_image
60+
return True
61+
return True
62+
1263

1364
def main(args: list[str]) -> None:
1465
parser = argparse.ArgumentParser()
@@ -19,27 +70,46 @@ def main(args: list[str]) -> None:
1970
default="",
2071
)
2172

22-
options = parser.parse_args(args)
73+
parser.add_argument(
74+
"--jetpack",
75+
help="is jetpack",
76+
type=str,
77+
choices=["true", "false"],
78+
default="false",
79+
)
80+
81+
parser.add_argument(
82+
"--limit-pr-builds",
83+
help="If it is a PR build",
84+
type=str,
85+
choices=["true", "false"],
86+
default=os.getenv("LIMIT_PR_BUILDS", "false"),
87+
)
2388

89+
options = parser.parse_args(args)
2490
if options.matrix == "":
25-
raise Exception("--matrix needs to be provided")
91+
raise ValueError("--matrix needs to be provided")
92+
93+
try:
94+
matrix_dict = json.loads(options.matrix)
95+
validate_matrix(matrix_dict)
96+
except json.JSONDecodeError as e:
97+
raise ValueError(f"Invalid JSON in matrix: {e}")
98+
except ValueError as e:
99+
raise ValueError(f"Invalid matrix structure: {e}")
26100

27-
matrix_dict = json.loads(options.matrix)
28101
includes = matrix_dict["include"]
29102
filtered_includes = []
103+
30104
for item in includes:
31-
if item["python_version"] in disabled_python_versions:
32-
continue
33-
if item["gpu_arch_type"] == "cuda-aarch64":
34-
# pytorch image:pytorch/manylinuxaarch64-builder:cuda12.8 comes with glibc2.28
35-
# however, TensorRT requires glibc2.31 on aarch64 platform
36-
# TODO: in future, if pytorch supports aarch64 with glibc2.31, we should switch to use the pytorch image
37-
item["container_image"] = "quay.io/pypa/manylinux_2_34_aarch64"
105+
if filter_matrix_item(
106+
item,
107+
options.jetpack == "true",
108+
options.limit_pr_builds == "true",
109+
):
38110
filtered_includes.append(item)
39-
else:
40-
filtered_includes.append(item)
41-
filtered_matrix_dict = {}
42-
filtered_matrix_dict["include"] = filtered_includes
111+
112+
filtered_matrix_dict = {"include": filtered_includes}
43113
print(json.dumps(filtered_matrix_dict))
44114

45115

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build and test Linux aarch64 wheels for Jetpack
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- nightly
9+
- release/*
10+
tags:
11+
# NOTE: Binary build pipelines should only get triggered on release candidate builds
12+
# Release candidate tags look like: v1.11.0-rc1
13+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
14+
workflow_dispatch:
15+
16+
jobs:
17+
generate-matrix:
18+
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
19+
with:
20+
package-type: wheel
21+
os: linux-aarch64
22+
test-infra-repository: pytorch/test-infra
23+
test-infra-ref: main
24+
with-rocm: false
25+
with-cpu: false
26+
27+
filter-matrix:
28+
needs: [generate-matrix]
29+
outputs:
30+
matrix: ${{ steps.filter.outputs.matrix }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.11"
36+
- uses: actions/checkout@v4
37+
with:
38+
repository: pytorch/tensorrt
39+
- name: Filter matrix
40+
id: filter
41+
env:
42+
LIMIT_PR_BUILDS: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ciflow/binaries/all') }}
43+
run: |
44+
set -eou pipefail
45+
echo "LIMIT_PR_BUILDS=${LIMIT_PR_BUILDS}"
46+
echo '${{ github.event_name }}'
47+
echo '${{ github.event.ref}}'
48+
MATRIX_BLOB=${{ toJSON(needs.generate-matrix.outputs.matrix) }}
49+
MATRIX_BLOB="$(python3 .github/scripts/filter-matrix.py --matrix "${MATRIX_BLOB}" --jetpack true --limit-pr-builds "${LIMIT_PR_BUILDS}")"
50+
echo "${MATRIX_BLOB}"
51+
echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}"
52+
53+
build:
54+
needs: filter-matrix
55+
permissions:
56+
id-token: write
57+
contents: read
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
include:
62+
- repository: pytorch/tensorrt
63+
pre-script: packaging/pre_build_script.sh
64+
env-var-script: packaging/env_vars.txt
65+
post-script: packaging/post_build_script.sh
66+
smoke-test-script: packaging/smoke_test_script.sh
67+
package-name: torch_tensorrt
68+
name: Build torch-tensorrt whl package
69+
uses: ./.github/workflows/build_wheels_linux_aarch64.yml
70+
with:
71+
repository: ${{ matrix.repository }}
72+
ref: ""
73+
test-infra-repository: pytorch/test-infra
74+
test-infra-ref: main
75+
build-matrix: ${{ needs.filter-matrix.outputs.matrix }}
76+
pre-script: ${{ matrix.pre-script }}
77+
env-var-script: ${{ matrix.env-var-script }}
78+
post-script: ${{ matrix.post-script }}
79+
package-name: ${{ matrix.package-name }}
80+
smoke-test-script: ${{ matrix.smoke-test-script }}
81+
trigger-event: ${{ github.event_name }}
82+
architecture: "aarch64"
83+
is-jetpack: true
84+
85+
86+
concurrency:
87+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}
88+
cancel-in-progress: true

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
filter-matrix:
2828
needs: [generate-matrix]
2929
outputs:
30-
matrix: ${{ steps.generate.outputs.matrix }}
30+
matrix: ${{ steps.filter.outputs.matrix }}
3131
runs-on: ubuntu-latest
3232
steps:
3333
- uses: actions/setup-python@v5
@@ -36,8 +36,10 @@ jobs:
3636
- uses: actions/checkout@v4
3737
with:
3838
repository: pytorch/tensorrt
39-
- name: Generate matrix
40-
id: generate
39+
- name: Filter matrix
40+
id: filter
41+
env:
42+
LIMIT_PR_BUILDS: ${{ github.event_name == 'pull_request' && !contains( github.event.pull_request.labels.*.name, 'ciflow/binaries/all') }}
4143
run: |
4244
set -eou pipefail
4345
MATRIX_BLOB=${{ toJSON(needs.generate-matrix.outputs.matrix) }}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and test Linux wheels
1+
name: Build and test Linux x86_64 wheels
22

33
on:
44
pull_request:
@@ -191,7 +191,6 @@ jobs:
191191
pushd .
192192
cd tests/py
193193
python -m pip install -r requirements.txt
194-
python -m pip install nvidia-modelopt[all] --extra-index-url https://pypi.nvidia.com
195194
cd dynamo
196195
python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 4 conversion/
197196
python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml automatic_plugin/test_automatic_plugin.py
@@ -226,7 +225,6 @@ jobs:
226225
pushd .
227226
cd tests/py
228227
python -m pip install -r requirements.txt
229-
python -m pip install nvidia-modelopt[all] --extra-index-url https://pypi.nvidia.com
230228
cd dynamo
231229
python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/
232230
popd

.github/workflows/build_wheels_linux_aarch64.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ on:
8888
required: false
8989
default: "python -m build --wheel"
9090
type: string
91+
is-jetpack:
92+
description: Set to true if the build is for jetpack
93+
required: false
94+
default: false
95+
type: boolean
9196
pip-install-torch-extra-args:
9297
# NOTE: Why does this exist?
9398
# Well setuptools / python packaging doesn't actually allow you to specify dependencies
@@ -128,7 +133,7 @@ jobs:
128133
UPLOAD_TO_BASE_BUCKET: ${{ matrix.upload_to_base_bucket }}
129134
ARCH: ${{ inputs.architecture }}
130135
BUILD_TARGET: ${{ inputs.build-target }}
131-
name: build-${{ matrix.build_name }}
136+
name: build-wheel-${{ matrix.python_version }}-${{ matrix.desired_cuda }}-${{ matrix.gpu_arch_type }}
132137
runs-on: ${{ matrix.validation_runner }}
133138
environment: ${{(inputs.trigger-event == 'schedule' || (inputs.trigger-event == 'push' && (startsWith(github.event.ref, 'refs/heads/nightly') || startsWith(github.event.ref, 'refs/tags/v')))) && 'pytorchbot-env' || ''}}
134139
container:
@@ -170,6 +175,11 @@ jobs:
170175
# when using Python version, less than the conda latest
171176
###############################################################################
172177
echo 'Installing conda-forge'
178+
if [[ ${{ inputs.is-jetpack }} == true ]]; then
179+
# jetpack base image is ubuntu 22.04, does not have curl installed
180+
apt-get update
181+
apt-get install -y curl git
182+
fi
173183
curl -L -o /mambaforge.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh
174184
chmod +x /mambaforge.sh
175185
/mambaforge.sh -b -p /opt/conda
@@ -195,12 +205,11 @@ jobs:
195205
python-version: ${{ env.PYTHON_VERSION }}
196206
cuda-version: ${{ env.CU_VERSION }}
197207
arch: ${{ env.ARCH }}
198-
199208
- name: Combine Env Var and Build Env Files
200209
if: ${{ inputs.env-var-script != '' }}
201210
working-directory: ${{ inputs.repository }}
202211
run: |
203-
set -euxo pipefail
212+
set -x
204213
cat "${{ inputs.env-var-script }}" >> "${BUILD_ENV_FILE}"
205214
- name: Add XPU Env Vars in Build Env File
206215
if: ${{ matrix.gpu_arch_type == 'xpu' }}
@@ -211,6 +220,7 @@ jobs:
211220
echo "source /opt/intel/oneapi/pti/latest/env/vars.sh"
212221
} >> "${BUILD_ENV_FILE}"
213222
- name: Install torch dependency
223+
if: ${{ inputs.is-jetpack == false }}
214224
run: |
215225
set -euxo pipefail
216226
# shellcheck disable=SC1090
@@ -241,12 +251,21 @@ jobs:
241251
working-directory: ${{ inputs.repository }}
242252
shell: bash -l {0}
243253
run: |
244-
set -euxo pipefail
254+
#set -euxo pipefail
255+
set -x
245256
source "${BUILD_ENV_FILE}"
246257
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
247258
${CONDA_RUN} python setup.py clean
248259
echo "Successfully ran `python setup.py clean`"
249-
${CONDA_RUN} python setup.py bdist_wheel
260+
if [[ "$BUILD_VERSION" != *"+"${CU_VERSION} ]]; then
261+
BUILD_VERSION="${BUILD_VERSION}+${CU_VERSION}"
262+
fi
263+
echo "BUILD_VERSION=$BUILD_VERSION"
264+
if [[ ${{ inputs.is-jetpack }} == false ]]; then
265+
${CONDA_RUN} python setup.py bdist_wheel
266+
else
267+
${CONDA_RUN} python setup.py bdist_wheel --jetpack --plat-name=linux_tegra_aarch64
268+
fi
250269
- name: Repair Manylinux_2_28 Wheel
251270
shell: bash -l {0}
252271
env:
@@ -272,6 +291,7 @@ jobs:
272291
script: ${{ inputs.post-script }}
273292
- name: Smoke Test
274293
shell: bash -l {0}
294+
if: ${{ inputs.is-jetpack == false }}
275295
env:
276296
PACKAGE_NAME: ${{ inputs.package-name }}
277297
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
@@ -316,7 +336,8 @@ jobs:
316336
upload:
317337
needs: build
318338
uses: pytorch/test-infra/.github/workflows/_binary_upload.yml@main
319-
if: always()
339+
# for jetpack builds, only upload to pytorch index for nightly builds
340+
if: ${{ inputs.is-jetpack == false || (github.event_name == 'push' && startsWith(github.event.ref, 'refs/heads/nightly')) }}
320341
with:
321342
repository: ${{ inputs.repository }}
322343
ref: ${{ inputs.ref }}

MODULE.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ http_archive(
8787
urls = ["https://download.pytorch.org/libtorch/nightly/cu128/libtorch-win-shared-with-deps-latest.zip"],
8888
)
8989

90+
http_archive(
91+
name = "torch_l4t",
92+
build_file = "@//third_party/libtorch:BUILD",
93+
strip_prefix = "torch",
94+
type = "zip",
95+
urls = ["https://pypi.jetson-ai-lab.dev/jp6/cu126/+f/6ef/f643c0a7acda9/torch-2.7.0-cp310-cp310-linux_aarch64.whl"],
96+
sha256 = "6eff643c0a7acda92734cc798338f733ff35c7df1a4434576f5ff7c66fc97319"
97+
)
98+
9099
# Download these tarballs manually from the NVIDIA website
91100
# Either place them in the distdir directory in third_party and use the --distdir flag
92101
# or modify the urls to "file:///<PATH TO TARBALL>/<TARBALL NAME>.tar.gz

core/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ cc_library(
6666
}) + select({
6767
":windows": ["@libtorch_win//:libtorch"],
6868
":use_torch_whl": ["@torch_whl//:libtorch"],
69+
":jetpack": ["@torch_l4t//:libtorch"],
6970
"//conditions:default": ["@libtorch"],
7071
}),
7172
alwayslink = True,

core/conversion/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ cc_library(
6161
}) + select({
6262
":windows": ["@libtorch_win//:libtorch"],
6363
":use_torch_whl": ["@torch_whl//:libtorch"],
64+
":jetpack": ["@torch_l4t//:libtorch"],
6465
"//conditions:default": ["@libtorch"],
6566
}),
6667
alwayslink = True,

core/conversion/conversionctx/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cc_library(
5656
}) + select({
5757
":windows": ["@libtorch_win//:libtorch"],
5858
":use_torch_whl": ["@torch_whl//:libtorch"],
59+
":jetpack": ["@torch_l4t//:libtorch"],
5960
"//conditions:default": ["@libtorch"],
6061
}),
6162
alwayslink = True,

0 commit comments

Comments
 (0)