Skip to content
Open
146 changes: 146 additions & 0 deletions .github/workflows/copy_prebuilt_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

# Reusable workflow that materializes a release run's artifact prefix from a
# fixed "prebuilt" prefix in the active artifact namespace.
#
# Behavior:
# - If `prebuilt_prefix` is empty, the job runs but is a successful no-op.
# Downstream jobs can keep `needs:` on this workflow without conditional
# plumbing for normal source-build runs.
# - If `prebuilt_prefix` is non-empty, the job copies all stage artifacts
# from that prefix into the active run's prefix using
# `artifact_manager.py copy --source-prefix-only --stage=all
# --require-matches`.
#
# This workflow is also exposed as `workflow_dispatch` for manual reruns,
# e.g. when re-staging a patched prebuilt prefix.

name: Copy Prebuilt Artifacts

on:
workflow_call:
inputs:
prebuilt_prefix:
description: >-
Source prefix component (the part before "-linux"/"-windows") to
copy artifacts from. Empty means no-op (source-build mode).
type: string
default: ""
platform:
description: 'Platform: "linux" or "windows".'
type: string
required: true
amdgpu_families:
description: "Semicolon-separated GPU families to copy."
type: string
required: true
expand_family_to_targets:
description: >-
Pass --expand-family-to-targets to artifact_manager copy. Required
for kpack-split (multi-arch) prefixes; should be false for
single-family release builds.
type: boolean
default: false
release_type:
description: 'Release type: "dev", "nightly", or "prerelease".'
type: string
required: true
repository:
description: "Repository to checkout. Defaults to github.repository."
type: string
default: ""
ref:
description: "Branch, tag, or SHA to checkout. Defaults to the triggering ref."
type: string
default: ""
workflow_dispatch:
inputs:
prebuilt_prefix:
description: 'Source prefix (e.g. "rerun-2026-04-30").'
type: string
required: true
platform:
description: 'Platform: "linux" or "windows".'
type: choice
options:
- linux
- windows
default: linux
amdgpu_families:
description: "Semicolon-separated GPU families to copy."
type: string
required: true
expand_family_to_targets:
description: "Pass --expand-family-to-targets to artifact_manager copy."
type: boolean
default: false
release_type:
description: 'Release type: "dev", "nightly", or "prerelease".'
type: choice
options:
- dev
- nightly
- prerelease
default: dev
ref:
description: "Branch, tag, or SHA to checkout."
type: string
default: ""

permissions:
contents: read

run-name: >-
Copy Prebuilt Artifacts
(${{ inputs.platform }}, ${{ inputs.release_type }}) | prebuilt: ${{ inputs.prebuilt_prefix }}

jobs:
copy:
name: Copy Prebuilt Artifacts
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
steps:
- name: No-op when prebuilt_prefix is empty
if: ${{ inputs.prebuilt_prefix == '' }}
run: echo "prebuilt_prefix is empty; skipping copy (source-build mode)."

- name: Checkout
if: ${{ inputs.prebuilt_prefix != '' }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref }}

- name: Setup Python
if: ${{ inputs.prebuilt_prefix != '' }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"

- name: Install artifact manager dependencies
if: ${{ inputs.prebuilt_prefix != '' }}
run: pip install boto3

- name: Configure AWS credentials
if: ${{ inputs.prebuilt_prefix != '' }}
uses: ./.github/actions/configure_aws_artifacts_credentials
with:
release_type: ${{ inputs.release_type }}

- name: Copy prebuilt artifacts
if: ${{ inputs.prebuilt_prefix != '' }}
env:
GITHUB_TOKEN: ${{ github.token }}
RELEASE_TYPE: ${{ inputs.release_type }}
run: |
python build_tools/artifact_manager.py copy \
--source-run-id="${{ inputs.prebuilt_prefix }}" \
--source-prefix-only \
--stage=all \
--platform="${{ inputs.platform }}" \
--amdgpu-families="${{ inputs.amdgpu_families }}" \
${{ inputs.expand_family_to_targets && '--expand-family-to-targets' || '' }} \
--require-matches
17 changes: 16 additions & 1 deletion .github/workflows/multi_arch_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ on:
description: "Branch, tag, or SHA to checkout. Defaults to the triggering ref."
type: string
default: ""
prebuilt_prefix:
description: >-
Optional fixed prefix component (the part before "-linux"/
"-windows") to copy artifacts from instead of building from
source. Empty (the default) selects normal source-build mode.
type: string
default: ""
workflow_dispatch:
inputs:
release_type:
Expand All @@ -65,14 +72,20 @@ on:
description: 'Comma-separated list of Windows GPU families. "all" = all, "none" = skip platform.'
type: string
default: "gfx110x"
prebuilt_prefix:
description: >-
Optional fixed prefix component to copy artifacts from instead of
building from source. Empty selects normal source-build mode.
type: string
default: ""

permissions:
contents: read

run-name: >-
Multi-Arch Release (${{ inputs.release_type }})
| Linux: ${{ inputs.linux_amdgpu_families || 'none' }}
| Windows: ${{ inputs.windows_amdgpu_families || 'none' }}
| Windows: ${{ inputs.windows_amdgpu_families || 'none' }}${{ inputs.prebuilt_prefix && format(' | prebuilt: {0}', inputs.prebuilt_prefix) || '' }}

jobs:
setup:
Expand Down Expand Up @@ -101,6 +114,7 @@ jobs:
release_type: ${{ inputs.release_type }}
repository: ${{ inputs.repository || github.repository }}
ref: ${{ needs.setup.outputs.ref }}
prebuilt_prefix: ${{ inputs.prebuilt_prefix }}
permissions:
contents: read
actions: write # Added permission to trigger workflows
Expand All @@ -119,6 +133,7 @@ jobs:
release_type: ${{ inputs.release_type }}
repository: ${{ inputs.repository || github.repository }}
ref: ${{ needs.setup.outputs.ref }}
prebuilt_prefix: ${{ inputs.prebuilt_prefix }}
permissions:
contents: read
actions: write # Added permission to trigger workflows
Expand Down
50 changes: 48 additions & 2 deletions .github/workflows/multi_arch_release_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ on:
ref:
description: "Branch, tag, or SHA to checkout. Defaults to the triggering ref."
type: string
prebuilt_prefix:
description: >-
Optional fixed prefix to copy artifacts from instead of building
from source. Empty selects normal source-build mode.
type: string
default: ""

permissions:
contents: read

jobs:
build_artifacts:
name: Build Artifacts
build_source:
name: Build Artifacts (source)
if: ${{ inputs.prebuilt_prefix == '' }}
uses: ./.github/workflows/multi_arch_build_portable_linux.yml
secrets: inherit
with:
Expand All @@ -53,6 +60,41 @@ jobs:
contents: read
id-token: write

copy_prebuilt:
name: Copy Prebuilt Artifacts
uses: ./.github/workflows/copy_prebuilt_artifacts.yml
Comment on lines +63 to +65
Copy link
Copy Markdown
Member

@ScottTodd ScottTodd May 6, 2026

Choose a reason for hiding this comment

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

Another thing to watch for:

the base_lib_generic.tar.zst contains dist_info.json with contents like

{
  "dist_amdgpu_targets" : "gfx942;gfx1100;gfx1101;gfx1102;gfx1103;gfx1151;gfx1200;gfx1201;gfx950"
}

just repackaging a subset of existing artifacts (e.g. choosing to release a subset of the targets that were built in a nightly release for a stable release) with a changed version will include the original list there, resulting in tools like rocm-sdk targets returning a list that may not match expectations (see also #4687)

secrets: inherit
with:
prebuilt_prefix: ${{ inputs.prebuilt_prefix }}
platform: linux
amdgpu_families: ${{ fromJSON(inputs.build_config).dist_amdgpu_families }}
expand_family_to_targets: true
release_type: ${{ inputs.release_type }}
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
permissions:
contents: read
id-token: write

build_artifacts:
name: Build Artifacts
needs: [build_source, copy_prebuilt]
if: ${{ always() }}
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref }}

