Skip to content

Commit a8e77ce

Browse files
cherry pick from release/2.14 branch back to main (#4687)
1 parent b021ec1 commit a8e77ce

33 files changed

Lines changed: 1704 additions & 1199 deletions
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env python3
2+
"""Drop CUDA architectures ExecuTorch's shims cannot compile for.
3+
4+
The shims call ``__dp4a``, which nvcc does not declare before sm_61, so a list carrying
5+
5.0 or 6.0 fails with ``identifier "__dp4a" is undefined`` whichever CUDA is in use. The
6+
cu126 build environment asks for ``5.0;6.0;7.0;7.5;8.0;8.6;9.0`` while the CUDA 13 ones
7+
start at 7.5, which is why only cu126 broke.
8+
9+
Filtering what the environment asked for rather than pinning a list here, so a channel
10+
that adds a newer architecture still builds for it without editing this file.
11+
"""
12+
13+
from __future__ import annotations
14+
15+
import sys
16+
17+
# The first architecture that declares __dp4a. GP100 is 6.0 and does not have it; the
18+
# rest of Pascal is 6.1 and does.
19+
MINIMUM = 6.1
20+
21+
# PyTorch accepts named architectures and expands each to a version list before building
22+
# its gencode flags (torch/utils/cpp_extension.py). Expand them the same way here, or a
23+
# name would pass through untouched and carry its sub-6.1 members into the build: Pascal
24+
# alone expands to 6.0;6.1+PTX, and 6.0 is precisely what this filter exists to drop.
25+
#
26+
# Ordered longest-key-first, and applied by substring replacement, because that is what
27+
# torch does: "Maxwell+Tegra" has to be replaced before "Maxwell", or the suffix is left
28+
# behind as "5.0;5.2+PTX+Tegra".
29+
NAMED_ARCHES = (
30+
("Kepler+Tesla", "3.7"),
31+
("Kepler", "3.5+PTX"),
32+
("Maxwell+Tegra", "5.3"),
33+
("Maxwell", "5.0;5.2+PTX"),
34+
("Pascal", "6.0;6.1+PTX"),
35+
("Volta+Tegra", "7.2"),
36+
("Volta", "7.0+PTX"),
37+
("Turing", "7.5+PTX"),
38+
("Ampere+Tegra", "8.7"),
39+
("Ampere", "8.0;8.6+PTX"),
40+
("Ada", "8.9+PTX"),
41+
("Hopper", "9.0+PTX"),
42+
("Blackwell+Tegra", "11.0"),
43+
("Blackwell", "10.0;10.3;12.0;12.1+PTX"),
44+
("Rubin", "10.7+PTX"),
45+
)
46+
47+
48+
def filter_arches(requested: str) -> list[str]:
49+
for name, versions in NAMED_ARCHES:
50+
requested = requested.replace(name, versions)
51+
kept = []
52+
# A list may be comma, space or semicolon separated. torch normalises spaces the same way
53+
# (torch/utils/cpp_extension.py does _arch_list.replace(' ', ';')), so accept all three rather
54+
# than silently passing a space-separated list through unfiltered.
55+
for entry in requested.replace(",", ";").replace(" ", ";").split(";"):
56+
entry = entry.strip()
57+
if not entry:
58+
continue
59+
# An entry may carry a suffix such as "8.6+PTX", which sorts by its number.
60+
number = entry.split("+", 1)[0]
61+
try:
62+
if float(number) >= MINIMUM:
63+
kept.append(entry)
64+
except ValueError:
65+
# Not a version this understands. Keep it and let the compiler judge,
66+
# rather than silently dropping a target that may be real.
67+
kept.append(entry)
68+
return kept
69+
70+
71+
def main(argv: list[str]) -> int:
72+
requested = argv[1] if len(argv) > 1 else ""
73+
kept = filter_arches(requested)
74+
if requested.strip() and not kept:
75+
# Printing nothing would leave nvcc to pick its own default, which is not what
76+
# the channel asked for and would ship a wheel for the wrong architectures.
77+
print(
78+
f"No CUDA architecture in {requested!r} is at or above sm_61, "
79+
"which ExecuTorch's CUDA shims require.",
80+
file=sys.stderr,
81+
)
82+
return 1
83+
print(";".join(kept))
84+
return 0
85+
86+
87+
if __name__ == "__main__":
88+
raise SystemExit(main(sys.argv))

‎.github/workflows/_test-linux.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ jobs:
106106
trigger-event: ${{ github.event_name }}
107107
architecture: ${{ inputs.architecture }}
108108
use-rtx: ${{ inputs.use-rtx }}
109+
# The runtime is a companion of the standard wheel, so ship it in the
110+
# same artifact bundle. RTX and PYTHON_ONLY wheels intentionally omit it.
111+
build-executorch-runtime: ${{ !inputs.python-only && !inputs.use-rtx }}
109112
pip-install-torch-extra-args: "--extra-index-url https://pypi.org/simple"
110113

111114
# Suite list from the manifest. Skipped for build-only channels (SBSA).

‎.github/workflows/build_linux.yml‎

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ on:
5454
description: "The target to build and publish (for repos that build multiple packages)"
5555
default: ""
5656
type: string
57+
artifact-name-prefix:
58+
description: "Optional prefix added to the GitHub wheel artifact name"
59+
default: ""
60+
type: string
5761
trigger-event:
5862
description: "Trigger Event in caller that determines whether or not to upload"
5963
default: ""
@@ -117,6 +121,11 @@ on:
117121
required: false
118122
type: boolean
119123
default: true
124+
build-executorch-runtime:
125+
description: "Build the companion torch-tensorrt-executorch-runtime wheel into dist/"
126+
required: false
127+
type: boolean
128+
default: false
120129
pip-install-torch-extra-args:
121130
# NOTE: Why does this exist?
122131
# Well setuptools / python packaging doesn't actually allow you to specify dependencies
@@ -273,6 +282,11 @@ jobs:
273282
- name: Mark TensorRT-RTX artifact
274283
if: ${{ inputs.use-rtx }}
275284
run: echo "ARTIFACT_NAME=${ARTIFACT_NAME}_rtx" >> "${GITHUB_ENV}"
285+
- name: Prefix wheel artifact
286+
if: ${{ inputs.artifact-name-prefix }}
287+
env:
288+
ARTIFACT_PREFIX: ${{ inputs.artifact-name-prefix }}
289+
run: echo "ARTIFACT_NAME=${ARTIFACT_PREFIX}-${ARTIFACT_NAME}" >> "${GITHUB_ENV}"
276290
- name: Combine Env Var and Build Env Files
277291
if: ${{ inputs.env-var-script != '' }}
278292
working-directory: ${{ inputs.repository }}
@@ -378,6 +392,41 @@ jobs:
378392
${CONDA_RUN} python setup.py bdist_wheel ${param}
379393
fi
380394
fi
395+
# Keep the ExecuTorch runtime in the standard wheel artifact. This makes
396+
# its packaging, manylinux repair, GitHub artifact, and PyTorch-index
397+
# upload follow the exact same path as torch-tensorrt itself.
398+
- name: Build the ExecuTorch runtime wheel
399+
if: ${{ inputs.build-executorch-runtime }}
400+
working-directory: ${{ inputs.repository }}
401+
shell: bash -l {0}
402+
run: |
403+
set -euxo pipefail
404+
source "${BUILD_ENV_FILE}"
405+
# The runtime links against the just-built standard wheel. Install it
406+
# without resolving dependencies so it cannot replace the matrix's
407+
# pinned torch/TensorRT packages.
408+
${CONDA_RUN} python -m pip install --no-deps dist/torch_tensorrt*.whl
409+
${CONDA_RUN} python -m pip install pyyaml "executorch==1.4.1"
410+
TORCH_CUDA_ARCH_LIST="$(${CONDA_RUN} python .github/scripts/filter-executorch-cuda-arches.py "${TORCH_CUDA_ARCH_LIST:-}")"
411+
export TORCH_CUDA_ARCH_LIST
412+
echo "TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST}"
413+
# Give the companion wheel the same channel/date and CUDA local-version
414+
# suffix as torch-tensorrt, while retaining its independent base version.
415+
main_version="$(sed 's/a0$//' version.txt)"
416+
runtime_version="$(<py/torch-tensorrt-executorch-runtime/version.txt)"
417+
if [[ "${BUILD_VERSION}" != "${main_version}"* ]]; then
418+
echo "Unexpected torch-tensorrt build version: ${BUILD_VERSION}" >&2
419+
exit 1
420+
fi
421+
if [[ ${{ inputs.is-release-wheel }} == true ]]; then
422+
BUILD_VERSION="${BUILD_VERSION%+*}"
423+
elif [[ "${BUILD_VERSION}" != *"+${CU_VERSION}" ]]; then
424+
BUILD_VERSION="${BUILD_VERSION}+${CU_VERSION}"
425+
fi
426+
export TORCH_TENSORRT_EXECUTORCH_RUNTIME_VERSION="${runtime_version}${BUILD_VERSION#"${main_version}"}"
427+
echo "TORCH_TENSORRT_EXECUTORCH_RUNTIME_VERSION=${TORCH_TENSORRT_EXECUTORCH_RUNTIME_VERSION}"
428+
${CONDA_RUN} python -m pip wheel --no-build-isolation --no-deps --wheel-dir dist \
429+
py/torch-tensorrt-executorch-runtime
381430
- name: Repair Manylinux_2_28 Wheel
382431
shell: bash -l {0}
383432
env:
@@ -402,6 +451,29 @@ jobs:
402451
with:
403452
repository: ${{ inputs.repository }}
404453
script: ${{ inputs.post-script }}
454+
- name: Inventory packaged wheels
455+
# Keep this immediately before the smoke test/upload boundary. When a
456+
# matrix row fails downstream, its log shows exactly which repaired
457+
# wheels (and package versions) were placed in the GitHub artifact.
458+
if: ${{ inputs.is-release-tarball == false }}
459+
shell: bash -l {0}
460+
working-directory: ${{ inputs.repository }}
461+
run: |
462+
set -euo pipefail
463+
shopt -s nullglob
464+
wheels=(dist/*.whl)
465+
if [[ ${#wheels[@]} -eq 0 ]]; then
466+
echo "No wheels were produced in dist/" >&2
467+
exit 1
468+
fi
469+
echo "Packaged wheels to upload:"
470+
for wheel in "${wheels[@]}"; do
471+
echo " $(basename "${wheel}") ($(stat -c%s "${wheel}") bytes)"
472+
metadata_path="$(unzip -Z1 "${wheel}" '*.dist-info/METADATA' | head -n1)"
473+
if [[ -n "${metadata_path}" ]]; then
474+
unzip -p "${wheel}" "${metadata_path}" | grep -E '^(Name|Version):' || true
475+
fi
476+
done
405477
- name: Smoke Test
406478
# Release tarball builds do not produce a wheel.
407479
if: ${{ inputs.run-smoke-test && inputs.is-release-tarball == false }}
@@ -412,8 +484,20 @@ jobs:
412484
run: |
413485
set -euxo pipefail
414486
source "${BUILD_ENV_FILE}"
415-
WHEEL_NAME=$(ls "${{ inputs.repository }}/dist/")
416-
echo "$WHEEL_NAME"
487+
# PACKAGE_NAME is the import package used below. The RTX
488+
# distribution intentionally has a different wheel stem while still
489+
# importing as torch_tensorrt.
490+
WHEEL_DISTRIBUTION="${PACKAGE_NAME}"
491+
if [[ "${USE_TRT_RTX}" == "true" ]]; then
492+
WHEEL_DISTRIBUTION="${PACKAGE_NAME}_rtx"
493+
fi
494+
WHEEL_PATH="$(find "${{ inputs.repository }}/dist" -maxdepth 1 -type f -name "${WHEEL_DISTRIBUTION}-*.whl" -print -quit)"
495+
if [[ -z "${WHEEL_PATH}" ]]; then
496+
echo "No wheel for distribution ${WHEEL_DISTRIBUTION} was built" >&2
497+
exit 1
498+
fi
499+
WHEEL_NAME="$(basename "${WHEEL_PATH}")"
500+
echo "${WHEEL_NAME}"
417501
if [[ ${{ inputs.architecture }} == "aarch64" ]]; then
418502
echo "Skipping smoke test for aarch64, since it is not an actual gpu runner"
419503
else

‎.github/workflows/build_windows.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ jobs:
190190
if: inputs.cross-compile
191191
shell: powershell
192192
env:
193-
CUDA_INSTALLER_URL: https://packages.nvidia.com/prerelease/cuda/13.4.0/local_installers/cuda_13.4.0_windows_x86_64.exe
193+
CUDA_INSTALLER_URL: https://developer.download.nvidia.com/compute/cuda/13.4.1/local_installers/cuda_13.4.1_windows_x86_64.exe
194194
CUDA_ROOT: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.4
195195
run: |
196196
$ErrorActionPreference = 'Stop'
197-
$installer = Join-Path $env:RUNNER_TEMP "cuda_13.4.0_windows_x86_64.exe"
197+
$installer = Join-Path $env:RUNNER_TEMP "cuda_13.4.1_windows_x86_64.exe"
198198
$cudaArm64Lib = Join-Path $env:CUDA_ROOT "lib\arm64\cudart.lib"
199199
$maxAttempts = 3
200200
for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) {

‎.github/workflows/ci-linux-x86_64.yml‎

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
types: [submitted]
1212
push:
1313
branches: [main, nightly, 'release/**']
14+
# Keep CI in lockstep with the release artifact workflows. A tag push is
15+
# resolved by _decide.yml as the full lane.
16+
tags:
17+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
1418
workflow_dispatch:
1519
inputs:
1620
lane:
@@ -109,9 +113,10 @@ jobs:
109113
name-prefix: "Python-only RTX "
110114
raw-matrix: ${{ needs.generate-matrix.outputs.matrix }}
111115

112-
# ExecuTorch runtime is supported by the standard TensorRT wheel only. Wait
113-
# for the standard channel to upload its wheel artifact, but still build the
114-
# runtime if a standard test fails.
116+
# ExecuTorch runtime is bundled with the standard wheel artifact. The build
117+
# uploads that artifact before the standard suite completes, so still run
118+
# this independent coverage if a standard test fails. A cancelled standard
119+
# channel may not have uploaded anything, so skip that case.
115120
#
116121
# A standard channel that was CANCELLED is different from one that failed a test:
117122
# it uploaded no wheel, so this job has nothing to download and dies with
@@ -120,32 +125,15 @@ jobs:
120125
# main shows ten red ExecuTorch rows whenever two commits land close together. The
121126
# standard channel has its own concurrency group, so it can be cancelled on its own
122127
# while this run continues.
123-
executorch-runtime-build:
124-
needs: [decide, generate-matrix, standard]
125-
if: >-
126-
!cancelled() &&
127-
needs.decide.result == 'success' &&
128-
needs.generate-matrix.result == 'success' &&
129-
needs.standard.result != 'cancelled' &&
130-
needs.decide.outputs.lane != 'skip' &&
131-
needs.decide.outputs.backend != 'rtx'
132-
uses: ./.github/workflows/executorch-build-linux.yml
133-
with:
134-
repository: pytorch/tensorrt
135-
ref: ""
136-
test-infra-repository: pytorch/test-infra
137-
test-infra-ref: main
138-
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
139-
140128
executorch-runtime-test:
141-
needs: [decide, generate-matrix, executorch-runtime-build]
129+
needs: [decide, generate-matrix, standard]
142130
if: >-
143131
always() &&
144132
needs.decide.result == 'success' &&
145133
needs.generate-matrix.result == 'success' &&
146134
needs.decide.outputs.lane != 'skip' &&
147135
needs.decide.outputs.backend != 'rtx' &&
148-
needs.executorch-runtime-build.result == 'success'
136+
needs.standard.result != 'cancelled'
149137
uses: ./.github/workflows/executorch-test-linux.yml
150138
with:
151139
repository: pytorch/tensorrt
@@ -156,7 +144,7 @@ jobs:
156144

157145
# Required check. Fails ONLY on a genuine failure; skipped/cancelled don't block.
158146
gate:
159-
needs: [decide, standard, rtx, python-only, python-only-rtx, executorch-runtime-build, executorch-runtime-test]
147+
needs: [decide, standard, rtx, python-only, python-only-rtx, executorch-runtime-test]
160148
if: always()
161149
runs-on: ubuntu-latest
162150
steps:
@@ -171,7 +159,7 @@ jobs:
171159
172160
# Consolidated, agent-friendly report over this run's suites (informational).
173161
report:
174-
needs: [standard, rtx, python-only, python-only-rtx, executorch-runtime-build, executorch-runtime-test]
162+
needs: [standard, rtx, python-only, python-only-rtx, executorch-runtime-test]
175163
if: always()
176164
runs-on: ubuntu-latest
177165
steps:

‎.github/workflows/ci-sbsa.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ on:
1313
types: [submitted]
1414
push:
1515
branches: [main, nightly, 'release/**']
16+
# Keep CI in lockstep with the release artifact workflows. A tag push is
17+
# resolved by _decide.yml as the full lane.
18+
tags:
19+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
1620
workflow_dispatch:
1721
inputs:
1822
lane:

‎.github/workflows/ci-windows.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
types: [submitted]
1212
push:
1313
branches: [main, nightly, 'release/**']
14+
# Keep CI in lockstep with the release artifact workflows. A tag push is
15+
# resolved by _decide.yml as the full lane.
16+
tags:
17+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
1418
workflow_dispatch:
1519
inputs:
1620
lane:

0 commit comments

Comments
 (0)