-
Notifications
You must be signed in to change notification settings - Fork 235
Expand file tree
/
Copy pathbuild_portable_linux_pytorch_wheels.yml
More file actions
415 lines (382 loc) · 17.3 KB
/
build_portable_linux_pytorch_wheels.yml
File metadata and controls
415 lines (382 loc) · 17.3 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
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
name: Build Portable Linux PyTorch Wheels
on:
workflow_call:
inputs:
amdgpu_family:
required: true
type: string
python_version:
required: true
type: string
release_type:
description: The type of release to build ("dev", "nightly", or "prerelease"). All developer-triggered jobs should use "dev"!
required: true
type: string
s3_subdir:
description: S3 subdirectory, not including the GPU-family
required: true
type: string
s3_staging_subdir:
description: S3 staging subdirectory, not including the GPU-family
required: true
type: string
cloudfront_url:
description: CloudFront URL pointing to Python index
required: true
type: string
cloudfront_staging_url:
description: CloudFront base URL pointing to staging Python index
required: true
type: string
rocm_version:
description: ROCm version to pip install (e.g. "7.10.0a20251124")
type: string
pytorch_git_ref:
description: PyTorch ref to checkout. (typically "nightly", or "release/X.Y")
required: true
type: string
cache_type:
description: "Compiler cache type (sccache, ccache, or none)"
required: false
type: string
default: "none"
repository:
description: "Repository to checkout. Otherwise, defaults to `github.repository`."
type: string
ref:
description: "Branch, tag or SHA to checkout. Defaults to the reference or SHA that triggered the workflow."
type: string
workflow_dispatch:
inputs:
amdgpu_family:
type: choice
options:
- gfx101X-dgpu
- gfx103X-all
- gfx110X-all
- gfx1150
- gfx1151
- gfx1152
- gfx1153
- gfx120X-all
- gfx900
- gfx906
- gfx908
- gfx90a
- gfx94X-dcgpu
- gfx950-dcgpu
default: gfx94X-dcgpu
python_version:
required: true
type: string
default: "3.12"
release_type:
description: The type of release to build ("dev", "nightly", or "prerelease"). All developer-triggered jobs should use "dev"!
type: string
default: "dev"
s3_subdir:
description: S3 subdirectory, not including the GPU-family
type: string
default: "v2"
s3_staging_subdir:
description: S3 staging subdirectory, not including the GPU-family
type: string
default: "v2-staging"
cloudfront_url:
description: CloudFront base URL pointing to Python index
type: string
default: "https://rocm.devreleases.amd.com/v2"
cloudfront_staging_url:
description: CloudFront base URL pointing to staging Python index
type: string
default: "https://rocm.devreleases.amd.com/v2-staging"
rocm_version:
description: ROCm version to pip install (e.g. "7.10.0a20251124")
type: string
pytorch_git_ref:
description: PyTorch ref to checkout. (typically "nightly", or "release/X.Y")
required: true
type: string
default: "release/2.8"
cache_type:
description: "Compiler cache type"
type: choice
options:
- none
- sccache
- ccache
default: none
run-name: Build portable Linux PyTorch Wheels (${{ inputs.amdgpu_family }}, ${{ inputs.python_version }}, ${{ inputs.release_type }})
jobs:
build_pytorch_wheels:
name: Build | ${{ inputs.amdgpu_family }} | py ${{ inputs.python_version }} | torch ${{ inputs.pytorch_git_ref }}
runs-on: ${{ github.repository_owner == 'ROCm' && 'azure-linux-scale-rocm' || 'ubuntu-24.04' }}
permissions:
id-token: write
contents: read
container:
image: ghcr.io/rocm/therock_build_manylinux_x86_64@sha256:702a5133851e6d1daf1207d2c9fbb01c2667914a5b6dc5a01faeb3ce66ea6421
env:
OUTPUT_DIR: ${{ github.workspace }}/output
PACKAGE_DIST_DIR: ${{ github.workspace }}/output/packages/dist
RELEASE_TYPE: ${{ inputs.release_type }}
S3_BUCKET_PY: "therock-${{ inputs.release_type }}-python"
optional_build_prod_arguments: ""
SCCACHE_BUCKET: "therock-${{ inputs.release_type }}-pytorch-sccache"
SCCACHE_REGION: us-east-2
SCCACHE_S3_KEY_PREFIX: "linux/${{ inputs.amdgpu_family }}/"
SCCACHE_S3_USE_SSL: "true"
SCCACHE_S3_SERVER_SIDE_ENCRYPTION: "true"
SCCACHE_IDLE_TIMEOUT: "600"
SCCACHE_LOG: warn
outputs:
cp_version: ${{ env.cp_version }}
# The following are python package versions produced by the build. The
# exact versions will depend on workflow inputs and the underlying code.
# For example:
# Inputs
# rocm_version : 7.10.0a20251120
# pytorch_git_ref : release/2.9
# Outputs
# torch_version : 2.9.1+rocm7.10.0a20251120
# torchaudio_version : 2.9.0+rocm7.10.0a20251120
# torchvision_version: 0.24.0+rocm7.10.0a20251120
# triton_version : 3.5.1+rocm7.10.0a20251120
# Future jobs can use these version outputs to identify newly built
# packages, for example via `pip install torch==${TORCH_VERSION}`.
torch_version: ${{ steps.build-pytorch-wheels.outputs.torch_version }}
torchaudio_version: ${{ steps.build-pytorch-wheels.outputs.torchaudio_version }}
apex_version: ${{ steps.build-pytorch-wheels.outputs.apex_version }}
torchvision_version: ${{ steps.build-pytorch-wheels.outputs.torchvision_version }}
triton_version: ${{ steps.build-pytorch-wheels.outputs.triton_version }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref || '' }}
- name: Configure Git Identity
run: |
git config --global user.name "therockbot"
git config --global user.email "therockbot@amd.com"
- name: Select Python version
run: |
python build_tools/github_actions/python_to_cp_version.py \
--python-version ${{ inputs.python_version }}
- name: Add selected Python version to PATH
run: |
python_dir="/opt/python/${{ env.cp_version }}"
if ! [ -x "${python_dir}/bin/python" ]; then
echo "ERROR: Could not find python: ${python_dir}"
exit 1
fi
echo "${python_dir}/bin" >> "$GITHUB_PATH"
- name: Install python deps for CI
run: |
pip install -r external-builds/pytorch/requirements-ci.txt
# Checkout nightly sources from https://github.com/pytorch/pytorch
- name: Checkout PyTorch Source Repos from nightly branch
if: ${{ inputs.pytorch_git_ref == 'nightly' }}
run: |
./external-builds/pytorch/pytorch_torch_repo.py checkout --repo-hashtag nightly
./external-builds/pytorch/pytorch_audio_repo.py checkout --repo-hashtag nightly
./external-builds/pytorch/pytorch_apex_repo.py checkout --repo-hashtag master
./external-builds/pytorch/pytorch_vision_repo.py checkout --repo-hashtag nightly
./external-builds/pytorch/pytorch_triton_repo.py checkout
# Checkout stable sources from https://github.com/ROCm/pytorch
- name: Checkout PyTorch Source Repos from stable branch
if: ${{ inputs.pytorch_git_ref != 'nightly' }}
run: |
./external-builds/pytorch/pytorch_torch_repo.py checkout --gitrepo-origin https://github.com/ROCm/pytorch.git --repo-hashtag ${{ inputs.pytorch_git_ref }}
./external-builds/pytorch/pytorch_audio_repo.py checkout --require-related-commit
./external-builds/pytorch/pytorch_apex_repo.py checkout --require-related-commit
./external-builds/pytorch/pytorch_vision_repo.py checkout --require-related-commit
./external-builds/pytorch/pytorch_triton_repo.py checkout
# Note: determine_version.py sets optional_build_prod_arguments in
# GITHUB_ENV, which includes --rocm-sdk-version and --version-suffix.
- name: Determine optional arguments passed to `build_prod_wheels.py`
if: ${{ inputs.rocm_version }}
run: |
python build_tools/github_actions/determine_version.py \
--rocm-version ${{ inputs.rocm_version }}
- name: Configure AWS Credentials for sccache
if: ${{ inputs.cache_type == 'sccache' && github.repository_owner == 'ROCm' }}
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::692859939525:role/therock-${{ inputs.release_type }}
- name: Verify sccache
if: ${{ inputs.cache_type == 'sccache' }}
run: |
echo "sccache version: $(sccache --version)"
echo "SCCACHE_BUCKET=${SCCACHE_BUCKET}"
echo "SCCACHE_S3_KEY_PREFIX=${SCCACHE_S3_KEY_PREFIX}"
- name: Build PyTorch Wheels
id: build-pytorch-wheels
run: |
cache_flag=""
if [ "${{ inputs.cache_type }}" = "sccache" ]; then
cache_flag="--use-sccache"
elif [ "${{ inputs.cache_type }}" = "ccache" ]; then
cache_flag="--use-ccache"
fi
echo "Building PyTorch wheels for ${{ inputs.amdgpu_family }} (cache: ${{ inputs.cache_type }})"
./external-builds/pytorch/build_prod_wheels.py \
build \
--install-rocm \
--index-url "${{ inputs.cloudfront_url }}/${{ inputs.amdgpu_family }}/" \
--clean \
--output-dir ${{ env.PACKAGE_DIST_DIR }} \
${cache_flag} \
${{ env.optional_build_prod_arguments }}
python ./build_tools/github_actions/write_torch_versions.py --dist-dir ${{ env.PACKAGE_DIST_DIR }}
- name: Report cache stats
if: ${{ !cancelled() && inputs.cache_type != 'none' }}
run: |
if [ "${{ inputs.cache_type }}" = "sccache" ]; then
echo "sccache stats:"
echo "--------------"
sccache --show-stats || true
elif [ "${{ inputs.cache_type }}" = "ccache" ]; then
echo "ccache stats:"
echo "-------------"
ccache -s -v || true
fi
- name: Sanity Check Wheel
run: |
python external-builds/pytorch/sanity_check_wheel.py ${{ env.PACKAGE_DIST_DIR }}/
- name: Generate PyTorch manifest
run: |
python build_tools/github_actions/generate_pytorch_manifest.py \
--manifest-dir "${{ env.PACKAGE_DIST_DIR }}/manifests" \
--python-version "${{ inputs.python_version }}" \
--pytorch-git-ref "${{ inputs.pytorch_git_ref }}" \
--pytorch-dir "external-builds/pytorch/pytorch" \
--pytorch-audio-dir "external-builds/pytorch/pytorch_audio" \
--pytorch-vision-dir "external-builds/pytorch/pytorch_vision" \
--triton-dir "external-builds/pytorch/triton" \
--apex-dir "external-builds/pytorch/apex"
- name: Configure AWS Credentials
if: always()
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::692859939525:role/therock-${{ inputs.release_type }}
- name: Upload wheels to S3 staging
if: ${{ github.repository_owner == 'ROCm' }}
run: |
aws s3 cp ${{ env.PACKAGE_DIST_DIR }}/ s3://${{ env.S3_BUCKET_PY }}/${{ inputs.s3_staging_subdir }}/${{ inputs.amdgpu_family }}/ \
--recursive --exclude "*" --include "*.whl"
- name: Upload PyTorch manifest to S3 artifacts
if: ${{ github.repository_owner == 'ROCm' }}
run: |
python build_tools/github_actions/upload_pytorch_manifest.py \
--dist-dir "${{ env.PACKAGE_DIST_DIR }}" \
--run-id "${{ github.run_id }}" \
--amdgpu-family "${{ inputs.amdgpu_family }}" \
--python-version "${{ inputs.python_version }}" \
--pytorch-git-ref "${{ inputs.pytorch_git_ref }}"
- name: (Re-)Generate Python package release index for staging
if: ${{ github.repository_owner == 'ROCm' }}
env:
# Environment variables to be set for `manage.py`
CUSTOM_PREFIX: "${{ inputs.s3_staging_subdir }}/${{ inputs.amdgpu_family }}"
run: |
python ./build_tools/third_party/s3_management/manage.py ${{ env.CUSTOM_PREFIX }}
generate_target_to_run:
name: Generate target_to_run
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
test_runs_on: ${{ steps.configure.outputs.test-runs-on }}
bypass_tests_for_releases: ${{ steps.configure.outputs.bypass_tests_for_releases }}
steps:
- name: Checking out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref || '' }}
- name: Generating target to run
id: configure
env:
TARGET: ${{ inputs.amdgpu_family }}
PLATFORM: "linux"
run: python ./build_tools/github_actions/configure_target_run.py
test_pytorch_wheels:
name: Test | ${{ inputs.amdgpu_family }} | ${{ needs.generate_target_to_run.outputs.test_runs_on }}
if: ${{ needs.generate_target_to_run.outputs.test_runs_on != '' }}
needs: [build_pytorch_wheels, generate_target_to_run]
permissions:
contents: read
uses: ./.github/workflows/test_pytorch_wheels.yml
with:
amdgpu_family: ${{ inputs.amdgpu_family }}
test_runs_on: ${{ needs.generate_target_to_run.outputs.test_runs_on }}
package_index_url: ${{ inputs.cloudfront_staging_url }}
python_version: ${{ inputs.python_version }}
torch_version: ${{ needs.build_pytorch_wheels.outputs.torch_version }}
pytorch_git_ref: ${{ inputs.pytorch_git_ref }}
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref || '' }}
upload_pytorch_wheels:
name: Release PyTorch Wheels to S3
needs: [build_pytorch_wheels, generate_target_to_run, test_pytorch_wheels]
if: ${{ !cancelled() }}
runs-on: ubuntu-24.04
permissions:
id-token: write
contents: read
env:
S3_BUCKET_PY: "therock-${{ inputs.release_type }}-python"
CP_VERSION: "${{ needs.build_pytorch_wheels.outputs.cp_version }}"
APEX_VERSION: "${{ needs.build_pytorch_wheels.outputs.apex_version }}"
TORCH_VERSION: "${{ needs.build_pytorch_wheels.outputs.torch_version }}"
TORCHAUDIO_VERSION: "${{ needs.build_pytorch_wheels.outputs.torchaudio_version }}"
TORCHVISION_VERSION: "${{ needs.build_pytorch_wheels.outputs.torchvision_version }}"
TRITON_VERSION: "${{ needs.build_pytorch_wheels.outputs.triton_version }}"
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref || '' }}
- name: Configure AWS Credentials
if: always()
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::692859939525:role/therock-${{ inputs.release_type }}
- name: Determine upload flag
env:
BUILD_RESULT: ${{ needs.build_pytorch_wheels.result }}
TEST_RESULT: ${{ needs.test_pytorch_wheels.result }}
TEST_RUNS_ON: ${{ needs.generate_target_to_run.outputs.test_runs_on }}
BYPASS_TESTS_FOR_RELEASES: ${{ needs.generate_target_to_run.outputs.bypass_tests_for_releases }}
run: python ./build_tools/github_actions/promote_wheels_based_on_policy.py
- name: Copy PyTorch wheels from staging to release S3
if: ${{ env.upload == 'true' }}
run: |
echo "Copying exact tested wheels to release S3 bucket..."
aws s3 cp \
s3://${S3_BUCKET_PY}/${{ inputs.s3_staging_subdir }}/${{ inputs.amdgpu_family }}/ \
s3://${S3_BUCKET_PY}/${{ inputs.s3_subdir }}/${{ inputs.amdgpu_family }}/ \
--recursive \
--exclude "*" \
--include "torch-${TORCH_VERSION}-${CP_VERSION}-linux_x86_64.whl" \
--include "torchaudio-${TORCHAUDIO_VERSION}-${CP_VERSION}-linux_x86_64.whl" \
--include "torchvision-${TORCHVISION_VERSION}-${CP_VERSION}-linux_x86_64.whl" \
--include "triton-${TRITON_VERSION}-${CP_VERSION}-linux_x86_64.whl" \
--include "apex-${APEX_VERSION}-${CP_VERSION}-linux_x86_64.whl"
- name: Install python deps for CI
run: |
pip install -r external-builds/pytorch/requirements-ci.txt
- name: (Re-)Generate Python package release index
if: ${{ env.upload == 'true' }}
env:
# Environment variables to be set for `manage.py`
CUSTOM_PREFIX: "${{ inputs.s3_subdir }}/${{ inputs.amdgpu_family }}"
run: |
python ./build_tools/third_party/s3_management/manage.py ${{ env.CUSTOM_PREFIX }}