- name: Verify active producer succeeded
run: |
python build_tools/github_actions/verify_artifacts_ready.py \
--prebuilt-prefix="${{ inputs.prebuilt_prefix }}" \
--build-source-result="${{ needs.build_source.result }}" \
--copy-prebuilt-result="${{ needs.copy_prebuilt.result }}"

build_tarballs:
needs: [build_artifacts]
name: Build Tarballs
Expand Down Expand Up @@ -169,11 +211,15 @@ jobs:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}

# PyTorch wheels are built from source. The prebuilt path only re-stages
# ROCm artifacts; it does not carry PyTorch wheels, so skip the dispatch
# in prebuilt mode.
# TODO: Consider switch pulling ROCm packages from the CDN instead of the artifact
# bucket if the job order is not altered.
build_pytorch_wheels:
needs: [build_artifacts, build_python_packages]
name: Build PyTorch Wheels
if: ${{ inputs.prebuilt_prefix == '' }}
runs-on: ubuntu-24.04
permissions:
actions: write
Expand Down
50 changes: 48 additions & 2 deletions .github/workflows/multi_arch_release_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ on:
ref:
description: "Branch, tag, or SHA to checkout. Defaults to the triggering ref."
type: string
prebuilt_prefix:
description: >-
Optional fixed prefix to copy artifacts from instead of building
from source. Empty selects normal source-build mode.
type: string
default: ""

permissions:
contents: read

jobs:
build_artifacts:
name: Build Artifacts
build_source:
name: Build Artifacts (source)
if: ${{ inputs.prebuilt_prefix == '' }}
uses: ./.github/workflows/multi_arch_build_windows.yml
secrets: inherit
with:
Expand All @@ -47,6 +54,41 @@ jobs:
contents: read
id-token: write

copy_prebuilt:
name: Copy Prebuilt Artifacts
uses: ./.github/workflows/copy_prebuilt_artifacts.yml
secrets: inherit
with:
prebuilt_prefix: ${{ inputs.prebuilt_prefix }}
platform: windows
amdgpu_families: ${{ fromJSON(inputs.build_config).dist_amdgpu_families }}
expand_family_to_targets: true
release_type: ${{ inputs.release_type }}
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
permissions:
contents: read
id-token: write

build_artifacts:
name: Build Artifacts
needs: [build_source, copy_prebuilt]
if: ${{ always() }}
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref }}

- name: Verify active producer succeeded
run: |
python build_tools/github_actions/verify_artifacts_ready.py \
--prebuilt-prefix="${{ inputs.prebuilt_prefix }}" \
--build-source-result="${{ needs.build_source.result }}" \
--copy-prebuilt-result="${{ needs.copy_prebuilt.result }}"

build_tarballs:
needs: [build_artifacts]
name: Build Tarballs
Expand Down Expand Up @@ -131,11 +173,15 @@ jobs:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}

# PyTorch wheels are built from source. The prebuilt path only re-stages
# ROCm artifacts; it does not carry PyTorch wheels, so skip the dispatch
# in prebuilt mode.
# TODO: Consider switch pulling ROCm packages from the CDN instead of the artifact
# bucket if the job order is not altered.
build_pytorch_wheels:
needs: [build_artifacts, build_python_packages]
name: Build PyTorch Wheels
if: ${{ inputs.prebuilt_prefix == '' }}
runs-on: ubuntu-24.04
permissions:
actions: write
Expand Down
Loading
Loading