-
Notifications
You must be signed in to change notification settings - Fork 235
Expand file tree
/
Copy pathbuild_windows_pytorch_wheels.yml
More file actions
449 lines (415 loc) · 18.4 KB
/
build_windows_pytorch_wheels.yml
File metadata and controls
449 lines (415 loc) · 18.4 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
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
name: Build Windows 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: gfx1151
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.9"
cache_type:
description: "Compiler cache type"
type: choice
options:
- none
- sccache
- ccache
default: none
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-windows-scale-rocm' || 'windows-2022' }}
permissions:
id-token: write
contents: read
env:
CHECKOUT_ROOT: B:/src
OUTPUT_DIR: ${{ github.workspace }}/output
# Note the \ here instead of /. This should be used from 'cmd' not 'bash'!
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: "windows/${{ 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
# 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 }}
torchvision_version: ${{ steps.build-pytorch-wheels.outputs.torchvision_version }}
defaults:
run:
# Note: there are mixed uses of 'bash' (this default) and 'cmd' below
shell: bash
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"
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ inputs.python_version }}
- name: Select Python version
run: |
python build_tools/github_actions/python_to_cp_version.py \
--python-version ${{ inputs.python_version }}
# TODO(amd-justchen): share with build_windows_artifacts.yml. Include in VM image? Dockerfile?
- name: Install requirements
run: |
choco source disable -n=chocolatey
choco source add -n=internal -s http://10.0.167.96:8081/repository/choco-group/ --priority=1
choco install --no-progress -y ninja --version 1.13.1
choco install --no-progress -y awscli
echo "$PATH;C:\Program Files\Amazon\AWSCLIV2" >> $GITHUB_PATH
- name: Install sccache
if: ${{ inputs.cache_type == 'sccache' }}
run: |
choco install --no-progress -y sccache
echo "sccache version: $(sccache --version)"
# After other installs, so MSVC get priority in the PATH.
- name: Configure MSVC
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
- 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
# TODO: switch to 'nightly' to match our Linux workflows?
- name: Checkout PyTorch source repos (nightly branch)
if: ${{ inputs.pytorch_git_ref == 'nightly' }}
run: |
git config --global core.longpaths true
python ./external-builds/pytorch/pytorch_torch_repo.py checkout \
--checkout-dir ${{ env.CHECKOUT_ROOT }}/torch \
--repo-hashtag nightly
python ./external-builds/pytorch/pytorch_audio_repo.py checkout \
--checkout-dir ${{ env.CHECKOUT_ROOT }}/audio \
--repo-hashtag nightly
python ./external-builds/pytorch/pytorch_vision_repo.py checkout \
--checkout-dir ${{ env.CHECKOUT_ROOT }}/vision \
--repo-hashtag nightly
# Checkout stable sources from https://github.com/ROCm/pytorch
- name: Checkout PyTorch Source Repos from stable branch
if: ${{ inputs.pytorch_git_ref != 'nightly' }}
run: |
git config --global core.longpaths true
python ./external-builds/pytorch/pytorch_torch_repo.py checkout \
--checkout-dir ${{ env.CHECKOUT_ROOT }}/torch \
--gitrepo-origin https://github.com/ROCm/pytorch.git \
--repo-hashtag ${{ inputs.pytorch_git_ref }}
python ./external-builds/pytorch/pytorch_audio_repo.py checkout \
--checkout-dir ${{ env.CHECKOUT_ROOT }}/audio \
--torch-dir ${{ env.CHECKOUT_ROOT }}/torch \
--require-related-commit
python ./external-builds/pytorch/pytorch_vision_repo.py checkout \
--checkout-dir ${{ env.CHECKOUT_ROOT }}/vision \
--torch-dir ${{ env.CHECKOUT_ROOT }}/torch \
--require-related-commit
# 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 }}
special-characters-workaround: true
- 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
# Using 'cmd' here is load bearing! There are configuration issues when
# run under 'bash': https://github.com/ROCm/TheRock/issues/827#issuecomment-3025858800
shell: cmd
run: |
set "CACHE_FLAG="
if "${{ inputs.cache_type }}"=="sccache" set "CACHE_FLAG=--use-sccache"
if "${{ inputs.cache_type }}"=="ccache" set "CACHE_FLAG=--use-ccache"
echo "Building PyTorch wheels for ${{ inputs.amdgpu_family }} (cache: ${{ inputs.cache_type }})"
python ./external-builds/pytorch/build_prod_wheels.py ^
build ^
--install-rocm ^
--index-url "${{ inputs.cloudfront_url }}/${{ inputs.amdgpu_family }}/" ^
--pytorch-dir ${{ env.CHECKOUT_ROOT }}/torch ^
--pytorch-audio-dir ${{ env.CHECKOUT_ROOT }}/audio ^
--pytorch-vision-dir ${{ env.CHECKOUT_ROOT }}/vision ^
--enable-pytorch-flash-attention-windows ^
--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
shell: cmd
run: |
python external-builds/pytorch/sanity_check_wheel.py ${{ env.PACKAGE_DIST_DIR }}
- name: Generate PyTorch manifest
shell: bash
run: |
python build_tools/github_actions/generate_pytorch_manifest.py \
--manifest-dir "${PACKAGE_DIST_DIR}/manifests" \
--python-version "${{ inputs.python_version }}" \
--pytorch-git-ref "${{ inputs.pytorch_git_ref }}" \
--pytorch-dir "${CHECKOUT_ROOT}/torch" \
--pytorch-audio-dir "${CHECKOUT_ROOT}/audio" \
--pytorch-vision-dir "${CHECKOUT_ROOT}/vision"
- 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 }}
special-characters-workaround: true
- name: Upload wheels to S3 staging
if: ${{ github.repository_owner == 'ROCm' }}
# Using 'cmd' here since PACKAGE_DIST_DIR uses \ in paths instead of /
shell: cmd
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' }}
shell: bash
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 }}"
shell: cmd
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: "windows"
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 }}"
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 }}"
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 }}
special-characters-workaround: true
- 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}-win_amd64.whl" \
--include "torchaudio-${TORCHAUDIO_VERSION}-${CP_VERSION}-win_amd64.whl" \
--include "torchvision-${TORCHVISION_VERSION}-${CP_VERSION}-win_amd64.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 }}