Files
TheRock/build_tools/github_actions/expand_amdgpu_families.py
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

91 lines
2.7 KiB
Python

#!/usr/bin/env python
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""Expand a list of AMD GPU families to their constituent gfx targets.
Reads `cmake/therock_amdgpu_targets.cmake` (the authoritative source of
truth) via `_therock_utils.cmake_amdgpu_targets` and prints the union
of gfx targets for the requested families as a comma-separated string.
Used by CI workflows that need build-side gfx targets (e.g.
`--pytorch-rocm-arch`) from a family list. Mirrors the pattern used by
`artifact_manager.py --expand-family-to-targets`.
Output modes:
* ``targets`` (default) — bare gfx targets, comma-separated:
python expand_amdgpu_families.py --amdgpu-families "gfx94X-dcgpu;gfx120X-all"
-> gfx942,gfx1200,gfx1201
* ``device-extras`` — pip device extras, comma-separated, and also
written to ``$GITHUB_OUTPUT`` as ``device_extras=...``:
python expand_amdgpu_families.py --amdgpu-families "gfx94X-dcgpu" \
--output-mode=device-extras
-> device-gfx942 (stdout)
-> device_extras=device-gfx942 (GITHUB_OUTPUT)
Fails with a non-zero exit code and a clear message if any requested
family is not present in the CMake source — silent drops were the bug
this helper exists to prevent.
"""
import argparse
import sys
from pathlib import Path
_BUILD_TOOLS_DIR = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(_BUILD_TOOLS_DIR))
from _therock_utils.cmake_amdgpu_targets import (
amdgpu_family_map,
expand_families,
)
from github_actions.github_actions_api import gha_set_output
def main(argv: list[str]) -> int:
p = argparse.ArgumentParser(prog="expand_amdgpu_families.py")
p.add_argument(
"--amdgpu-families",
required=True,
type=str,
help=(
"Semicolon-separated list of AMD GPU families to expand "
"(e.g. 'gfx94X-dcgpu;gfx120X-all')."
),
)
p.add_argument(
"--output-mode",
choices=["targets", "device-extras"],
default="targets",
help=(
"'targets' prints bare gfx targets (default). "
"'device-extras' prints pip device extras (device-gfxNNN) "
"and writes them to GITHUB_OUTPUT as device_extras=..."
),
)
args = p.parse_args(argv)
families = [f.strip() for f in args.amdgpu_families.split(";") if f.strip()]
if not families:
print("")
return 0
targets = expand_families(families, amdgpu_family_map())
if args.output_mode == "device-extras":
result = ",".join(f"device-{t}" for t in targets)
print(result)
gha_set_output({"device_extras": result})
else:
print(",".join(targets))
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))