Skip to content

Commit 6eebf8e

Browse files
committed
simplify the release linux workflow
1 parent 2c82f74 commit 6eebf8e

File tree

3 files changed

+59
-19
lines changed

3 files changed

+59
-19
lines changed

.github/scripts/generate-release-matrix.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
import sys
66

77
RELEASE_CUDA_VERSION = {
8-
"wheel": ["cu128"],
9-
"tarball": ["cu128"],
8+
"wheel": ["cu129"],
9+
"tarball": ["cu129"],
1010
}
1111
RELEASE_PYTHON_VERSION = {
12-
"wheel": ["3.9", "3.10", "3.11", "3.12", "3.13"],
12+
"wheel": ["3.10", "3.11", "3.12", "3.13"],
1313
"tarball": ["3.11"],
1414
}
1515

1616
CXX11_TARBALL_CONTAINER_IMAGE = {
17-
"cu128": "pytorch/libtorch-cxx11-builder:cuda12.8-main",
17+
"cu129": "pytorch/libtorch-cxx11-builder:cuda12.9-main",
1818
}
1919

2020

.github/workflows/build_wheels_linux.yml

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ on:
117117
required: false
118118
default: false
119119
type: boolean
120+
is-release-wheel:
121+
description: Set to true if the build is for release wheel
122+
required: false
123+
default: false
124+
type: boolean
125+
is-release-tarball:
126+
description: Set to true if the build is for release tarball
127+
required: false
128+
default: false
129+
type: boolean
120130
secrets:
121131
PYPI_API_TOKEN:
122132
description: An optional token to upload to pypi
@@ -265,22 +275,41 @@ jobs:
265275
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
266276
${CONDA_RUN} python setup.py clean
267277
echo "Successfully ran `python setup.py clean`"
268-
if [[ "$BUILD_VERSION" != *"+"${CU_VERSION} ]]; then
269-
BUILD_VERSION="${BUILD_VERSION}+${CU_VERSION}"
278+
if [[ ${{ inputs.is-release-wheel }} == true || ${{ inputs.is-release-tarball }} == true ]]; then
279+
# release version for upload to pypi
280+
# BUILD_VERSION example: 2.4.0+cu121, we don't want the +cu121 part, so remove +cu121
281+
BUILD_VERSION=${BUILD_VERSION%+*}
282+
if [[ ${{ inputs.is-release-tarball }} == true ]]; then
283+
mkdir -p release/tarball
284+
TRT_VERSION=$(cat dev_dep_versions.yml | grep __tensorrt_version__ | sed 's/__tensorrt_version__: //g' | sed 's/"//g')
285+
bazel build //:libtorchtrt --compilation_mode opt --config=linux
286+
cp bazel-bin/libtorchtrt.tar.gz \
287+
release/tarball/libtorchtrt-${BUILD_VERSION}-tensorrt${TRT_VERSION}-cuda${CU_VERSION:2}-libtorch${PYTORCH_VERSION}-x86_64-linux.tar.gz
288+
else
289+
if [[ ${{ inputs.is-release-wheel }} == true ]]; then
290+
param="--release"
291+
fi
292+
fi
293+
else
294+
# release version for upload to pytorch index
295+
if [[ "$BUILD_VERSION" != *"+"${CU_VERSION} ]]; then
296+
BUILD_VERSION="${BUILD_VERSION}+${CU_VERSION}"
297+
fi
270298
fi
299+
271300
echo "BUILD_VERSION=$BUILD_VERSION"
272301
echo "USE_TRT_RTX=$USE_TRT_RTX"
273302
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
274303
if [[ ${{ inputs.use-rtx }} == true ]]; then
275304
echo "Building tensorrt-rtx wheel"
276-
${CONDA_RUN} python setup.py bdist_wheel --use-rtx
305+
${CONDA_RUN} python setup.py bdist_wheel ${param} --use-rtx
277306
else
278307
if [[ ${{ inputs.is-jetpack }} == true ]]; then
279308
echo "Building tensorrt wheel for jetpack"
280-
${CONDA_RUN} python setup.py bdist_wheel --jetpack
309+
${CONDA_RUN} python setup.py bdist_wheel ${param} --jetpack
281310
else
282311
echo "Building standard tensorrt wheel"
283-
${CONDA_RUN} python setup.py bdist_wheel
312+
${CONDA_RUN} python setup.py bdist_wheel ${param}
284313
fi
285314
fi
286315
- name: Repair Manylinux_2_28 Wheel
@@ -289,7 +318,7 @@ jobs:
289318
PACKAGE_NAME: ${{ inputs.package-name }}
290319
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
291320
# TODO: lan to verify whether manylinux repair is needed for jetpack
292-
#if: ${{ inputs.is-jetpack == true }}
321+
if: ${{ inputs.is-release-tarball == false }}
293322
run: |
294323
set -euxo pipefail
295324
source "${BUILD_ENV_FILE}"
@@ -312,6 +341,7 @@ jobs:
312341
env:
313342
PACKAGE_NAME: ${{ inputs.package-name }}
314343
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
344+
if: ${{ inputs.is-release-tarball == false }}
315345
run: |
316346
set -euxo pipefail
317347
source "${BUILD_ENV_FILE}"
@@ -348,18 +378,27 @@ jobs:
348378
# NB: Only upload to GitHub after passing smoke tests
349379

