Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 83 additions & 27 deletions .github/workflows/build_windows_pytorch_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,50 @@ name: Build Windows PyTorch Wheels
on:
workflow_call:
inputs:
AMDGPU_FAMILIES:
amdgpu_family:
required: true
type: string
python_version:
required: true
type: string
s3_bucket:
release_type:
description: The type of release to build ("nightly", or "dev")
required: true
type: string
s3_subdir:
description: S3 subdirectory, not including the GPU-family
required: true
type: string
cloudfront_url:
description: CloudFront URL pointing to Python index
required: true
type: string
rocm_version:
description: ROCm version to pip install
type: string
workflow_dispatch:
inputs:
AMDGPU_FAMILIES:
amdgpu_family:
required: true
type: string
python_version:
required: true
type: string
s3_bucket:
required: true
default:
release_type:
description: The type of release to build ("nightly", or "dev")
type: string
default: "dev"
s3_subdir:
description: S3 subdirectory, not including the GPU-family
type: string
default: "v2"
cloudfront_url:
description: CloudFront base URL pointing to Python index
type: string
default: "d25kgig7rdsyks.cloudfront.net/v2"
rocm_version:
description: ROCm version to pip install
type: string

permissions:
Expand All @@ -30,13 +55,14 @@ permissions:

jobs:
build_pytorch_wheels:
name: Build Windows PyTorch Wheels | ${{ inputs.AMDGPU_FAMILIES }} | Python ${{ inputs.python_version }}
name: Build Windows PyTorch Wheels | ${{ inputs.amdgpu_family }} | Python ${{ inputs.python_version }}
runs-on: ${{ github.repository_owner == 'ROCm' && 'azure-windows-scale-rocm' || 'windows-2022' }}
env:
CHECKOUT_ROOT: C:/src
OUTPUT_DIR: ${{ github.workspace }}/output
PACKAGE_DIST_DIR: ${{ github.workspace }}/output/packages/dist
S3_BUCKET: ${{ inputs.s3_bucket }}
S3_ENDPOINT: "s3.us-east-2.amazonaws.com"
PACKAGE_DIST_DIR: ${{ github.workspace }}\output\packages\dist
S3_BUCKET_PY: "therock-${{ inputs.release_type }}-python"
optional_build_prod_arguments: ""
defaults:
run:
shell: bash
Expand All @@ -53,30 +79,60 @@ jobs:
with:
python-version: ${{ inputs.python_version }}

# TODO(amd-justchen): share with build_windows_packages.yml. Include in VM image? Dockerfile?
- name: Install requirements
run: |
# ninja pinned due to a bug in the 1.13.0 release:
# https://github.com/ninja-build/ninja/issues/2616
choco install --no-progress -y ninja --version 1.12.1
choco install --no-progress -y awscli
echo "$PATH;C:\Program Files\Amazon\AWSCLIV2" >> $GITHUB_PATH

# After other installs, so MSVC get priority in the PATH.
- name: Configure MSVC
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0

- name: Checkout PyTorch Source Repos
run: |
python ./external-builds/pytorch/pytorch_torch_repo.py checkout
# TODO(scotttodd): include these
git config --global core.longpaths true
python ./external-builds/pytorch/pytorch_torch_repo.py checkout --repo ${{ env.CHECKOUT_ROOT }}/torch
# TODO(#910): Support torchvision and torchaudio on Windows
# python ./external-builds/pytorch/pytorch_audio_repo.py checkout
# python ./external-builds/pytorch/pytorch_vision_repo.py checkout

# TODO(scotttodd): build wheels, put into a directory location for next step to use
- name: Determine optional arguments passed to `build_prod_wheels.py`
if: ${{ inputs.rocm_version }}
run: |
pip install packaging
python build_tools/github_actions/determine_version.py \
--rocm-version ${{ inputs.rocm_version }}

# TODO(scotttodd): add upload once working
- name: Build PyTorch Wheels
shell: cmd
run: |
echo "Building PyTorch wheels for ${{ inputs.amdgpu_family }}"
python ./external-builds/pytorch/build_prod_wheels.py build --pytorch-dir ${{ env.CHECKOUT_ROOT }}/torch --clean --output-dir ${{ env.PACKAGE_DIST_DIR }} ${{ env.optional_build_prod_arguments }}

# - name: Upload wheels to S3
# if: ${{ github.repository_owner == 'ROCm' }}
# run: |
# aws s3 cp ${{ env.PACKAGE_DIST_DIR }}/ s3://${{ env.S3_BUCKET }}/${{ inputs.AMDGPU_FAMILIES }}/ \
# --recursive --exclude "*" --include "*.whl"
- name: Configure AWS Credentials
if: always()
uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df # v4.2.1
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::692859939525:role/therock-${{ inputs.release_type }}-releases

# - name: (Re-)Generate Python package release index
# if: ${{ github.repository_owner == 'ROCm' }}
# TODO(#827, #910): enable this once we build torch audio and vision on Windows
# - name: Sanity Check Wheel
# run: |
# pip install boto3
# python ./build_tools/packaging/python/generate_release_index.py \
# --bucket=${{ env.S3_BUCKET }} \
# --endpoint=${{ env.S3_ENDPOINT }} \
# --subdir=${{ inputs.AMDGPU_FAMILIES }} \
# --output=${{ github.workspace }}/index.html
# aws s3 cp ${{ github.workspace }}/index.html s3://${{ env.S3_BUCKET }}/${{ inputs.AMDGPU_FAMILIES }}/
# python external-builds/pytorch/sanity_check_wheel.py ${{ env.PACKAGE_DIST_DIR }}/

