Skip to content

Commit 719e318

Browse files
committed
test
1 parent 2cffb54 commit 719e318

File tree

4 files changed

+341
-3
lines changed

4 files changed

+341
-3
lines changed

.bazelrc

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ build:cxx11_abi --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1"
3636
build:cxx11_abi --linkopt="-D_GLIBCXX_USE_CXX11_ABI=1"
3737
build:cxx11_abi --define=abi=cxx11_abi
3838

39+
build:jetpack --//toolchains/dep_collection:compute_libs=jetpack
40+
3941
build:ci_testing --define=torchtrt_src=prebuilt --cxxopt="-DDISABLE_TEST_IN_CI" --action_env "NVIDIA_TF32_OVERRIDE=0"
4042
build:use_precompiled_torchtrt --define=torchtrt_src=prebuilt
4143

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727

2828
filter-matrix:
2929
needs: [generate-matrix]
30+
env:
31+
LIMIT_PR_BUILDS: ${{ github.event_name == 'pull_request' && !contains( github.event.pull_request.labels.*.name, 'ciflow/binaries/all') }}
3032
outputs:
3133
matrix: ${{ steps.generate.outputs.matrix }}
3234
runs-on: ubuntu-latest
@@ -37,7 +39,7 @@ jobs:
3739
- uses: actions/checkout@v4
3840
with:
3941
repository: pytorch/tensorrt
40-
- name: Generate release matrix
42+
- name: Generate matrix
4143
id: generate
4244
run: |
4345
set -eou pipefail
@@ -62,7 +64,7 @@ jobs:
6264
smoke-test-script: packaging/smoke_test_script.sh
6365
package-name: torch_tensorrt
6466
name: Build torch-tensorrt whl package
65-
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main
67+
uses: ./.github/workflows/build_wheels_linux_aarch64.yml
6668
with:
6769
repository: ${{ matrix.repository }}
6870
ref: ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
name: Build Linux Wheels For aarch64
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
repository:
7+
description: 'Repository to checkout, defaults to ""'
8+
default: ""
9+
type: string
10+
ref:
11+
description: 'Reference to checkout, defaults to "nightly"'
12+
default: "nightly"
13+
type: string
14+
test-infra-repository:
15+
description: "Test infra repository to use"
16+
default: "pytorch/test-infra"
17+
type: string
18+
test-infra-ref:
19+
description: "Test infra reference to use"
20+
default: ""
21+
type: string
22+
build-matrix:
23+
description: "Build matrix to utilize"
24+
default: ""
25+
type: string
26+
pre-script:
27+
description: "Pre script to run prior to build"
28+
default: ""
29+
type: string
30+
post-script:
31+
description: "Post script to run prior to build"
32+
default: ""
33+
type: string
34+
smoke-test-script:
35+
description: "Script for Smoke Test for a specific domain"
36+
default: ""
37+
type: string
38+
env-var-script:
39+
description: "Script that sets Domain-Specific Environment Variables"
40+
default: ""
41+
type: string
42+
package-name:
43+
description: "Name of the actual python package that is imported in the smoke test"
44+
default: ""
45+
type: string
46+
build-target:
47+
description: "The target to build and publish (for repos that build multiple packages)"
48+
default: ""
49+
type: string
50+
trigger-event:
51+
description: "Trigger Event in caller that determines whether or not to upload"
52+
default: ""
53+
type: string
54+
cache-path:
55+
description: "The path(s) on the runner to cache or restore. The path is relative to repository."
56+
default: ""
57+
type: string
58+
cache-key:
59+
description: "The key created when saving a cache and the key used to search for a cache."
60+
default: ""
61+
type: string
62+
architecture:
63+
description: Architecture to build for x86_64 for default Linux, or aarch64 for Linux aarch64 builds
64+
required: false
65+
type: string
66+
default: x86_64
67+
submodules:
68+
description: Works as stated in actions/checkout, but the default value is recursive
69+
required: false
70+
type: string
71+
default: recursive
72+
setup-miniconda:
73+
description: Set to true if setup-miniconda is needed
74+
required: false
75+
type: boolean
76+
default: true
77+
build-platform:
78+
description: Platform to build wheels, choose from 'python-build-package' or 'setup-py'
79+
required: false
80+
type: string
81+
default: 'setup-py'
82+
upload-to-pypi:
83+
description: The comma-separated list of CUDA arch to be uploaded to pypi
84+
default: ""
85+
type: string
86+
build-command:
87+
description: The build command to use if build-platform is python-build-package
88+
required: false
89+
default: "python -m build --wheel"
90+
type: string
91+
pip-install-torch-extra-args:
92+
# NOTE: Why does this exist?
93+
# Well setuptools / python packaging doesn't actually allow you to specify dependencies
94+
# that come from other index URLs when you are building a package for "security" purposes.
95+
# Unfortunately for us our nightlies (torch, torchvision, etc.) only exist on download.pytorch.org
96+
# which means that if our users depend on things like torchvision then they need to have
97+
# an ability to install these dependencies from download.pytorch.org, as part of the build process
98+
# which currently the do not have the ability to do through normal means, hence this parameter
99+
# Reference: https://discuss.python.org/t/specifying-extra-index-url-in-setup-cfg-option-dependencies/19377
100+
description: Extra arguments to pass to the command that install base torch dependency
101+
required: false
102+
default: ""
103+
type: string
104+
timeout:
105+
description: 'Timeout for the job (in minutes)'
106+
default: 120
107+
type: number
108+
secrets:
109+
PYPI_API_TOKEN:
110+
description: An optional token to upload to pypi
111+
required: false
112+
113+
permissions:
114+
id-token: write
115+
contents: read
116+
117+
jobs:
118+
build:
119+
strategy:
120+
fail-fast: false
121+
matrix: ${{ fromJSON(inputs.build-matrix) }}
122+
env:
123+
PYTHON_VERSION: ${{ matrix.python_version }}
124+
PACKAGE_TYPE: wheel
125+
REPOSITORY: ${{ inputs.repository }}
126+
REF: ${{ inputs.ref }}
127+
CU_VERSION: ${{ matrix.desired_cuda }}
128+
UPLOAD_TO_BASE_BUCKET: ${{ matrix.upload_to_base_bucket }}
129+
ARCH: ${{ inputs.architecture }}
130+
BUILD_TARGET: ${{ inputs.build-target }}
131+
name: build-${{ matrix.build_name }}
132+
runs-on: ${{ matrix.validation_runner }}
133+
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' || ''}}
134+
container:
135+
image: ${{ matrix.container_image }}
136+
options: ${{ matrix.gpu_arch_type == 'cuda' && '--gpus all' || ' ' }}
137+
timeout-minutes: ${{ inputs.timeout }}
138+
steps:
139+
- name: Clean workspace
140+
shell: bash -l {0}
141+
run: |
142+
set -euxo pipefail
143+
echo "::group::Cleanup debug output"
144+
rm -rf "${GITHUB_WORKSPACE}"
145+
mkdir -p "${GITHUB_WORKSPACE}"
146+
147+
if [[ "${{ inputs.architecture }}" = "aarch64" ]]; then
148+
rm -rf "${RUNNER_TEMP}/*"
149+
fi
150+
echo "::endgroup::"
151+
152+
- uses: actions/checkout@v4
153+
with:
154+
# Support the use case where we need to checkout someone's fork
155+
repository: ${{ inputs.test-infra-repository }}
156+
ref: ${{ inputs.test-infra-ref }}
157+
path: test-infra
158+
159+
- name: Install Miniforge
160+
if: ${{ inputs.architecture == 'aarch64' }}
161+
shell: bash -l {0}
162+
env:
163+
DESIRED_PYTHON: ${{ matrix.python_version }}
164+
run: |
165+
set -euxo pipefail
166+
# TODO: Get rid of Conda, we already have all versions of PyThon one needs in the docker
167+
###############################################################################
168+
# Install conda
169+
# disable SSL_verify due to getting "Could not find a suitable TLS CA certificate bundle, invalid path"
170+
# when using Python version, less than the conda latest
171+
###############################################################################
172+
echo 'Installing conda-forge'
173+
curl -L -o /mambaforge.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh
174+
chmod +x /mambaforge.sh
175+
/mambaforge.sh -b -p /opt/conda
176+
rm /mambaforge.sh
177+
source /opt/conda/etc/profile.d/conda.sh
178+
conda config --set ssl_verify False
179+
echo "/opt/conda/bin" >> $GITHUB_PATH
180+
- uses: ./test-infra/.github/actions/set-channel
181+
- name: Set PYTORCH_VERSION
182+
if: ${{ env.CHANNEL == 'test' }}
183+
run: |
184+
# When building RC, set the version to be the current candidate version,
185+
# otherwise, leave it alone so nightly will pick up the latest
186+
echo "PYTORCH_VERSION=${{ matrix.stable_version }}" >> "${GITHUB_ENV}"
187+
- uses: ./test-infra/.github/actions/setup-binary-builds
188+
env:
189+
PLATFORM: ${{ inputs.architecture == 'aarch64' && 'linux-aarch64' || ''}}
190+
with:
191+
repository: ${{ inputs.repository }}
192+
ref: ${{ inputs.ref }}
193+
submodules: ${{ inputs.submodules }}
194+
setup-miniconda: false
195+
python-version: ${{ env.PYTHON_VERSION }}
196+
cuda-version: ${{ env.CU_VERSION }}
197+
arch: ${{ env.ARCH }}
198+
199+
- name: Combine Env Var and Build Env Files
200+
if: ${{ inputs.env-var-script != '' }}
201+
working-directory: ${{ inputs.repository }}
202+
run: |
203+
set -euxo pipefail
204+
cat "${{ inputs.env-var-script }}" >> "${BUILD_ENV_FILE}"
205+
- name: Add XPU Env Vars in Build Env File
206+
if: ${{ matrix.gpu_arch_type == 'xpu' }}
207+
run: |
208+
{
209+
echo "set +u"
210+
echo "source /opt/intel/oneapi/compiler/latest/env/vars.sh"
211+
echo "source /opt/intel/oneapi/pti/latest/env/vars.sh"
212+
} >> "${BUILD_ENV_FILE}"
213+
- name: Install torch dependency
214+
run: |
215+
set -euxo pipefail
216+
# shellcheck disable=SC1090
217+
source "${BUILD_ENV_FILE}"
218+
# shellcheck disable=SC2086
219+
${CONDA_RUN} ${PIP_INSTALL_TORCH} ${{ inputs.pip-install-torch-extra-args }}
220+
- name: Run Pre-Script with Caching
221+
if: ${{ inputs.pre-script != '' }}
222+
uses: ./test-infra/.github/actions/run-script-with-cache
223+
with:
224+
cache-path: ${{ inputs.cache-path }}
225+
cache-key: ${{ inputs.cache-key }}
226+
repository: ${{ inputs.repository }}
227+
script: ${{ inputs.pre-script }}
228+
- name: Build the wheel (python-build-package)
229+
if: ${{ inputs.build-platform == 'python-build-package' }}
230+
working-directory: ${{ inputs.repository }}
231+
shell: bash -l {0}
232+
run: |
233+
set -euxo pipefail
234+
source "${BUILD_ENV_FILE}"
235+
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
236+
${CONDA_RUN} python -m pip install build==1.2.2
237+
echo "Successfully installed Python build package"
238+
${CONDA_RUN} ${{ inputs.build-command }}
239+
- name: Build the wheel (setup-py)
240+
if: ${{ inputs.build-platform == 'setup-py' }}
241+
working-directory: ${{ inputs.repository }}
242+
shell: bash -l {0}
243+
run: |
244+
set -euxo pipefail
245+
source "${BUILD_ENV_FILE}"
246+
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
247+
${CONDA_RUN} python setup.py clean
248+
echo "Successfully ran `python setup.py clean`"
249+
${CONDA_RUN} python setup.py bdist_wheel
250+
- name: Repair Manylinux_2_28 Wheel
251+
shell: bash -l {0}
252+
env:
253+
PACKAGE_NAME: ${{ inputs.package-name }}
254+
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
255+
run: |
256+
set -euxo pipefail
257+
source "${BUILD_ENV_FILE}"
258+
# for pkg in ${{ inputs.repository }}/dist/*-linux_*.whl; do
259+
# # if the glob didn't match anything
260+
# if [[ ! -e $pkg ]]; then
261+
# continue
262+
# fi
263+
# abs_pkg=$(realpath $pkg)
264+
# ./test-infra/.github/scripts/repair_manylinux_2_28.sh $abs_pkg
265+
# done
266+
echo "Repair Manylinux_2_28 Wheel is not supported for aarch64"
267+
- name: Run Post-Script
268+
if: ${{ inputs.post-script != '' }}
269+
uses: ./test-infra/.github/actions/run-script-with-cache
270+
with:
271+
repository: ${{ inputs.repository }}
272+
script: ${{ inputs.post-script }}
273+
- name: Smoke Test
274+
shell: bash -l {0}
275+
env:
276+
PACKAGE_NAME: ${{ inputs.package-name }}
277+
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
278+
run: |
279+
set -euxo pipefail
280+
source "${BUILD_ENV_FILE}"
281+
WHEEL_NAME=$(ls "${{ inputs.repository }}/dist/")
282+
echo "$WHEEL_NAME"
283+
284+
${CONDA_RUN} pip install "${{ inputs.repository }}/dist/$WHEEL_NAME"
285+
# Checking that we have a pinned version of torch in our dependency tree
286+
(
287+
pushd "${RUNNER_TEMP}"
288+
unzip -o "${GITHUB_WORKSPACE}/${{ inputs.repository }}/dist/$WHEEL_NAME"
289+
# Ensure that pytorch version is pinned, should output file where it was found
290+
grep "Requires-Dist: torch (==.*)" -r .
291+
)
292+
293+
if [[ (! -f "${{ inputs.repository }}"/${SMOKE_TEST_SCRIPT}) ]]; then
294+
echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} not found"
295+
if [[ "${PACKAGE_NAME}" = "torchrec" ]]; then
296+
# Special case for torchrec temporarily since __version__ does not
297+
# work correctly on main in torchrec. This block will be
298+
# removed once we fix it.
299+
${CONDA_RUN} python -c "import ${PACKAGE_NAME}"
300+
else
301+
${CONDA_RUN} python -c "import ${PACKAGE_NAME}; print('package version is ', ${PACKAGE_NAME}.__version__)"
302+
fi
303+
else
304+
echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} found"
305+
${CONDA_RUN} python "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT}"
306+
fi
307+
# NB: Only upload to GitHub after passing smoke tests
308+
309+
- name: Upload wheel to GitHub
310+
continue-on-error: true
311+
uses: actions/upload-artifact@v4
312+
with:
313+
name: ${{ env.ARTIFACT_NAME }}
314+
path: ${{ inputs.repository }}/dist/
315+
316+
upload:
317+
needs: build
318+
uses: ./.github/workflows/_binary_upload.yml
319+
if: always()
320+
with:
321+
repository: ${{ inputs.repository }}
322+
ref: ${{ inputs.ref }}
323+
test-infra-repository: ${{ inputs.test-infra-repository }}
324+
test-infra-ref: ${{ inputs.test-infra-ref }}
325+
build-matrix: ${{ inputs.build-matrix }}
326+
architecture: ${{ inputs.architecture }}
327+
trigger-event: ${{ inputs.trigger-event }}
328+
upload-to-pypi: ${{ inputs.upload-to-pypi }}
329+
secrets:
330+
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
331+
332+
concurrency:
333+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}
334+
cancel-in-progress: true

packaging/pre_build_script.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ python3 -m pip install pyyaml
77

88
yum install -y ninja-build gettext
99

10-
PLATFORM="amd64"
10+
BAZEL_PLATFORM="amd64"
1111

1212
if [[ $(uname -m) == "aarch64" ]]; then
1313
BAZEL_PLATFORM=arm64

0 commit comments

Comments
 (0)