350380
- name: Upload wheel to GitHub
381+
if: ${{ inputs.is-release-wheel == false }}
351382
continue-on-error: true
352383
uses: actions/upload-artifact@v4
353384
with:
354385
name: ${{ env.ARTIFACT_NAME }}
355386
path: ${{ inputs.repository }}/dist/
387+
- name: Upload tarball to GitHub
388+
if: ${{ inputs.is-release-tarball == true }}
389+
continue-on-error: true
390+
uses: actions/upload-artifact@v4
391+
with:
392+
name: ${{ env.ARTIFACT_NAME }}
393+
path: ${{ inputs.repository }}/release/tarball/
356394

357395
upload:
358396
needs: build
359397
name: upload-wheel-${{ matrix.python_version }}-${{ matrix.desired_cuda }}-${{ matrix.gpu_arch_type }}-${{ inputs.is-jetpack }}
360398
uses: pytorch/test-infra/.github/workflows/_binary_upload.yml@main
361399
# if it is not jetpack nor rtx, then upload to pytorch index
362-
if: ${{ inputs.is-jetpack == false && inputs.use-rtx == false }}
400+
# if it is the release wheel or tarball, then skip upload to pytorch index
401+
if: ${{ inputs.is-jetpack == false && inputs.use-rtx == false && inputs.is-release-wheel == false && inputs.is-release-tarball == false }}
363402
with:
364403
repository: ${{ inputs.repository }}
365404
ref: ${{ inputs.ref }}
@@ -373,5 +412,5 @@ jobs:
373412
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
374413

375414
concurrency:
376-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{inputs.use-rtx}}-${{inputs.architecture}}-${{inputs.is-jetpack}}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}
415+
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' }}
377416
cancel-in-progress: true

.github/workflows/release-linux.yml renamed to .github/workflows/release-linux-x86_64.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: Release Linux wheels and tarball artifacts
1+
name: Release x86_64 Linux wheels and tarball artifacts
22

33
on:
4+
pull_request:
45
push:
56
tags:
67
# NOTE: Binary build pipelines should only get triggered on release candidate builds
@@ -59,8 +60,8 @@ jobs:
5960
env-var-script: packaging/env_vars.txt
6061
post-script: packaging/post_build_script.sh
6162
smoke-test-script: packaging/smoke_test_script.sh
62-
cxx11-tarball-release: "true"
63-
uses: ./.github/workflows/release-wheel-linux.yml
63+
is-release-tarball: "true"
64+
uses: ./.github/workflows/build_wheels_linux.yml
6465
with:
6566
repository: ${{ matrix.repository }}
6667
ref: ""
@@ -73,7 +74,7 @@ jobs:
7374
package-name: ${{ matrix.package-name }}
7475
smoke-test-script: ${{ matrix.smoke-test-script }}
7576
trigger-event: ${{ github.event_name }}
76-
cxx11-tarball-release: "true"
77+
is-release-tarball: "true"
7778

7879
generate-release-wheel-matrix:
7980
needs: [generate-matrix]
@@ -109,8 +110,8 @@ jobs:
109110
env-var-script: packaging/env_vars.txt
110111
post-script: packaging/post_build_script.sh
111112
smoke-test-script: packaging/smoke_test_script.sh
112-
cxx11-tarball-release: "true"
113-
uses: ./.github/workflows/release-wheel-linux.yml
113+
is-release-wheel: "true"
114+
uses: ./.github/workflows/build_wheels_linux.yml
114115
with:
115116
repository: ${{ matrix.repository }}
116117
ref: ""
@@ -123,7 +124,7 @@ jobs:
123124
package-name: ${{ matrix.package-name }}
124125
smoke-test-script: ${{ matrix.smoke-test-script }}
125126
trigger-event: ${{ github.event_name }}
126-
cxx11-tarball-release: "false"
127+
is-release-wheel: "true"
127128

128129
concurrency:
129130
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}

0 commit comments

Comments
 (0)