- name: Upload wheels to S3
if: ${{ github.repository_owner == 'ROCm' }}
shell: cmd
run: |
aws s3 cp ${{ env.PACKAGE_DIST_DIR }}/ s3://${{ env.S3_BUCKET_PY }}/${{ inputs.s3_subdir }}/${{ inputs.amdgpu_family }}/ --recursive --exclude "*" --include "*.whl"

- name: (Re-)Generate Python package release index
if: ${{ github.repository_owner == 'ROCm' }}
run: |
pip install boto3 packaging
python ./build_tools/third_party/s3_management/manage.py ${{ inputs.s3_subdir }}/${{ inputs.amdgpu_family }}
21 changes: 17 additions & 4 deletions .github/workflows/release_windows_pytorch_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ name: Release Windows PyTorch Wheels

on:
workflow_dispatch:
inputs:
release_type:
description: The type of release to build ("nightly", or "dev")
type: string
default: "dev"
s3_subdir:
description: S3 subdirectory, not including the GPU-family
type: string
default: "v2"
cloudfront_url:
description: CloudFront URL pointing to Python index
type: string
default: "d25kgig7rdsyks.cloudfront.net/v2"

# TODO(scotttodd): add schedule once working
# schedule:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I dropped running on schedule from the Linux workflow and instead trigger this workflow from the release portable Linux packages workflow.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I'll make those updates. I had been testing exclusively with workflow_dispatch.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied over changes from #983 to these files. I'll want to test before marking this ready for review/merge... once the dependent PRs are merged.

Expand All @@ -25,8 +38,8 @@ jobs:

uses: ./.github/workflows/build_windows_pytorch_wheels.yml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently revised this workflow further (PR #998) and expect for this particular line the workflows are identically. Could merge them and rather add an input parameter that tells if to build for Linux or Windows maybe?.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, merging should be possible now :D

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we can go for it as is, this isn't blocking but wanted to flag that we can clean in a follow up :)

with:
AMDGPU_FAMILIES: ${{ matrix.config.AMDGPU_FAMILIES }}
amdgpu_family: ${{ matrix.config.AMDGPU_FAMILIES }}
python_version: ${{ matrix.python_version }}
# TODO: switch to nightly once ready (and allow 'dev' from workflow_dispatch)
# s3_bucket: therock-nightly-python
s3_bucket: therock-dev-python
release_type: ${{ inputs.release_type || 'nightly' }}
s3_subdir: ${{ inputs.s3_subdir || 'v2' }}
cloudfront_url: ${{ inputs.cloudfront_url || 'd2awnip2yjpvqn.cloudfront.net/v2' }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defaults can be dropped if not planning to run on schedule.

9 changes: 7 additions & 2 deletions external-builds/pytorch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ mix/match build steps.
- On Windows:

```bash
# TODO(#827): switch from therock-dev-python index to therock-nightly-python
python build_prod_wheels.py build \
--install-rocm --index-url https://d25kgig7rdsyks.cloudfront.net/v2/gfx110X-dgpu/ \
--install-rocm --index-url https://d2awnip2yjpvqn.cloudfront.net/v2/gfx110X-dgpu/ \
--pytorch-dir C:/b/pytorch \
--output-dir %HOME%/tmp/pyout
```
Expand All @@ -125,9 +124,15 @@ The `rocm[libraries,devel]` packages can be installed in multiple ways:
- Manually installing from a release index:

```bash
# From therock-nightly-python
python -m pip install \
--index-url https://d2awnip2yjpvqn.cloudfront.net/v2/gfx110X-dgpu/ \
rocm[libraries,devel]

# OR from therock-dev-python
python -m pip install \
--index-url https://d25kgig7rdsyks.cloudfront.net/v2/gfx110X-dgpu/ \
rocm[libraries,devel]
```

- Building the rocm Python packages from artifacts fetched from a CI run:
Expand Down
11 changes: 6 additions & 5 deletions external-builds/pytorch/build_prod_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
# Note that triton must be checked out after pytorch as it depends on pins
# in the former.
python pytorch_torch_repo.py checkout
python pytorch_torch_audio_repo.py checkout
python pytorch_torch_vision_repo.py checkout
python pytorch_audio_repo.py checkout
python pytorch_vision_repo.py checkout
python pytorch_triton_repo.py checkout

# On Windows, using shorter paths to avoid compile command length limits:
Expand Down Expand Up @@ -381,11 +381,12 @@ def do_build(args: argparse.Namespace):
env.update(addl_triton_env)

if is_windows:
llvm_dir = root_dir / "lib" / "llvm" / "bin"
env.update(
{
"HIP_CLANG_PATH": str((root_dir / "lib" / "llvm" / "bin").as_posix()),
"CC": str((root_dir / "lib" / "llvm" / "bin" / "clang-cl").as_posix()),
"CXX": str((root_dir / "lib" / "llvm" / "bin" / "clang-cl").as_posix()),
"HIP_CLANG_PATH": str(llvm_dir.resolve().as_posix()),
"CC": str((llvm_dir / "clang-cl.exe").resolve()),
"CXX": str((llvm_dir / "clang-cl.exe").resolve()),
}
)
else:
Expand Down