Repository navigation
674 lines (660 loc) · 32.8 KB
/
Copy pathbuild_linux.yml
File metadata and controls
674 lines (660 loc) · 32.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
# Synced from pytorch/test-infra build_wheels_linux.yml at c4a3250c59bca917923a480c1712ae55f3f2d77e.
# This workflow is used to build the wheels for the Linux platform
# it should be periodically synced with https://github.com/pytorch/test-infra/blob/main/.github/workflows/build_wheels_linux.yml
name: Build Linux Wheels
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
post-script:
description: "Post script to run prior to build"
default: ""
type: string
smoke-test-script:
description: "Script for Smoke Test for a specific domain"
default: ""
type: string
env-var-script:
description: "Script that sets Domain-Specific Environment Variables"
default: ""
type: string
python-only:
description: "Build the PYTHON_ONLY=1 wheel"
default: false
type: boolean
package-name:
description: "Name of the actual python package that is imported in the smoke test"
default: ""
type: string
build-target:
description: "The target to build and publish (for repos that build multiple packages)"
default: ""
type: string
artifact-name-prefix:
description: "Optional prefix added to the GitHub wheel artifact name"
default: ""
type: string
trigger-event:
description: "Trigger Event in caller that determines whether or not to upload"
default: ""
type: string
cache-path:
description: "The path(s) on the runner to cache or restore. The path is relative to repository."
default: ""
type: string
cache-key:
description: "The key created when saving a cache and the key used to search for a cache."
default: ""
type: string
architecture:
description: Architecture to build for x86_64 for default Linux, or aarch64 for Linux aarch64 builds
required: false
type: string
default: x86_64
runner:
description: "Override runner for builds"
default: ""
type: string
submodules:
description: Works as stated in actions/checkout, but the default value is recursive
required: false
type: string
default: recursive
setup-miniconda:
description: Set to true if setup-miniconda is needed
required: false
type: boolean
default: true
build-platform:
description: Platform to build wheels, choose from 'python-build-package' or 'setup-py'
required: false
type: string
default: 'setup-py'
upload-to-pypi:
description: The comma-separated list of CUDA arch to be uploaded to pypi
default: ""
type: string
build-command:
description: The build command to use if build-platform is python-build-package
required: false
default: "python -m build --wheel"
type: string
wheel-upload-path:
description: Custom wheel upload path
required: false
type: string
wheel-nightly-policy:
description: Custom wheel upload policy for nightly
type: string
default: ''
also-upload-to-gpu-arch-versions:
description: "Comma-separated list of extra gpu_arch_versions to upload the wheel to (e.g. 'xpu' to also upload a cpu wheel to the xpu index)"
required: false
type: string
default: ''
run-smoke-test:
description: Set to true if smoke test is needed
required: false
type: boolean
default: true
build-executorch-runtime:
description: "Build the companion torch-tensorrt-executorch-runtime wheel into dist/"
required: false
type: boolean
default: false
pip-install-torch-extra-args:
# NOTE: Why does this exist?
# Well setuptools / python packaging doesn't actually allow you to specify dependencies
# that come from other index URLs when you are building a package for "security" purposes.
# Unfortunately for us our nightlies (torch, torchvision, etc.) only exist on download.pytorch.org
# which means that if our users depend on things like torchvision then they need to have
# an ability to install these dependencies from download.pytorch.org, as part of the build process
# which currently the do not have the ability to do through normal means, hence this parameter
# Reference: https://discuss.python.org/t/specifying-extra-index-url-in-setup-cfg-option-dependencies/19377
description: Extra arguments to pass to the command that install base torch dependency
required: false
default: ""
type: string
timeout:
description: 'Timeout for the job (in minutes)'
default: 120
type: number
use-rtx:
description: "Set to true if use TensorRT-RTX"
default: false
type: boolean
required: false
is-jetpack:
description: Set to true if the build is for jetpack
required: false
default: false
type: boolean
is-release-wheel:
description: Set to true if the build is for release wheel
required: false
default: false
type: boolean
is-release-tarball:
description: Set to true if the build is for release tarball
required: false
default: false
type: boolean
secrets:
PYPI_API_TOKEN:
description: An optional token to upload to pypi
required: false
R2_ACCOUNT_ID:
description: Cloudflare R2 account ID
required: false
R2_ACCESS_KEY_ID:
description: Cloudflare R2 access key ID
required: false
R2_SECRET_ACCESS_KEY:
description: Cloudflare R2 secret access key
required: false
permissions:
id-token: write
contents: read
jobs:
build:
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 }}
UPLOAD_TO_BASE_BUCKET: ${{ matrix.upload_to_base_bucket }}
ARCH: ${{ inputs.architecture }}
BUILD_TARGET: ${{ inputs.build-target }}
USE_TRT_RTX: ${{ inputs.use-rtx }}
name: build-wheel-${{ matrix.python_version }}-${{ matrix.desired_cuda }}-${{ matrix.gpu_arch_type }}-${{ inputs.architecture }}-${{ inputs.use-rtx }}-${{ inputs.is-jetpack }}
runs-on: ${{ (inputs.runner != '' && inputs.runner) || matrix.validation_runner }}
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' || ''}}
container:
image: ${{ matrix.container_image }}
options: ${{ matrix.gpu_arch_type == 'cuda' && '--gpus all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,video' || ' ' }}
timeout-minutes: ${{ inputs.timeout }}
steps:
- name: Clean workspace
shell: bash -l {0}
run: |
set -euxo pipefail
echo "::group::Cleanup debug output"
# Clear the workspace without removing the directory itself. On an OSDC
# runner GITHUB_WORKSPACE is a bind mount into the job container, and
# deleting it detaches the mount: later steps fail with "getcwd: cannot
# access parent directories" and local actions resolve against a host
# path that no longer matches what the container sees. EC2 runners reuse
# the workspace between jobs, so its contents still need clearing.
find "${GITHUB_WORKSPACE}" -mindepth 1 -delete 2>/dev/null || true
mkdir -p "${GITHUB_WORKSPACE}"
if [[ "${{ inputs.architecture }}" = "aarch64" ]]; then
rm -rf "${RUNNER_TEMP}/*"
fi
echo "::endgroup::"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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: Install Miniforge
if: ${{ inputs.architecture == 'aarch64' }}
shell: bash -l {0}
env:
DESIRED_PYTHON: ${{ matrix.python_version }}
run: |
set -euxo pipefail
# TODO: Get rid of Conda, we already have all versions of PyThon one needs in the docker
###############################################################################
# Install conda
# disable SSL_verify due to getting "Could not find a suitable TLS CA certificate bundle, invalid path"
# when using Python version, less than the conda latest
###############################################################################
echo 'Installing conda-forge'
if [[ ${{ inputs.is-jetpack }} == true ]]; then
# jetpack base image is ubuntu 22.04, does not have curl installed
apt-get update
apt-get install -y curl git
fi
# Pin the installer. The shared setup-binary-builds action installs
# conda=25.3.0 into this base env, and conda 25.3.0 has no Python 3.14
# build. Miniforge releases newer than this one put the base env on
# Python 3.14, which makes that install unsatisfiable and fails every
# aarch64 wheel build. Bump this tag only together with that pin.
curl -fL -o /mambaforge.sh https://github.com/conda-forge/miniforge/releases/download/26.3.2-3/Miniforge3-Linux-aarch64.sh
chmod +x /mambaforge.sh
/mambaforge.sh -b -p /opt/conda
rm /mambaforge.sh
source /opt/conda/etc/profile.d/conda.sh
conda config --set ssl_verify False
echo "/opt/conda/bin" >> $GITHUB_PATH
- uses: pytorch/test-infra/.github/actions/set-channel@main
- name: Set PYTORCH_VERSION
if: ${{ env.CHANNEL == 'test' }}
run: |
# When building RC, set the version to be the current candidate version,
# otherwise, leave it alone so nightly will pick up the latest
echo "PYTORCH_VERSION=${{ matrix.stable_version }}" >> "${GITHUB_ENV}"
- uses: pytorch/test-infra/.github/actions/setup-binary-builds@main
env:
PLATFORM: ${{ inputs.architecture == 'aarch64' && 'linux-aarch64' || ''}}
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
submodules: ${{ inputs.submodules }}
setup-miniconda: false
python-version: ${{ env.PYTHON_VERSION }}
cuda-version: ${{ env.CU_VERSION }}
arch: ${{ env.ARCH }}
# Standard and RTX wheels are built for the same Python/CUDA/architecture
# matrix entries. Keep their GitHub artifact names distinct so consumers
# cannot download an RTX wheel for a standard-TensorRT job.
- name: Mark Python-only artifact
if: ${{ inputs.python-only }}
run: echo "ARTIFACT_NAME=${ARTIFACT_NAME}_python_only" >> "${GITHUB_ENV}"
- name: Mark TensorRT-RTX artifact
if: ${{ inputs.use-rtx }}
run: echo "ARTIFACT_NAME=${ARTIFACT_NAME}_rtx" >> "${GITHUB_ENV}"
- name: Prefix wheel artifact
if: ${{ inputs.artifact-name-prefix }}
env:
ARTIFACT_PREFIX: ${{ inputs.artifact-name-prefix }}
run: echo "ARTIFACT_NAME=${ARTIFACT_PREFIX}-${ARTIFACT_NAME}" >> "${GITHUB_ENV}"
- name: Combine Env Var and Build Env Files
if: ${{ inputs.env-var-script != '' }}
working-directory: ${{ inputs.repository }}
run: |
set -euxo pipefail
cat "${{ inputs.env-var-script }}" >> "${BUILD_ENV_FILE}"
- name: Add XPU Env Vars in Build Env File
if: ${{ matrix.gpu_arch_type == 'xpu' }}
run: |
{
echo "set +u"
echo "source /opt/intel/oneapi/compiler/latest/env/vars.sh"
echo "source /opt/intel/oneapi/pti/latest/env/vars.sh"
} >> "${BUILD_ENV_FILE}"
- name: Install torch dependency
if: ${{ inputs.is-jetpack == false }}
run: |
set -euxo pipefail
# shellcheck disable=SC1090
source "${BUILD_ENV_FILE}"
# shellcheck disable=SC2086
${CONDA_RUN} ${PIP_INSTALL_TORCH} ${{ inputs.pip-install-torch-extra-args }}
- name: Run Pre-Script with Caching
if: ${{ inputs.pre-script != '' }}
uses: pytorch/test-infra/.github/actions/run-script-with-cache@main
with:
cache-path: ${{ inputs.cache-path }}
cache-key: ${{ inputs.cache-key }}
repository: ${{ inputs.repository }}
script: ${{ inputs.pre-script }}
# Persist bazel's action cache across runs so the C++/CUDA compile — the
# serial long pole — reuses unchanged action outputs instead of rebuilding
# from scratch. Lives under RUNNER_TEMP (the "Clean workspace" step wipes
# GITHUB_WORKSPACE). setup.py picks up BAZEL_DISK_CACHE (exported below).
# Key is COARSE (toolchain/deps, not the commit) so most PRs restore a warm
# cache; the restore-keys prefix makes even a dep bump an incremental build.
- name: Cache the bazel C++/CUDA build
if: ${{ inputs.architecture != 'aarch64' }}
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/trt-bazel-disk-cache
key: trt-bazel-${{ inputs.architecture }}-${{ matrix.desired_cuda }}-rtx${{ inputs.use-rtx }}-${{ hashFiles('**/MODULE.bazel', '**/WORKSPACE', '**/.bazelrc', '**/dev_dep_versions.yml') }}
restore-keys: |
trt-bazel-${{ inputs.architecture }}-${{ matrix.desired_cuda }}-rtx${{ inputs.use-rtx }}-
# Named before either wheel is built: the main wheel's executorch extra can require exactly this
# companion, and the companion build below takes its version from the same variable.
- name: Name the ExecuTorch runtime companion
if: ${{ inputs.build-executorch-runtime }}
working-directory: ${{ inputs.repository }}
shell: bash -l {0}
run: |
set -euo pipefail
source "${BUILD_ENV_FILE}"
version="$(${CONDA_RUN} python packaging/executorch_runtime_version.py ${{ inputs.is-release-wheel }})"
echo "TORCH_TENSORRT_EXECUTORCH_RUNTIME_VERSION=${version}" >> "${GITHUB_ENV}"
# A release wheel has no CUDA label, the form PyPI needs; its cu132 build goes to PyPI. Any
# other build goes to this run's PyTorch channel.
if [[ ${{ inputs.is-release-wheel }} == true ]]; then
echo "TORCH_TENSORRT_EXECUTORCH_RUNTIME_CHANNEL=pypi" >> "${GITHUB_ENV}"
else
echo "TORCH_TENSORRT_EXECUTORCH_RUNTIME_CHANNEL=${CHANNEL}" >> "${GITHUB_ENV}"
fi
- name: Build the wheel (python-build-package)
if: ${{ inputs.build-platform == 'python-build-package' }}
working-directory: ${{ inputs.repository }}
shell: bash -l {0}
run: |
set -euxo pipefail
source "${BUILD_ENV_FILE}"
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
${CONDA_RUN} python -m pip install build==1.2.2
echo "Successfully installed Python build package"
${CONDA_RUN} ${{ inputs.build-command }}
- name: Build the wheel (setup-py)
if: ${{ inputs.build-platform == 'setup-py' }}
working-directory: ${{ inputs.repository }}
shell: bash -l {0}
run: |
set -x
source "${BUILD_ENV_FILE}"
# Reuse the cached bazel action outputs (see "Cache the bazel..." step).
export BAZEL_DISK_CACHE="${RUNNER_TEMP}/trt-bazel-disk-cache"
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
${CONDA_RUN} python setup.py clean
echo "Successfully ran `python setup.py clean`"
if [[ ${{ inputs.is-release-wheel }} == true || ${{ inputs.is-release-tarball }} == true ]]; then
# release version for upload to pypi
# BUILD_VERSION example: 2.4.0+cu121, we don't want the +cu121 part, so remove +cu121
BUILD_VERSION=${BUILD_VERSION%+*}
if [[ ${{ inputs.is-release-tarball }} == true ]]; then
mkdir -p release/tarball
TRT_VERSION=$(cat dev_dep_versions.yml | grep __tensorrt_version__ | sed 's/__tensorrt_version__: //g' | sed 's/"//g')
bazel build //:libtorchtrt --compilation_mode opt --config=linux
cp bazel-bin/libtorchtrt.tar.gz \
release/tarball/libtorchtrt-${BUILD_VERSION}-tensorrt${TRT_VERSION}-cuda${CU_VERSION:2}-libtorch${PYTORCH_VERSION}-${{inputs.architecture}}-linux.tar.gz
return 0
else
if [[ ${{ inputs.is-release-wheel }} == true ]]; then
param="--release"
fi
fi
else
# release version for upload to pytorch index
if [[ "$BUILD_VERSION" != *"+"${CU_VERSION} ]]; then
BUILD_VERSION="${BUILD_VERSION}+${CU_VERSION}"
fi
fi
echo "BUILD_VERSION=$BUILD_VERSION"
echo "USE_TRT_RTX=$USE_TRT_RTX"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
if [[ ${{ inputs.use-rtx }} == true ]]; then
echo "Building tensorrt-rtx wheel"
${CONDA_RUN} python setup.py bdist_wheel ${param} --use-rtx
else
if [[ ${{ inputs.is-jetpack }} == true ]]; then
echo "Building tensorrt wheel for jetpack"
${CONDA_RUN} python setup.py bdist_wheel ${param} --jetpack
else
echo "Building standard tensorrt wheel"
${CONDA_RUN} python setup.py bdist_wheel ${param}
fi
fi
# Keep the ExecuTorch runtime in the standard wheel artifact. This makes
# its packaging, manylinux repair, GitHub artifact, and PyTorch-index
# upload follow the exact same path as torch-tensorrt itself.
- name: Build the ExecuTorch runtime wheel
id: executorch-runtime
if: ${{ env.TORCH_TENSORRT_EXECUTORCH_RUNTIME_VERSION != '' }}
working-directory: ${{ inputs.repository }}
shell: bash -l {0}
run: |
set -euxo pipefail
source "${BUILD_ENV_FILE}"
# Preserve the matrix's torch while installing the just-built main wheel.
${CONDA_RUN} python -m pip install --no-deps dist/torch_tensorrt-*.whl
${CONDA_RUN} python - <<'PY'
import importlib.metadata
import subprocess
import sys
from packaging.requirements import Requirement
from packaging.utils import canonicalize_name
main = importlib.metadata.distribution("torch-tensorrt")
library = main.locate_file("torch_tensorrt/lib/libtorchtrt.so")
if not library.is_file():
sys.exit("The main wheel has no libtorchtrt.so; the companion needs the full runtime build")
# Native archives do not install Python metadata. Reuse the main wheel's selection.
requirements = [Requirement(value) for value in main.requires or []]
tensorrt = [
str(requirement) for requirement in requirements
if canonicalize_name(requirement.name) in {
"tensorrt", "tensorrt-cu13", "tensorrt-cu13-bindings", "tensorrt-cu13-libs"
}
and (requirement.marker is None or requirement.marker.evaluate())
]
if not tensorrt:
sys.exit("The main wheel declares no CUDA 13 TensorRT dependencies")
subprocess.check_call([sys.executable, "-m", "pip", "install", *tensorrt])
PY
# Both channels that carry a pinned ExecuTorch are named directly rather than through the
# channel variable: a dated development build is only on the nightly channel, and a release
# is on the test channel. The default index stays in the set for the other requirements,
# which means a pin naming a version the default index also publishes could resolve to the
# processor-only build from there. pip prefers the labelled CUDA build of the same version,
# and what refuses the other is the delegate's own build, which reads the installed
# ExecuTorch's local label and stops unless it names a CUDA build, so the failure is a clear
# message rather than a configure error about a missing extension.
# The version itself comes from the requirement file, so moving the pin to a newer
# nightly changes no file in this directory.
${CONDA_RUN} python -m pip install pyyaml patchelf "wheel>=0.40" \
--extra-index-url "https://download.pytorch.org/whl/nightly/${CU_VERSION}" \
--extra-index-url "https://download.pytorch.org/whl/test/${CU_VERSION}" \
-r packaging/executorch_pin.txt
echo "TORCH_TENSORRT_EXECUTORCH_RUNTIME_VERSION=${TORCH_TENSORRT_EXECUTORCH_RUNTIME_VERSION:?}"
${CONDA_RUN} python -m pip wheel --no-build-isolation --no-deps --wheel-dir dist \
py/torch-tensorrt-executorch-runtime
- name: Repair Manylinux_2_28 Wheel
shell: bash -l {0}
env:
PACKAGE_NAME: ${{ inputs.package-name }}
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
# TODO: lan to verify whether manylinux repair is needed for jetpack
if: ${{ inputs.is-release-tarball == false }}
run: |
set -euxo pipefail
source "${BUILD_ENV_FILE}"
for pkg in ${{ inputs.repository }}/dist/*-linux_*.whl; do
# if the glob didn't match anything
if [[ ! -e $pkg ]]; then
continue
fi
abs_pkg=$(realpath $pkg)
if [[ "$(basename "${pkg}")" == torch_tensorrt_executorch_runtime-* ]]; then
# The companion is retagged, not repaired, and that is deliberate rather than a gap. The
# shared repair script handles CPython-tagged wheels only, and repairing would vendor the
# libraries this wheel exists to stop shipping. Its one shared object already resolves
# everything it needs through search paths relative to its own location, the same way
# ExecuTorch's backends do, so there is nothing for a repair to add. What it does need is a
# platform tag naming the floor the object really requires, which is what happens here.
case "${ARCH}" in
x86_64) platform_tag=manylinux_2_28_x86_64 ;;
aarch64) platform_tag=manylinux_2_35_aarch64 ;;
*) echo "Unsupported delegate architecture: ${ARCH}" >&2; exit 1 ;;
esac
${CONDA_RUN} python -m wheel tags --remove --platform-tag "${platform_tag}" "${abs_pkg}"
elif [[ "${ARCH}" == aarch64 && ${{ inputs.is-jetpack }} == false && ${{ inputs.python-only }} == false ]]; then
# Built in manylinux_2_39, the SBSA wheel needs glibc 2.38 and GCC 14's libstdc++, so a
# manylinux_2_28 tag would let pip install it on systems where it cannot load. A Python-only
# wheel has no compiled code, so it keeps the manylinux_2_28 repair below. Builds without the
# runtime companion keep the conda environment's wheel 0.37, which has no tags command.
${CONDA_RUN} python -m pip install "wheel>=0.40"
${CONDA_RUN} python -m wheel tags --remove --platform-tag manylinux_2_39_aarch64 "${abs_pkg}"
else
./test-infra/.github/scripts/repair_manylinux_2_28.sh "${abs_pkg}"
fi
done
- name: Run Post-Script
if: ${{ inputs.post-script != '' }}
uses: pytorch/test-infra/.github/actions/run-script-with-cache@main
with:
repository: ${{ inputs.repository }}
script: ${{ inputs.post-script }}
- name: Check the retagged ExecuTorch runtime wheel
if: ${{ steps.executorch-runtime.outcome == 'success' }}
shell: bash -l {0}
working-directory: ${{ inputs.repository }}
run: |
set -euo pipefail
source "${BUILD_ENV_FILE}"
shopt -s nullglob
wheels=(dist/torch_tensorrt_executorch_runtime-*.whl)
if [[ ${#wheels[@]} -ne 1 ]]; then
echo "Expected one retagged ExecuTorch companion, found ${#wheels[@]}" >&2
exit 1
fi
${CONDA_RUN} python .github/scripts/check-executorch-runtime-wheel.py "${wheels[0]}" --architecture "${ARCH}"
${CONDA_RUN} python -m pip install --no-deps "${wheels[0]}"
delegate="$(TORCH_TENSORRT_SKIP_DELEGATE_REGISTRATION=1 ${CONDA_RUN} python -c 'import torch_tensorrt_executorch_runtime as m; print(m._delegate_path())')"
# Build-machine library paths must not hide a broken installed RUNPATH.
if ! resolution="$(env -u LD_LIBRARY_PATH ldd -r "${delegate}" 2>&1)"; then
printf '%s\n' "${resolution}" >&2
exit 1
fi
printf '%s\n' "${resolution}"
if grep -E "not found|undefined symbol" <<< "${resolution}"; then
echo "The installed delegate has unresolved dependencies" >&2
exit 1
fi
env -u LD_LIBRARY_PATH ${CONDA_RUN} python -c "import torch_tensorrt_executorch_runtime"
- name: Inventory packaged wheels
# Keep this immediately before the smoke test/upload boundary. When a
# matrix row fails downstream, its log shows exactly which repaired
# wheels (and package versions) were placed in the GitHub artifact.
if: ${{ inputs.is-release-tarball == false }}
shell: bash -l {0}
working-directory: ${{ inputs.repository }}
run: |
set -euo pipefail
shopt -s nullglob
wheels=(dist/*.whl)
if [[ ${#wheels[@]} -eq 0 ]]; then
echo "No wheels were produced in dist/" >&2
exit 1
fi
echo "Packaged wheels to upload:"
for wheel in "${wheels[@]}"; do
echo " $(basename "${wheel}") ($(stat -c%s "${wheel}") bytes)"
metadata_path="$(unzip -Z1 "${wheel}" '*.dist-info/METADATA' | head -n1)"
if [[ -n "${metadata_path}" ]]; then
unzip -p "${wheel}" "${metadata_path}" | grep -E '^(Name|Version):' || true
fi
done
- name: Smoke Test
# Release tarball builds do not produce a wheel.
if: ${{ inputs.run-smoke-test && inputs.is-release-tarball == false }}
shell: bash -l {0}
env:
PACKAGE_NAME: ${{ inputs.package-name }}
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
run: |
set -euxo pipefail
source "${BUILD_ENV_FILE}"
# PACKAGE_NAME is the import package used below. The RTX
# distribution intentionally has a different wheel stem while still
# importing as torch_tensorrt.
WHEEL_DISTRIBUTION="${PACKAGE_NAME}"
if [[ "${USE_TRT_RTX}" == "true" ]]; then
WHEEL_DISTRIBUTION="${PACKAGE_NAME}_rtx"
fi
WHEEL_PATH="$(find "${{ inputs.repository }}/dist" -maxdepth 1 -type f -name "${WHEEL_DISTRIBUTION}-*.whl" -print -quit)"
if [[ -z "${WHEEL_PATH}" ]]; then
echo "No wheel for distribution ${WHEEL_DISTRIBUTION} was built" >&2
exit 1
fi
WHEEL_NAME="$(basename "${WHEEL_PATH}")"
echo "${WHEEL_NAME}"
if [[ ${{ inputs.architecture }} == "aarch64" ]]; then
echo "Skipping smoke test for aarch64, since it is not an actual gpu runner"
else
${CONDA_RUN} pip install "${{ inputs.repository }}/dist/$WHEEL_NAME" --use-deprecated=legacy-resolver --extra-index-url https://download.pytorch.org/${CHANNEL}/${CU_VERSION}
# Checking that we have a pinned version of torch in our dependency tree
(
pushd "${RUNNER_TEMP}"
unzip -o "${GITHUB_WORKSPACE}/${{ inputs.repository }}/dist/$WHEEL_NAME"
# Ensure that pytorch version is pinned, should output file where it was found
grep "Requires-Dist: torch (==.*)" -r .
)
if [[ (! -f "${{ inputs.repository }}"/${SMOKE_TEST_SCRIPT}) ]]; then
echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} not found"
if [[ "${PACKAGE_NAME}" = "torchrec" ]]; then
# Special case for torchrec temporarily since __version__ does not
# work correctly on main in torchrec. This block will be
# removed once we fix it.
${CONDA_RUN} python -c "import ${PACKAGE_NAME}"
else
${CONDA_RUN} python -c "import ${PACKAGE_NAME}; print('package version is ', ${PACKAGE_NAME}.__version__)"
fi
else
echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} found"
${CONDA_RUN} python "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT}"
fi
fi
# NB: Only upload to GitHub after passing smoke tests
- name: Upload wheel to GitHub
if: ${{ inputs.is-release-tarball == false }}
continue-on-error: true
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ inputs.repository }}/dist/
- name: Upload cxx11 tarball to GitHub
if: ${{ inputs.is-release-tarball == true }}
continue-on-error: true
uses: actions/upload-artifact@v6
with:
name: cxx11-tarball-${{ env.PYTHON_VERSION }}-${{ env.CU_VERSION }}
path: ${{ inputs.repository }}/release/tarball/
upload:
needs: build
name: upload-wheel-${{ matrix.python_version }}-${{ matrix.desired_cuda }}-${{ matrix.gpu_arch_type }}-${{ inputs.is-jetpack }}
uses: pytorch/test-infra/.github/workflows/_binary_upload.yml@main
# if it is not jetpack, then upload to pytorch index
# if it is the release wheel or tarball, then skip upload to pytorch index
if: ${{ inputs.python-only == false && inputs.is-jetpack == false && inputs.is-release-wheel == false && inputs.is-release-tarball == false }}
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
test-infra-repository: ${{ inputs.test-infra-repository }}
test-infra-ref: ${{ inputs.test-infra-ref }}
build-matrix: ${{ inputs.build-matrix }}
# setup-binary-upload builds its artifact name from this input. RTX wheels
# use the same suffix as the build and test jobs; keep the actual build
# architecture above unchanged.
architecture: ${{ inputs.architecture }}${{ inputs.use-rtx && '_rtx' || '' }}
trigger-event: ${{ inputs.trigger-event }}
upload-to-pypi: ${{ inputs.upload-to-pypi }}
wheel-upload-path: ${{ inputs.wheel-upload-path }}
wheel-nightly-policy: ${{ inputs.wheel-nightly-policy }}
also-upload-to-gpu-arch-versions: ${{ inputs.also-upload-to-gpu-arch-versions }}
secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
concurrency:
# env-var-script distinguishes the python-only build (env_vars_python_only.txt)
# from the standard build (env_vars.txt). Without it, the standard and
# python-only channels of the SAME run share this group and cancel-in-progress
# kills one of them — which is why "run everything" never completed. (Local
# addition to the test-infra-synced key; keep on re-sync.)
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{inputs.is-release-wheel}}-${{inputs.is-release-tarball}}-${{inputs.use-rtx}}-${{inputs.architecture}}-${{inputs.is-jetpack}}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'no-tag' }}-${{ inputs.use-rtx }}-${{ inputs.env-var-script }}
cancel-in-progress: true