From 967eab12d1d499b02827e7f2b8509614ae87c737 Mon Sep 17 00:00:00 2001 From: Thomas Vy Date: Thu, 19 Nov 2026 14:00:05 -0500 Subject: [PATCH 1/4] feat(setup): install the newest ROCm nightly that Quartz reports usable for the GPU arch setup_env.py --torch-mode rocm reads the Quartz status.json of each TheRock nightly and installs the newest one of the last 14 days that qualifies for the host platform and the GPU architecture: - the ROCm and PyTorch builds of the platform are success - the TheRock target of the arch is among the built architectures - the wheels URL is set - pipelines.rocm.test and pipelines.pytorch.test of the target are success, when the entry exists A missing test entry does not reject the nightly. Setup prints the suites without a result and records them as untested. When no nightly qualifies, setup lists each nightly with every failed check, for example "linux rocm tests of gfx94X-dcgpu are failure". --rocm-version pins a build and warns when Quartz reports a failed build or test for the arch. --torch-index-url without --rocm-version installs the newest build on that index and does not read Quartz. Setup writes dnn-bench-rocm-build.json into the venv. Result files copy it to environment.rocm_build_version, rocm_build_date, therock_commit and rocm_build_untested. The image build script selects the nightly on the host and passes it as ROCM_VERSION. CI logs the selected build and takes the ROCM_VERSION repository variable. check-deserialize builds for gfx942: Quartz reports failed gfx90a ROCm tests on every nightly from 20261106 to 20261119. --- .github/workflows/check-deserialize.yml | 19 +- .github/workflows/setup.yml | 12 +- ...Dockerfile.dnn-benchmark-performance-linux | 16 + .../build-dnn-benchmark-performance-image.sh | 33 ++ docs/results-schema.md | 4 + docs/setup.md | 134 ++++- setup_env.py | 471 +++++++++++++++-- src/dnn_benchmarking/metrics/machine_info.py | 43 ++ .../reporting/suite_results.py | 4 + .../data/quartz/nightly/20261113/status.json | 479 ++++++++++++++++++ .../data/quartz/nightly/20261114/status.json | 290 +++++++++++ .../data/quartz/nightly/20261115/status.json | 479 ++++++++++++++++++ .../data/quartz/nightly/20261116/status.json | 479 ++++++++++++++++++ .../data/quartz/nightly/20261117/status.json | 479 ++++++++++++++++++ .../data/quartz/nightly/20261118/status.json | 479 ++++++++++++++++++ .../data/quartz/nightly/20261119/status.json | 380 ++++++++++++++ tests/unit/metrics/test_machine_info.py | 4 + tests/unit/reporting/test_schema_v3.py | 3 +- tests/unit/test_setup_env.py | 464 ++++++++++++++++- 19 files changed, 4209 insertions(+), 63 deletions(-) create mode 100644 tests/unit/data/quartz/nightly/20261113/status.json create mode 100644 tests/unit/data/quartz/nightly/20261114/status.json create mode 100644 tests/unit/data/quartz/nightly/20261115/status.json create mode 100644 tests/unit/data/quartz/nightly/20261116/status.json create mode 100644 tests/unit/data/quartz/nightly/20261117/status.json create mode 100644 tests/unit/data/quartz/nightly/20261118/status.json create mode 100644 tests/unit/data/quartz/nightly/20261119/status.json diff --git a/.github/workflows/check-deserialize.yml b/.github/workflows/check-deserialize.yml index 1eae2eb4..bc44e766 100644 --- a/.github/workflows/check-deserialize.yml +++ b/.github/workflows/check-deserialize.yml @@ -49,14 +49,25 @@ jobs: # No GPU required: from_json + validate + build_operation_graph only # assemble and finalize the backend operation-graph descriptor, no - # plan build or kernel execution. The check imports only - # hipdnn_frontend, so --no-aiter skips the AITER build, which needs a - # ROCm version file that this runner does not have. + # plan build or kernel execution. ROCm PyTorch is the newest nightly + # that Quartz reports as built and not failing tests for the arch, or + # the ROCM_VERSION repository variable when it is set. The arch is + # gfx942, not gfx90a: Quartz reports failed gfx90a ROCm tests on most + # nightlies, and this build does not run on a GPU. The check imports + # only hipdnn_frontend, so --no-aiter skips the AITER build. - name: Build hipDNN (no GPU) env: PIP_NO_CACHE_DIR: "1" + ROCM_VERSION: ${{ vars.ROCM_VERSION }} run: | - python setup_env.py --gpu-arch gfx90a --workspace .ci-workspace -y --no-aiter + python setup_env.py --gpu-arch gfx942 --workspace .ci-workspace -y --no-aiter \ + ${ROCM_VERSION:+--rocm-version "$ROCM_VERSION"} + + - name: Log the ROCm build + run: | + python -c 'import json, sys; r = json.load(open(sys.argv[1])); print("ROCm", r["rocm_version"], "built", r["build_date"], "from TheRock", r["therock_commit"], "(" + r["source"] + "), untested:", r["untested"])' \ + .ci-workspace/.venv/dnn-bench-rocm-build.json | + tee -a "$GITHUB_STEP_SUMMARY" - name: Check opgraph-level graph deserialization run: | diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index 34728dfb..d2096a8c 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -105,15 +105,25 @@ jobs: python-version: '3.12' # No --gpu-arch: detected from the runner's own GPU, so this job works - # on any GPU runner label. + # on any GPU runner label. ROCm PyTorch is the newest nightly that + # Quartz reports as built and not failing tests for that GPU, or the + # ROCM_VERSION repository variable when it is set. - name: Full rocm-mode build env: PIP_NO_CACHE_DIR: "1" + ROCM_VERSION: ${{ vars.ROCM_VERSION }} run: | python setup_env.py \ --workspace .ci-gpu-workspace \ + ${ROCM_VERSION:+--rocm-version "$ROCM_VERSION"} \ -y + - name: Log the ROCm build + run: | + python -c 'import json, sys; r = json.load(open(sys.argv[1])); print("ROCm", r["rocm_version"], "built", r["build_date"], "from TheRock", r["therock_commit"], "(" + r["source"] + "), untested:", r["untested"])' \ + .ci-gpu-workspace/.venv/dnn-bench-rocm-build.json | + tee -a "$GITHUB_STEP_SUMMARY" + # activate (not $VENV/python) for the ROCM_PATH/LD_LIBRARY_PATH that # conftest.py's plugin discovery needs. No -m filter: gpu tests run here. - name: Install test extras and run full suite on hardware diff --git a/dockerfiles/Dockerfile.dnn-benchmark-performance-linux b/dockerfiles/Dockerfile.dnn-benchmark-performance-linux index 26056488..66f345ef 100644 --- a/dockerfiles/Dockerfile.dnn-benchmark-performance-linux +++ b/dockerfiles/Dockerfile.dnn-benchmark-performance-linux @@ -41,6 +41,13 @@ WORKDIR ${WORKSPACE_DIR} COPY . . +# The ROCm wheel version to install. The build script selects the newest +# nightly that Quartz reports as usable for DEVICE_TARGET, or takes its +# --rocm-version. Empty => setup installs the newest ROCm PyTorch on +# ROCM_TORCH_INDEX_URL. Declared here, not at the stage top, so a new ROCm +# build keeps the apt layer. +ARG ROCM_VERSION="" + RUN --mount=type=cache,target=/root/.cache/pip <<'EOF' set -eu @@ -71,6 +78,9 @@ fi if [ -n "${ROCM_LIBRARIES_REF}" ]; then set -- "$@" --rocm-libraries-ref "${ROCM_LIBRARIES_REF}" fi +if [ -n "${ROCM_VERSION}" ]; then + set -- "$@" --rocm-version "${ROCM_VERSION}" +fi python3.12 setup_env.py "$@" @@ -190,6 +200,12 @@ RUN useradd --create-home --user-group --groups video dnnbench && \ chown dnnbench:dnnbench "${WORKSPACE_DIR}" USER dnnbench +# The ROCm wheel version that the builder stage installed, when the build +# named one. The results also record it, with its TheRock build date and +# commit (environment.rocm_build_version, rocm_build_date, therock_commit). +ARG ROCM_VERSION="" +LABEL com.amd.dnn-benchmark.rocm-version="${ROCM_VERSION}" + # One-shot benchmark CLI, not a long-running service. HEALTHCHECK NONE diff --git a/dockerfiles/build-dnn-benchmark-performance-image.sh b/dockerfiles/build-dnn-benchmark-performance-image.sh index e0cacaa9..d4b5380e 100755 --- a/dockerfiles/build-dnn-benchmark-performance-image.sh +++ b/dockerfiles/build-dnn-benchmark-performance-image.sh @@ -4,6 +4,7 @@ set -euo pipefail container_command="docker" device_target="gfx942" tag="" +rocm_version="" build_args=() usage() { @@ -16,12 +17,17 @@ Options: --container-command CMD Container command. Default: docker --device-target TARGET ROCm PyTorch GPU architecture. Default: gfx942 --tag TAG Image tag. Default: dnn-benchmark-performance: + --rocm-version VERSION ROCm wheel version to install, for example + 10.3.0a20261117. Default: the newest nightly that + Quartz reports as built for the device target, + selected on this host. -h, --help Show this help. Examples: ./build-dnn-benchmark-performance-image.sh ./build-dnn-benchmark-performance-image.sh --container-command podman ./build-dnn-benchmark-performance-image.sh --device-target gfx950 + ./build-dnn-benchmark-performance-image.sh --rocm-version 10.3.0a20261117 EOF } @@ -42,6 +48,11 @@ while [[ $# -gt 0 ]]; do tag="$2" shift 2 ;; + --rocm-version) + [[ $# -ge 2 ]] || { echo "--rocm-version requires a value" >&2; exit 2; } + rocm_version="$2" + shift 2 + ;; -h|--help) usage exit 0 @@ -78,10 +89,32 @@ if [[ -z "${rocm_libraries_ref}" ]]; then echo "WARNING: could not resolve the rocm-libraries submodule commit; the image will build its moving branch." >&2 fi +# Select the ROCm nightly here, with the same rule as setup_env.py. The image +# then installs and labels that ROCm build even when a newer nightly appears. +resolved="$(python3 - "${repo_root}/setup_env.py" "${device_target}" "${rocm_version}" <<'PY' +import importlib.util +import sys + +spec = importlib.util.spec_from_file_location("setup_env", sys.argv[1]) +setup_env = importlib.util.module_from_spec(spec) +spec.loader.exec_module(setup_env) +device_target, rocm_version = sys.argv[2:] +if rocm_version: + build = setup_env.describe_rocm_version(rocm_version, "", "linux", device_target) +else: + build = setup_env.select_quartz_nightly("linux", device_target) +print(build.rocm_version, build.index_url) +PY +)" +read -r rocm_version rocm_index_url <<<"${resolved}" +echo "ROCm ${rocm_version} from ${rocm_index_url}" + DOCKER_BUILDKIT="${DOCKER_BUILDKIT:-1}" "${container_command}" build \ -f "${script_dir}/Dockerfile.dnn-benchmark-performance-linux" \ --build-arg "DEVICE_TARGET=${device_target}" \ --build-arg "ROCM_LIBRARIES_REF=${rocm_libraries_ref}" \ + --build-arg "ROCM_VERSION=${rocm_version}" \ + --build-arg "ROCM_TORCH_INDEX_URL=${rocm_index_url}" \ -t "${tag}" \ "${build_args[@]}" \ "${repo_root}" diff --git a/docs/results-schema.md b/docs/results-schema.md index db7a8c11..22d733d7 100644 --- a/docs/results-schema.md +++ b/docs/results-schema.md @@ -104,6 +104,10 @@ The CLI collects these values one time, at suite start. | `cuda_version` | string | The `cuda` value of `torch/version.py` for a CUDA PyTorch. `null` for a ROCm PyTorch. | | `cudnn_version` | string | cuDNN version. Set only for a CUDA PyTorch that the process has already imported. | | `hipdnn_version` | string | `hipdnn_frontend.__version__`. | +| `rocm_build_version` | string | The ROCm wheel version that `setup_env.py` installed in `--torch-mode rocm`, for example `10.3.0a20261117`. The tool reads it from `dnn-bench-rocm-build.json` in the venv of the running Python (`sys.prefix`). `null` when the venv has no such record: ROCm came from somewhere else, or setup did not install ROCm PyTorch. Files written before this key was added do not have it; `schema_version` stays 2. See [setup.md](setup.md#rocm-nightly-selection). | +| `rocm_build_date` | string | `YYYYMMDD` build date of that ROCm build, from its Quartz `status.json`. `null` without a record, or when Quartz has no `status.json` for the version. Files written before this key was added do not have it. | +| `therock_commit` | string | The full TheRock commit of that ROCm build, from its Quartz `status.json`. `null` in the same cases as `rocm_build_date`. Files written before this key was added do not have it. | +| `rocm_build_untested` | array of strings | The Quartz test suites (`rocm`, `pytorch`) that report no result for the GPU architecture of that ROCm build. Setup accepts such a build but records that the suite did not test the architecture. `[]` when both suites tested it. `null` in the same cases as `rocm_build_date`. Files written before this key was added do not have it. See [setup.md](setup.md#rocm-nightly-selection). | | `python_version` | string | Python version. | | `torch_version` | string | `__version__` of `torch/version.py`. | | `amdsmi_available` | bool | `true` when amdsmi loads. Without amdsmi, `gpu_hbm_gb`, `gpu_pcie_link`, `amdgpu_driver_version`, `gpu_power_cap_w`, `gpu_max_sclk_mhz`, `gpu_compute_partition` and all clock values are `null`. | diff --git a/docs/setup.md b/docs/setup.md index 0396a93e..4b2ef60f 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -20,8 +20,9 @@ stages are: 1. `Virtual environment`: create `/.venv`, or reuse it. See [Reusing a venv](#reusing-a-venv). -2. `PyTorch (--torch-mode rocm)`: detect the GPU architecture and install the - matching ROCm PyTorch nightly (`torch[device-]`). Its ROCm SDK +2. `PyTorch (--torch-mode rocm)`: detect the GPU architecture, select the + ROCm nightly (see [ROCm nightly selection](#rocm-nightly-selection)) and + install its ROCm PyTorch (`torch[device-]`). Its ROCm SDK libraries and toolchain are used for the build. 3. `dnn-benchmarking package`: install dnn-benchmarking (editable unless `--no-editable`). @@ -67,7 +68,8 @@ The setup prints the prefix as `Using hipDNN/ROCm prefix: ...`. | `--torch-mode {rocm,cuda,cpu,existing,none}` | How to provide PyTorch. Default `rocm`. See [Torch modes](#torch-modes). | | `--workspace WORKSPACE` | Root for the venv, the Python bytecode cache and the runtime caches. See [Workspace](#workspace). | | `--no-editable` | Install dnn-benchmarking and the rocKE packages into the venv. The default links to the source tree. | -| `--torch-index-url URL` | pip index URL for PyTorch. | +| `--torch-index-url URL` | pip index URL for PyTorch. In `rocm` mode without `--rocm-version`, setup does not read Quartz and installs the newest build on this index. | +| `--rocm-version VERSION` | ROCm wheel version for `--torch-mode rocm`, for example `10.3.0a20261117`. Default: the newest nightly that Quartz reports as built, with no failed tests for the GPU architecture. See [ROCm nightly selection](#rocm-nightly-selection). | | `--gpu-arch GPU_ARCH` | GPU architecture for the ROCm PyTorch nightly and the build. See [GPU architecture](#gpu-architecture). | | `--rocm-prefix ROCM_PREFIX` | ROCm and hipDNN prefix for the binding and provider builds. This prefix has priority over the venv ROCm SDK. | | `--reuse-artifacts` | Reuse an installed hipDNN prefix and `hipdnn_frontend` package without building them. `rocm`, `cpu` and `none` need a pre-existing venv with matching PyTorch (`none`: no torch) and reject `--clean` before workspace changes. `existing` keeps the installed torch. CUDA-only setup needs no hipDNN bindings. | @@ -112,7 +114,7 @@ dnn-benchmarking finds the engine plugins in | Mode | PyTorch | hipDNN and providers | Use | |---|---|---|---| -| `rocm` (default) | ROCm nightly for the detected architecture | Built against the ROCm SDK from the PyTorch wheels | Benchmarks on AMD GPUs. | +| `rocm` (default) | ROCm nightly for the detected architecture, selected with Quartz | Built against the ROCm SDK from the PyTorch wheels | Benchmarks on AMD GPUs. | | `cuda` | CUDA PyTorch from PyPI, or `--torch-index-url` | Not built. No bindings, no amdsmi, no `ROCM_PATH` | `--runtime pytorch` on NVIDIA GPUs. | | `cpu` | CPU-only PyTorch | Built from source, or reused from the installed prefix with a prepared CPU venv and `--reuse-artifacts`. | CI and `--validate pytorch` with a system ROCm. | | `existing` | Keep the PyTorch in the venv | ROCm PyTorch: its SDK libraries. CUDA PyTorch: the `cuda` path. CPU PyTorch: the installed ROCm. | Reuse a venv. | @@ -145,7 +147,8 @@ PyTorch and the bindings, but reinstalls the dnn-benchmarking package. It rejects a fresh hipDNN reuse venv, `--clean` or a different torch mode before changing the workspace. In `cpu` and `rocm` modes, setup checks a recorded torch source. It rejects mismatched explicit -`--torch-index-url` and ROCm `--gpu-arch` flags before modifying the venv. +`--torch-index-url`, and ROCm `--gpu-arch` and `--rocm-version` flags, before +modifying the venv. For example, after preparing `.workspace/.venv` with CPU PyTorch and the bindings: @@ -209,6 +212,81 @@ architecture, give `--gpu-arch`: On Windows the default is `gfx1151`. +## ROCm nightly selection + +[Quartz](https://github.com/ROCm/Quartz) publishes a `status.json` for each +TheRock nightly. In `--torch-mode rocm`, setup reads these files to select +the ROCm nightly that it installs: + +1. Setup reads `nightly/latest.json` from + `https://raw.githubusercontent.com/ROCm/quartz/main/`. This gives the build + date of the newest nightly. +2. Setup reads `nightly//status.json` for that day and for each + earlier day, 14 days in total. It takes the first nightly that has all of + these, for the platform of the host (`linux` or `windows`) and the GPU + architecture: + - `summary..rocm.build.status` is `success`. + - `summary..pytorch.build.status` is `success`. + - `summary..architectures` has a TheRock target for the GPU + architecture. A target that ends in `X` is a family: `gfx94X-dcgpu` + covers `gfx942`, `gfx110X-all` covers `gfx1100` to `gfx1103`. + - `summary..urls.wheels` is set. + - `pipelines.rocm.test...status` is `success`, when + this entry exists. + - `pipelines.pytorch.test...status` is `success`, when + this entry exists. Quartz rolls the results of the PyTorch variants up + into this status: `failure` when a variant failed, else `in_progress` + while a variant runs. +3. Setup installs `rocm[libraries,devel,device-]==` and + `torch[device-]` from that wheels URL. The torch wheel requires the + `rocm` version that it was built with, so pip installs the torch of the + same nightly. +4. When no nightly in the 14 days qualifies, setup stops with an error that + lists each nightly and each reason it was rejected, for example + `linux rocm tests of gfx94X-dcgpu are failure`. Setup does not install an + unchecked build instead. + +A test entry that is `failure`, `in_progress`, `cancelled` or any value +other than `success` rejects the nightly. A missing test entry does not: +Quartz does not run every suite on every architecture. For example, the +nightlies 20261113 to 20261119 have no ROCm test entry for `gfx950-dcgpu`. +Setup then accepts the nightly, prints the suites without a result, and +records them as untested. + +Setup does not read the test counters, `pipelines.pytorch.test_full` or +`summary.overall_status`. These include all architectures and test suites +that often fail, so almost no nightly has an overall `success`. Setup also +stops when a `status.json` has a schema major other than 2. + +To install a known build, for example to repeat an older run, give its +version: + +```bash +python3 setup_env.py --rocm-version 10.3.0a20261114 +``` + +Setup installs that version even when Quartz reports it as failed, and shows +a warning that names each failed build or test of the GPU architecture. +`--torch-index-url` gives another index. `--torch-index-url` without +`--rocm-version` installs the newest build on that index and does not read +Quartz. + +After the install, setup writes `/.venv/dnn-bench-rocm-build.json`: +the ROCm wheel version, the TheRock build date and commit from Quartz, the +untested suites (`untested`, for example `["rocm"]`), the `status.json` URL, +the index URL, and what selected the build (`quartz`, `--rocm-version` or +`--torch-index-url`). The build date, commit and untested suites are `null` +when Quartz has no `status.json` for the version. Result files copy them to +`environment.rocm_build_version`, `environment.rocm_build_date`, +`environment.therock_commit` and `environment.rocm_build_untested` (see +[results-schema.md](results-schema.md#environment)). + +CI (`setup.yml` gpu-test and `check-deserialize.yml`) uses the selected +nightly. `check-deserialize.yml` builds for `gfx942`, because Quartz reports +failed `gfx90a` ROCm tests on most nightlies. To use a known build instead, +set the `ROCM_VERSION` repository variable. Each job prints the ROCm build +and its untested suites in its log and in the job summary. + ## rocm-libraries source `rocm-libraries/` is a git submodule. It holds the hipDNN and provider @@ -335,18 +413,20 @@ python3 setup_env.py --clean -y ### Reusing a venv Without `--clean`, setup keeps the venv and its PyTorch and builds -incrementally. When setup installs PyTorch it records the index URL and GPU -architecture in `/.venv/dnn-bench-torch.json`. On a later run, an -explicit `--gpu-arch` or `--torch-index-url` that differs from the record +incrementally. It does not read Quartz again. When setup installs PyTorch it +records the index URL and GPU architecture in +`/.venv/dnn-bench-torch.json`, and the ROCm build in +`dnn-bench-rocm-build.json`. On a later run, an explicit `--gpu-arch`, +`--torch-index-url` or `--rocm-version` that differs from the record stops setup with an error that asks for `--clean`. Without them, a `--torch-mode rocm` run builds for the recorded GPU architecture and installs -a missing rocm-sdk-devel from the recorded index. If no detected GPU has the -recorded architecture, setup stops with an error that names the detected and -the recorded architectures. Then pass `--clean` to set up the venv again (add -`--gpu-arch` on a host with several architectures), or -`--gpu-arch ` to keep the recorded build. When one of the -detected GPUs has the recorded architecture, or setup detects no GPU, setup -uses the recorded architecture. A venv without the record +a missing rocm-sdk-devel of the recorded ROCm version from the recorded index. +If no detected GPU has the recorded architecture, setup stops with an error +that names the detected and the recorded architectures. Then pass `--clean` +to set up the venv again (add `--gpu-arch` on a host with several +architectures), or `--gpu-arch ` to keep the recorded build. +When one of the detected GPUs has the recorded architecture, or setup detects +no GPU, setup uses the recorded architecture. A venv without the record (PyTorch installed another way) cannot be checked; setup shows a warning instead. A different `--torch-mode` than the one in the venv also asks for `--clean`, including `--torch-mode none` on a venv that has PyTorch. @@ -389,12 +469,30 @@ from the local checkout: | `--container-command CMD` | `docker` | Container command. | | `--device-target TARGET` | `gfx942` | ROCm PyTorch architecture: `gfx90a`, `gfx942`, `gfx950`, `gfx1151` or `gfx1152`. | | `--tag TAG` | `dnn-benchmark-performance:` | Image tag. | +| `--rocm-version VERSION` | newest usable Quartz nightly | ROCm wheel version to install. | | `-- ARGS...` | none | More arguments for the container build command. | The script passes the pinned `rocm-libraries` commit to the build, because -the build context has no `.git`. The image runs `setup_env.py --torch-mode -rocm --no-editable -y` with the venv in `/opt/dnn-benchmark/.venv`. The -entry point is `dnn-benchmark`, so arguments go straight to the tool: +the build context has no `.git`. The script also selects the ROCm nightly for +`--device-target` on the host, as in +[ROCm nightly selection](#rocm-nightly-selection), unless `--rocm-version` +names one. The host thus needs `python3`. When no nightly qualifies for the +device target, for example while Quartz reports failed `gfx90a` tests, the +script stops; then pass `--rocm-version`. The script passes the version as +the `ROCM_VERSION` build argument and the wheels URL as +`ROCM_TORCH_INDEX_URL`. A new nightly thus rebuilds the setup layer. The +image carries the ROCm version in the label +`com.amd.dnn-benchmark.rocm-version`: + +```bash +docker inspect --format \ + '{{ index .Config.Labels "com.amd.dnn-benchmark.rocm-version" }}' \ + dnn-benchmark-performance:gfx942 +``` + +The image runs `setup_env.py --torch-mode rocm --rocm-version +--no-editable -y` with the venv in `/opt/dnn-benchmark/.venv`. The entry +point is `dnn-benchmark`, so arguments go straight to the tool: ```bash docker run --rm --device=/dev/kfd --device=/dev/dri --group-add video \ diff --git a/setup_env.py b/setup_env.py index a1d08e42..d56e36c6 100755 --- a/setup_env.py +++ b/setup_env.py @@ -22,6 +22,8 @@ import argparse import contextlib +import dataclasses +import datetime import functools import json import os @@ -33,8 +35,10 @@ import subprocess import sys import time +import urllib.error +import urllib.request from pathlib import Path -from typing import NoReturn +from typing import Dict, NoReturn, Optional, Tuple IS_WINDOWS = platform.system() == "Windows" @@ -91,6 +95,24 @@ def aiter_build_requires(aiter_dir: Path) -> list[str]: # and Windows always resolve the exact same torch/rocm-sdk-* build. ROCM_TORCH_INDEX_URL = f"{ROCM_NIGHTLY_BASE}/whl-next/" +# Quartz (https://github.com/ROCm/Quartz) publishes one status.json for each +# TheRock nightly. Setup reads it to pick the ROCm PyTorch nightly. The +# consumer guide is docs/status-json in that repository. +QUARTZ_NIGHTLY_URL = "https://raw.githubusercontent.com/ROCm/quartz/main/nightly/" +# The status.json schema major that setup reads. A newer minor only adds +# optional fields; another major can move the fields that setup reads. +QUARTZ_SCHEMA_MAJOR = "2" +# Setup searches the newest nightly and the nightlies of this many days in +# total, then stops with an error. +QUARTZ_LOOKBACK_DAYS = 14 +QUARTZ_TIMEOUT_S = 30 +# The Quartz test suites (pipelines..test) whose result for the GPU +# architecture setup checks. +QUARTZ_TEST_SUITES = ("rocm", "pytorch") +# The ROCm wheel version of a nightly, for example 10.3.0a20261117. The group +# is the build date. +_NIGHTLY_VERSION = re.compile(r"\d+\.\d+\.\d+a(\d{8})") + # Windows has no rocm_agent_enumerator/rocminfo to detect the local arch with, # so fall back to a default target known to have published wheels. WINDOWS_DEFAULT_GPU_ARCH = "gfx1151" @@ -115,6 +137,13 @@ def aiter_build_requires(aiter_dir: Path) -> list[str]: # differently is wiped. BUILD_RECORD = "dnn-bench-prefixes.json" +# Written into the venv after setup installs ROCm PyTorch: the ROCm wheel +# version, the TheRock build date and commit from Quartz, the Quartz test +# suites with no result for the GPU architecture, and what selected +# the build. dnn_benchmarking.metrics.machine_info reads it into the result +# environment, and a reused venv checks --rocm-version against it. +ROCM_BUILD_RECORD = "dnn-bench-rocm-build.json" + # --- Small process helpers ------------------------------------------------- @@ -200,6 +229,268 @@ def git_output(args) -> str: return result.stdout.strip() +# --- ROCm nightly selection (Quartz) ---------------------------------------- + + +@dataclasses.dataclass(frozen=True) +class RocmBuild: + """The TheRock build that setup installs ROCm PyTorch from. + + ``rocm_version`` is the ROCm wheel version that pip pins; "" installs the + newest build on ``index_url``. ``build_date``, ``therock_commit``, + ``status_url`` and ``untested`` come from the Quartz status.json, or are + None when setup did not read one. ``untested`` names the Quartz test + suites with no result for the GPU architecture. ``source`` names what + selected the build. + """ + + rocm_version: str + index_url: str + source: str + build_date: Optional[str] = None + therock_commit: Optional[str] = None + status_url: Optional[str] = None + untested: Optional[Tuple[str, ...]] = None + + +def quartz_platform() -> str: + """The ``summary`` key of this host's platform in a Quartz status.json.""" + return "windows" if IS_WINDOWS else "linux" + + +def fetch_quartz_text(url: str) -> Optional[str]: + """The body of ``url``, or None when the server answers 404 Not Found. + + A nightly that did not run has no status.json, so 404 is an expected + answer. Every other failure stops setup with the URL. + """ + try: + with urllib.request.urlopen(url, timeout=QUARTZ_TIMEOUT_S) as response: + return response.read().decode("utf-8") + except urllib.error.HTTPError as exc: + if exc.code == 404: + return None + fail(f"cannot read {url}: {exc}") + except (urllib.error.URLError, TimeoutError) as exc: + fail(f"cannot read {url}: {exc}") + + +def _parse_quartz_status(url: str, body: str) -> dict: + """The status.json document in ``body``; exit when setup cannot read it.""" + try: + document = json.loads(body) + except ValueError as exc: + fail(f"{url} is not valid JSON: {exc}") + major = str(document.get("schema_version", "")).split(".")[0] + if major != QUARTZ_SCHEMA_MAJOR: + fail( + f"{url} has status.json schema {document.get('schema_version')!r}; " + f"setup reads schema {QUARTZ_SCHEMA_MAJOR}.x only.", + "Update the Quartz reader in setup_env.py, or pass --rocm-version.", + ) + return document + + +def _quartz_status_url(build_date: str) -> str: + return f"{QUARTZ_NIGHTLY_URL}{build_date}/status.json" + + +def quartz_arch_matches(gpu_arch: str, target: str) -> bool: + """True when the TheRock build target ``target`` covers ``gpu_arch``. + + Quartz lists the targets that TheRock built: one GPU (``gfx90a``, + ``gfx950-dcgpu``) or a family whose last character is ``X`` + (``gfx94X-dcgpu`` covers gfx942, ``gfx110X-all`` covers gfx1100 to + gfx1103). The part after ``-`` names a product line, not a GPU. + """ + family = target.split("-", 1)[0].lower() + arch = gpu_arch.lower() + if family.endswith("x"): + return len(arch) == len(family) and arch.startswith(family[:-1]) + return arch == family + + +def quartz_target(targets, gpu_arch: str) -> Optional[str]: + """The TheRock build target among ``targets`` that covers ``gpu_arch``. + + A target for the one GPU wins over a family target. None when no + target covers ``gpu_arch``. + """ + matches = [target for target in targets if quartz_arch_matches(gpu_arch, target)] + exact = [t for t in matches if not t.split("-", 1)[0].lower().endswith("x")] + return (exact or matches or [None])[0] + + +def quartz_arch_tests( + document: dict, platform_name: str, gpu_arch: str +) -> Tuple[Dict[str, Tuple[str, str]], Tuple[str, ...]]: + """The Quartz test results of ``gpu_arch`` on ``platform_name``. + + Returns ``{suite: (target, status)}`` for each suite in QUARTZ_TEST_SUITES + that has a test entry for a target that covers ``gpu_arch``, and the + suites without one. Setup reads the status of the target only. Quartz + rolls the PyTorch variants up into it: ``failure`` when a variant failed, + else ``in_progress`` while a variant runs. + """ + pipelines = document.get("pipelines", {}) + results = {} + untested = [] + for suite in QUARTZ_TEST_SUITES: + entries = pipelines.get(suite, {}).get("test", {}).get(platform_name, {}) + target = quartz_target(entries, gpu_arch) + if target is None: + untested.append(suite) + else: + results[suite] = (target, str(entries[target].get("status") or "absent")) + return results, tuple(untested) + + +def quartz_rejection(document: dict, platform_name: str, gpu_arch: str) -> str: + """Why the build cannot supply ROCm PyTorch for ``gpu_arch``; "" if it can. + + Setup needs the ROCm and the PyTorch build of ``platform_name`` to be + ``success``, and ``gpu_arch`` among the built architectures. The ROCm and + PyTorch tests of ``gpu_arch`` must be ``success`` when Quartz has them; a + suite with no entry for ``gpu_arch`` does not reject the build. Setup does + not read the test counters or ``overall_status``: they fold in every + architecture, and some are routinely red. The result names every check + that fails, separated by "; ". + """ + if document.get("release_type") != "nightly": + return f"release_type is {document.get('release_type')!r}, not 'nightly'" + if document.get("build_variant", "release") != "release": + return f"build_variant is {document.get('build_variant')!r}" + if not _NIGHTLY_VERSION.fullmatch(str(document.get("rocm_version", ""))): + return f"rocm_version {document.get('rocm_version')!r} is not a nightly" + summary = document.get("summary", {}).get(platform_name) + if not summary: + return f"no {platform_name} build" + reasons = [] + if quartz_target(summary.get("architectures", []), gpu_arch) is None: + reasons.append(f"{gpu_arch} is not among its {platform_name} architectures") + for pipeline in ("rocm", "pytorch"): + status = summary.get(pipeline, {}).get("build", {}).get("status") + if status != "success": + reasons.append(f"{platform_name} {pipeline} build is {status or 'absent'}") + if not summary.get("urls", {}).get("wheels"): + reasons.append(f"no {platform_name} wheels URL") + results, _ = quartz_arch_tests(document, platform_name, gpu_arch) + for suite, (target, status) in results.items(): + if status != "success": + reasons.append(f"{platform_name} {suite} tests of {target} are {status}") + return "; ".join(reasons) + + +def _rocm_build_from_quartz( + document: dict, + url: str, + platform_name: str, + gpu_arch: str, + source: str, + index_url: str = "", +) -> RocmBuild: + """The build that ``document`` describes. An explicit ``index_url`` wins + over the wheels URL of the document.""" + urls = document.get("summary", {}).get(platform_name, {}).get("urls", {}) + _, untested = quartz_arch_tests(document, platform_name, gpu_arch) + return RocmBuild( + rocm_version=document["rocm_version"], + index_url=index_url or urls.get("wheels") or ROCM_TORCH_INDEX_URL, + source=source, + build_date=document.get("build_date") or None, + therock_commit=document.get("therock_commit") or None, + status_url=url, + untested=untested, + ) + + +def _newest_quartz_nightly() -> datetime.date: + """The build date of the nightly that ``nightly/latest.json`` names. + + The pointer is a git symlink, so raw GitHub serves its target path (for + example ``20261118/status.json``) instead of the document. + """ + url = f"{QUARTZ_NIGHTLY_URL}latest.json" + body = fetch_quartz_text(url) + if body is None: + fail(f"Quartz publishes no {url}.", "Pass --rocm-version to install a build.") + if body.lstrip().startswith("{"): + build_date = str(_parse_quartz_status(url, body).get("build_date", "")) + else: + build_date = body.strip().split("/", 1)[0] + try: + return datetime.datetime.strptime(build_date, "%Y%m%d").date() + except ValueError: + fail(f"{url} names no nightly build date: {body.strip()[:80]!r}") + + +def select_quartz_nightly(platform_name: str, gpu_arch: str) -> RocmBuild: + """The newest nightly that Quartz reports usable for ``gpu_arch``. + + Setup starts at ``nightly/latest.json`` and goes back one day at a time, + QUARTZ_LOOKBACK_DAYS days in total, because the newest nightly can be + failed or still running. It exits with every rejected build and its + reason when no build qualifies. + """ + newest = _newest_quartz_nightly() + rejected = [] + for days_back in range(QUARTZ_LOOKBACK_DAYS): + build_date = (newest - datetime.timedelta(days=days_back)).strftime("%Y%m%d") + url = _quartz_status_url(build_date) + body = fetch_quartz_text(url) + if body is None: + rejected.append(f" {build_date}: no status.json") + continue + document = _parse_quartz_status(url, body) + reason = quartz_rejection(document, platform_name, gpu_arch) + if reason: + rejected.append( + f" {build_date} ({document.get('rocm_version')}): {reason}" + ) + continue + return _rocm_build_from_quartz(document, url, platform_name, gpu_arch, "quartz") + fail( + f"Quartz reports no usable ROCm nightly for {platform_name} {gpu_arch} in " + f"the {QUARTZ_LOOKBACK_DAYS} days up to {newest:%Y%m%d}:", + *rejected, + "Pass --rocm-version VERSION to install a specific build.", + ) + + +def describe_rocm_version( + rocm_version: str, index_url: str, platform_name: str, gpu_arch: str +) -> RocmBuild: + """The --rocm-version build, with its Quartz metadata when Quartz has it. + + An explicit version is installed even when Quartz reports it unusable, + so an older run can be reproduced; setup only warns. A version that is + not a nightly, or a nightly from before Quartz, has no build date or + TheRock commit. ``index_url`` is --torch-index-url, "" when not given. + """ + match = _NIGHTLY_VERSION.fullmatch(rocm_version) + url = _quartz_status_url(match[1]) if match else "" + body = fetch_quartz_text(url) if url else None + document = _parse_quartz_status(url, body) if body is not None else {} + if document.get("rocm_version") != rocm_version: + warn( + f"Quartz has no nightly status.json for ROCm {rocm_version}.", + "The results record no TheRock build date, commit or test coverage " + "for it.", + ) + return RocmBuild( + rocm_version, index_url or ROCM_TORCH_INDEX_URL, "--rocm-version" + ) + reason = quartz_rejection(document, platform_name, gpu_arch) + if reason: + warn( + f"Quartz reports that ROCm {rocm_version} is not usable: {reason}.", + "Installing it because --rocm-version names it.", + ) + return _rocm_build_from_quartz( + document, url, platform_name, gpu_arch, "--rocm-version", index_url + ) + + def default_workspace() -> Path: """Env override, else /workspace when present and writable (Linux only), else /.workspace.""" @@ -454,6 +745,16 @@ def _commit_sha(value: str) -> str: return sha +def _rocm_version(value: str) -> str: + """--rocm-version: a ROCm wheel version such as 10.3.0a20261117.""" + version = value.strip() + if not re.fullmatch(r"[0-9][0-9A-Za-z.+!-]*", version): + raise argparse.ArgumentTypeError( + f"expected a ROCm wheel version such as 10.3.0a20261117, got {value!r}" + ) + return version + + def _cmake_define(value: str) -> str: """Normalise a --cmake-arg value to a `-DNAME=VALUE` CMake define. @@ -492,7 +793,9 @@ def build_parser() -> argparse.ArgumentParser: default="rocm", help=( "Select how torch is provided. Default: rocm\n" - " rocm: install ROCm torch nightly, use ROCm libraries/toolchain " + " rocm: install the ROCm torch nightly that Quartz reports as " + "built, with no failed tests for the GPU arch (see --rocm-version), " + "use ROCm libraries/toolchain " "from the torch wheel's bundled ROCm SDK packages, and build local " "hipDNN/provider artifacts when absent.\n" " cuda: install CUDA torch from PyPI (or --torch-index-url) for the " @@ -529,7 +832,26 @@ def build_parser() -> argparse.ArgumentParser: parser.add_argument( "--torch-index-url", default="", - help="Override the pip index URL used for torch.", + help=( + "Override the pip index URL used for torch. In rocm mode without " + "--rocm-version, setup does not read Quartz and installs the " + "newest ROCm torch on this index." + ), + ) + parser.add_argument( + "--rocm-version", + type=_rocm_version, + default=None, + metavar="VERSION", + help=( + "ROCm wheel version for --torch-mode rocm, for example " + "10.3.0a20261117. Setup installs it even when Quartz reports it " + "failed, to reproduce an older run. Default: the newest nightly " + f"of the last {QUARTZ_LOOKBACK_DAYS} days whose ROCm and PyTorch " + "builds Quartz reports as success for the GPU architecture, with " + "no failed or unfinished ROCm or PyTorch tests of that " + "architecture." + ), ) parser.add_argument( "--gpu-arch", @@ -576,7 +898,8 @@ def build_parser() -> argparse.ArgumentParser: "Delete and recreate the virtual environment and wipe the hipDNN/" "provider and binding CMake build directories. By default setup " "reuses the existing venv (and its torch) and rebuilds incrementally; " - "changing its --torch-mode, --gpu-arch or --torch-index-url then " + "changing its --torch-mode, --gpu-arch, --torch-index-url or " + "--rocm-version then " "requires --clean. A build directory configured with other CMake " "arguments (another --workspace, --rocm-prefix, GPU arch or " "--cmake-arg) is wiped without --clean." @@ -642,6 +965,7 @@ def __init__(self, args: argparse.Namespace) -> None: self.rocm_libraries_ref = args.rocm_libraries_ref self.gpu_arch_override = args.gpu_arch self.torch_index_url = args.torch_index_url + self.rocm_version = args.rocm_version self.editable_install = args.editable_install self.extra_cmake_args = list(args.cmake_args) self.resolved_torch_index_url = "" @@ -1150,12 +1474,15 @@ def ensure_rocm_wheel_devel_prefix(self, index_url: str) -> str: "--rocm-prefix.", ) + # The devel package must match the ROCm wheels already in the venv. + version = (self._read_venv_record(ROCM_BUILD_RECORD) or {}).get("rocm_version") + package = f"rocm-sdk-devel=={version}" if version else "rocm-sdk-devel" print( "ROCm SDK compiler/toolchain prefix not found; installing " - f"rocm-sdk-devel from {index_url}...", + f"{package} from {index_url}...", file=sys.stderr, ) - self.pip("install", "--pre", "rocm-sdk-devel", "--index-url", index_url) + self.pip("install", "--pre", package, "--index-url", index_url) root = self._rocm_sdk_devel_root(report_errors=True) if root: @@ -1359,41 +1686,107 @@ def install_torch(self) -> None: return arch = self._require_gpu_arch() print(f"GPU arch: {arch}") - print(f"Installing ROCm PyTorch from {index_url}") - # ROCm nightlies are pre-release, so --pre lets pip select them. - # device- is the pip extra that pulls the matching - # rocm-sdk-device- package; the base rocm-sdk-core/-libraries - # packages are OS/arch-agnostic on this index, so Linux and - # Windows always resolve the exact same nightly. - self.pip( - "install", - "--pre", - f"torch[device-{arch}]", - f"rocm[libraries,devel,device-{arch}]", - "--index-url", - index_url, - ) + build = self.select_rocm_build(arch) + index_url = self.resolved_torch_index_url = build.index_url + self.install_rocm_torch(build, arch) self.installed_torch_mode = self.get_torch_mode() self.require_torch_mode(mode) (self.venv_dir / TORCH_RECORD).write_text( json.dumps({"torch_index_url": index_url, "gpu_arch": arch}) + "\n" ) + if mode == "rocm": + self.write_rocm_build_record(build) + + def select_rocm_build(self, arch: str) -> RocmBuild: + """The ROCm build to install: --rocm-version, else the newest build on + --torch-index-url, else the newest nightly that Quartz reports usable.""" + platform_name = quartz_platform() + if self.rocm_version: + return describe_rocm_version( + self.rocm_version, self.torch_index_url, platform_name, arch + ) + if self.torch_index_url: + return RocmBuild("", self.torch_index_url, "--torch-index-url") + print(f"Selecting the ROCm nightly from Quartz ({QUARTZ_NIGHTLY_URL})") + return select_quartz_nightly(platform_name, arch) + + def install_rocm_torch(self, build: RocmBuild, arch: str) -> None: + """Install ROCm PyTorch and the ROCm SDK wheels of ``build``.""" + if build.rocm_version: + print( + f"Installing ROCm PyTorch for ROCm {build.rocm_version} " + f"(TheRock {build.therock_commit or 'commit unknown'}, " + f"built {build.build_date or 'on an unknown date'}) " + f"from {build.index_url}" + ) + else: + print(f"Installing the newest ROCm PyTorch from {build.index_url}") + if build.untested: + print( + f"Quartz has no {' or '.join(build.untested)} test result for " + f"{arch} in this nightly; setup records it as untested." + ) + # The torch wheel requires rocm[libraries]==, so the + # pin on rocm also selects a torch of that build. + pin = f"=={build.rocm_version}" if build.rocm_version else "" + # ROCm nightlies are pre-release, so --pre lets pip select them. + # device- is the pip extra that pulls the matching + # rocm-sdk-device- package; the base rocm-sdk-core/-libraries + # packages are OS/arch-agnostic on this index, so Linux and + # Windows always resolve the exact same nightly. + self.pip( + "install", + "--pre", + f"torch[device-{arch}]", + f"rocm[libraries,devel,device-{arch}]{pin}", + "--index-url", + build.index_url, + ) + + def installed_rocm_version(self) -> str: + """The version of the ``rocm`` package in the venv.""" + result = self.probe("import importlib.metadata as m; print(m.version('rocm'))") + if result.returncode != 0: + fail( + "cannot read the version of the installed rocm package.", + result.stderr.strip(), + ) + return result.stdout.strip() + + def write_rocm_build_record(self, build: RocmBuild) -> None: + """Record the installed ROCm build for the result environment.""" + record = { + "rocm_version": build.rocm_version or self.installed_rocm_version(), + "build_date": build.build_date, + "therock_commit": build.therock_commit, + "source": build.source, + "status_url": build.status_url, + "index_url": build.index_url, + "untested": None if build.untested is None else list(build.untested), + } + (self.venv_dir / ROCM_BUILD_RECORD).write_text(json.dumps(record) + "\n") + + def _read_venv_record(self, name: str) -> Optional[dict]: + """A JSON record that setup wrote into the venv, or None when absent + or unreadable.""" + try: + return json.loads((self.venv_dir / name).read_text()) + except (OSError, ValueError): + return None def require_same_torch_source(self, check_arch: bool = False) -> None: """Fail when an explicit flag differs from what the reused venv holds. - Compares --torch-index-url (and --gpu-arch with ``check_arch``) with - the TORCH_RECORD written when setup installed torch. A venv without - the record (torch installed some other way) cannot be checked. With + Compares --torch-index-url (and, with ``check_arch``, --gpu-arch and + --rocm-version) with the TORCH_RECORD and ROCM_BUILD_RECORD written + when setup installed torch. A venv without the record (torch + installed some other way) cannot be checked. With ``check_arch`` and no --gpu-arch, the build uses the recorded arch, and fails when the detected GPU has another arch; with no --torch-index-url, the toolchain uses the recorded index. """ - try: - record = json.loads((self.venv_dir / TORCH_RECORD).read_text()) - except (OSError, ValueError): - record = None + record = self._read_venv_record(TORCH_RECORD) if ( check_arch and not self.gpu_arch_override @@ -1420,22 +1813,30 @@ def require_same_torch_source(self, check_arch: bool = False) -> None: self.resolved_torch_index_url = record.get( "torch_index_url", self.resolved_torch_index_url ) - checks = [("--torch-index-url", self.torch_index_url, "torch_index_url")] + checks = [ + ("--torch-index-url", self.torch_index_url, TORCH_RECORD, "torch_index_url") + ] if check_arch: - checks.append(("--gpu-arch", self.gpu_arch_override, "gpu_arch")) - for flag, value, key in checks: + checks.append( + ("--gpu-arch", self.gpu_arch_override, TORCH_RECORD, "gpu_arch") + ) + checks.append( + ("--rocm-version", self.rocm_version, ROCM_BUILD_RECORD, "rocm_version") + ) + for flag, value, record_name, key in checks: if not value: continue - if record is None: + recorded = self._read_venv_record(record_name) + if recorded is None: warn( - f"{self.venv_dir} has no {TORCH_RECORD}, so setup cannot check " + f"{self.venv_dir} has no {record_name}, so setup cannot check " f"that its torch matches {flag} {value}.", "Pass --clean if it does not.", ) - elif record.get(key) != value: + elif recorded.get(key) != value: fail( f"{flag} {value} differs from the " - f"'{record.get(key) or 'default'}' that {self.venv_dir} " + f"'{recorded.get(key) or 'default'}' that {self.venv_dir} " "was set up with.", "Pass --clean to recreate the virtual environment, or use " "another --workspace.", @@ -2176,6 +2577,8 @@ def main(argv=None) -> int: parser.error( "--clean deletes the virtual environment --torch-mode existing reuses" ) + if args.rocm_version and args.torch_mode != "rocm": + parser.error("--rocm-version needs --torch-mode rocm") setup = Setup(args) try: return setup.run() diff --git a/src/dnn_benchmarking/metrics/machine_info.py b/src/dnn_benchmarking/metrics/machine_info.py index 1c48edd5..6e4a7533 100644 --- a/src/dnn_benchmarking/metrics/machine_info.py +++ b/src/dnn_benchmarking/metrics/machine_info.py @@ -11,6 +11,7 @@ """ import importlib.util +import json import os import platform import re @@ -130,6 +131,47 @@ def _hipdnn_version() -> Optional[str]: return getattr(hipdnn_frontend, "__version__", None) +#: The venv record that setup_env.py writes after it installs ROCm PyTorch +#: (``ROCM_BUILD_RECORD`` there). +ROCM_BUILD_RECORD = "dnn-bench-rocm-build.json" + + +def _rocm_build() -> Dict[str, Any]: + """The ROCm build that setup_env.py installed, for the result environment. + + ``rocm_build_version`` is the ROCm wheel version. ``rocm_build_date``, + ``therock_commit`` and ``rocm_build_untested`` come from the Quartz + status.json of that build; ``rocm_build_untested`` lists the Quartz test + suites with no result for the GPU architecture. Each value is None when + the venv has no record (ROCm from somewhere else) or the record does not + know it. + """ + keys = { + "rocm_build_version": "rocm_version", + "rocm_build_date": "build_date", + "therock_commit": "therock_commit", + } + build: Dict[str, Any] = dict.fromkeys([*keys, "rocm_build_untested"]) + path = Path(sys.prefix) / ROCM_BUILD_RECORD + try: + record = json.loads(path.read_text()) + except FileNotFoundError: + return build + except (OSError, ValueError) as e: + warn_once("machine_info", f"cannot read {path}: {e!r}") + return build + if not isinstance(record, dict): + warn_once("machine_info", f"{path} is not a JSON object") + return build + for key, record_key in keys.items(): + value = record.get(record_key) + build[key] = value if isinstance(value, str) else None + untested = record.get("untested") + if isinstance(untested, list) and all(isinstance(s, str) for s in untested): + build["rocm_build_untested"] = untested + return build + + def collect_environment_info() -> Dict[str, Any]: """Host, GPU and software versions for the result ``environment`` block. @@ -154,6 +196,7 @@ def collect_environment_info() -> Dict[str, Any]: "gpu_model": gpu_model, "gpu_arch": gpu_arch, "hipdnn_version": _hipdnn_version(), + **_rocm_build(), "python_version": platform.python_version(), "amdsmi_available": amdsmi_available, } diff --git a/src/dnn_benchmarking/reporting/suite_results.py b/src/dnn_benchmarking/reporting/suite_results.py index 26dcd2ff..d0468a57 100644 --- a/src/dnn_benchmarking/reporting/suite_results.py +++ b/src/dnn_benchmarking/reporting/suite_results.py @@ -84,6 +84,10 @@ "cuda_version", "cudnn_version", "hipdnn_version", + "rocm_build_version", + "rocm_build_date", + "therock_commit", + "rocm_build_untested", "python_version", "torch_version", "amdsmi_available", diff --git a/tests/unit/data/quartz/nightly/20261113/status.json b/tests/unit/data/quartz/nightly/20261113/status.json new file mode 100644 index 00000000..2b8485a5 --- /dev/null +++ b/tests/unit/data/quartz/nightly/20261113/status.json @@ -0,0 +1,479 @@ +{ + "schema_version": "2.2", + "release_type": "nightly", + "rocm_version": "10.3.0a20261113", + "build_date": "20261113", + "build_variant": "release", + "therock_commit": "963b9f51d1949ef4f328de28327ff02b2031fa7d", + "trigger_workflow_run_id": 43333652034, + "trigger_run_attempt": 1, + "created_at": "2026-11-13T00:01:20Z", + "completed_at": "2026-11-13T06:08:45Z", + "orchestrator_conclusion": "success", + "pytorch_enabled": true, + "jax_enabled": true, + "status_json_created": "2026-11-13T00:02:09Z", + "status_json_last_updated": "2026-11-14T16:58:35Z", + "summary": { + "overall_status": "failure", + "linux": { + "status": "failure", + "architectures": [ + "gfx94X-dcgpu", + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx125X-dcgpu", + "gfx90a", + "gfx950-dcgpu", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43333652034-linux/index.html", + "rpm": "https://nightly.repo.amd.com/rocm/core/packages//20261113-43333652034/", + "deb": "https://nightly.repo.amd.com/rocm/core/packages//20261113-43333652034/" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 2, + "failure": 3, + "in_progress": 0, + "cancelled": 2, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 51, + "failure": 17, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test_full": { + "success": 0, + "failure": 3, + "in_progress": 0, + "cancelled": 1, + "skipped": 0 + } + }, + "jax": { + "build": { + "status": "failure", + "success": 19, + "failure": 3, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 16, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "native_packages": { + "rpm": { + "status": "success" + }, + "deb": { + "status": "success" + } + } + }, + "windows": { + "status": "failure", + "architectures": [ + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx90a", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43333652034-windows/index.html" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 0, + "failure": 4, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 19, + "failure": 37, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + } + } + }, + "pipelines": { + "rocm": { + "test": { + "linux": { + "gfx1151": { + "status": "cancelled", + "run_id": 43358211790, + "run_attempt": 3, + "started_at": "2026-11-13T10:49:59Z", + "completed_at": "2026-11-13T13:24:14Z" + }, + "gfx90a": { + "status": "failure", + "run_id": 43358227834, + "run_attempt": 2, + "started_at": "2026-11-13T05:06:07Z", + "completed_at": "2026-11-13T06:00:02Z" + }, + "gfx94X-dcgpu": { + "status": "success", + "run_id": 43358227594, + "run_attempt": 3, + "started_at": "2026-11-13T06:29:00Z", + "completed_at": "2026-11-13T07:50:24Z" + } + }, + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 43373358131, + "run_attempt": 3, + "started_at": "2026-11-13T10:49:43Z", + "completed_at": "2026-11-13T13:02:28Z" + } + } + } + }, + "pytorch": { + "test": { + "linux": { + "gfx94X-dcgpu": { + "status": "failure", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:41:22Z", + "completed_at": "2026-11-13T12:52:42Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:41:22Z", + "completed_at": "2026-11-13T09:20:38Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:43:51Z", + "completed_at": "2026-11-13T09:20:27Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:44:05Z", + "completed_at": "2026-11-13T09:27:24Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T11:00:47Z", + "completed_at": "2026-11-13T11:08:19Z" + } + ] + }, + "gfx1151": { + "status": "failure", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T09:15:12Z", + "completed_at": "2026-11-13T12:52:42Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T09:15:12Z", + "completed_at": "2026-11-13T09:44:30Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T09:19:57Z", + "completed_at": "2026-11-13T09:55:35Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T09:24:32Z", + "completed_at": "2026-11-13T09:53:26Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T12:44:44Z", + "completed_at": "2026-11-13T12:51:12Z" + } + ] + }, + "gfx90a": { + "status": "failure", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:40:32Z", + "completed_at": "2026-11-13T12:52:42Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:40:32Z", + "completed_at": "2026-11-13T09:42:11Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:44:00Z", + "completed_at": "2026-11-13T09:41:44Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:45:53Z", + "completed_at": "2026-11-13T09:42:50Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T11:00:35Z", + "completed_at": "2026-11-13T11:15:04Z" + } + ] + }, + "gfx950-dcgpu": { + "status": "failure", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:40:28Z", + "completed_at": "2026-11-13T12:52:42Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:40:28Z", + "completed_at": "2026-11-13T09:07:02Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:44:05Z", + "completed_at": "2026-11-13T09:06:53Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T08:44:06Z", + "completed_at": "2026-11-13T09:08:32Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43375853428, + "run_attempt": 2, + "started_at": "2026-11-13T11:00:41Z", + "completed_at": "2026-11-13T11:06:03Z" + } + ] + } + }, + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 43376551823, + "run_attempt": 2, + "started_at": "2026-11-13T09:52:02Z", + "completed_at": "2026-11-13T13:21:36Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43376551823, + "run_attempt": 2, + "started_at": "2026-11-13T09:52:02Z", + "completed_at": "2026-11-13T10:15:43Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "failure", + "run_id": 43376551823, + "run_attempt": 2, + "started_at": "2026-11-13T12:42:45Z", + "completed_at": "2026-11-13T13:16:59Z" + }, + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43376551823, + "run_attempt": 2, + "started_at": "2026-11-13T12:42:46Z", + "completed_at": "2026-11-13T13:20:18Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43376551823, + "run_attempt": 2, + "started_at": "2026-11-13T12:42:45Z", + "completed_at": "2026-11-13T12:55:37Z" + } + ] + }, + "gfx90a": { + "status": "failure", + "run_id": 43376551823, + "run_attempt": 2, + "started_at": "2026-11-13T06:07:52Z", + "completed_at": "2026-11-13T12:59:53Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43376551823, + "run_attempt": 2, + "started_at": "2026-11-13T12:42:30Z", + "completed_at": "2026-11-13T12:56:16Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "failure", + "run_id": 43376551823, + "run_attempt": 2, + "started_at": "2026-11-13T12:42:30Z", + "completed_at": "2026-11-13T12:59:53Z" + }, + { + "py": "3.11", + "torch": "release/2.15", + "status": "failure", + "run_id": 43376551823, + "run_attempt": 1, + "started_at": "2026-11-13T06:07:52Z", + "completed_at": "2026-11-13T12:20:29Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43376551823, + "run_attempt": 2, + "started_at": "2026-11-13T12:42:30Z", + "completed_at": "2026-11-13T12:45:59Z" + } + ] + } + } + } + } + } +} diff --git a/tests/unit/data/quartz/nightly/20261114/status.json b/tests/unit/data/quartz/nightly/20261114/status.json new file mode 100644 index 00000000..f51ac2da --- /dev/null +++ b/tests/unit/data/quartz/nightly/20261114/status.json @@ -0,0 +1,290 @@ +{ + "schema_version": "2.2", + "release_type": "nightly", + "rocm_version": "10.3.0a20261114", + "build_date": "20261114", + "build_variant": "release", + "therock_commit": "2c9d452433c5f8644300a22d83c0a75a486f8f19", + "trigger_workflow_run_id": 43531276507, + "trigger_run_attempt": 2, + "created_at": "2026-11-14T00:01:09Z", + "completed_at": "2026-11-14T13:54:00Z", + "orchestrator_conclusion": "success", + "pytorch_enabled": true, + "jax_enabled": true, + "status_json_created": "2026-11-14T00:02:10Z", + "status_json_last_updated": "2026-11-15T18:01:59Z", + "summary": { + "overall_status": "failure", + "linux": { + "status": "failure", + "architectures": [ + "gfx94X-dcgpu", + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx125X-dcgpu", + "gfx90a", + "gfx950-dcgpu", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43531276507-linux/index.html", + "rpm": "https://nightly.repo.amd.com/rocm/core/packages//20261114-43531276507/", + "deb": "https://nightly.repo.amd.com/rocm/core/packages//20261114-43531276507/" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 0, + "failure": 7, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "failure", + "success": 0, + "failure": 20, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 0, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "jax": { + "build": { + "status": "failure", + "success": 19, + "failure": 3, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 16, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "native_packages": { + "rpm": { + "status": "success" + }, + "deb": { + "status": "success" + } + } + }, + "windows": { + "status": "failure", + "architectures": [ + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx90a", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43531276507-windows/index.html" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 0, + "failure": 4, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 18, + "failure": 38, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + } + } + }, + "pipelines": { + "rocm": { + "test": { + "linux": { + "gfx94X-dcgpu": { + "status": "failure", + "run_id": 43551314442, + "run_attempt": 2, + "started_at": "2026-11-14T11:31:03Z", + "completed_at": "2026-11-14T13:12:09Z" + }, + "gfx90a": { + "status": "failure", + "run_id": 43551315546, + "run_attempt": 2, + "started_at": "2026-11-14T11:47:26Z", + "completed_at": "2026-11-14T12:10:21Z" + }, + "gfx1151": { + "status": "failure", + "run_id": 43551315273, + "run_attempt": 3, + "started_at": "2026-11-14T13:06:04Z", + "completed_at": "2026-11-14T13:51:45Z" + } + }, + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 43597407853, + "run_attempt": 1, + "started_at": "2026-11-14T12:58:34Z", + "completed_at": "2026-11-14T14:59:16Z" + } + } + } + }, + "pytorch": { + "test": { + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-14T17:45:08Z", + "completed_at": "2026-11-15T10:02:10Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "failure", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-15T09:23:45Z", + "completed_at": "2026-11-15T09:58:16Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-14T17:45:08Z", + "completed_at": "2026-11-14T18:14:05Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "failure", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-15T09:27:18Z", + "completed_at": "2026-11-15T10:00:56Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-15T09:22:47Z", + "completed_at": "2026-11-15T09:55:15Z" + } + ] + }, + "gfx90a": { + "status": "failure", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-15T08:46:16Z", + "completed_at": "2026-11-15T09:58:28Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "failure", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-15T08:46:16Z", + "completed_at": "2026-11-15T09:55:26Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-15T08:46:16Z", + "completed_at": "2026-11-15T08:46:20Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "failure", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-15T08:46:16Z", + "completed_at": "2026-11-15T09:58:28Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43602000802, + "run_attempt": 2, + "started_at": "2026-11-15T08:46:16Z", + "completed_at": "2026-11-15T09:27:19Z" + } + ] + } + } + } + } + } +} diff --git a/tests/unit/data/quartz/nightly/20261115/status.json b/tests/unit/data/quartz/nightly/20261115/status.json new file mode 100644 index 00000000..7ef1a323 --- /dev/null +++ b/tests/unit/data/quartz/nightly/20261115/status.json @@ -0,0 +1,479 @@ +{ + "schema_version": "2.2", + "release_type": "nightly", + "rocm_version": "10.3.0a20261115", + "build_date": "20261115", + "build_variant": "release", + "therock_commit": "62d1ac21a0eda4df3871c6c8d4570cb0ee9a4637", + "trigger_workflow_run_id": 43656079872, + "trigger_run_attempt": 1, + "created_at": "2026-11-15T00:01:11Z", + "completed_at": "2026-11-15T06:01:29Z", + "orchestrator_conclusion": "success", + "pytorch_enabled": true, + "jax_enabled": true, + "status_json_created": "2026-11-15T00:02:06Z", + "status_json_last_updated": "2026-11-17T22:03:02Z", + "summary": { + "overall_status": "failure", + "linux": { + "status": "failure", + "architectures": [ + "gfx94X-dcgpu", + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx125X-dcgpu", + "gfx90a", + "gfx950-dcgpu", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43656079872-linux/index.html", + "deb": "https://nightly.repo.amd.com/rocm/core/packages//20261115-43656079872/", + "rpm": "https://nightly.repo.amd.com/rocm/core/packages//20261115-43656079872/" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 0, + "failure": 6, + "in_progress": 0, + "cancelled": 1, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 68, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test_full": { + "success": 0, + "failure": 4, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "jax": { + "build": { + "status": "failure", + "success": 19, + "failure": 3, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 16, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "native_packages": { + "rpm": { + "status": "success" + }, + "deb": { + "status": "success" + } + } + }, + "windows": { + "status": "failure", + "architectures": [ + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx90a", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43656079872-windows/index.html" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 0, + "failure": 3, + "in_progress": 0, + "cancelled": 1, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 19, + "failure": 37, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + } + } + }, + "pipelines": { + "rocm": { + "test": { + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 43665153091, + "run_attempt": 1, + "started_at": "2026-11-15T01:53:05Z", + "completed_at": "2026-11-15T04:56:38Z" + } + }, + "linux": { + "gfx1151": { + "status": "failure", + "run_id": 43671525578, + "run_attempt": 1, + "started_at": "2026-11-15T03:15:26Z", + "completed_at": "2026-11-15T05:22:18Z" + }, + "gfx94X-dcgpu": { + "status": "failure", + "run_id": 43671525242, + "run_attempt": 1, + "started_at": "2026-11-15T03:15:26Z", + "completed_at": "2026-11-15T04:21:33Z" + }, + "gfx90a": { + "status": "failure", + "run_id": 43671525485, + "run_attempt": 1, + "started_at": "2026-11-15T03:15:26Z", + "completed_at": "2026-11-15T04:36:32Z" + } + } + } + }, + "pytorch": { + "test": { + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 43667716418, + "run_attempt": 3, + "started_at": "2026-11-15T09:12:11Z", + "completed_at": "2026-11-16T04:44:07Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43667716418, + "run_attempt": 3, + "started_at": "2026-11-15T09:19:51Z", + "completed_at": "2026-11-15T09:52:39Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43667716418, + "run_attempt": 3, + "started_at": "2026-11-15T09:12:11Z", + "completed_at": "2026-11-15T09:55:27Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "failure", + "run_id": 43667716418, + "run_attempt": 3, + "started_at": "2026-11-16T03:59:55Z", + "completed_at": "2026-11-16T04:34:51Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43667716418, + "run_attempt": 3, + "started_at": "2026-11-16T04:00:30Z", + "completed_at": "2026-11-16T04:31:53Z" + } + ] + }, + "gfx90a": { + "status": "failure", + "run_id": 43667716418, + "run_attempt": 3, + "started_at": "2026-11-15T02:25:28Z", + "completed_at": "2026-11-16T04:35:00Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "failure", + "run_id": 43667716418, + "run_attempt": 1, + "started_at": "2026-11-15T02:25:28Z", + "completed_at": "2026-11-15T06:26:59Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43667716418, + "run_attempt": 1, + "started_at": "2026-11-15T02:25:28Z", + "completed_at": "2026-11-15T06:40:41Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "failure", + "run_id": 43667716418, + "run_attempt": 3, + "started_at": "2026-11-16T03:56:56Z", + "completed_at": "2026-11-16T04:12:50Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43667716418, + "run_attempt": 3, + "started_at": "2026-11-16T03:56:56Z", + "completed_at": "2026-11-16T04:35:00Z" + } + ] + } + }, + "linux": { + "gfx94X-dcgpu": { + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:35:43Z", + "completed_at": "2026-11-16T08:03:46Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:35:43Z", + "completed_at": "2026-11-15T09:14:26Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:36:41Z", + "completed_at": "2026-11-15T09:12:02Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:37:25Z", + "completed_at": "2026-11-15T09:13:55Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:46:33Z", + "completed_at": "2026-11-15T09:24:45Z" + } + ] + }, + "gfx1151": { + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:35:43Z", + "completed_at": "2026-11-16T08:03:46Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:35:43Z", + "completed_at": "2026-11-15T08:57:41Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:36:37Z", + "completed_at": "2026-11-15T09:03:42Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:37:25Z", + "completed_at": "2026-11-15T09:04:14Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:46:33Z", + "completed_at": "2026-11-15T09:16:31Z" + } + ] + }, + "gfx90a": { + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:35:53Z", + "completed_at": "2026-11-16T08:03:46Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:35:53Z", + "completed_at": "2026-11-15T09:20:40Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:37:55Z", + "completed_at": "2026-11-15T09:19:19Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-16T03:56:20Z", + "completed_at": "2026-11-16T04:40:50Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-15T08:46:44Z", + "completed_at": "2026-11-15T09:30:23Z" + } + ] + }, + "gfx950-dcgpu": { + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-16T03:56:18Z", + "completed_at": "2026-11-16T08:03:46Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-16T03:56:22Z", + "completed_at": "2026-11-16T04:18:53Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-16T03:56:18Z", + "completed_at": "2026-11-16T04:30:39Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-16T03:56:18Z", + "completed_at": "2026-11-16T04:29:31Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 43683515736, + "run_attempt": 3, + "started_at": "2026-11-16T03:56:18Z", + "completed_at": "2026-11-16T04:29:05Z" + } + ] + } + } + } + } + } +} diff --git a/tests/unit/data/quartz/nightly/20261116/status.json b/tests/unit/data/quartz/nightly/20261116/status.json new file mode 100644 index 00000000..0e2fbfa6 --- /dev/null +++ b/tests/unit/data/quartz/nightly/20261116/status.json @@ -0,0 +1,479 @@ +{ + "schema_version": "2.2", + "release_type": "nightly", + "rocm_version": "10.3.0a20261116", + "build_date": "20261116", + "build_variant": "release", + "therock_commit": "1e21477a5ca2ac34ffcf4e80b2955e46ddaa9f09", + "trigger_workflow_run_id": 43777893761, + "trigger_run_attempt": 2, + "created_at": "2026-11-16T00:01:05Z", + "completed_at": "2026-11-16T09:51:29Z", + "orchestrator_conclusion": "success", + "pytorch_enabled": true, + "jax_enabled": true, + "status_json_created": "2026-11-16T00:01:49Z", + "status_json_last_updated": "2026-11-17T19:25:04Z", + "summary": { + "overall_status": "failure", + "linux": { + "status": "in_progress", + "architectures": [ + "gfx94X-dcgpu", + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx125X-dcgpu", + "gfx90a", + "gfx950-dcgpu", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://therock-nightly-artifacts.s3.amazonaws.com/43777893761-linux/tarballs/", + "wheels": "https://therock-nightly-artifacts.s3.amazonaws.com/43777893761-linux/python/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43777893761-linux/index.html", + "deb": "https://therock-nightly-artifacts.s3.amazonaws.com/43777893761-linux/packages/deb/", + "rpm": "https://therock-nightly-artifacts.s3.amazonaws.com/43777893761-linux/packages/rpm/x86_64" + }, + "rocm": { + "build": { + "status": "in_progress" + }, + "test": { + "success": 1, + "failure": 6, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 68, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test_full": { + "success": 0, + "failure": 4, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "jax": { + "build": { + "status": "failure", + "success": 19, + "failure": 3, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 16, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "native_packages": { + "rpm": { + "status": "success" + }, + "deb": { + "status": "in_progress" + } + } + }, + "windows": { + "status": "failure", + "architectures": [ + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx90a", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43777893761-windows/index.html" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 3, + "failure": 1, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 30, + "failure": 26, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + } + } + }, + "pipelines": { + "rocm": { + "test": { + "windows": { + "gfx1151": { + "status": "success", + "run_id": 43804145310, + "run_attempt": 4, + "started_at": "2026-11-16T09:25:32Z", + "completed_at": "2026-11-16T10:27:33Z" + } + }, + "linux": { + "gfx1151": { + "status": "failure", + "run_id": 43821679563, + "run_attempt": 2, + "started_at": "2026-11-16T11:07:19Z", + "completed_at": "2026-11-16T13:03:13Z" + }, + "gfx94X-dcgpu": { + "status": "success", + "run_id": 43821678266, + "run_attempt": 2, + "started_at": "2026-11-16T08:36:59Z", + "completed_at": "2026-11-16T08:43:17Z" + }, + "gfx90a": { + "status": "failure", + "run_id": 43821678080, + "run_attempt": 1, + "started_at": "2026-11-16T07:08:25Z", + "completed_at": "2026-11-16T08:37:58Z" + } + } + } + }, + "pytorch": { + "test": { + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 43806627982, + "run_attempt": 2, + "started_at": "2026-11-16T08:42:51Z", + "completed_at": "2026-11-16T15:02:02Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43806627982, + "run_attempt": 2, + "started_at": "2026-11-16T08:42:51Z", + "completed_at": "2026-11-16T09:32:49Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "failure", + "run_id": 43806627982, + "run_attempt": 2, + "started_at": "2026-11-16T13:35:42Z", + "completed_at": "2026-11-16T13:39:10Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43806627982, + "run_attempt": 2, + "started_at": "2026-11-16T13:35:42Z", + "completed_at": "2026-11-16T15:00:57Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43806627982, + "run_attempt": 2, + "started_at": "2026-11-16T13:35:42Z", + "completed_at": "2026-11-16T14:14:09Z" + } + ] + }, + "gfx90a": { + "status": "failure", + "run_id": 43806627982, + "run_attempt": 2, + "started_at": "2026-11-16T04:52:00Z", + "completed_at": "2026-11-16T14:21:12Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43806627982, + "run_attempt": 1, + "started_at": "2026-11-16T04:52:00Z", + "completed_at": "2026-11-16T08:41:34Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "failure", + "run_id": 43806627982, + "run_attempt": 2, + "started_at": "2026-11-16T13:35:26Z", + "completed_at": "2026-11-16T13:38:25Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43806627982, + "run_attempt": 2, + "started_at": "2026-11-16T13:35:26Z", + "completed_at": "2026-11-16T14:21:12Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 43806627982, + "run_attempt": 2, + "started_at": "2026-11-16T13:35:26Z", + "completed_at": "2026-11-16T13:39:18Z" + } + ] + } + }, + "linux": { + "gfx94X-dcgpu": { + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:24:11Z", + "completed_at": "2026-11-16T17:00:29Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:24:11Z", + "completed_at": "2026-11-16T13:05:28Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:27:10Z", + "completed_at": "2026-11-16T13:02:03Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:27:35Z", + "completed_at": "2026-11-16T13:04:27Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:36:55Z", + "completed_at": "2026-11-16T13:16:32Z" + } + ] + }, + "gfx1151": { + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:24:11Z", + "completed_at": "2026-11-16T17:00:29Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:24:11Z", + "completed_at": "2026-11-16T12:55:04Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:27:10Z", + "completed_at": "2026-11-16T12:54:28Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:27:20Z", + "completed_at": "2026-11-16T12:47:07Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T14:14:00Z", + "completed_at": "2026-11-16T14:44:52Z" + } + ] + }, + "gfx90a": { + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:24:19Z", + "completed_at": "2026-11-16T17:00:29Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:24:19Z", + "completed_at": "2026-11-16T13:32:42Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:27:18Z", + "completed_at": "2026-11-16T13:27:27Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:27:28Z", + "completed_at": "2026-11-16T13:29:14Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T13:35:12Z", + "completed_at": "2026-11-16T14:18:10Z" + } + ] + }, + "gfx950-dcgpu": { + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:25:16Z", + "completed_at": "2026-11-16T17:00:29Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:25:16Z", + "completed_at": "2026-11-16T12:52:49Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T13:41:40Z", + "completed_at": "2026-11-16T14:03:32Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:28:03Z", + "completed_at": "2026-11-16T12:50:53Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 43843438917, + "run_attempt": 3, + "started_at": "2026-11-16T12:39:49Z", + "completed_at": "2026-11-16T13:05:15Z" + } + ] + } + } + } + } + } +} diff --git a/tests/unit/data/quartz/nightly/20261117/status.json b/tests/unit/data/quartz/nightly/20261117/status.json new file mode 100644 index 00000000..f81ef9cf --- /dev/null +++ b/tests/unit/data/quartz/nightly/20261117/status.json @@ -0,0 +1,479 @@ +{ + "schema_version": "2.2", + "release_type": "nightly", + "rocm_version": "10.3.0a20261117", + "build_date": "20261117", + "build_variant": "release", + "therock_commit": "494a841656580751bd9db757b81dead0eb34d9eb", + "trigger_workflow_run_id": 43984167450, + "trigger_run_attempt": 1, + "created_at": "2026-11-17T00:01:15Z", + "completed_at": "2026-11-17T06:18:36Z", + "orchestrator_conclusion": "success", + "pytorch_enabled": true, + "jax_enabled": true, + "status_json_created": "2026-11-17T00:02:06Z", + "status_json_last_updated": "2026-11-18T22:03:56Z", + "summary": { + "overall_status": "failure", + "linux": { + "status": "failure", + "architectures": [ + "gfx94X-dcgpu", + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx125X-dcgpu", + "gfx90a", + "gfx950-dcgpu", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43984167450-linux/index.html", + "deb": "https://nightly.repo.amd.com/rocm/core/packages//20261117-43984167450/", + "rpm": "https://nightly.repo.amd.com/rocm/core/packages//20261117-43984167450/" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 2, + "failure": 5, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 68, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test_full": { + "success": 0, + "failure": 4, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "jax": { + "build": { + "status": "failure", + "success": 19, + "failure": 3, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 16, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "native_packages": { + "rpm": { + "status": "success" + }, + "deb": { + "status": "success" + } + } + }, + "windows": { + "status": "failure", + "architectures": [ + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx90a", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/43984167450-windows/index.html" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 1, + "failure": 3, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 18, + "failure": 38, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + } + } + }, + "pipelines": { + "rocm": { + "test": { + "linux": { + "gfx90a": { + "status": "failure", + "run_id": 44009655172, + "run_attempt": 3, + "started_at": "2026-11-17T05:56:18Z", + "completed_at": "2026-11-17T06:37:38Z" + }, + "gfx1151": { + "status": "failure", + "run_id": 44009654721, + "run_attempt": 3, + "started_at": "2026-11-17T07:40:34Z", + "completed_at": "2026-11-17T08:07:07Z" + }, + "gfx94X-dcgpu": { + "status": "success", + "run_id": 44009654391, + "run_attempt": 3, + "started_at": "2026-11-17T05:13:59Z", + "completed_at": "2026-11-17T05:22:11Z" + } + }, + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 44026544795, + "run_attempt": 3, + "started_at": "2026-11-17T11:08:34Z", + "completed_at": "2026-11-17T12:14:56Z" + } + } + } + }, + "pytorch": { + "test": { + "linux": { + "gfx94X-dcgpu": { + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:49:15Z", + "completed_at": "2026-11-17T10:43:47Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:49:15Z", + "completed_at": "2026-11-17T09:28:53Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:51:05Z", + "completed_at": "2026-11-17T09:28:23Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:51:26Z", + "completed_at": "2026-11-17T09:27:23Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T09:01:13Z", + "completed_at": "2026-11-17T09:40:07Z" + } + ] + }, + "gfx1151": { + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:49:15Z", + "completed_at": "2026-11-17T10:43:47Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:49:15Z", + "completed_at": "2026-11-17T09:20:00Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:51:05Z", + "completed_at": "2026-11-17T09:18:53Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:51:24Z", + "completed_at": "2026-11-17T09:11:53Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T10:12:21Z", + "completed_at": "2026-11-17T10:42:28Z" + } + ] + }, + "gfx90a": { + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:49:26Z", + "completed_at": "2026-11-17T10:43:47Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:49:26Z", + "completed_at": "2026-11-17T09:33:52Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:51:13Z", + "completed_at": "2026-11-17T09:31:59Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:51:34Z", + "completed_at": "2026-11-17T09:33:58Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T09:00:55Z", + "completed_at": "2026-11-17T09:50:20Z" + } + ] + }, + "gfx950-dcgpu": { + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:49:24Z", + "completed_at": "2026-11-17T10:43:47Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:49:24Z", + "completed_at": "2026-11-17T09:16:01Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:51:11Z", + "completed_at": "2026-11-17T09:15:02Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T08:51:32Z", + "completed_at": "2026-11-17T09:15:42Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44029961992, + "run_attempt": 2, + "started_at": "2026-11-17T09:01:05Z", + "completed_at": "2026-11-17T09:26:42Z" + } + ] + } + }, + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:40:39Z", + "completed_at": "2026-11-17T14:04:10Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.13", + "status": "failure", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:54:12Z", + "completed_at": "2026-11-17T13:27:03Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:40:39Z", + "completed_at": "2026-11-17T13:11:41Z" + }, + { + "py": "3.11", + "torch": "release/2.15", + "status": "failure", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:53:04Z", + "completed_at": "2026-11-17T13:27:16Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:57:03Z", + "completed_at": "2026-11-17T14:03:30Z" + } + ] + }, + "gfx90a": { + "status": "failure", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:40:15Z", + "completed_at": "2026-11-17T13:27:24Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.13", + "status": "failure", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:40:15Z", + "completed_at": "2026-11-17T13:11:53Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:40:15Z", + "completed_at": "2026-11-17T12:57:03Z" + }, + { + "py": "3.11", + "torch": "release/2.15", + "status": "failure", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:40:15Z", + "completed_at": "2026-11-17T13:11:53Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44030176505, + "run_attempt": 2, + "started_at": "2026-11-17T12:40:15Z", + "completed_at": "2026-11-17T13:27:24Z" + } + ] + } + } + } + } + } +} diff --git a/tests/unit/data/quartz/nightly/20261118/status.json b/tests/unit/data/quartz/nightly/20261118/status.json new file mode 100644 index 00000000..06fa0353 --- /dev/null +++ b/tests/unit/data/quartz/nightly/20261118/status.json @@ -0,0 +1,479 @@ +{ + "schema_version": "2.2", + "release_type": "nightly", + "rocm_version": "10.3.0a20261118", + "build_date": "20261118", + "build_variant": "release", + "therock_commit": "8504464cb4ce7857dd45c02075bd624b89f05588", + "trigger_workflow_run_id": 44204278609, + "trigger_run_attempt": 2, + "created_at": "2026-11-18T00:00:58Z", + "completed_at": "2026-11-18T05:52:24Z", + "orchestrator_conclusion": "success", + "pytorch_enabled": true, + "jax_enabled": true, + "status_json_created": "2026-11-18T00:02:11Z", + "status_json_last_updated": "2026-11-19T09:55:44Z", + "summary": { + "overall_status": "failure", + "linux": { + "status": "failure", + "architectures": [ + "gfx94X-dcgpu", + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx125X-dcgpu", + "gfx90a", + "gfx950-dcgpu", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/44204278609-linux/index.html", + "deb": "https://nightly.repo.amd.com/rocm/core/packages//20261118-44204278609/", + "rpm": "https://nightly.repo.amd.com/rocm/core/packages//20261118-44204278609/" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 2, + "failure": 4, + "in_progress": 0, + "cancelled": 1, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 35, + "failure": 33, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test_full": { + "success": 0, + "failure": 4, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "jax": { + "build": { + "status": "failure", + "success": 19, + "failure": 3, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 16, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "native_packages": { + "rpm": { + "status": "success" + }, + "deb": { + "status": "success" + } + } + }, + "windows": { + "status": "failure", + "architectures": [ + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx90a", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/44204278609-windows/index.html" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 1, + "failure": 2, + "in_progress": 1, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 17, + "failure": 39, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + } + } + }, + "pipelines": { + "rocm": { + "test": { + "linux": { + "gfx1151": { + "status": "failure", + "run_id": 44230227371, + "run_attempt": 3, + "started_at": "2026-11-18T09:28:50Z", + "completed_at": "2026-11-18T09:44:03Z" + }, + "gfx94X-dcgpu": { + "status": "success", + "run_id": 44230225252, + "run_attempt": 1, + "started_at": "2026-11-18T03:24:41Z", + "completed_at": "2026-11-18T04:30:43Z" + }, + "gfx90a": { + "status": "failure", + "run_id": 44230223546, + "run_attempt": 3, + "started_at": "2026-11-18T05:45:09Z", + "completed_at": "2026-11-18T06:22:36Z" + } + }, + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 44244342104, + "run_attempt": 3, + "started_at": "2026-11-18T10:28:26Z", + "completed_at": "2026-11-18T11:33:15Z" + } + } + } + }, + "pytorch": { + "test": { + "linux": { + "gfx94X-dcgpu": { + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:21:57Z", + "completed_at": "2026-11-18T18:10:11Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:21:57Z", + "completed_at": "2026-11-18T08:01:36Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:24:47Z", + "completed_at": "2026-11-18T08:02:11Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:25:35Z", + "completed_at": "2026-11-18T08:03:15Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:33:34Z", + "completed_at": "2026-11-18T08:12:55Z" + } + ] + }, + "gfx1151": { + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:28:24Z", + "completed_at": "2026-11-18T18:10:11Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T11:03:46Z", + "completed_at": "2026-11-18T11:34:36Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:28:24Z", + "completed_at": "2026-11-18T07:49:04Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:37:24Z", + "completed_at": "2026-11-18T08:07:36Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T10:56:29Z", + "completed_at": "2026-11-18T11:41:06Z" + } + ] + }, + "gfx90a": { + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:22:05Z", + "completed_at": "2026-11-18T18:10:11Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:22:05Z", + "completed_at": "2026-11-18T08:03:54Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:24:57Z", + "completed_at": "2026-11-18T08:04:49Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:25:37Z", + "completed_at": "2026-11-18T08:06:11Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:33:43Z", + "completed_at": "2026-11-18T08:16:14Z" + } + ] + }, + "gfx950-dcgpu": { + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:22:04Z", + "completed_at": "2026-11-18T18:10:11Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:22:04Z", + "completed_at": "2026-11-18T07:48:17Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:24:59Z", + "completed_at": "2026-11-18T07:48:47Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:26:25Z", + "completed_at": "2026-11-18T07:50:29Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44239149610, + "run_attempt": 2, + "started_at": "2026-11-18T07:33:47Z", + "completed_at": "2026-11-18T07:59:57Z" + } + ] + } + }, + "windows": { + "gfx1151": { + "status": "failure", + "run_id": 44247169305, + "run_attempt": 2, + "started_at": "2026-11-18T09:52:44Z", + "completed_at": "2026-11-19T02:05:41Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44247169305, + "run_attempt": 2, + "started_at": "2026-11-18T13:17:51Z", + "completed_at": "2026-11-18T13:47:01Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44247169305, + "run_attempt": 2, + "started_at": "2026-11-18T09:52:44Z", + "completed_at": "2026-11-18T10:23:01Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "failure", + "run_id": 44247169305, + "run_attempt": 2, + "started_at": "2026-11-18T13:19:06Z", + "completed_at": "2026-11-18T13:56:39Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 44247169305, + "run_attempt": 2, + "started_at": "2026-11-18T13:22:10Z", + "completed_at": "2026-11-18T14:19:14Z" + } + ] + }, + "gfx90a": { + "status": "failure", + "run_id": 44247169305, + "run_attempt": 2, + "started_at": "2026-11-18T05:51:43Z", + "completed_at": "2026-11-18T13:17:26Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "failure", + "run_id": 44247169305, + "run_attempt": 1, + "started_at": "2026-11-18T05:51:43Z", + "completed_at": "2026-11-18T09:51:07Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44247169305, + "run_attempt": 2, + "started_at": "2026-11-18T13:17:23Z", + "completed_at": "2026-11-18T13:17:26Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "failure", + "run_id": 44247169305, + "run_attempt": 2, + "started_at": "2026-11-18T13:17:23Z", + "completed_at": "2026-11-18T13:17:26Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "failure", + "run_id": 44247169305, + "run_attempt": 2, + "started_at": "2026-11-18T13:17:23Z", + "completed_at": "2026-11-18T13:17:26Z" + } + ] + } + } + } + } + } +} diff --git a/tests/unit/data/quartz/nightly/20261119/status.json b/tests/unit/data/quartz/nightly/20261119/status.json new file mode 100644 index 00000000..d0161d51 --- /dev/null +++ b/tests/unit/data/quartz/nightly/20261119/status.json @@ -0,0 +1,380 @@ +{ + "schema_version": "2.2", + "release_type": "nightly", + "rocm_version": "10.3.0a20261119", + "build_date": "20261119", + "build_variant": "release", + "therock_commit": "93b7a6b2f355e70b833b7b057ef406f6e6d3024e", + "trigger_workflow_run_id": 44425566533, + "trigger_run_attempt": 2, + "created_at": "2026-11-19T00:01:12Z", + "completed_at": "2026-11-19T16:37:02Z", + "orchestrator_conclusion": "success", + "pytorch_enabled": true, + "jax_enabled": true, + "status_json_created": "2026-11-19T00:02:16Z", + "status_json_last_updated": "2026-11-19T17:29:48Z", + "summary": { + "overall_status": "failure", + "linux": { + "status": "failure", + "architectures": [ + "gfx94X-dcgpu", + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx125X-dcgpu", + "gfx90a", + "gfx950-dcgpu", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/44425566533-linux/index.html", + "deb": "https://nightly.repo.amd.com/rocm/core/packages//20261119-44425566533/", + "rpm": "https://nightly.repo.amd.com/rocm/core/packages//20261119-44425566533/" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 2, + "failure": 4, + "in_progress": 1, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "success", + "success": 20, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 44, + "failure": 22, + "in_progress": 2, + "cancelled": 0, + "skipped": 0 + }, + "test_full": { + "success": 0, + "failure": 3, + "in_progress": 1, + "cancelled": 0, + "skipped": 0 + } + }, + "jax": { + "build": { + "status": "failure", + "success": 19, + "failure": 3, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + }, + "test": { + "success": 15, + "failure": 1, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "native_packages": { + "rpm": { + "status": "success" + }, + "deb": { + "status": "success" + } + } + }, + "windows": { + "status": "in_progress", + "architectures": [ + "gfx110X-all", + "gfx1151", + "gfx120X-all", + "gfx90a", + "gfx900", + "gfx90c", + "gfx906", + "gfx908", + "gfx101X-dgpu", + "gfx103X-all", + "gfx1150", + "gfx1152", + "gfx1153", + "gfx117X-all" + ], + "urls": { + "tarballs": "https://nightly.repo.amd.com/rocm/core/tarball/", + "wheels": "https://nightly.repo.amd.com/rocm/whl-next/", + "artifacts": "https://therock-nightly-artifacts.s3.amazonaws.com/44425566533-windows/index.html" + }, + "rocm": { + "build": { + "status": "success" + }, + "test": { + "success": 2, + "failure": 1, + "in_progress": 1, + "cancelled": 0, + "skipped": 0 + } + }, + "pytorch": { + "build": { + "status": "in_progress" + }, + "test": { + "success": 0, + "failure": 0, + "in_progress": 0, + "cancelled": 0, + "skipped": 0 + } + } + } + }, + "pipelines": { + "rocm": { + "test": { + "linux": { + "gfx94X-dcgpu": { + "status": "success", + "run_id": 44450853090, + "run_attempt": 3, + "started_at": "2026-11-19T05:47:17Z", + "completed_at": "2026-11-19T06:04:52Z" + }, + "gfx1151": { + "status": "failure", + "run_id": 44450851469, + "run_attempt": 2, + "started_at": "2026-11-19T05:47:56Z", + "completed_at": "2026-11-19T06:21:28Z" + }, + "gfx90a": { + "status": "failure", + "run_id": 44450852917, + "run_attempt": 3, + "started_at": "2026-11-19T06:41:07Z", + "completed_at": "2026-11-19T07:01:40Z" + } + }, + "windows": { + "gfx1151": { + "status": "success", + "run_id": 44509904206, + "run_attempt": 4, + "started_at": "2026-11-19T16:53:53Z", + "completed_at": "2026-11-19T17:11:23Z" + } + } + } + }, + "pytorch": { + "test": { + "linux": { + "gfx94X-dcgpu": { + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:20:12Z", + "completed_at": "2026-11-19T08:26:47Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:20:12Z", + "completed_at": "2026-11-19T08:02:57Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:22:06Z", + "completed_at": "2026-11-19T08:00:52Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:22:21Z", + "completed_at": "2026-11-19T08:00:53Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:46:58Z", + "completed_at": "2026-11-19T08:26:47Z" + } + ] + }, + "gfx1151": { + "status": "in_progress", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:21:58Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T12:25:13Z", + "completed_at": "2026-11-19T12:48:01Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:21:58Z", + "completed_at": "2026-11-19T07:49:42Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:22:22Z", + "completed_at": "2026-11-19T07:57:54Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "in_progress", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T12:44:35Z" + } + ] + }, + "gfx90a": { + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:20:20Z", + "completed_at": "2026-11-19T08:36:09Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:20:20Z", + "completed_at": "2026-11-19T08:09:46Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:22:08Z", + "completed_at": "2026-11-19T08:07:21Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:22:30Z", + "completed_at": "2026-11-19T08:06:28Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:47:07Z", + "completed_at": "2026-11-19T08:36:09Z" + } + ] + }, + "gfx950-dcgpu": { + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:20:20Z", + "completed_at": "2026-11-19T08:12:02Z", + "variants": [ + { + "py": "3.11", + "torch": "release/2.15", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:20:20Z", + "completed_at": "2026-11-19T07:46:15Z" + }, + { + "py": "3.11", + "torch": "release/2.13", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:22:17Z", + "completed_at": "2026-11-19T07:44:56Z" + }, + { + "py": "3.11", + "torch": "release/2.14", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:22:31Z", + "completed_at": "2026-11-19T07:45:35Z" + }, + { + "py": "3.11", + "torch": "nightly", + "status": "success", + "run_id": 44459894891, + "run_attempt": 2, + "started_at": "2026-11-19T07:47:16Z", + "completed_at": "2026-11-19T08:12:02Z" + } + ] + } + } + } + } + } +} diff --git a/tests/unit/metrics/test_machine_info.py b/tests/unit/metrics/test_machine_info.py index b629d4c8..d9b702ef 100644 --- a/tests/unit/metrics/test_machine_info.py +++ b/tests/unit/metrics/test_machine_info.py @@ -34,6 +34,10 @@ "cuda_version", "cudnn_version", "hipdnn_version", + "rocm_build_version", + "rocm_build_date", + "therock_commit", + "rocm_build_untested", "python_version", "torch_version", "amdsmi_available", diff --git a/tests/unit/reporting/test_schema_v3.py b/tests/unit/reporting/test_schema_v3.py index 26dabdde..834e021e 100644 --- a/tests/unit/reporting/test_schema_v3.py +++ b/tests/unit/reporting/test_schema_v3.py @@ -37,7 +37,8 @@ "kernel_version", "gpu_model", "gpu_arch", "gpu_compute_units", "gpu_hbm_gb", "gpu_pcie_link", "amdgpu_driver_version", "gpu_power_cap_w", "gpu_max_sclk_mhz", "gpu_compute_partition", "rocm_version", "cuda_version", - "cudnn_version", "hipdnn_version", "python_version", "torch_version", + "cudnn_version", "hipdnn_version", "rocm_build_version", "rocm_build_date", + "therock_commit", "rocm_build_untested", "python_version", "torch_version", "amdsmi_available", "selection_env", } # fmt: skip SUMMARY_KEYS = { diff --git a/tests/unit/test_setup_env.py b/tests/unit/test_setup_env.py index ffa76b1c..ce21cd0a 100644 --- a/tests/unit/test_setup_env.py +++ b/tests/unit/test_setup_env.py @@ -13,10 +13,19 @@ import subprocess import sys from pathlib import Path +from types import SimpleNamespace import pytest _SETUP_ENV = Path(__file__).resolve().parents[2] / "setup_env.py" +# Quartz nightly status.json files 20261113 to 20261119, recorded from +# ROCm/quartz. Their `pipelines` block keeps only the rocm and pytorch test +# entries of gfx94X-dcgpu, gfx950-dcgpu, gfx90a and gfx1151. Linux facts the +# tests use: 20261116 has a ROCm build in progress, 20261114 a failed PyTorch +# build. gfx94X-dcgpu ROCm tests fail on 20261114 and 20261115, and its +# PyTorch tests fail on 20261113. gfx950-dcgpu has no ROCm test entry, and +# its PyTorch tests fail on 20261113. gfx90a ROCm tests fail on every day. +_QUARTZ_NIGHTLY = Path(__file__).resolve().parent / "data" / "quartz" / "nightly" @pytest.fixture(scope="module") @@ -28,6 +37,43 @@ def setup_env(): return module +@pytest.fixture(autouse=True) +def _no_quartz_network(setup_env, monkeypatch): + def refuse(url): + raise AssertionError(f"unit test fetched {url}") + + monkeypatch.setattr(setup_env, "fetch_quartz_text", refuse) + + +def _quartz_document(build_date: str) -> dict: + return json.loads((_QUARTZ_NIGHTLY / build_date / "status.json").read_text()) + + +@pytest.fixture +def quartz(setup_env, monkeypatch): + """Serve the recorded nightlies. ``latest`` is the build date that + nightly/latest.json names; ``documents`` replaces a recorded document by + build date; ``fetched`` lists every URL read. Setup reads the Linux + summary of the recorded nightlies on every host, Windows included.""" + served = SimpleNamespace(latest="20261119", documents={}, fetched=[]) + + def fetch(url): + served.fetched.append(url) + relative = url.removeprefix(setup_env.QUARTZ_NIGHTLY_URL) + if relative == "latest.json": + # A git symlink: raw GitHub serves its target path. + return f"{served.latest}/status.json" + build_date = relative.split("/", 1)[0] + if build_date in served.documents: + return json.dumps(served.documents[build_date]) + path = _QUARTZ_NIGHTLY / relative + return path.read_text() if path.is_file() else None + + monkeypatch.setattr(setup_env, "fetch_quartz_text", fetch) + monkeypatch.setattr(setup_env, "quartz_platform", lambda: "linux") + return served + + def _setup(setup_env, tmp_path, *argv): args = setup_env.build_parser().parse_args( ["--workspace", str(tmp_path / "ws"), "--gpu-arch", "gfx90a", *argv] @@ -1006,10 +1052,14 @@ def test_clean_with_existing_torch_mode_is_a_usage_error(setup_env) -> None: assert exc.value.code == 2 +_RECORDED_ROCM_VERSION = "10.3.0a20261115" + + def _reused_venv(setup_env, tmp_path, monkeypatch, mode, *argv, record=True): """A Setup over a venv that setup filled with ``mode`` torch from its - default index (gfx90a for rocm). ``record=False`` drops the TORCH_RECORD, - as on a venv set up before setup wrote one.""" + default index (gfx90a and ROCm _RECORDED_ROCM_VERSION for rocm). + ``record=False`` drops the records, as on a venv set up before setup + wrote them.""" setup = _setup(setup_env, tmp_path, "--torch-mode", mode, *argv) setup.venv_dir.mkdir(parents=True) if record: @@ -1022,6 +1072,10 @@ def _reused_venv(setup_env, tmp_path, monkeypatch, mode, *argv, record=True): (setup.venv_dir / setup_env.TORCH_RECORD).write_text( json.dumps({"torch_index_url": index_url, "gpu_arch": arch}) ) + if mode == "rocm": + (setup.venv_dir / setup_env.ROCM_BUILD_RECORD).write_text( + json.dumps({"rocm_version": _RECORDED_ROCM_VERSION}) + ) setup.installed_torch_mode = mode pip_calls = [] monkeypatch.setattr(setup, "pip", lambda *a, **kw: pip_calls.append(a)) @@ -1034,8 +1088,9 @@ def _reused_venv(setup_env, tmp_path, monkeypatch, mode, *argv, record=True): [], ["--gpu-arch", "gfx90a"], ["--torch-index-url", "https://nightly.repo.amd.com/rocm/whl-next/"], + ["--rocm-version", _RECORDED_ROCM_VERSION], ], - ids=["no-flags", "same-arch", "same-index"], + ids=["no-flags", "same-arch", "same-index", "same-rocm-version"], ) def test_reused_venv_keeps_torch_when_flags_match( setup_env, tmp_path, monkeypatch, argv @@ -1050,10 +1105,17 @@ def test_reused_venv_keeps_torch_when_flags_match( [ ("rocm", ["--gpu-arch", "gfx942"]), ("rocm", ["--torch-index-url", "https://example.invalid/"]), + ("rocm", ["--rocm-version", "10.3.0a20261110"]), ("cpu", ["--torch-index-url", "https://example.invalid/"]), ("cuda", ["--torch-index-url", "https://example.invalid/"]), ], - ids=["rocm-other-arch", "rocm-other-index", "cpu-other-index", "cuda-other-index"], + ids=[ + "rocm-other-arch", + "rocm-other-index", + "rocm-other-version", + "cpu-other-index", + "cuda-other-index", + ], ) def test_reused_venv_refuses_a_different_explicit_torch_source( setup_env, tmp_path, monkeypatch, capsys, mode, argv @@ -1086,7 +1148,7 @@ def test_reused_venv_without_a_record_warns_and_keeps_torch( def test_fresh_torch_install_records_its_source( - setup_env, tmp_path, monkeypatch + setup_env, tmp_path, monkeypatch, quartz ) -> None: setup = _setup(setup_env, tmp_path, "--gpu-arch", "gfx942") setup.venv_dir.mkdir(parents=True) @@ -1105,6 +1167,398 @@ def test_fresh_torch_install_records_its_source( other.install_torch() +# --- ROCm nightly selection (Quartz) ---------------------------------------- + + +@pytest.mark.parametrize( + "latest, arch, build_date, therock_commit, untested", + [ + ( + "20261119", + "gfx942", + "20261119", + "93b7a6b2f355e70b833b7b057ef406f6e6d3024e", + (), + ), + ( + "20261119", + "gfx950", + "20261119", + "93b7a6b2f355e70b833b7b057ef406f6e6d3024e", + ("rocm",), + ), + ( + "20261116", + "gfx950", + "20261115", + "62d1ac21a0eda4df3871c6c8d4570cb0ee9a4637", + ("rocm",), + ), + ( + "20261124", + "gfx942", + "20261119", + "93b7a6b2f355e70b833b7b057ef406f6e6d3024e", + (), + ), + ], + ids=[ + "arch-tests-pass", + "no-rocm-test-entry", + "rocm-build-in-progress", + "days-without-a-nightly", + ], +) +def test_selection_takes_the_newest_nightly_that_passes_for_the_arch( + setup_env, quartz, latest, arch, build_date, therock_commit, untested +) -> None: + quartz.latest = latest + build = setup_env.select_quartz_nightly("linux", arch) + assert build.build_date == build_date + assert build.rocm_version == f"10.3.0a{build_date}" + assert build.therock_commit == therock_commit + assert build.untested == untested + assert build.index_url == "https://nightly.repo.amd.com/rocm/whl-next/" + assert build.source == "quartz" + assert ( + build.status_url + == f"https://raw.githubusercontent.com/ROCm/quartz/main/nightly/{build_date}/status.json" + ) + + +@pytest.mark.parametrize( + "suite, status", + [ + ("rocm", "failure"), + ("pytorch", "failure"), + ("pytorch", "in_progress"), + ("rocm", "cancelled"), + ], +) +def test_selection_skips_a_nightly_whose_arch_tests_did_not_pass( + setup_env, quartz, suite, status +) -> None: + document = _quartz_document("20261119") + document["pipelines"][suite]["test"]["linux"]["gfx94X-dcgpu"]["status"] = status + quartz.documents["20261119"] = document + + assert setup_env.select_quartz_nightly("linux", "gfx942").build_date == "20261118" + # gfx950 does not read the gfx94X-dcgpu entry. + assert setup_env.select_quartz_nightly("linux", "gfx950").build_date == "20261119" + + +def test_selection_accepts_an_arch_without_test_entries(setup_env, quartz) -> None: + document = _quartz_document("20261119") + del document["pipelines"]["pytorch"]["test"]["linux"]["gfx950-dcgpu"] + quartz.documents["20261119"] = document + + build = setup_env.select_quartz_nightly("linux", "gfx950") + + assert build.build_date == "20261119" + assert build.untested == ("rocm", "pytorch") + + +def test_selection_skips_a_nightly_without_the_gpu_arch(setup_env, quartz) -> None: + document = _quartz_document("20261117") + document["summary"]["linux"]["architectures"].remove("gfx950-dcgpu") + quartz.documents["20261117"] = document + quartz.latest = "20261117" + # 20261116 has the arch but a Linux ROCm build in progress. + build = setup_env.select_quartz_nightly("linux", "gfx950") + assert build.build_date == "20261115" + + +@pytest.mark.parametrize( + "arch, target, matches", + [ + ("gfx942", "gfx94X-dcgpu", True), + ("gfx950", "gfx950-dcgpu", True), + ("gfx1101", "gfx110X-all", True), + ("gfx90a", "gfx90a", True), + ("gfx90a", "gfx94X-dcgpu", False), + ("gfx942", "gfx950-dcgpu", False), + ("gfx9500", "gfx950-dcgpu", False), + ("gfx11011", "gfx110X-all", False), + ], +) +def test_arch_matches_a_therock_build_target(setup_env, arch, target, matches) -> None: + assert setup_env.quartz_arch_matches(arch, target) is matches + + +@pytest.mark.parametrize( + "latest, arch, rejections", + [ + ( + "20261116", + "gfx942", + [ + "20261116 (10.3.0a20261116): linux rocm build is in_progress\n", + "20261115 (10.3.0a20261115): linux rocm tests of gfx94X-dcgpu " + "are failure\n", + "20261114 (10.3.0a20261114): linux pytorch build is failure; " + "linux rocm tests of gfx94X-dcgpu are failure\n", + "20261113 (10.3.0a20261113): linux pytorch tests of gfx94X-dcgpu " + "are failure\n", + "20261103: no status.json\n", + ], + ), + ( + "20261114", + "gfx950", + [ + "20261114 (10.3.0a20261114): linux pytorch build is failure\n", + "20261113 (10.3.0a20261113): linux pytorch tests of gfx950-dcgpu " + "are failure\n", + ], + ), + ( + "20261119", + "gfx90a", + [ + f"{day} (10.3.0a{day}): linux rocm tests of gfx90a are failure\n" + for day in ("20261119", "20261118", "20261117", "20261115") + ], + ), + ( + "20261119", + "gfx1151", + [ + "20261119 (10.3.0a20261119): linux rocm tests of gfx1151 are " + "failure; linux pytorch tests of gfx1151 are in_progress\n", + "20261113 (10.3.0a20261113): linux rocm tests of gfx1151 are " + "cancelled; linux pytorch tests of gfx1151 are failure\n", + ], + ), + ], + ids=["gfx942", "gfx950", "gfx90a", "gfx1151"], +) +def test_selection_fails_and_names_each_failed_check( + setup_env, quartz, capsys, latest, arch, rejections +) -> None: + quartz.latest = latest + with pytest.raises(SystemExit) as exc: + setup_env.select_quartz_nightly("linux", arch) + assert exc.value.code == 1 + err = capsys.readouterr().err + for rejection in rejections: + assert f" {rejection}" in err + + +def test_selection_fails_when_no_nightly_in_the_window_qualifies( + setup_env, quartz, capsys +) -> None: + # No recorded Windows build lists a gfx94X target. + with pytest.raises(SystemExit) as exc: + setup_env.select_quartz_nightly("windows", "gfx942") + assert exc.value.code == 1 + err = capsys.readouterr().err + for day in range(13, 20): + build_date = f"202611{day}" + assert f"{build_date} (10.3.0a{build_date}): gfx942 is not among" in err + assert "20261106: no status.json" in err + # latest.json, then exactly one bounded window of nightlies. + assert len(quartz.fetched) == 1 + setup_env.QUARTZ_LOOKBACK_DAYS + + +def test_selection_stops_at_an_unsupported_schema_major( + setup_env, quartz, capsys +) -> None: + document = _quartz_document("20261119") + document["schema_version"] = "3.0" + quartz.documents["20261119"] = document + with pytest.raises(SystemExit): + setup_env.select_quartz_nightly("linux", "gfx942") + assert "schema '3.0'" in capsys.readouterr().err + + +def _fresh_rocm_setup(setup_env, tmp_path, monkeypatch, *argv, arch="gfx942"): + """A Setup that installs ROCm torch for ``arch`` into an empty venv.""" + setup = _setup(setup_env, tmp_path, "--gpu-arch", arch, *argv) + setup.venv_dir.mkdir(parents=True) + pip_calls = [] + monkeypatch.setattr(setup, "pip", lambda *a, **kw: pip_calls.append(a)) + monkeypatch.setattr(setup, "get_torch_mode", lambda: "rocm") + return setup, pip_calls + + +def _recorded_environment(setup, monkeypatch) -> dict: + from dnn_benchmarking.metrics import machine_info + + monkeypatch.setattr(sys, "prefix", str(setup.venv_dir)) + info = machine_info.collect_environment_info() + return { + key: info[key] + for key in ( + "rocm_build_version", + "rocm_build_date", + "therock_commit", + "rocm_build_untested", + ) + } + + +@pytest.mark.parametrize( + "arch, latest, environment", + [ + ( + "gfx942", + "20261119", + { + "rocm_build_version": "10.3.0a20261119", + "rocm_build_date": "20261119", + "therock_commit": "93b7a6b2f355e70b833b7b057ef406f6e6d3024e", + "rocm_build_untested": [], + }, + ), + ( + "gfx950", + "20261116", + { + "rocm_build_version": "10.3.0a20261115", + "rocm_build_date": "20261115", + "therock_commit": "62d1ac21a0eda4df3871c6c8d4570cb0ee9a4637", + "rocm_build_untested": ["rocm"], + }, + ), + ], +) +def test_rocm_install_pins_the_selected_nightly_and_records_it( + setup_env, tmp_path, monkeypatch, quartz, capsys, arch, latest, environment +) -> None: + quartz.latest = latest + setup, pip_calls = _fresh_rocm_setup(setup_env, tmp_path, monkeypatch, arch=arch) + + setup.install_torch() + + assert pip_calls == [ + ( + "install", + "--pre", + f"torch[device-{arch}]", + f"rocm[libraries,devel,device-{arch}]=={environment['rocm_build_version']}", + "--index-url", + "https://nightly.repo.amd.com/rocm/whl-next/", + ) + ] + assert _recorded_environment(setup, monkeypatch) == environment + out = capsys.readouterr().out + assert ("Quartz has no rocm test result" in out) is bool( + environment["rocm_build_untested"] + ) + + +@pytest.mark.parametrize( + "version, warnings, untested", + [ + ( + "10.3.0a20261115", + ["linux rocm tests of gfx94X-dcgpu are failure"], + [], + ), + ( + "10.3.0a20261114", + [ + "linux pytorch build is failure", + "linux rocm tests of gfx94X-dcgpu are failure", + ], + ["pytorch"], + ), + ], + ids=["rocm-tests-failed", "pytorch-build-failed"], +) +def test_rocm_version_installs_a_failed_nightly_with_its_metadata( + setup_env, tmp_path, monkeypatch, quartz, capsys, version, warnings, untested +) -> None: + setup, pip_calls = _fresh_rocm_setup( + setup_env, tmp_path, monkeypatch, "--rocm-version", version + ) + + setup.install_torch() + + build_date = version.removeprefix("10.3.0a") + assert pip_calls[0][3] == f"rocm[libraries,devel,device-gfx942]=={version}" + err = capsys.readouterr().err + for warning in warnings: + assert warning in err + # Only the named build is read: no search for a newer one. + assert quartz.fetched == [f"{setup_env.QUARTZ_NIGHTLY_URL}{build_date}/status.json"] + assert _recorded_environment(setup, monkeypatch) == { + "rocm_build_version": version, + "rocm_build_date": build_date, + "therock_commit": _quartz_document(build_date)["therock_commit"], + "rocm_build_untested": untested, + } + + +def test_rocm_version_unknown_to_quartz_records_no_build_metadata( + setup_env, tmp_path, monkeypatch, quartz, capsys +) -> None: + setup, pip_calls = _fresh_rocm_setup( + setup_env, tmp_path, monkeypatch, "--rocm-version", "10.3.0a20261001" + ) + + setup.install_torch() + + assert pip_calls[0][3:] == ( + "rocm[libraries,devel,device-gfx942]==10.3.0a20261001", + "--index-url", + setup_env.ROCM_TORCH_INDEX_URL, + ) + assert "Quartz has no nightly status.json" in capsys.readouterr().err + assert _recorded_environment(setup, monkeypatch) == { + "rocm_build_version": "10.3.0a20261001", + "rocm_build_date": None, + "therock_commit": None, + "rocm_build_untested": None, + } + + +def test_torch_index_url_installs_its_newest_rocm_without_quartz( + setup_env, tmp_path, monkeypatch +) -> None: + # The autouse guard fails the test on any Quartz fetch. + setup, pip_calls = _fresh_rocm_setup( + setup_env, tmp_path, monkeypatch, "--torch-index-url", "https://mirror.invalid/" + ) + monkeypatch.setattr(setup, "installed_rocm_version", lambda: "10.3.0a20261117") + + setup.install_torch() + + assert pip_calls[0][3:] == ( + "rocm[libraries,devel,device-gfx942]", + "--index-url", + "https://mirror.invalid/", + ) + assert _recorded_environment(setup, monkeypatch)["rocm_build_version"] == ( + "10.3.0a20261117" + ) + + +def test_rocm_version_needs_rocm_torch_mode(setup_env) -> None: + with pytest.raises(SystemExit) as exc: + setup_env.main(["--torch-mode", "cpu", "--rocm-version", "10.3.0a20261115"]) + assert exc.value.code == 2 + + +def test_missing_toolchain_is_installed_at_the_recorded_rocm_version( + setup_env, tmp_path, monkeypatch +) -> None: + setup, pip_calls = _reused_venv(setup_env, tmp_path, monkeypatch, "rocm") + roots = iter([None, "/devel"]) + monkeypatch.setattr(setup, "_rocm_sdk_devel_root", lambda **kw: next(roots)) + + assert setup.ensure_rocm_wheel_devel_prefix("https://index.invalid/") == "/devel" + assert pip_calls == [ + ( + "install", + "--pre", + f"rocm-sdk-devel=={_RECORDED_ROCM_VERSION}", + "--index-url", + "https://index.invalid/", + ) + ] + + def _host_gpu_archs(setup_env, monkeypatch, archs): """rocm_agent_enumerator reports ``archs`` (plus the CPU agent).""" real_run, real_which = setup_env.subprocess.run, setup_env.shutil.which From 580c10ee983966ac5c369458f489d9bd1231b323 Mon Sep 17 00:00:00 2001 From: Samuel Reeder Date: Mon, 23 Nov 2026 19:43:11 +0000 Subject: [PATCH 2/4] feat(setup): pin ROCm + rocm-libraries in rocm-pin.json, remove rocm-libraries submodule, add Quartz bump workflow Replace the independent rocm-libraries git submodule + rolling nightly wheel setup with a single checked-in rocm-pin.json that pins the ROCm/PyTorch wheel version, TheRock commit, and matching rocm-libraries commit together: - Add rocm-pin.json (10.3.0a20261123 / TheRock eaa2f988 / rocm-libraries 6b5f0a16) so default setup_env.py, CI, and Docker builds stay in lockstep (preventing MIOpen/miopen-provider ABI skew such as ROCm/rocm-libraries#16128) with zero runtime Quartz/TheRock network calls. - Remove the rocm-libraries git submodule (.gitmodules, gitlink, add /rocm-libraries/ to .gitignore); keep the aiter submodule. setup_env.py sparse-clones rocm-libraries on demand from https://github.com/ROCm/rocm-libraries.git. - Support --rocm-version latest for opt-in live Quartz selection, resolving the matching rocm-libraries commit from ROCm/TheRock via a tree-filtered git fetch (advisory on existing checkouts; --rocm-libraries-ref still overrides). - Add .github/workflows/bump-rocm-pin.yml to open/update bump PRs from the newest Quartz nightly passing Linux gfx942 + gfx950 tests and Windows gfx1151 builds, skipping redundant pushes when the open bump branch already has the candidate pin. Trigger check-deserialize on rocm-pin.json and setup_env.py changes. - Simplify build-dnn-benchmark-performance-image.sh and move ROCM_TORCH_INDEX_URL, ROCM_VERSION, and ROCM_LIBRARIES_REF below COPY . . in Dockerfile.dnn-benchmark-performance-linux so new pins reuse the apt layer. --- .dockerignore | 5 +- .github/dependabot.yml | 5 +- .github/workflows/bump-rocm-pin.yml | 172 ++++++++ .github/workflows/check-deserialize.yml | 17 +- .github/workflows/setup.yml | 8 +- .gitignore | 3 + .gitmodules | 4 - ...Dockerfile.dnn-benchmark-performance-linux | 16 +- .../build-dnn-benchmark-performance-image.sh | 69 ++- docs/results-schema.md | 8 +- docs/setup.md | 126 +++--- rocm-libraries | 1 - rocm-pin.json | 7 + setup_env.py | 393 +++++++++++++++--- tests/unit/test_setup_env.py | 379 ++++++++++++++++- 15 files changed, 1029 insertions(+), 184 deletions(-) create mode 100644 .github/workflows/bump-rocm-pin.yml delete mode 160000 rocm-libraries create mode 100644 rocm-pin.json diff --git a/.dockerignore b/.dockerignore index ba2fe63e..6b33444b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,5 @@ -# Local VCS/worktree state is not needed inside the image. Without it -# setup_env.py cannot resolve the rocm-libraries pin, so the build script -# passes it as the ROCM_LIBRARIES_REF build arg. +# Local VCS/worktree state is not needed inside the image. setup_env.py reads +# rocm-pin.json from the build context for the ROCm and rocm-libraries pins. .git **/.git diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2421e6c9..1d214a6a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,9 +11,8 @@ updates: patterns: - "*" - # rocm-libraries and aiter. Dependabot takes one entry per ecosystem and - # directory, so both submodules share this entry and its title form: - # "chore(deps): bump from to ". + # aiter submodule. rocm-libraries is pinned alongside ROCm in rocm-pin.json + # and updated by .github/workflows/bump-rocm-pin.yml. - package-ecosystem: "gitsubmodule" directory: "/" cooldown: diff --git a/.github/workflows/bump-rocm-pin.yml b/.github/workflows/bump-rocm-pin.yml new file mode 100644 index 00000000..0cedcc66 --- /dev/null +++ b/.github/workflows/bump-rocm-pin.yml @@ -0,0 +1,172 @@ +# Copyright Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT + +name: bump-rocm-pin + +on: + schedule: + # Mondays and Wednesdays at 16:00 UTC (~12:00 America/New_York), matching + # the submodule cadence in dependabot.yml. + - cron: '0 16 * * 1,3' + workflow_dispatch: + inputs: + rocm_version: + description: 'Optional ROCm nightly version (e.g. 10.3.0a20261123); blank selects newest Quartz nightly passing linux gfx942 + gfx950.' + required: false + default: '' + type: string + +permissions: + contents: read + +concurrency: + group: bump-rocm-pin + cancel-in-progress: false + +jobs: + bump: + runs-on: ubuntu-24.04 + timeout-minutes: 15 + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + with: + python-version: '3.12' + + - name: Resolve candidate ROCm pin from Quartz + id: resolve + env: + REQUESTED_VERSION: ${{ inputs.rocm_version }} + run: | + python3 - <<'PY' + import importlib.util + import json + import os + from pathlib import Path + + spec = importlib.util.spec_from_file_location("setup_env", "setup_env.py") + setup_env = importlib.util.module_from_spec(spec) + spec.loader.exec_module(setup_env) + + pin_path = Path("rocm-pin.json") + current = setup_env.read_rocm_pin(pin_path) + requested = os.environ.get("REQUESTED_VERSION", "").strip() + if requested: + requested = setup_env._rocm_version(requested) + if not requested or requested == "latest": + build = setup_env.select_quartz_nightly_for_archs( + "linux", + ("gfx942", "gfx950"), + require_platform_builds=( + ("windows", setup_env.WINDOWS_DEFAULT_GPU_ARCH), + ), + ) + else: + build = setup_env.describe_rocm_version( + requested, "", "linux", "gfx942" + ) + if not build.therock_commit: + setup_env.fail( + f"Quartz has no therock_commit for ROCm {build.rocm_version}." + ) + rocm_libraries_commit = setup_env.resolve_therock_rocm_libraries_commit( + build.therock_commit + ) + new_pin = { + "rocm_version": build.rocm_version, + "build_date": build.build_date, + "therock_commit": build.therock_commit, + "rocm_libraries_commit": rocm_libraries_commit, + "index_url": build.index_url, + } + is_manual = bool(requested and requested != "latest") + current_date = current.build_date or "" + new_date = build.build_date or "" + # Scheduled bumps only move forward; manual dispatch may pin any version. + if not is_manual and current_date and new_date and new_date < current_date: + changed = False + else: + changed = ( + build.rocm_version != current.rocm_version + or rocm_libraries_commit != current.rocm_libraries_commit + or build.therock_commit != current.therock_commit + ) + if changed: + pin_path.write_text( + json.dumps(new_pin, indent=2) + "\n", encoding="utf-8" + ) + + out = Path(os.environ["GITHUB_OUTPUT"]) + with out.open("a", encoding="utf-8") as f: + f.write(f"changed={'true' if changed else 'false'}\n") + f.write(f"old_version={current.rocm_version}\n") + f.write(f"new_version={build.rocm_version}\n") + f.write(f"therock_commit={build.therock_commit}\n") + f.write(f"old_rocm_libraries={current.rocm_libraries_commit}\n") + f.write(f"new_rocm_libraries={rocm_libraries_commit}\n") + print( + f"Current: {current.rocm_version} ({current.rocm_libraries_commit[:12]}) -> " + f"Candidate: {build.rocm_version} ({rocm_libraries_commit[:12]}), " + f"changed={changed}" + ) + PY + + - name: Open or update bump PR + if: steps.resolve.outputs.changed == 'true' + env: + # Setting repository secret ROCM_PIN_BUMP_TOKEN (a PAT or GitHub App + # token) lets the pushed branch trigger pull_request CI checks + # automatically; otherwise GITHUB_TOKEN opens/updates the PR. + GH_TOKEN: ${{ secrets.ROCM_PIN_BUMP_TOKEN || secrets.GITHUB_TOKEN }} + OLD_VERSION: ${{ steps.resolve.outputs.old_version }} + NEW_VERSION: ${{ steps.resolve.outputs.new_version }} + THEROCK_COMMIT: ${{ steps.resolve.outputs.therock_commit }} + OLD_ROCM_LIBRARIES: ${{ steps.resolve.outputs.old_rocm_libraries }} + NEW_ROCM_LIBRARIES: ${{ steps.resolve.outputs.new_rocm_libraries }} + REPO: ${{ github.repository }} + run: | + set -euo pipefail + branch="chore/bump-rocm-pin" + title="chore(deps): bump ROCm pin to ${NEW_VERSION}" + body=$(cat < \`${NEW_VERSION}\` + - **TheRock commit:** \`${THEROCK_COMMIT}\` + - **rocm-libraries commit:** \`${OLD_ROCM_LIBRARIES}\` -> \`${NEW_ROCM_LIBRARIES}\` + EOF + ) + + remote="https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git" + # Skip pushing when the open bump branch already carries this exact + # pin, so scheduled runs do not trigger redundant GPU CI or overwrite + # manual fix-up commits on the bump PR. + if git fetch --quiet "${remote}" "refs/heads/${branch}" 2>/dev/null; then + if git show FETCH_HEAD:rocm-pin.json 2>/dev/null | cmp -s - rocm-pin.json; then + echo "Branch ${branch} already has this exact rocm-pin.json; skipping push." + exit 0 + fi + fi + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -B "${branch}" + git add rocm-pin.json + git commit -m "${title}" + git push --force "${remote}" "HEAD:refs/heads/${branch}" + existing=$(gh pr list --repo "${REPO}" --head "${branch}" --state open --json number --jq '.[0].number // empty') + if [ -n "${existing}" ]; then + gh api -X PATCH "repos/${REPO}/pulls/${existing}" \ + -f title="${title}" \ + -f body="${body}" >/dev/null + echo "Updated PR #${existing}" + else + gh pr create --repo "${REPO}" --base main --head "${branch}" \ + --title "${title}" \ + --body "${body}" + fi diff --git a/.github/workflows/check-deserialize.yml b/.github/workflows/check-deserialize.yml index bc44e766..26662294 100644 --- a/.github/workflows/check-deserialize.yml +++ b/.github/workflows/check-deserialize.yml @@ -10,6 +10,8 @@ on: - 'src/dnn_benchmarking/graph/**' - 'tools/check_deserialize.py' - '.github/workflows/check-deserialize.yml' + - 'rocm-pin.json' + - 'setup_env.py' push: branches: [main] paths: @@ -17,6 +19,8 @@ on: - 'src/dnn_benchmarking/graph/**' - 'tools/check_deserialize.py' - '.github/workflows/check-deserialize.yml' + - 'rocm-pin.json' + - 'setup_env.py' permissions: contents: read @@ -49,12 +53,11 @@ jobs: # No GPU required: from_json + validate + build_operation_graph only # assemble and finalize the backend operation-graph descriptor, no - # plan build or kernel execution. ROCm PyTorch is the newest nightly - # that Quartz reports as built and not failing tests for the arch, or - # the ROCM_VERSION repository variable when it is set. The arch is - # gfx942, not gfx90a: Quartz reports failed gfx90a ROCm tests on most - # nightlies, and this build does not run on a GPU. The check imports - # only hipdnn_frontend, so --no-aiter skips the AITER build. + # plan build or kernel execution. ROCm PyTorch and rocm-libraries come + # from rocm-pin.json, or the ROCM_VERSION repository variable when set. + # The arch is gfx942, not gfx90a: Quartz reports failed gfx90a ROCm tests + # on most nightlies, and this build does not run on a GPU. The check + # imports only hipdnn_frontend, so --no-aiter skips the AITER build. - name: Build hipDNN (no GPU) env: PIP_NO_CACHE_DIR: "1" @@ -65,7 +68,7 @@ jobs: - name: Log the ROCm build run: | - python -c 'import json, sys; r = json.load(open(sys.argv[1])); print("ROCm", r["rocm_version"], "built", r["build_date"], "from TheRock", r["therock_commit"], "(" + r["source"] + "), untested:", r["untested"])' \ + python -c 'import json, sys; r = json.load(open(sys.argv[1])); print("ROCm", r["rocm_version"], "built", r["build_date"], "from TheRock", r["therock_commit"], "rocm-libraries", r.get("rocm_libraries_commit"), "(" + r["source"] + "), untested:", r["untested"])' \ .ci-workspace/.venv/dnn-bench-rocm-build.json | tee -a "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index d2096a8c..8e99c9a8 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -105,9 +105,9 @@ jobs: python-version: '3.12' # No --gpu-arch: detected from the runner's own GPU, so this job works - # on any GPU runner label. ROCm PyTorch is the newest nightly that - # Quartz reports as built and not failing tests for that GPU, or the - # ROCM_VERSION repository variable when it is set. + # on any GPU runner label. ROCm PyTorch and rocm-libraries come from + # rocm-pin.json, or the ROCM_VERSION repository variable when set + # (including 'latest' for live Quartz selection). - name: Full rocm-mode build env: PIP_NO_CACHE_DIR: "1" @@ -120,7 +120,7 @@ jobs: - name: Log the ROCm build run: | - python -c 'import json, sys; r = json.load(open(sys.argv[1])); print("ROCm", r["rocm_version"], "built", r["build_date"], "from TheRock", r["therock_commit"], "(" + r["source"] + "), untested:", r["untested"])' \ + python -c 'import json, sys; r = json.load(open(sys.argv[1])); print("ROCm", r["rocm_version"], "built", r["build_date"], "from TheRock", r["therock_commit"], "rocm-libraries", r.get("rocm_libraries_commit"), "(" + r["source"] + "), untested:", r["untested"])' \ .ci-gpu-workspace/.venv/dnn-bench-rocm-build.json | tee -a "$GITHUB_STEP_SUMMARY" diff --git a/.gitignore b/.gitignore index 40ee674b..9c782d71 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,6 @@ credentials.* # default --profiling-output-dir profiling-output/ + +# setup_env.py sparse-clones rocm-libraries at the commit pinned in rocm-pin.json +/rocm-libraries/ diff --git a/.gitmodules b/.gitmodules index adddb409..04429d43 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "rocm-libraries"] - path = rocm-libraries - url = https://github.com/ROCm/rocm-libraries.git - branch = develop [submodule "aiter"] path = aiter url = https://github.com/ROCm/aiter.git diff --git a/dockerfiles/Dockerfile.dnn-benchmark-performance-linux b/dockerfiles/Dockerfile.dnn-benchmark-performance-linux index 66f345ef..6fa1ea71 100644 --- a/dockerfiles/Dockerfile.dnn-benchmark-performance-linux +++ b/dockerfiles/Dockerfile.dnn-benchmark-performance-linux @@ -8,12 +8,6 @@ FROM ${BASE_IMAGE} AS builder ARG DEVICE_TARGET=gfx942 ARG FETCHCONTENT_GIT_SSL_NO_VERIFY=false -ARG ROCM_TORCH_INDEX_URL=https://nightly.repo.amd.com/rocm/whl-next/ -# The build context has no .git (see .dockerignore), so setup_env.py cannot -# resolve the rocm-libraries submodule pin itself. The build script passes it -# (`git rev-parse HEAD:rocm-libraries`); empty => setup warns and builds the -# moving .gitmodules branch. -ARG ROCM_LIBRARIES_REF="" ENV DEBIAN_FRONTEND=noninteractive \ HIP_PLATFORM=amd \ @@ -41,12 +35,12 @@ WORKDIR ${WORKSPACE_DIR} COPY . . -# The ROCm wheel version to install. The build script selects the newest -# nightly that Quartz reports as usable for DEVICE_TARGET, or takes its -# --rocm-version. Empty => setup installs the newest ROCm PyTorch on -# ROCM_TORCH_INDEX_URL. Declared here, not at the stage top, so a new ROCm -# build keeps the apt layer. +# The ROCm wheel version, rocm-libraries commit, and optional torch index URL. +# Empty => setup_env.py reads them from rocm-pin.json in the build context. +# Declared here, not at the stage top, so a new pin or index keeps the apt layer. +ARG ROCM_TORCH_INDEX_URL="" ARG ROCM_VERSION="" +ARG ROCM_LIBRARIES_REF="" RUN --mount=type=cache,target=/root/.cache/pip <<'EOF' set -eu diff --git a/dockerfiles/build-dnn-benchmark-performance-image.sh b/dockerfiles/build-dnn-benchmark-performance-image.sh index d4b5380e..67b9b9a6 100755 --- a/dockerfiles/build-dnn-benchmark-performance-image.sh +++ b/dockerfiles/build-dnn-benchmark-performance-image.sh @@ -5,6 +5,7 @@ container_command="docker" device_target="gfx942" tag="" rocm_version="" +rocm_libraries_ref="" build_args=() usage() { @@ -17,10 +18,13 @@ Options: --container-command CMD Container command. Default: docker --device-target TARGET ROCm PyTorch GPU architecture. Default: gfx942 --tag TAG Image tag. Default: dnn-benchmark-performance: - --rocm-version VERSION ROCm wheel version to install, for example - 10.3.0a20261117. Default: the newest nightly that - Quartz reports as built for the device target, - selected on this host. + --rocm-version VERSION ROCm wheel version to install ('latest' for the + newest usable Quartz nightly, or a specific version + such as 10.3.0a20261123). Default: rocm-pin.json. + --rocm-libraries-ref SHA Full 40-character rocm-libraries commit to build. + Default: matched to --rocm-version (from + rocm-pin.json by default, or from TheRock for + 'latest' / explicit versions). -h, --help Show this help. Examples: @@ -53,6 +57,11 @@ while [[ $# -gt 0 ]]; do rocm_version="$2" shift 2 ;; + --rocm-libraries-ref) + [[ $# -ge 2 ]] || { echo "--rocm-libraries-ref requires a value" >&2; exit 2; } + rocm_libraries_ref="$2" + shift 2 + ;; -h|--help) usage exit 0 @@ -82,32 +91,52 @@ fi script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" repo_root="$(cd -- "${script_dir}/.." && pwd)" -# The image build context excludes .git, so resolve the pinned rocm-libraries -# commit here; setup_env.py otherwise falls back to a moving branch. -rocm_libraries_ref="$(git -C "${repo_root}" rev-parse HEAD:rocm-libraries 2>/dev/null || true)" -if [[ -z "${rocm_libraries_ref}" ]]; then - echo "WARNING: could not resolve the rocm-libraries submodule commit; the image will build its moving branch." >&2 -fi - -# Select the ROCm nightly here, with the same rule as setup_env.py. The image -# then installs and labels that ROCm build even when a newer nightly appears. -resolved="$(python3 - "${repo_root}/setup_env.py" "${device_target}" "${rocm_version}" <<'PY' +# Resolve the ROCm build and matching rocm-libraries commit here, using the +# same rule as setup_env.py: rocm-pin.json by default (no network or host git +# required), or Quartz + TheRock when --rocm-version is 'latest' or another +# version. +resolved="$(python3 - "${repo_root}/setup_env.py" "${device_target}" "${rocm_version}" "${rocm_libraries_ref}" <<'PY' +import argparse import importlib.util import sys spec = importlib.util.spec_from_file_location("setup_env", sys.argv[1]) setup_env = importlib.util.module_from_spec(spec) spec.loader.exec_module(setup_env) -device_target, rocm_version = sys.argv[2:] +device_target, rocm_version, rocm_libraries_ref = sys.argv[2:] +if rocm_libraries_ref: + try: + rocm_libraries_ref = setup_env._commit_sha(rocm_libraries_ref) + except argparse.ArgumentTypeError as exc: + print(f"ERROR: --rocm-libraries-ref: {exc}", file=sys.stderr) + sys.exit(2) if rocm_version: - build = setup_env.describe_rocm_version(rocm_version, "", "linux", device_target) -else: + try: + rocm_version = setup_env._rocm_version(rocm_version) + except argparse.ArgumentTypeError as exc: + print(f"ERROR: --rocm-version: {exc}", file=sys.stderr) + sys.exit(2) +pin = setup_env.read_rocm_pin() +if not rocm_version or rocm_version == pin.rocm_version: + build = pin +elif rocm_version == "latest": build = setup_env.select_quartz_nightly("linux", device_target) -print(build.rocm_version, build.index_url) +else: + build = setup_env.describe_rocm_version(rocm_version, "", "linux", device_target) +if not rocm_libraries_ref: + if build.rocm_libraries_commit: + rocm_libraries_ref = build.rocm_libraries_commit + elif build.therock_commit: + rocm_libraries_ref = setup_env.resolve_therock_rocm_libraries_commit( + build.therock_commit + ) + else: + rocm_libraries_ref = pin.rocm_libraries_commit or "" +print(build.rocm_version, build.index_url, rocm_libraries_ref) PY )" -read -r rocm_version rocm_index_url <<<"${resolved}" -echo "ROCm ${rocm_version} from ${rocm_index_url}" +read -r rocm_version rocm_index_url rocm_libraries_ref <<<"${resolved}" +echo "ROCm ${rocm_version} from ${rocm_index_url} (rocm-libraries ${rocm_libraries_ref})" DOCKER_BUILDKIT="${DOCKER_BUILDKIT:-1}" "${container_command}" build \ -f "${script_dir}/Dockerfile.dnn-benchmark-performance-linux" \ diff --git a/docs/results-schema.md b/docs/results-schema.md index 22d733d7..ab108c34 100644 --- a/docs/results-schema.md +++ b/docs/results-schema.md @@ -104,10 +104,10 @@ The CLI collects these values one time, at suite start. | `cuda_version` | string | The `cuda` value of `torch/version.py` for a CUDA PyTorch. `null` for a ROCm PyTorch. | | `cudnn_version` | string | cuDNN version. Set only for a CUDA PyTorch that the process has already imported. | | `hipdnn_version` | string | `hipdnn_frontend.__version__`. | -| `rocm_build_version` | string | The ROCm wheel version that `setup_env.py` installed in `--torch-mode rocm`, for example `10.3.0a20261117`. The tool reads it from `dnn-bench-rocm-build.json` in the venv of the running Python (`sys.prefix`). `null` when the venv has no such record: ROCm came from somewhere else, or setup did not install ROCm PyTorch. Files written before this key was added do not have it; `schema_version` stays 2. See [setup.md](setup.md#rocm-nightly-selection). | -| `rocm_build_date` | string | `YYYYMMDD` build date of that ROCm build, from its Quartz `status.json`. `null` without a record, or when Quartz has no `status.json` for the version. Files written before this key was added do not have it. | -| `therock_commit` | string | The full TheRock commit of that ROCm build, from its Quartz `status.json`. `null` in the same cases as `rocm_build_date`. Files written before this key was added do not have it. | -| `rocm_build_untested` | array of strings | The Quartz test suites (`rocm`, `pytorch`) that report no result for the GPU architecture of that ROCm build. Setup accepts such a build but records that the suite did not test the architecture. `[]` when both suites tested it. `null` in the same cases as `rocm_build_date`. Files written before this key was added do not have it. See [setup.md](setup.md#rocm-nightly-selection). | +| `rocm_build_version` | string | The ROCm wheel version that `setup_env.py` installed in `--torch-mode rocm`, for example `10.3.0a20261123`. The tool reads it from `dnn-bench-rocm-build.json` in the venv of the running Python (`sys.prefix`). `null` when the venv has no such record: ROCm came from somewhere else, or setup did not install ROCm PyTorch. See [setup.md](setup.md#rocm-nightly-selection). | +| `rocm_build_date` | string | `YYYYMMDD` build date of that ROCm build, from `rocm-pin.json` or its Quartz `status.json`. `null` without a record, or when Quartz has no `status.json` for the version. | +| `therock_commit` | string | The full TheRock commit of that ROCm build, from `rocm-pin.json` or its Quartz `status.json`. `null` in the same cases as `rocm_build_date`. | +| `rocm_build_untested` | array of strings | The Quartz test suites (`rocm`, `pytorch`) that report no result for the GPU architecture of that ROCm build. `[]` when both suites tested it. `null` when setup read no Quartz `status.json` (for example `rocm-pin.json` or an unknown `--rocm-version`). See [setup.md](setup.md#rocm-nightly-selection). | | `python_version` | string | Python version. | | `torch_version` | string | `__version__` of `torch/version.py`. | | `amdsmi_available` | bool | `true` when amdsmi loads. Without amdsmi, `gpu_hbm_gb`, `gpu_pcie_link`, `amdgpu_driver_version`, `gpu_power_cap_w`, `gpu_max_sclk_mhz`, `gpu_compute_partition` and all clock values are `null`. | diff --git a/docs/setup.md b/docs/setup.md index 4b2ef60f..7da1b40b 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -20,10 +20,11 @@ stages are: 1. `Virtual environment`: create `/.venv`, or reuse it. See [Reusing a venv](#reusing-a-venv). -2. `PyTorch (--torch-mode rocm)`: detect the GPU architecture, select the - ROCm nightly (see [ROCm nightly selection](#rocm-nightly-selection)) and - install its ROCm PyTorch (`torch[device-]`). Its ROCm SDK - libraries and toolchain are used for the build. +2. `PyTorch (--torch-mode rocm)`: detect the GPU architecture, resolve the + ROCm nightly (from `rocm-pin.json` by default; see + [ROCm nightly selection](#rocm-nightly-selection)) and install its ROCm + PyTorch (`torch[device-]`). Its ROCm SDK libraries and toolchain are + used for the build. 3. `dnn-benchmarking package`: install dnn-benchmarking (editable unless `--no-editable`). 4. `rocm-libraries sources`: fetch `rocm-libraries` if it is absent (see @@ -68,14 +69,14 @@ The setup prints the prefix as `Using hipDNN/ROCm prefix: ...`. | `--torch-mode {rocm,cuda,cpu,existing,none}` | How to provide PyTorch. Default `rocm`. See [Torch modes](#torch-modes). | | `--workspace WORKSPACE` | Root for the venv, the Python bytecode cache and the runtime caches. See [Workspace](#workspace). | | `--no-editable` | Install dnn-benchmarking and the rocKE packages into the venv. The default links to the source tree. | -| `--torch-index-url URL` | pip index URL for PyTorch. In `rocm` mode without `--rocm-version`, setup does not read Quartz and installs the newest build on this index. | -| `--rocm-version VERSION` | ROCm wheel version for `--torch-mode rocm`, for example `10.3.0a20261117`. Default: the newest nightly that Quartz reports as built, with no failed tests for the GPU architecture. See [ROCm nightly selection](#rocm-nightly-selection). | +| `--torch-index-url URL` | pip index URL for PyTorch. In `rocm` mode without `--rocm-version`, setup installs the newest build on this index instead of `rocm-pin.json`. | +| `--rocm-version VERSION` | ROCm wheel version for `--torch-mode rocm`: `latest` (newest usable Quartz nightly) or a specific version such as `10.3.0a20261123`. Default: the version pinned in `rocm-pin.json`. See [ROCm nightly selection](#rocm-nightly-selection). | | `--gpu-arch GPU_ARCH` | GPU architecture for the ROCm PyTorch nightly and the build. See [GPU architecture](#gpu-architecture). | | `--rocm-prefix ROCM_PREFIX` | ROCm and hipDNN prefix for the binding and provider builds. This prefix has priority over the venv ROCm SDK. | | `--reuse-artifacts` | Reuse an installed hipDNN prefix and `hipdnn_frontend` package without building them. `rocm`, `cpu` and `none` need a pre-existing venv with matching PyTorch (`none`: no torch) and reject `--clean` before workspace changes. `existing` keeps the installed torch. CUDA-only setup needs no hipDNN bindings. | | `--no-aiter` | Skip the `AITER` stage. Only `--runtime aiter` needs it. | | `--clean` | Delete and create again the venv, and delete the hipDNN, provider and binding build directories. Not allowed with `--torch-mode existing`. | -| `--rocm-libraries-ref SHA` | Full 40-character `rocm-libraries` commit to fetch when `rocm-libraries/` is absent. Abbreviated SHAs and branch names are rejected. | +| `--rocm-libraries-ref SHA` | Full 40-character `rocm-libraries` commit to fetch when `rocm-libraries/` is absent. Default: matched to `--rocm-version` (`latest` or explicit), else `rocm_libraries_commit` from `rocm-pin.json`. Abbreviated SHAs and branch names are rejected. | | `--cmake-arg NAME=VALUE` | Extra CMake define for the hipDNN and provider configure. Repeatable. See [Extra CMake defines](#extra-cmake-defines). | | `-y`, `--yes` | Answer yes to every prompt. Required when stdin is not a terminal and a prompt would show. | @@ -114,7 +115,7 @@ dnn-benchmarking finds the engine plugins in | Mode | PyTorch | hipDNN and providers | Use | |---|---|---|---| -| `rocm` (default) | ROCm nightly for the detected architecture, selected with Quartz | Built against the ROCm SDK from the PyTorch wheels | Benchmarks on AMD GPUs. | +| `rocm` (default) | ROCm nightly pinned in `rocm-pin.json` (or `--rocm-version latest` via Quartz) | Built against the ROCm SDK from the PyTorch wheels | Benchmarks on AMD GPUs. | | `cuda` | CUDA PyTorch from PyPI, or `--torch-index-url` | Not built. No bindings, no amdsmi, no `ROCM_PATH` | `--runtime pytorch` on NVIDIA GPUs. | | `cpu` | CPU-only PyTorch | Built from source, or reused from the installed prefix with a prepared CPU venv and `--reuse-artifacts`. | CI and `--validate pytorch` with a system ROCm. | | `existing` | Keep the PyTorch in the venv | ROCm PyTorch: its SDK libraries. CUDA PyTorch: the `cuda` path. CPU PyTorch: the installed ROCm. | Reuse a venv. | @@ -214,9 +215,20 @@ On Windows the default is `gfx1151`. ## ROCm nightly selection -[Quartz](https://github.com/ROCm/Quartz) publishes a `status.json` for each -TheRock nightly. In `--torch-mode rocm`, setup reads these files to select -the ROCm nightly that it installs: +By default, `--torch-mode rocm` installs the ROCm nightly and matching +`rocm-libraries` commit checked into `rocm-pin.json`. This keeps the ROCm +PyTorch wheels, MIOpen and `miopen-provider` in lockstep without reading +Quartz on every setup run, and isolates upstream regressions to scheduled bump +PRs (`.github/workflows/bump-rocm-pin.yml`). + +To pull the newest passing nightly directly from +[Quartz](https://github.com/ROCm/Quartz), pass `--rocm-version latest`: + +```bash +python3 setup_env.py --rocm-version latest +``` + +With `--rocm-version latest`, setup reads Quartz's `status.json` files: 1. Setup reads `nightly/latest.json` from `https://raw.githubusercontent.com/ROCm/quartz/main/`. This gives the build @@ -240,7 +252,8 @@ the ROCm nightly that it installs: 3. Setup installs `rocm[libraries,devel,device-]==` and `torch[device-]` from that wheels URL. The torch wheel requires the `rocm` version that it was built with, so pip installs the torch of the - same nightly. + same nightly. Setup also resolves the `rocm-libraries` commit pinned by + that nightly's `therock_commit` in `ROCm/TheRock`. 4. When no nightly in the 14 days qualifies, setup stops with an error that lists each nightly and each reason it was rejected, for example `linux rocm tests of gfx94X-dcgpu are failure`. Setup does not install an @@ -249,7 +262,7 @@ the ROCm nightly that it installs: A test entry that is `failure`, `in_progress`, `cancelled` or any value other than `success` rejects the nightly. A missing test entry does not: Quartz does not run every suite on every architecture. For example, the -nightlies 20261113 to 20261119 have no ROCm test entry for `gfx950-dcgpu`. +nightlies 20261113 to 20261123 have no ROCm test entry for `gfx950-dcgpu`. Setup then accepts the nightly, prints the suites without a result, and records them as untested. @@ -258,7 +271,7 @@ Setup does not read the test counters, `pipelines.pytorch.test_full` or that often fail, so almost no nightly has an overall `success`. Setup also stops when a `status.json` has a schema major other than 2. -To install a known build, for example to repeat an older run, give its +To install a specific build, for example to repeat an older run, give its version: ```bash @@ -269,41 +282,52 @@ Setup installs that version even when Quartz reports it as failed, and shows a warning that names each failed build or test of the GPU architecture. `--torch-index-url` gives another index. `--torch-index-url` without `--rocm-version` installs the newest build on that index and does not read -Quartz. +`rocm-pin.json` or Quartz. After the install, setup writes `/.venv/dnn-bench-rocm-build.json`: -the ROCm wheel version, the TheRock build date and commit from Quartz, the -untested suites (`untested`, for example `["rocm"]`), the `status.json` URL, -the index URL, and what selected the build (`quartz`, `--rocm-version` or -`--torch-index-url`). The build date, commit and untested suites are `null` -when Quartz has no `status.json` for the version. Result files copy them to -`environment.rocm_build_version`, `environment.rocm_build_date`, -`environment.therock_commit` and `environment.rocm_build_untested` (see +the ROCm wheel version, the TheRock build date and commit, the matched +`rocm-libraries` commit, the untested suites (`untested`, for example +`["rocm"]` when selected via Quartz, or `null` when selected from +`rocm-pin.json`), the `status.json` URL, the index URL, and what selected the +build (`rocm-pin.json`, `quartz`, `--rocm-version` or `--torch-index-url`). +Result files copy the build fields to `environment.rocm_build_version`, +`environment.rocm_build_date`, `environment.therock_commit` and +`environment.rocm_build_untested` (see [results-schema.md](results-schema.md#environment)). -CI (`setup.yml` gpu-test and `check-deserialize.yml`) uses the selected -nightly. `check-deserialize.yml` builds for `gfx942`, because Quartz reports -failed `gfx90a` ROCm tests on most nightlies. To use a known build instead, -set the `ROCM_VERSION` repository variable. Each job prints the ROCm build -and its untested suites in its log and in the job summary. +CI (`setup.yml` gpu-test and `check-deserialize.yml`) uses `rocm-pin.json`. +To test another build in CI, set the `ROCM_VERSION` repository variable (for +example `latest` or a specific version). Each job prints the ROCm build and +`rocm-libraries` commit in its log and in the job summary. The scheduled +`.github/workflows/bump-rocm-pin.yml` workflow opens PRs to advance +`rocm-pin.json` to the newest Quartz nightly passing Linux `gfx942` and +`gfx950` tests and Windows `gfx1151` builds. When the `ROCM_PIN_BUMP_TOKEN` +repository secret is configured, GitHub runs `gpu-tests` and +`check-deserialize` on each bump PR automatically. ## rocm-libraries source -`rocm-libraries/` is a git submodule. It holds the hipDNN and provider -sources. - -- When `rocm-libraries/` is absent, setup does a sparse, blobless clone of - the pinned submodule commit (`git rev-parse HEAD:rocm-libraries`). The clone - contains only `cmake`, `shared/ctest`, `projects/hipdnn` and - `dnn-providers`, not the full monorepo. `shared/ctest` carries the CMake +`rocm-libraries/` is cloned on demand by `setup_env.py` (it is gitignored, +not a git submodule). It holds the hipDNN and provider sources. + +- When `rocm-libraries/` is absent, setup does a sparse, blobless clone from + `https://github.com/ROCm/rocm-libraries.git`. It selects the commit in this + order: + 1. `--rocm-libraries-ref SHA`, when passed. + 2. In `--torch-mode rocm` (or `--torch-mode existing` with a ROCm venv that + has `dnn-bench-rocm-build.json`), the `rocm_libraries_commit` recorded + for the installed ROCm build (from `rocm-pin.json` by default, or + resolved from `ROCm/TheRock` at the Quartz nightly's `therock_commit` + when `--rocm-version latest` or an explicit `--rocm-version` was used). + 3. Otherwise (`--torch-mode cpu`, `--torch-mode none`, a custom + `--torch-index-url` without `--rocm-version`, or a `--rocm-version` + unknown to Quartz), `rocm_libraries_commit` from `rocm-pin.json`. + The clone contains only `.dvc`, `cmake`, `shared/ctest`, `projects/hipdnn` + and `dnn-providers`, not the full monorepo. `shared/ctest` carries the CMake file that declares hipDNN's test categories; the rest of `shared/` (Tensile and friends) stays out. -- Where no git metadata exists (Docker builds, source tarballs), give - `--rocm-libraries-ref SHA`. Without it, setup uses the moving - `.gitmodules` branch and shows a warning. -- Setup uses an existing checkout as it is. A checkout from - `git submodule update --init` also works. Setup shows a warning when the - checkout is not at the pinned commit. When that checkout is sparse and was +- Setup uses an existing checkout as it is. Setup shows a warning when the + checkout is not at the expected commit. When that checkout is sparse and was made by an older setup, the root directories added since are added to its sparse set; a full checkout is left alone. @@ -469,18 +493,20 @@ from the local checkout: | `--container-command CMD` | `docker` | Container command. | | `--device-target TARGET` | `gfx942` | ROCm PyTorch architecture: `gfx90a`, `gfx942`, `gfx950`, `gfx1151` or `gfx1152`. | | `--tag TAG` | `dnn-benchmark-performance:` | Image tag. | -| `--rocm-version VERSION` | newest usable Quartz nightly | ROCm wheel version to install. | +| `--rocm-version VERSION` | `rocm-pin.json` | ROCm wheel version to install (`latest` for Quartz, or a specific version). | +| `--rocm-libraries-ref SHA` | matched to `--rocm-version` | Full 40-character `rocm-libraries` commit to build. | | `-- ARGS...` | none | More arguments for the container build command. | -The script passes the pinned `rocm-libraries` commit to the build, because -the build context has no `.git`. The script also selects the ROCm nightly for -`--device-target` on the host, as in -[ROCm nightly selection](#rocm-nightly-selection), unless `--rocm-version` -names one. The host thus needs `python3`. When no nightly qualifies for the -device target, for example while Quartz reports failed `gfx90a` tests, the -script stops; then pass `--rocm-version`. The script passes the version as -the `ROCM_VERSION` build argument and the wheels URL as -`ROCM_TORCH_INDEX_URL`. A new nightly thus rebuilds the setup layer. The +By default, the script reads `rocm-pin.json` on the host (requiring only +`python3`, with no network or host `git` call) and passes `ROCM_VERSION`, +`ROCM_LIBRARIES_REF` and `ROCM_TORCH_INDEX_URL` to the build. When +`--rocm-version latest` or another version is passed, it queries Quartz and +resolves the matching `rocm-libraries` commit from `ROCm/TheRock` on the host +(requiring `git` and HTTPS access to `github.com`), unless +`--rocm-libraries-ref` overrides it. Both `ROCM_VERSION` and +`ROCM_LIBRARIES_REF` are declared after the `apt-get` stage, so a new pin +reuses the apt layer and rebuilds only the setup layer. A direct `docker build` +without build arguments reads `rocm-pin.json` from the build context. The image carries the ROCm version in the label `com.amd.dnn-benchmark.rocm-version`: diff --git a/rocm-libraries b/rocm-libraries deleted file mode 160000 index 28f91cf4..00000000 --- a/rocm-libraries +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 28f91cf4b8f3e518c5b36cbdb6faaa2a36d631e3 diff --git a/rocm-pin.json b/rocm-pin.json new file mode 100644 index 00000000..d14b26fd --- /dev/null +++ b/rocm-pin.json @@ -0,0 +1,7 @@ +{ + "rocm_version": "10.3.0a20261123", + "build_date": "20261123", + "therock_commit": "eaa2f988a7330c3e0d54c4bc7b52d06fda40c8ed", + "rocm_libraries_commit": "6b5f0a16f7562fdb94fe4405836998322b507431", + "index_url": "https://nightly.repo.amd.com/rocm/whl-next/" +} diff --git a/setup_env.py b/setup_env.py index d56e36c6..ace19f6c 100755 --- a/setup_env.py +++ b/setup_env.py @@ -34,6 +34,7 @@ import stat import subprocess import sys +import tempfile import time import urllib.error import urllib.request @@ -44,7 +45,9 @@ IS_WINDOWS = platform.system() == "Windows" SCRIPT_DIR = Path(__file__).resolve().parent +ROCM_PIN_FILE = SCRIPT_DIR / "rocm-pin.json" ROCM_LIBRARIES_DIR = SCRIPT_DIR / "rocm-libraries" +ROCM_LIBRARIES_REPO_URL = "https://github.com/ROCm/rocm-libraries.git" # Root directories that setup and the hipDNN/provider configure read. Only # shared/ctest supplies a file from shared; the rest of that tree is unnecessary. ROCM_LIBRARIES_ROOT_DIRS = (".dvc", "cmake", "shared/ctest") @@ -112,6 +115,10 @@ def aiter_build_requires(aiter_dir: Path) -> list[str]: # The ROCm wheel version of a nightly, for example 10.3.0a20261117. The group # is the build date. _NIGHTLY_VERSION = re.compile(r"\d+\.\d+\.\d+a(\d{8})") +# TheRock repository whose rocm-libraries submodule gitlink supplies the +# rocm-libraries commit that a Quartz-selected ROCm nightly was built from. +THEROCK_REPO_URL = "https://github.com/ROCm/TheRock.git" +THEROCK_ROCM_LIBRARIES_PATH = "rocm-libraries" # Windows has no rocm_agent_enumerator/rocminfo to detect the local arch with, # so fall back to a default target known to have published wheels. @@ -238,10 +245,10 @@ class RocmBuild: ``rocm_version`` is the ROCm wheel version that pip pins; "" installs the newest build on ``index_url``. ``build_date``, ``therock_commit``, - ``status_url`` and ``untested`` come from the Quartz status.json, or are - None when setup did not read one. ``untested`` names the Quartz test - suites with no result for the GPU architecture. ``source`` names what - selected the build. + ``status_url``, ``untested`` and ``rocm_libraries_commit`` come from + ``rocm-pin.json`` or Quartz, or are None when unavailable. ``untested`` + names the Quartz test suites with no result for the GPU architecture. + ``source`` names what selected the build. """ rocm_version: str @@ -251,6 +258,7 @@ class RocmBuild: therock_commit: Optional[str] = None status_url: Optional[str] = None untested: Optional[Tuple[str, ...]] = None + rocm_libraries_commit: Optional[str] = None def quartz_platform() -> str: @@ -345,16 +353,23 @@ def quartz_arch_tests( return results, tuple(untested) -def quartz_rejection(document: dict, platform_name: str, gpu_arch: str) -> str: +def quartz_rejection( + document: dict, + platform_name: str, + gpu_arch: str, + *, + check_tests: bool = True, +) -> str: """Why the build cannot supply ROCm PyTorch for ``gpu_arch``; "" if it can. Setup needs the ROCm and the PyTorch build of ``platform_name`` to be - ``success``, and ``gpu_arch`` among the built architectures. The ROCm and - PyTorch tests of ``gpu_arch`` must be ``success`` when Quartz has them; a - suite with no entry for ``gpu_arch`` does not reject the build. Setup does - not read the test counters or ``overall_status``: they fold in every - architecture, and some are routinely red. The result names every check - that fails, separated by "; ". + ``success``, and ``gpu_arch`` among the built architectures. When + ``check_tests`` is True, the ROCm and PyTorch tests of ``gpu_arch`` must + also be ``success`` when Quartz has them; a suite with no entry for + ``gpu_arch`` does not reject the build. Setup does not read the test + counters or ``overall_status``: they fold in every architecture, and some + are routinely red. The result names every check that fails, separated by + "; ". """ if document.get("release_type") != "nightly": return f"release_type is {document.get('release_type')!r}, not 'nightly'" @@ -374,10 +389,13 @@ def quartz_rejection(document: dict, platform_name: str, gpu_arch: str) -> str: reasons.append(f"{platform_name} {pipeline} build is {status or 'absent'}") if not summary.get("urls", {}).get("wheels"): reasons.append(f"no {platform_name} wheels URL") - results, _ = quartz_arch_tests(document, platform_name, gpu_arch) - for suite, (target, status) in results.items(): - if status != "success": - reasons.append(f"{platform_name} {suite} tests of {target} are {status}") + if check_tests: + results, _ = quartz_arch_tests(document, platform_name, gpu_arch) + for suite, (target, status) in results.items(): + if status != "success": + reasons.append( + f"{platform_name} {suite} tests of {target} are {status}" + ) return "; ".join(reasons) @@ -424,13 +442,19 @@ def _newest_quartz_nightly() -> datetime.date: fail(f"{url} names no nightly build date: {body.strip()[:80]!r}") -def select_quartz_nightly(platform_name: str, gpu_arch: str) -> RocmBuild: - """The newest nightly that Quartz reports usable for ``gpu_arch``. +def select_quartz_nightly_for_archs( + platform_name: str, + gpu_archs: Tuple[str, ...], + index_url: str = "", + *, + require_platform_builds: Tuple[Tuple[str, str], ...] = (), +) -> RocmBuild: + """The newest nightly that Quartz reports usable for every arch in ``gpu_archs``. - Setup starts at ``nightly/latest.json`` and goes back one day at a time, - QUARTZ_LOOKBACK_DAYS days in total, because the newest nightly can be - failed or still running. It exits with every rejected build and its - reason when no build qualifies. + ``require_platform_builds`` takes additional ``(platform, gpu_arch)`` pairs + whose ROCm and PyTorch builds and wheels URL must also be ``success`` (for + example ``(("windows", "gfx1151"),)`` when bumping ``rocm-pin.json``), + without rejecting on flaky test entries for those extra platforms. """ newest = _newest_quartz_nightly() rejected = [] @@ -442,21 +466,41 @@ def select_quartz_nightly(platform_name: str, gpu_arch: str) -> RocmBuild: rejected.append(f" {build_date}: no status.json") continue document = _parse_quartz_status(url, body) - reason = quartz_rejection(document, platform_name, gpu_arch) - if reason: + reasons = [] + for arch in gpu_archs: + reason = quartz_rejection(document, platform_name, arch) + if reason and reason not in reasons: + reasons.append(reason) + for extra_platform, extra_arch in require_platform_builds: + reason = quartz_rejection( + document, extra_platform, extra_arch, check_tests=False + ) + if reason and reason not in reasons: + reasons.append(reason) + if reasons: rejected.append( - f" {build_date} ({document.get('rocm_version')}): {reason}" + f" {build_date} ({document.get('rocm_version')}): {'; '.join(reasons)}" ) continue - return _rocm_build_from_quartz(document, url, platform_name, gpu_arch, "quartz") + return _rocm_build_from_quartz( + document, url, platform_name, gpu_archs[0], "quartz", index_url + ) + arch_list = ", ".join(gpu_archs) fail( - f"Quartz reports no usable ROCm nightly for {platform_name} {gpu_arch} in " + f"Quartz reports no usable ROCm nightly for {platform_name} {arch_list} in " f"the {QUARTZ_LOOKBACK_DAYS} days up to {newest:%Y%m%d}:", *rejected, "Pass --rocm-version VERSION to install a specific build.", ) +def select_quartz_nightly( + platform_name: str, gpu_arch: str, index_url: str = "" +) -> RocmBuild: + """The newest nightly that Quartz reports usable for ``gpu_arch``.""" + return select_quartz_nightly_for_archs(platform_name, (gpu_arch,), index_url) + + def describe_rocm_version( rocm_version: str, index_url: str, platform_name: str, gpu_arch: str ) -> RocmBuild: @@ -491,6 +535,144 @@ def describe_rocm_version( ) +def read_rocm_pin(path: Optional[Path] = None) -> RocmBuild: + """Read the checked-in ROCm + rocm-libraries pin from ``rocm-pin.json``.""" + pin_path = ROCM_PIN_FILE if path is None else path + try: + data = json.loads(pin_path.read_text(encoding="utf-8")) + except (OSError, ValueError) as exc: + fail( + f"cannot read ROCm pin file {pin_path}: {exc}.", + "Restore rocm-pin.json, or pass --rocm-version and --rocm-libraries-ref.", + ) + if not isinstance(data, dict): + fail(f"{pin_path} must contain a JSON object.") + rocm_version = str(data.get("rocm_version") or "").strip() + if not re.fullmatch(r"[0-9][0-9A-Za-z.+!-]*", rocm_version): + fail( + f"{pin_path} has invalid rocm_version {data.get('rocm_version')!r}.", + "Expected a ROCm wheel version such as 10.3.0a20261123.", + ) + rocm_libraries_commit = str(data.get("rocm_libraries_commit") or "").strip().lower() + if not re.fullmatch(r"[0-9a-f]{40}", rocm_libraries_commit): + fail( + f"{pin_path} has invalid rocm_libraries_commit " + f"{data.get('rocm_libraries_commit')!r}.", + "Expected a 40-character commit SHA.", + ) + therock_raw = data.get("therock_commit") + therock_commit: Optional[str] = None + if therock_raw: + therock_commit = str(therock_raw).strip().lower() + if not re.fullmatch(r"[0-9a-f]{40}", therock_commit): + fail( + f"{pin_path} has invalid therock_commit {therock_raw!r}.", + "Expected a 40-character commit SHA.", + ) + build_date = str(data.get("build_date") or "").strip() or None + index_url = str(data.get("index_url") or "").strip() or ROCM_TORCH_INDEX_URL + status_url = _quartz_status_url(build_date) if build_date else None + return RocmBuild( + rocm_version=rocm_version, + index_url=index_url, + source=pin_path.name, + build_date=build_date, + therock_commit=therock_commit, + status_url=status_url, + untested=None, + rocm_libraries_commit=rocm_libraries_commit, + ) + + +def _fetch_therock_rocm_libraries_commit( + therock_commit: str, repo_url: Optional[str] = None +) -> str: + """Resolve the rocm-libraries gitlink at ``therock_commit`` in TheRock. + + Raises ``RuntimeError`` on invalid input, missing git, fetch failure, or a + missing submodule entry so callers can choose fatal vs advisory handling. + """ + url = repo_url or THEROCK_REPO_URL + commit = therock_commit.strip().lower() + if not re.fullmatch(r"[0-9a-f]{40}", commit): + raise RuntimeError( + f"expected a 40-character TheRock commit SHA, got {therock_commit!r}." + ) + with tempfile.TemporaryDirectory(prefix="therock-ref-") as tmp: + git = ["-C", tmp] + try: + git_output(["init", "--bare", "--quiet", tmp]) + git_output( + [ + *git, + "fetch", + "--quiet", + "--depth", + "1", + "--filter=tree:0", + url, + commit, + ] + ) + entry = git_output( + [*git, "ls-tree", "FETCH_HEAD", "--", THEROCK_ROCM_LIBRARIES_PATH] + ) + except FileNotFoundError as exc: + raise RuntimeError( + f"git not found on PATH; cannot resolve {THEROCK_ROCM_LIBRARIES_PATH} " + f"commit for TheRock {commit}." + ) from exc + except subprocess.CalledProcessError as exc: + detail = (exc.stderr or exc.stdout or "").strip() + msg = ( + f"cannot resolve {THEROCK_ROCM_LIBRARIES_PATH} commit for " + f"TheRock {commit} from {url}." + ) + if detail: + msg = f"{msg}\n{detail}" + raise RuntimeError(msg) from exc + parts = entry.split() + if ( + len(parts) != 4 + or parts[0] != "160000" + or parts[1] != "commit" + or not re.fullmatch(r"[0-9a-f]{40}", parts[2]) + or parts[3] != THEROCK_ROCM_LIBRARIES_PATH + ): + raise RuntimeError( + f"TheRock commit {commit} has no '{THEROCK_ROCM_LIBRARIES_PATH}' " + f"submodule entry in {url} (got {entry!r})." + ) + return parts[2] + + +def resolve_therock_rocm_libraries_commit( + therock_commit: str, + repo_url: Optional[str] = None, + *, + required: bool = True, +) -> Optional[str]: + """The rocm-libraries submodule commit pinned by ``therock_commit`` in TheRock. + + Uses a bare, tree-filtered git fetch of the single commit (~10 KB, no + GitHub REST API rate limit) and reads the ``rocm-libraries`` gitlink via + ``git ls-tree``. When ``required`` is True, exits with an actionable error + on failure; when False (advisory check for an existing checkout), warns and + returns None. + """ + try: + return _fetch_therock_rocm_libraries_commit(therock_commit, repo_url) + except RuntimeError as exc: + lines = str(exc).splitlines() + if required: + fail( + *lines, + "Pass --rocm-libraries-ref to select rocm-libraries explicitly.", + ) + warn(*lines, "Keeping the existing rocm-libraries/ checkout.") + return None + + def default_workspace() -> Path: """Env override, else /workspace when present and writable (Linux only), else /.workspace.""" @@ -746,11 +928,14 @@ def _commit_sha(value: str) -> str: def _rocm_version(value: str) -> str: - """--rocm-version: a ROCm wheel version such as 10.3.0a20261117.""" + """--rocm-version: 'latest' (Quartz) or a wheel version such as 10.3.0a20261123.""" version = value.strip() + if version.lower() == "latest": + return "latest" if not re.fullmatch(r"[0-9][0-9A-Za-z.+!-]*", version): raise argparse.ArgumentTypeError( - f"expected a ROCm wheel version such as 10.3.0a20261117, got {value!r}" + f"expected 'latest' or a ROCm wheel version such as 10.3.0a20261123, " + f"got {value!r}" ) return version @@ -793,9 +978,8 @@ def build_parser() -> argparse.ArgumentParser: default="rocm", help=( "Select how torch is provided. Default: rocm\n" - " rocm: install the ROCm torch nightly that Quartz reports as " - "built, with no failed tests for the GPU arch (see --rocm-version), " - "use ROCm libraries/toolchain " + " rocm: install the ROCm torch nightly pinned in rocm-pin.json " + "(or --rocm-version latest / VERSION), use ROCm libraries/toolchain " "from the torch wheel's bundled ROCm SDK packages, and build local " "hipDNN/provider artifacts when absent.\n" " cuda: install CUDA torch from PyPI (or --torch-index-url) for the " @@ -844,13 +1028,12 @@ def build_parser() -> argparse.ArgumentParser: default=None, metavar="VERSION", help=( - "ROCm wheel version for --torch-mode rocm, for example " - "10.3.0a20261117. Setup installs it even when Quartz reports it " - "failed, to reproduce an older run. Default: the newest nightly " - f"of the last {QUARTZ_LOOKBACK_DAYS} days whose ROCm and PyTorch " - "builds Quartz reports as success for the GPU architecture, with " - "no failed or unfinished ROCm or PyTorch tests of that " - "architecture." + "ROCm wheel version for --torch-mode rocm: 'latest' (the newest " + f"nightly of the last {QUARTZ_LOOKBACK_DAYS} days that Quartz " + "reports usable for the GPU architecture) or a specific version " + "such as 10.3.0a20261123 (installed even when Quartz reports it " + "failed, to reproduce an older run). Default: the version pinned " + "in rocm-pin.json." ), ) parser.add_argument( @@ -912,10 +1095,10 @@ def build_parser() -> argparse.ArgumentParser: help=( "Full 40-character rocm-libraries commit to fetch when " "rocm-libraries/ is absent. " - "Default: the submodule commit pinned in this repository (`git " - "rev-parse HEAD:rocm-libraries`). Needed where no git metadata " - "exists (Docker builds, source tarballs); without it setup falls " - "back to the moving .gitmodules branch and warns." + "Default: in rocm mode with --rocm-version latest or a " + "Quartz-known --rocm-version, the rocm-libraries commit pinned by " + "that nightly's TheRock commit; otherwise rocm_libraries_commit " + "from rocm-pin.json." ), ) parser.add_argument( @@ -1021,29 +1204,74 @@ def require_python_version() -> None: # -- rocm-libraries checkout -------------------------------------------- + def _resolve_rocm_libraries_ref( + self, *, required: bool = True + ) -> Tuple[str, str, Optional[str]]: + """Return ``(ref, source, therock_commit)`` for the rocm-libraries checkout. + + Precedence: + 1. Explicit ``--rocm-libraries-ref``. + 2. In ``rocm`` mode (or ``existing`` on a ROCm venv), the cached + ``rocm_libraries_commit`` in ``ROCM_BUILD_RECORD`` (already set when + installed from ``rocm-pin.json``), or resolved from its Quartz + ``therock_commit`` via ``ROCm/TheRock`` so ``miopen-provider`` and + hipDNN stay in lockstep with the wheel's MIOpen. + 3. ``rocm_libraries_commit`` from the checked-in ``rocm-pin.json``. + """ + if self.rocm_libraries_ref: + return self.rocm_libraries_ref, "--rocm-libraries-ref", None + if self.installed_torch_mode == "rocm": + record = self._read_venv_record(ROCM_BUILD_RECORD) + if record: + therock_commit = record.get("therock_commit") + if not isinstance(therock_commit, str) or not therock_commit: + therock_commit = None + recorded_ref = record.get("rocm_libraries_commit") + if isinstance(recorded_ref, str) and re.fullmatch( + r"[0-9a-f]{40}", recorded_ref + ): + source = str(record.get("source") or "quartz") + return recorded_ref, source, therock_commit + if therock_commit: + print( + "Resolving rocm-libraries commit for TheRock " + f"{therock_commit[:12]}..." + ) + ref = resolve_therock_rocm_libraries_commit( + therock_commit, required=required + ) + if ref is None: + return "", "quartz", therock_commit + record["rocm_libraries_commit"] = ref + try: + (self.venv_dir / ROCM_BUILD_RECORD).write_text( + json.dumps(record) + "\n" + ) + except OSError: + pass + return ref, "quartz", therock_commit + pin = read_rocm_pin() + return pin.rocm_libraries_commit or "", pin.source, pin.therock_commit + def ensure_rocm_libraries_checkout(self) -> None: """Fetch rocm-libraries if absent. - It is a git submodule (see .gitmodules), so `git submodule update - --init` also works. This is the fast path used only when the directory - isn't already a checkout: a sparse, blobless clone of the pinned - submodule commit (or --rocm-libraries-ref), limited to the hipDNN/ - provider sources and root CMake tooling this script builds. - To build against a different ref, check it out directly, e.g. + Clones a sparse, blobless checkout of the resolved commit + (--rocm-libraries-ref, else the commit matched to the installed ROCm + build, else rocm-pin.json), limited to the hipDNN/provider sources and + root CMake tooling this script builds. To build against a different + ref, check it out directly, e.g. `git -C rocm-libraries fetch --depth 1 origin && git -C rocm-libraries checkout FETCH_HEAD`. """ - gitmodules = str(SCRIPT_DIR / ".gitmodules") - ref = self.rocm_libraries_ref or self._pinned_submodule_commit( - "rocm-libraries", - "The hipDNN/provider build is not reproducible. Pass " - "--rocm-libraries-ref (`git rev-parse " - "HEAD:rocm-libraries` in a checkout of this repository).", + has_checkout = (ROCM_LIBRARIES_DIR / ".git").exists() + ref, source, therock_commit = self._resolve_rocm_libraries_ref( + required=not has_checkout ) # Only a full commit id can be compared with HEAD; a branch moves. pinned = re.fullmatch(r"[0-9a-f]{40}", ref) is not None - if (ROCM_LIBRARIES_DIR / ".git").exists(): + if has_checkout: # A sparse clone made by an older setup lacks root dirs added since. missing = [ path @@ -1058,11 +1286,24 @@ def ensure_rocm_libraries_checkout(self) -> None: # sparse clone would otherwise go unnoticed. head = git_output(["-C", str(ROCM_LIBRARIES_DIR), "rev-parse", "HEAD"]) if pinned and head != ref: - warn( - f"rocm-libraries is at {head[:12]}, not the pinned {ref[:12]}. " - "Check out that commit in rocm-libraries/ (e.g. `git submodule " - "update rocm-libraries`) or delete the directory to fetch it." - ) + if source == "quartz": + therock_note = ( + f" (matched to TheRock {therock_commit[:12]})" + if therock_commit + else " (matched to the Quartz ROCm nightly)" + ) + warn( + f"rocm-libraries is at {head[:12]}, not {ref[:12]}" + f"{therock_note}. Check out that commit in " + "rocm-libraries/ or delete the directory to fetch it " + "(or pass --rocm-libraries-ref to override)." + ) + else: + warn( + f"rocm-libraries is at {head[:12]}, not the pinned " + f"{ref[:12]}. Check out that commit in rocm-libraries/ " + "or delete the directory to fetch it." + ) if not (ROCM_LIBRARIES_DIR / "CMakePresets.json").is_file(): warn( "rocm-libraries/CMakePresets.json is missing (a non-cone " @@ -1070,14 +1311,13 @@ def ensure_rocm_libraries_checkout(self) -> None: ) return - # An uninitialised submodule leaves an empty directory; anything else - # here is not ours to delete without asking. + # Leave any non-empty non-git directory intact unless confirmed. if ROCM_LIBRARIES_DIR.exists() and any(ROCM_LIBRARIES_DIR.iterdir()): self._confirm( f"replace {ROCM_LIBRARIES_DIR}, which is not a git checkout and " "is not empty" ) - url = git_output(["config", "-f", gitmodules, "submodule.rocm-libraries.url"]) + url = ROCM_LIBRARIES_REPO_URL print( f"Fetching rocm-libraries ({ref}) via sparse checkout " f"({', '.join(ROCM_LIBRARIES_SPARSE_DIRS)})..." @@ -1699,17 +1939,28 @@ def install_torch(self) -> None: self.write_rocm_build_record(build) def select_rocm_build(self, arch: str) -> RocmBuild: - """The ROCm build to install: --rocm-version, else the newest build on - --torch-index-url, else the newest nightly that Quartz reports usable.""" + """The ROCm build to install: --rocm-version (latest or explicit), else + the newest build on --torch-index-url, else rocm-pin.json.""" platform_name = quartz_platform() + if self.rocm_version == "latest": + print( + f"Selecting the newest ROCm nightly from Quartz ({QUARTZ_NIGHTLY_URL})" + ) + return select_quartz_nightly(platform_name, arch, self.torch_index_url) if self.rocm_version: + if ROCM_PIN_FILE.is_file(): + pin = read_rocm_pin() + if pin.rocm_version == self.rocm_version: + return dataclasses.replace( + pin, + index_url=self.torch_index_url or pin.index_url, + ) return describe_rocm_version( self.rocm_version, self.torch_index_url, platform_name, arch ) if self.torch_index_url: return RocmBuild("", self.torch_index_url, "--torch-index-url") - print(f"Selecting the ROCm nightly from Quartz ({QUARTZ_NIGHTLY_URL})") - return select_quartz_nightly(platform_name, arch) + return read_rocm_pin() def install_rocm_torch(self, build: RocmBuild, arch: str) -> None: """Install ROCm PyTorch and the ROCm SDK wheels of ``build``.""" @@ -1760,6 +2011,7 @@ def write_rocm_build_record(self, build: RocmBuild) -> None: "rocm_version": build.rocm_version or self.installed_rocm_version(), "build_date": build.build_date, "therock_commit": build.therock_commit, + "rocm_libraries_commit": build.rocm_libraries_commit, "source": build.source, "status_url": build.status_url, "index_url": build.index_url, @@ -1817,6 +2069,13 @@ def require_same_torch_source(self, check_arch: bool = False) -> None: ("--torch-index-url", self.torch_index_url, TORCH_RECORD, "torch_index_url") ] if check_arch: + if self.rocm_version == "latest": + fail( + "--rocm-version latest requests a fresh Quartz nightly and " + f"cannot reuse {self.venv_dir}.", + "Pass --clean to recreate the virtual environment, or omit " + "--rocm-version to keep the installed build.", + ) checks.append( ("--gpu-arch", self.gpu_arch_override, TORCH_RECORD, "gpu_arch") ) diff --git a/tests/unit/test_setup_env.py b/tests/unit/test_setup_env.py index ce21cd0a..90f0e336 100644 --- a/tests/unit/test_setup_env.py +++ b/tests/unit/test_setup_env.py @@ -39,10 +39,20 @@ def setup_env(): @pytest.fixture(autouse=True) def _no_quartz_network(setup_env, monkeypatch): - def refuse(url): + def refuse_url(url): raise AssertionError(f"unit test fetched {url}") - monkeypatch.setattr(setup_env, "fetch_quartz_text", refuse) + def refuse_therock( + therock_commit, repo_url=setup_env.THEROCK_REPO_URL, *, required=True + ): + raise AssertionError( + f"unit test resolved TheRock {therock_commit} from {repo_url}" + ) + + monkeypatch.setattr(setup_env, "fetch_quartz_text", refuse_url) + monkeypatch.setattr( + setup_env, "resolve_therock_rocm_libraries_commit", refuse_therock + ) def _quartz_document(build_date: str) -> dict: @@ -617,14 +627,23 @@ def rocm_libraries(setup_env, tmp_path, monkeypatch): repo = tmp_path / "repo" repo.mkdir() - (repo / ".gitmodules").write_text( - '[submodule "rocm-libraries"]\n' - "\tpath = rocm-libraries\n" - f"\turl = {origin.as_uri()}\n" - "\tbranch = main\n" + pin_file = repo / "rocm-pin.json" + pin_file.write_text( + json.dumps( + { + "rocm_version": _RECORDED_ROCM_VERSION, + "build_date": "20261115", + "therock_commit": "62d1ac21a0eda4df3871c6c8d4570cb0ee9a4637", + "rocm_libraries_commit": _head(src), + "index_url": setup_env.ROCM_TORCH_INDEX_URL, + } + ) + + "\n" ) monkeypatch.setattr(setup_env, "SCRIPT_DIR", repo) + monkeypatch.setattr(setup_env, "ROCM_PIN_FILE", pin_file) monkeypatch.setattr(setup_env, "ROCM_LIBRARIES_DIR", repo / "rocm-libraries") + monkeypatch.setattr(setup_env, "ROCM_LIBRARIES_REPO_URL", origin.as_uri()) return repo / "rocm-libraries" @@ -1422,14 +1441,15 @@ def _recorded_environment(setup, monkeypatch) -> dict: ), ], ) -def test_rocm_install_pins_the_selected_nightly_and_records_it( +def test_rocm_install_latest_pins_the_selected_nightly_and_records_it( setup_env, tmp_path, monkeypatch, quartz, capsys, arch, latest, environment ) -> None: quartz.latest = latest - setup, pip_calls = _fresh_rocm_setup(setup_env, tmp_path, monkeypatch, arch=arch) + setup, pip_calls = _fresh_rocm_setup( + setup_env, tmp_path, monkeypatch, "--rocm-version", "latest", arch=arch + ) setup.install_torch() - assert pip_calls == [ ( "install", @@ -1559,6 +1579,345 @@ def test_missing_toolchain_is_installed_at_the_recorded_rocm_version( ] +# --- Checked-in rocm-pin.json & Quartz -> TheRock -> rocm-libraries --------- + + +def test_rocm_install_defaults_to_rocm_pin_without_network( + setup_env, tmp_path, monkeypatch, rocm_libraries +) -> None: + # The autouse guard fails on any Quartz or TheRock network call. + pin = setup_env.read_rocm_pin() + setup, pip_calls = _fresh_rocm_setup( + setup_env, tmp_path, monkeypatch, arch="gfx950" + ) + + setup.install_torch() + setup.ensure_rocm_libraries_checkout() + + assert pip_calls == [ + ( + "install", + "--pre", + "torch[device-gfx950]", + f"rocm[libraries,devel,device-gfx950]=={pin.rocm_version}", + "--index-url", + pin.index_url, + ) + ] + assert _recorded_environment(setup, monkeypatch) == { + "rocm_build_version": pin.rocm_version, + "rocm_build_date": pin.build_date, + "therock_commit": pin.therock_commit, + "rocm_build_untested": None, + } + saved = json.loads((setup.venv_dir / setup_env.ROCM_BUILD_RECORD).read_text()) + assert saved["source"] == "rocm-pin.json" + assert saved["rocm_libraries_commit"] == pin.rocm_libraries_commit + assert _head(rocm_libraries) == pin.rocm_libraries_commit + + +def test_read_rocm_pin_rejects_missing_or_invalid_fields( + setup_env, tmp_path, capsys +) -> None: + missing = tmp_path / "missing.json" + with pytest.raises(SystemExit) as exc: + setup_env.read_rocm_pin(missing) + assert exc.value.code == 1 + assert "cannot read ROCm pin file" in capsys.readouterr().err + + bad = tmp_path / "bad.json" + bad.write_text( + json.dumps( + {"rocm_version": "10.3.0a20261123", "rocm_libraries_commit": "short"} + ) + ) + with pytest.raises(SystemExit) as exc: + setup_env.read_rocm_pin(bad) + assert exc.value.code == 1 + assert "invalid rocm_libraries_commit" in capsys.readouterr().err + + +def test_reused_venv_refuses_rocm_version_latest( + setup_env, tmp_path, monkeypatch, capsys +) -> None: + setup, _ = _reused_venv( + setup_env, tmp_path, monkeypatch, "rocm", "--rocm-version", "latest" + ) + with pytest.raises(SystemExit) as exc: + setup.install_torch() + assert exc.value.code == 1 + assert "--rocm-version latest" in capsys.readouterr().err + + +def test_select_quartz_nightly_for_archs_requires_every_arch(setup_env, quartz) -> None: + # On 20261116, rocm build is in_progress; on 20261115, gfx950 passes but + # gfx942 fails rocm tests; on 20261119 both gfx942 and gfx950 pass. + quartz.latest = "20261119" + build = setup_env.select_quartz_nightly_for_archs("linux", ("gfx942", "gfx950")) + assert build.build_date == "20261119" + + # Make 20261119 fail gfx950 pytorch tests -> must walk back to 20261118. + doc = _quartz_document("20261119") + doc["pipelines"]["pytorch"]["test"]["linux"]["gfx950-dcgpu"]["status"] = "failure" + quartz.documents["20261119"] = doc + build = setup_env.select_quartz_nightly_for_archs("linux", ("gfx942", "gfx950")) + assert build.build_date == "20261118" + + # require_platform_builds checks that the extra platform's builds and wheels + # succeeded (without rejecting on test failures): on 20261119 Windows + # pytorch build is in_progress, so requiring Windows gfx1151 builds walks + # back to a nightly where Windows finished building. + quartz.documents.clear() + build = setup_env.select_quartz_nightly_for_archs( + "linux", + ("gfx942", "gfx950"), + require_platform_builds=(("windows", setup_env.WINDOWS_DEFAULT_GPU_ARCH),), + ) + assert build.build_date == "20261118" + + +def _make_fake_therock_repo( + tmp_path: Path, rocm_libraries_commit: str | None +) -> tuple[Path, str]: + """Create a local bare TheRock repo whose tip optionally pins rocm-libraries.""" + src = tmp_path / "therock-src" + src.mkdir() + _git("init", "-q", "-b", "main", cwd=src) + if rocm_libraries_commit is not None: + _git( + "update-index", + "--add", + "--cacheinfo", + f"160000,{rocm_libraries_commit},rocm-libraries", + cwd=src, + ) + else: + (src / "README.md").write_text("no submodule\n") + _git("add", "README.md", cwd=src) + _git("commit", "-q", "-m", "therock pin", cwd=src) + commit = _head(src) + bare = tmp_path / "therock.git" + _git("clone", "-q", "--bare", str(src), str(bare)) + _git("config", "uploadpack.allowfilter", "true", cwd=bare) + return bare, commit + + +def test_resolve_therock_rocm_libraries_commit_reads_submodule_gitlink( + setup_env, tmp_path, monkeypatch +) -> None: + if shutil.which("git") is None: + pytest.skip("git unavailable") + monkeypatch.undo() + expected_sha = "1234567890abcdef" * 2 + "12345678" + bare, therock_commit = _make_fake_therock_repo(tmp_path, expected_sha) + + resolved = setup_env.resolve_therock_rocm_libraries_commit( + therock_commit, repo_url=bare.as_uri() + ) + + assert resolved == expected_sha + + +def test_resolve_therock_rocm_libraries_commit_fails_when_submodule_missing( + setup_env, tmp_path, monkeypatch, capsys +) -> None: + if shutil.which("git") is None: + pytest.skip("git unavailable") + monkeypatch.undo() + bare, therock_commit = _make_fake_therock_repo(tmp_path, None) + + with pytest.raises(SystemExit) as exc: + setup_env.resolve_therock_rocm_libraries_commit( + therock_commit, repo_url=bare.as_uri() + ) + + assert exc.value.code == 1 + err = capsys.readouterr().err + assert "no 'rocm-libraries' submodule entry" in err + assert "--rocm-libraries-ref" in err + + +def test_resolve_therock_rocm_libraries_commit_rejects_bad_sha( + setup_env, monkeypatch, capsys +) -> None: + monkeypatch.undo() + with pytest.raises(SystemExit) as exc: + setup_env.resolve_therock_rocm_libraries_commit("not-a-sha") + + assert exc.value.code == 1 + assert "40-character TheRock commit SHA" in capsys.readouterr().err + + +def test_resolve_therock_rocm_libraries_commit_handles_missing_git( + setup_env, monkeypatch, capsys +) -> None: + monkeypatch.undo() + + def no_git(*_args, **_kwargs): + raise FileNotFoundError("git") + + monkeypatch.setattr(setup_env, "git_output", no_git) + + with pytest.raises(SystemExit) as exc: + setup_env.resolve_therock_rocm_libraries_commit("f" * 40) + + assert exc.value.code == 1 + err = capsys.readouterr().err + assert "git not found on PATH" in err + assert "--rocm-libraries-ref" in err + + +def _two_commit_rocm_libraries(tmp_path: Path) -> tuple[str, str]: + """Advance the local rocm_libraries origin by one commit; return (first, second).""" + src = tmp_path / "src" + first = _head(src) + (src / "projects/hipdnn/matched.txt").write_text("matched\n") + _git("add", ".", cwd=src) + _git("commit", "-q", "-m", "matched commit", cwd=src) + _git("fetch", "-q", str(src), "main:main", cwd=tmp_path / "origin.git") + return first, _head(src) + + +def test_rocm_mode_checks_out_quartz_matched_rocm_libraries_and_caches_it( + setup_env, tmp_path, monkeypatch, rocm_libraries +) -> None: + _, quartz_sha = _two_commit_rocm_libraries(tmp_path) + therock_sha = "a" * 40 + calls = [] + monkeypatch.setattr( + setup_env, + "resolve_therock_rocm_libraries_commit", + lambda sha, repo_url=setup_env.THEROCK_REPO_URL, *, required=True: ( + calls.append(sha), + quartz_sha, + )[1], + ) + + setup = _setup(setup_env, tmp_path) + setup.venv_dir.mkdir(parents=True) + setup.installed_torch_mode = "rocm" + record_path = setup.venv_dir / setup_env.ROCM_BUILD_RECORD + record_path.write_text( + json.dumps( + {"rocm_version": _RECORDED_ROCM_VERSION, "therock_commit": therock_sha} + ) + ) + + setup.ensure_rocm_libraries_checkout() + + assert calls == [therock_sha] + assert _head(rocm_libraries) == quartz_sha + saved = json.loads(record_path.read_text()) + assert saved["rocm_libraries_commit"] == quartz_sha + + # A second run against the same venv reuses the cached rocm_libraries_commit + # without querying TheRock again. + setup.ensure_rocm_libraries_checkout() + assert calls == [therock_sha] + + +def test_rocm_mode_warns_when_existing_checkout_differs_from_quartz_match( + setup_env, tmp_path, monkeypatch, capsys, rocm_libraries +) -> None: + older_sha, quartz_sha = _two_commit_rocm_libraries(tmp_path) + therock_sha = "b" * 40 + _setup( + setup_env, tmp_path, "--rocm-libraries-ref", older_sha + ).ensure_rocm_libraries_checkout() + assert _head(rocm_libraries) == older_sha + + monkeypatch.setattr( + setup_env, + "resolve_therock_rocm_libraries_commit", + lambda sha, repo_url=setup_env.THEROCK_REPO_URL, *, required=True: quartz_sha, + ) + setup = _setup(setup_env, tmp_path) + setup.venv_dir.mkdir(parents=True) + setup.installed_torch_mode = "rocm" + (setup.venv_dir / setup_env.ROCM_BUILD_RECORD).write_text( + json.dumps( + {"rocm_version": _RECORDED_ROCM_VERSION, "therock_commit": therock_sha} + ) + ) + + setup.ensure_rocm_libraries_checkout() + + assert _head(rocm_libraries) == older_sha + err = capsys.readouterr().err + assert f"not {quartz_sha[:12]} (matched to TheRock {therock_sha[:12]})" in err + + +def test_rocm_mode_reuses_existing_checkout_when_therock_lookup_fails( + setup_env, tmp_path, monkeypatch, capsys, rocm_libraries +) -> None: + older_sha, _ = _two_commit_rocm_libraries(tmp_path) + _setup( + setup_env, tmp_path, "--rocm-libraries-ref", older_sha + ).ensure_rocm_libraries_checkout() + assert _head(rocm_libraries) == older_sha + + missing_repo = (tmp_path / "no-such-therock.git").as_uri() + monkeypatch.undo() + monkeypatch.setattr(setup_env, "ROCM_LIBRARIES_DIR", rocm_libraries) + monkeypatch.setattr(setup_env, "THEROCK_REPO_URL", missing_repo) + setup = _setup(setup_env, tmp_path) + setup.venv_dir.mkdir(parents=True) + setup.installed_torch_mode = "rocm" + (setup.venv_dir / setup_env.ROCM_BUILD_RECORD).write_text( + json.dumps({"rocm_version": _RECORDED_ROCM_VERSION, "therock_commit": "e" * 40}) + ) + + setup.ensure_rocm_libraries_checkout() + + assert _head(rocm_libraries) == older_sha + err = capsys.readouterr().err + assert "WARNING:" in err + assert missing_repo in err + assert "Keeping the existing rocm-libraries/ checkout." in err + + +def test_explicit_rocm_libraries_ref_overrides_quartz_therock_commit( + setup_env, tmp_path, rocm_libraries +) -> None: + explicit_sha, _ = _two_commit_rocm_libraries(tmp_path) + setup = _setup(setup_env, tmp_path, "--rocm-libraries-ref", explicit_sha) + setup.venv_dir.mkdir(parents=True) + setup.installed_torch_mode = "rocm" + record_path = setup.venv_dir / setup_env.ROCM_BUILD_RECORD + record_path.write_text( + json.dumps({"rocm_version": _RECORDED_ROCM_VERSION, "therock_commit": "c" * 40}) + ) + + setup.ensure_rocm_libraries_checkout() + + assert _head(rocm_libraries) == explicit_sha + assert "rocm_libraries_commit" not in json.loads(record_path.read_text()) + + +@pytest.mark.parametrize( + "torch_mode, record", + [ + ("cpu", {"rocm_version": _RECORDED_ROCM_VERSION, "therock_commit": "d" * 40}), + ("rocm", {"rocm_version": _RECORDED_ROCM_VERSION, "therock_commit": None}), + ("rocm", None), + ], + ids=["cpu-mode", "rocm-without-therock-commit", "rocm-without-record"], +) +def test_rocm_libraries_falls_back_to_rocm_pin_without_quartz_therock_commit( + setup_env, tmp_path, rocm_libraries, torch_mode, record +) -> None: + pin_sha, _ = _two_commit_rocm_libraries(tmp_path) + setup = _setup(setup_env, tmp_path, "--torch-mode", torch_mode) + setup.venv_dir.mkdir(parents=True) + setup.installed_torch_mode = torch_mode + if record is not None: + (setup.venv_dir / setup_env.ROCM_BUILD_RECORD).write_text(json.dumps(record)) + + setup.ensure_rocm_libraries_checkout() + + assert _head(rocm_libraries) == pin_sha + + def _host_gpu_archs(setup_env, monkeypatch, archs): """rocm_agent_enumerator reports ``archs`` (plus the CPU agent).""" real_run, real_which = setup_env.subprocess.run, setup_env.shutil.which From 436727c5b74d73452ee00a54d943afe7b7a430ba Mon Sep 17 00:00:00 2001 From: Samuel Reeder Date: Tue, 24 Nov 2026 16:00:38 +0000 Subject: [PATCH 3/4] feat(setup): switch rocm-pin.json to per-arch pins and enable bump PR auto-merge Address review feedback on #147: - Key rocm-pin.json by architecture under archs (gfx90a, gfx942, gfx950, gfx1151) with a default fallback (gfx950), so each arch tracks its own last-known-good ROCm nightly + matched rocm-libraries commit (gfx90a pinned at 10.3.0a20261120 / bd4da658; gfx942, gfx950, gfx1151 at 10.3.0a20261123 / 6b5f0a16). - Update bump-rocm-pin.yml to advance each arch independently from Quartz (leaving failing archs untouched) and enable squash auto-merge on the bump PR (main ruleset blocks direct/force pushes). - Update Docker build script, docs/setup.md, and unit tests. --- .github/workflows/bump-rocm-pin.yml | 258 +++++++++++++----- .../build-dnn-benchmark-performance-image.sh | 2 +- docs/setup.md | 24 +- rocm-pin.json | 36 ++- setup_env.py | 172 ++++++++---- tests/unit/test_setup_env.py | 139 +++++++--- 6 files changed, 461 insertions(+), 170 deletions(-) diff --git a/.github/workflows/bump-rocm-pin.yml b/.github/workflows/bump-rocm-pin.yml index 0cedcc66..9fc37806 100644 --- a/.github/workflows/bump-rocm-pin.yml +++ b/.github/workflows/bump-rocm-pin.yml @@ -11,10 +11,15 @@ on: workflow_dispatch: inputs: rocm_version: - description: 'Optional ROCm nightly version (e.g. 10.3.0a20261123); blank selects newest Quartz nightly passing linux gfx942 + gfx950.' + description: 'Optional ROCm nightly version (e.g. 10.3.0a20261123); blank or latest bumps each arch independently from Quartz.' required: false + type: string default: '' + archs: + description: 'Optional comma-separated archs to update (e.g. gfx942,gfx950); blank updates all archs in rocm-pin.json.' + required: false type: string + default: '' permissions: contents: read @@ -34,16 +39,18 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: python-version: '3.12' - - name: Resolve candidate ROCm pin from Quartz + - name: Resolve per-arch ROCm pins from Quartz id: resolve env: - REQUESTED_VERSION: ${{ inputs.rocm_version }} + REQUESTED_VERSION: ${{ inputs.rocm_version || '' }} + REQUESTED_ARCHS: ${{ inputs.archs || '' }} run: | - python3 - <<'PY' + python - <<'PY' import importlib.util import json import os @@ -53,67 +60,175 @@ jobs: setup_env = importlib.util.module_from_spec(spec) spec.loader.exec_module(setup_env) + # Memoize Quartz HTTP fetches across arch checks. + _real_fetch = setup_env.fetch_quartz_text + _fetch_cache: dict[str, str | None] = {} + + def _cached_fetch(url: str) -> str | None: + if url not in _fetch_cache: + _fetch_cache[url] = _real_fetch(url) + return _fetch_cache[url] + + setup_env.fetch_quartz_text = _cached_fetch + + # Per-arch Quartz gate: (primary_platform, extra_build_only_platforms). + # Linux datacenter archs gate on Linux build+tests; gfx1151 gates on + # Windows build+tests plus Linux wheel builds. + arch_gates: dict[str, tuple[str, tuple[tuple[str, str], ...]]] = { + "gfx90a": ("linux", ()), + "gfx942": ("linux", ()), + "gfx950": ("linux", ()), + "gfx1151": ("windows", (("linux", "gfx1151"),)), + } + pin_path = Path("rocm-pin.json") - current = setup_env.read_rocm_pin(pin_path) + default_arch, current_pins = setup_env.read_rocm_pins(pin_path) + requested = os.environ.get("REQUESTED_VERSION", "").strip() if requested: requested = setup_env._rocm_version(requested) - if not requested or requested == "latest": - build = setup_env.select_quartz_nightly_for_archs( - "linux", - ("gfx942", "gfx950"), - require_platform_builds=( - ("windows", setup_env.WINDOWS_DEFAULT_GPU_ARCH), - ), - ) - else: - build = setup_env.describe_rocm_version( - requested, "", "linux", "gfx942" - ) - if not build.therock_commit: - setup_env.fail( - f"Quartz has no therock_commit for ROCm {build.rocm_version}." - ) - rocm_libraries_commit = setup_env.resolve_therock_rocm_libraries_commit( - build.therock_commit - ) - new_pin = { - "rocm_version": build.rocm_version, - "build_date": build.build_date, - "therock_commit": build.therock_commit, - "rocm_libraries_commit": rocm_libraries_commit, - "index_url": build.index_url, - } is_manual = bool(requested and requested != "latest") - current_date = current.build_date or "" - new_date = build.build_date or "" - # Scheduled bumps only move forward; manual dispatch may pin any version. - if not is_manual and current_date and new_date and new_date < current_date: - changed = False + + archs_raw = os.environ.get("REQUESTED_ARCHS", "").strip() + if archs_raw: + target_archs = [a.strip().lower() for a in archs_raw.split(",") if a.strip()] + unknown = [a for a in target_archs if a not in current_pins] + if unknown: + setup_env.fail( + f"Unknown arch(s) in inputs.archs: {', '.join(unknown)}.", + f"Expected a subset of: {', '.join(current_pins)}.", + ) else: - changed = ( + target_archs = list(current_pins) + + therock_cache: dict[str, str] = {} + + def resolve_rl(therock_commit: str) -> str: + if therock_commit not in therock_cache: + therock_cache[therock_commit] = ( + setup_env.resolve_therock_rocm_libraries_commit(therock_commit) + ) + return therock_cache[therock_commit] + + new_archs_data: dict[str, dict[str, str | None]] = {} + bumped_archs: list[str] = [] + bumped_versions: set[str] = set() + rows: list[str] = [] + + for arch, current in current_pins.items(): + current_entry = { + "rocm_version": current.rocm_version, + "build_date": current.build_date, + "therock_commit": current.therock_commit, + "rocm_libraries_commit": current.rocm_libraries_commit, + "index_url": current.index_url, + } + if arch not in target_archs: + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | skipped | `{current.rocm_version}` | " + f"`{(current.rocm_libraries_commit or '')[:12]}` |" + ) + continue + + plat, extra_builds = arch_gates.get(arch, ("linux", ())) + if is_manual: + build = setup_env.describe_rocm_version(requested, "", plat, arch) + else: + build = setup_env.find_quartz_nightly( + plat, arch, require_platform_builds=extra_builds + ) + + if build is None: + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | unchanged (no passing nightly in {setup_env.QUARTZ_LOOKBACK_DAYS}d) | " + f"`{current.rocm_version}` | `{(current.rocm_libraries_commit or '')[:12]}` |" + ) + continue + + if not build.therock_commit: + if is_manual: + setup_env.fail( + f"Quartz has no therock_commit for ROCm {build.rocm_version}." + ) + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | unchanged (no therock_commit) | " + f"`{current.rocm_version}` | `{(current.rocm_libraries_commit or '')[:12]}` |" + ) + continue + + current_date = current.build_date or "" + new_date = build.build_date or "" + # Scheduled bumps only move forward; manual dispatch may pin any version. + if not is_manual and current_date and new_date and new_date < current_date: + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | unchanged (newest passing {new_date} < pinned {current_date}) | " + f"`{current.rocm_version}` | `{(current.rocm_libraries_commit or '')[:12]}` |" + ) + continue + + rl_commit = resolve_rl(build.therock_commit) + entry_changed = ( build.rocm_version != current.rocm_version - or rocm_libraries_commit != current.rocm_libraries_commit + or rl_commit != current.rocm_libraries_commit or build.therock_commit != current.therock_commit ) + if entry_changed: + new_archs_data[arch] = { + "rocm_version": build.rocm_version, + "build_date": build.build_date, + "therock_commit": build.therock_commit, + "rocm_libraries_commit": rl_commit, + "index_url": build.index_url, + } + bumped_archs.append(arch) + bumped_versions.add(build.rocm_version) + rows.append( + f"| `{arch}` | **bumped** | `{current.rocm_version}` -> `{build.rocm_version}` | " + f"`{(current.rocm_libraries_commit or '')[:12]}` -> `{rl_commit[:12]}` |" + ) + else: + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | unchanged | `{current.rocm_version}` | " + f"`{(current.rocm_libraries_commit or '')[:12]}` |" + ) + + changed = bool(bumped_archs) if changed: pin_path.write_text( - json.dumps(new_pin, indent=2) + "\n", encoding="utf-8" + json.dumps({"default": default_arch, "archs": new_archs_data}, indent=2) + + "\n", + encoding="utf-8", ) + if len(bumped_versions) == 1: + ver = next(iter(bumped_versions)) + title = f"chore(deps): bump ROCm pin ({', '.join(bumped_archs)} -> {ver})" + else: + title = f"chore(deps): bump ROCm pin ({', '.join(bumped_archs)})" + body_lines = [ + "Bump per-arch entries in `rocm-pin.json` to the newest passing Quartz nightly (archs without a newer passing nightly stay untouched):", + "", + "| Arch | Status | ROCm / PyTorch | rocm-libraries |", + "|---|---|---|---|", + *rows, + "", + ] + body_path = Path(os.environ["RUNNER_TEMP"]) / "bump-rocm-pin-body.md" + body_path.write_text("\n".join(body_lines), encoding="utf-8") + else: + title = "" out = Path(os.environ["GITHUB_OUTPUT"]) with out.open("a", encoding="utf-8") as f: f.write(f"changed={'true' if changed else 'false'}\n") - f.write(f"old_version={current.rocm_version}\n") - f.write(f"new_version={build.rocm_version}\n") - f.write(f"therock_commit={build.therock_commit}\n") - f.write(f"old_rocm_libraries={current.rocm_libraries_commit}\n") - f.write(f"new_rocm_libraries={rocm_libraries_commit}\n") - print( - f"Current: {current.rocm_version} ({current.rocm_libraries_commit[:12]}) -> " - f"Candidate: {build.rocm_version} ({rocm_libraries_commit[:12]}), " - f"changed={changed}" - ) + f.write(f"title={title}\n") + + print("\n".join(rows)) + print(f"changed={changed}") PY - name: Open or update bump PR @@ -123,24 +238,12 @@ jobs: # token) lets the pushed branch trigger pull_request CI checks # automatically; otherwise GITHUB_TOKEN opens/updates the PR. GH_TOKEN: ${{ secrets.ROCM_PIN_BUMP_TOKEN || secrets.GITHUB_TOKEN }} - OLD_VERSION: ${{ steps.resolve.outputs.old_version }} - NEW_VERSION: ${{ steps.resolve.outputs.new_version }} - THEROCK_COMMIT: ${{ steps.resolve.outputs.therock_commit }} - OLD_ROCM_LIBRARIES: ${{ steps.resolve.outputs.old_rocm_libraries }} - NEW_ROCM_LIBRARIES: ${{ steps.resolve.outputs.new_rocm_libraries }} + PR_TITLE: ${{ steps.resolve.outputs.title }} REPO: ${{ github.repository }} run: | set -euo pipefail branch="chore/bump-rocm-pin" - title="chore(deps): bump ROCm pin to ${NEW_VERSION}" - body=$(cat < \`${NEW_VERSION}\` - - **TheRock commit:** \`${THEROCK_COMMIT}\` - - **rocm-libraries commit:** \`${OLD_ROCM_LIBRARIES}\` -> \`${NEW_ROCM_LIBRARIES}\` - EOF - ) + body_file="${RUNNER_TEMP}/bump-rocm-pin-body.md" remote="https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git" # Skip pushing when the open bump branch already carries this exact @@ -157,16 +260,25 @@ jobs: git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git checkout -B "${branch}" git add rocm-pin.json - git commit -m "${title}" + git commit -m "${PR_TITLE}" git push --force "${remote}" "HEAD:refs/heads/${branch}" - existing=$(gh pr list --repo "${REPO}" --head "${branch}" --state open --json number --jq '.[0].number // empty') - if [ -n "${existing}" ]; then - gh api -X PATCH "repos/${REPO}/pulls/${existing}" \ - -f title="${title}" \ - -f body="${body}" >/dev/null - echo "Updated PR #${existing}" + + pr_number=$(gh pr list --repo "${REPO}" --head "${branch}" --state open --json number --jq '.[0].number // empty') + if [ -n "${pr_number}" ]; then + gh pr edit "${pr_number}" --repo "${REPO}" \ + --title "${PR_TITLE}" \ + --body-file "${body_file}" + echo "Updated PR #${pr_number}" else - gh pr create --repo "${REPO}" --base main --head "${branch}" \ - --title "${title}" \ - --body "${body}" + pr_url=$(gh pr create --repo "${REPO}" --base main --head "${branch}" \ + --title "${PR_TITLE}" \ + --body-file "${body_file}") + echo "Created ${pr_url}" + pr_number="${pr_url##*/}" + fi + + # Enable squash auto-merge so the bump PR merges as soon as required + # checks and CODEOWNER approval pass (main ruleset blocks direct push). + if ! gh pr merge "${pr_number}" --repo "${REPO}" --auto --squash; then + echo "::warning::Could not enable auto-merge on PR #${pr_number}; merge manually after review." fi diff --git a/dockerfiles/build-dnn-benchmark-performance-image.sh b/dockerfiles/build-dnn-benchmark-performance-image.sh index 67b9b9a6..fa6167f7 100755 --- a/dockerfiles/build-dnn-benchmark-performance-image.sh +++ b/dockerfiles/build-dnn-benchmark-performance-image.sh @@ -116,7 +116,7 @@ if rocm_version: except argparse.ArgumentTypeError as exc: print(f"ERROR: --rocm-version: {exc}", file=sys.stderr) sys.exit(2) -pin = setup_env.read_rocm_pin() +pin = setup_env.read_rocm_pin(device_target) if not rocm_version or rocm_version == pin.rocm_version: build = pin elif rocm_version == "latest": diff --git a/docs/setup.md b/docs/setup.md index 7da1b40b..64b69472 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -215,11 +215,13 @@ On Windows the default is `gfx1151`. ## ROCm nightly selection -By default, `--torch-mode rocm` installs the ROCm nightly and matching -`rocm-libraries` commit checked into `rocm-pin.json`. This keeps the ROCm -PyTorch wheels, MIOpen and `miopen-provider` in lockstep without reading -Quartz on every setup run, and isolates upstream regressions to scheduled bump -PRs (`.github/workflows/bump-rocm-pin.yml`). +By default, `--torch-mode rocm` installs the per-architecture ROCm nightly and +matching `rocm-libraries` commit checked into `rocm-pin.json` (falling back to +its `default` entry for unlisted architectures). This keeps the ROCm PyTorch +wheels, MIOpen and `miopen-provider` in lockstep without reading Quartz on +every setup run, lets each architecture advance independently as its Quartz +tests pass, and isolates upstream regressions to scheduled bump PRs +(`.github/workflows/bump-rocm-pin.yml`). To pull the newest passing nightly directly from [Quartz](https://github.com/ROCm/Quartz), pass `--rocm-version latest`: @@ -299,11 +301,13 @@ CI (`setup.yml` gpu-test and `check-deserialize.yml`) uses `rocm-pin.json`. To test another build in CI, set the `ROCM_VERSION` repository variable (for example `latest` or a specific version). Each job prints the ROCm build and `rocm-libraries` commit in its log and in the job summary. The scheduled -`.github/workflows/bump-rocm-pin.yml` workflow opens PRs to advance -`rocm-pin.json` to the newest Quartz nightly passing Linux `gfx942` and -`gfx950` tests and Windows `gfx1151` builds. When the `ROCM_PIN_BUMP_TOKEN` -repository secret is configured, GitHub runs `gpu-tests` and -`check-deserialize` on each bump PR automatically. +`.github/workflows/bump-rocm-pin.yml` workflow checks each architecture in +`rocm-pin.json` independently (`gfx90a`, `gfx942`, `gfx950` on Linux; +`gfx1151` on Windows + Linux builds), advances only the architectures whose +Quartz tests pass, leaves failing architectures untouched, and opens a bump PR +with squash auto-merge enabled. When the `ROCM_PIN_BUMP_TOKEN` repository +secret is configured, GitHub runs `gpu-tests` and `check-deserialize` on each +bump PR automatically. ## rocm-libraries source diff --git a/rocm-pin.json b/rocm-pin.json index d14b26fd..5cb64d1b 100644 --- a/rocm-pin.json +++ b/rocm-pin.json @@ -1,7 +1,33 @@ { - "rocm_version": "10.3.0a20261123", - "build_date": "20261123", - "therock_commit": "eaa2f988a7330c3e0d54c4bc7b52d06fda40c8ed", - "rocm_libraries_commit": "6b5f0a16f7562fdb94fe4405836998322b507431", - "index_url": "https://nightly.repo.amd.com/rocm/whl-next/" + "default": "gfx950", + "archs": { + "gfx90a": { + "rocm_version": "10.3.0a20261120", + "build_date": "20261120", + "therock_commit": "c65aaf72258393b6c47631bb2b7143b3a29f35a0", + "rocm_libraries_commit": "bd4da6582949103a3333938bd32b02f784b1640f", + "index_url": "https://nightly.repo.amd.com/rocm/whl-next/" + }, + "gfx942": { + "rocm_version": "10.3.0a20261123", + "build_date": "20261123", + "therock_commit": "eaa2f988a7330c3e0d54c4bc7b52d06fda40c8ed", + "rocm_libraries_commit": "6b5f0a16f7562fdb94fe4405836998322b507431", + "index_url": "https://nightly.repo.amd.com/rocm/whl-next/" + }, + "gfx950": { + "rocm_version": "10.3.0a20261123", + "build_date": "20261123", + "therock_commit": "eaa2f988a7330c3e0d54c4bc7b52d06fda40c8ed", + "rocm_libraries_commit": "6b5f0a16f7562fdb94fe4405836998322b507431", + "index_url": "https://nightly.repo.amd.com/rocm/whl-next/" + }, + "gfx1151": { + "rocm_version": "10.3.0a20261123", + "build_date": "20261123", + "therock_commit": "eaa2f988a7330c3e0d54c4bc7b52d06fda40c8ed", + "rocm_libraries_commit": "6b5f0a16f7562fdb94fe4405836998322b507431", + "index_url": "https://nightly.repo.amd.com/rocm/whl-next/" + } + } } diff --git a/setup_env.py b/setup_env.py index ace19f6c..e26020c6 100755 --- a/setup_env.py +++ b/setup_env.py @@ -39,7 +39,7 @@ import urllib.error import urllib.request from pathlib import Path -from typing import Dict, NoReturn, Optional, Tuple +from typing import Dict, List, NoReturn, Optional, Tuple IS_WINDOWS = platform.system() == "Windows" @@ -442,22 +442,21 @@ def _newest_quartz_nightly() -> datetime.date: fail(f"{url} names no nightly build date: {body.strip()[:80]!r}") -def select_quartz_nightly_for_archs( +def _find_quartz_nightly( platform_name: str, - gpu_archs: Tuple[str, ...], + gpu_arch: str, index_url: str = "", *, require_platform_builds: Tuple[Tuple[str, str], ...] = (), -) -> RocmBuild: - """The newest nightly that Quartz reports usable for every arch in ``gpu_archs``. +) -> Tuple[Optional[RocmBuild], List[str], datetime.date]: + """Search back QUARTZ_LOOKBACK_DAYS for a usable nightly for ``gpu_arch``. ``require_platform_builds`` takes additional ``(platform, gpu_arch)`` pairs - whose ROCm and PyTorch builds and wheels URL must also be ``success`` (for - example ``(("windows", "gfx1151"),)`` when bumping ``rocm-pin.json``), - without rejecting on flaky test entries for those extra platforms. + whose ROCm and PyTorch builds and wheels URL must also be ``success`` + without rejecting on test entries for those extra platforms. """ newest = _newest_quartz_nightly() - rejected = [] + rejected: List[str] = [] for days_back in range(QUARTZ_LOOKBACK_DAYS): build_date = (newest - datetime.timedelta(days=days_back)).strftime("%Y%m%d") url = _quartz_status_url(build_date) @@ -467,38 +466,60 @@ def select_quartz_nightly_for_archs( continue document = _parse_quartz_status(url, body) reasons = [] - for arch in gpu_archs: - reason = quartz_rejection(document, platform_name, arch) - if reason and reason not in reasons: - reasons.append(reason) + reason = quartz_rejection(document, platform_name, gpu_arch) + if reason: + reasons.append(reason) for extra_platform, extra_arch in require_platform_builds: - reason = quartz_rejection( + extra_reason = quartz_rejection( document, extra_platform, extra_arch, check_tests=False ) - if reason and reason not in reasons: - reasons.append(reason) + if extra_reason and extra_reason not in reasons: + reasons.append(extra_reason) if reasons: rejected.append( f" {build_date} ({document.get('rocm_version')}): {'; '.join(reasons)}" ) continue - return _rocm_build_from_quartz( - document, url, platform_name, gpu_archs[0], "quartz", index_url + return ( + _rocm_build_from_quartz( + document, url, platform_name, gpu_arch, "quartz", index_url + ), + rejected, + newest, ) - arch_list = ", ".join(gpu_archs) - fail( - f"Quartz reports no usable ROCm nightly for {platform_name} {arch_list} in " - f"the {QUARTZ_LOOKBACK_DAYS} days up to {newest:%Y%m%d}:", - *rejected, - "Pass --rocm-version VERSION to install a specific build.", + return None, rejected, newest + + +def find_quartz_nightly( + platform_name: str, + gpu_arch: str, + index_url: str = "", + *, + require_platform_builds: Tuple[Tuple[str, str], ...] = (), +) -> Optional[RocmBuild]: + """The newest usable Quartz nightly for ``gpu_arch``, or None if none passed.""" + build, _, _ = _find_quartz_nightly( + platform_name, + gpu_arch, + index_url, + require_platform_builds=require_platform_builds, ) + return build def select_quartz_nightly( platform_name: str, gpu_arch: str, index_url: str = "" ) -> RocmBuild: """The newest nightly that Quartz reports usable for ``gpu_arch``.""" - return select_quartz_nightly_for_archs(platform_name, (gpu_arch,), index_url) + build, rejected, newest = _find_quartz_nightly(platform_name, gpu_arch, index_url) + if build is not None: + return build + fail( + f"Quartz reports no usable ROCm nightly for {platform_name} {gpu_arch} in " + f"the {QUARTZ_LOOKBACK_DAYS} days up to {newest:%Y%m%d}:", + *rejected, + "Pass --rocm-version VERSION to install a specific build.", + ) def describe_rocm_version( @@ -535,47 +556,40 @@ def describe_rocm_version( ) -def read_rocm_pin(path: Optional[Path] = None) -> RocmBuild: - """Read the checked-in ROCm + rocm-libraries pin from ``rocm-pin.json``.""" - pin_path = ROCM_PIN_FILE if path is None else path - try: - data = json.loads(pin_path.read_text(encoding="utf-8")) - except (OSError, ValueError) as exc: - fail( - f"cannot read ROCm pin file {pin_path}: {exc}.", - "Restore rocm-pin.json, or pass --rocm-version and --rocm-libraries-ref.", - ) - if not isinstance(data, dict): - fail(f"{pin_path} must contain a JSON object.") - rocm_version = str(data.get("rocm_version") or "").strip() +def _parse_rocm_pin_entry(entry: object, label: str, source_name: str) -> RocmBuild: + if not isinstance(entry, dict): + fail(f"{label} must be a JSON object.") + rocm_version = str(entry.get("rocm_version") or "").strip() if not re.fullmatch(r"[0-9][0-9A-Za-z.+!-]*", rocm_version): fail( - f"{pin_path} has invalid rocm_version {data.get('rocm_version')!r}.", + f"{label} has invalid rocm_version {entry.get('rocm_version')!r}.", "Expected a ROCm wheel version such as 10.3.0a20261123.", ) - rocm_libraries_commit = str(data.get("rocm_libraries_commit") or "").strip().lower() + rocm_libraries_commit = ( + str(entry.get("rocm_libraries_commit") or "").strip().lower() + ) if not re.fullmatch(r"[0-9a-f]{40}", rocm_libraries_commit): fail( - f"{pin_path} has invalid rocm_libraries_commit " - f"{data.get('rocm_libraries_commit')!r}.", + f"{label} has invalid rocm_libraries_commit " + f"{entry.get('rocm_libraries_commit')!r}.", "Expected a 40-character commit SHA.", ) - therock_raw = data.get("therock_commit") + therock_raw = entry.get("therock_commit") therock_commit: Optional[str] = None if therock_raw: therock_commit = str(therock_raw).strip().lower() if not re.fullmatch(r"[0-9a-f]{40}", therock_commit): fail( - f"{pin_path} has invalid therock_commit {therock_raw!r}.", + f"{label} has invalid therock_commit {therock_raw!r}.", "Expected a 40-character commit SHA.", ) - build_date = str(data.get("build_date") or "").strip() or None - index_url = str(data.get("index_url") or "").strip() or ROCM_TORCH_INDEX_URL + build_date = str(entry.get("build_date") or "").strip() or None + index_url = str(entry.get("index_url") or "").strip() or ROCM_TORCH_INDEX_URL status_url = _quartz_status_url(build_date) if build_date else None return RocmBuild( rocm_version=rocm_version, index_url=index_url, - source=pin_path.name, + source=source_name, build_date=build_date, therock_commit=therock_commit, status_url=status_url, @@ -584,6 +598,56 @@ def read_rocm_pin(path: Optional[Path] = None) -> RocmBuild: ) +def read_rocm_pins( + path: Optional[Path] = None, +) -> Tuple[str, Dict[str, RocmBuild]]: + """Read all per-arch pins and the default arch key from ``rocm-pin.json``.""" + pin_path = ROCM_PIN_FILE if path is None else path + try: + data = json.loads(pin_path.read_text(encoding="utf-8")) + except (OSError, ValueError) as exc: + fail( + f"cannot read ROCm pin file {pin_path}: {exc}.", + "Restore rocm-pin.json, or pass --rocm-version and --rocm-libraries-ref.", + ) + if not isinstance(data, dict): + fail(f"{pin_path} must contain a JSON object.") + archs_raw = data.get("archs") + if not isinstance(archs_raw, dict) or not archs_raw: + fail(f"{pin_path} must contain a non-empty 'archs' object.") + pins: Dict[str, RocmBuild] = {} + for arch_key, entry in archs_raw.items(): + if not isinstance(arch_key, str) or not arch_key.strip(): + fail(f"{pin_path} has an empty architecture key in 'archs'.") + norm_arch = arch_key.strip().lower() + pins[norm_arch] = _parse_rocm_pin_entry( + entry, f"{pin_path}['archs'][{norm_arch!r}]", pin_path.name + ) + default_arch = str(data.get("default") or "").strip().lower() + if default_arch not in pins: + fail( + f"{pin_path} has invalid default arch {data.get('default')!r}.", + f"Expected one of: {', '.join(pins)}.", + ) + return default_arch, pins + + +def read_rocm_pin( + gpu_arch: Optional[str] = None, path: Optional[Path] = None +) -> RocmBuild: + """Read the checked-in ROCm + rocm-libraries pin for ``gpu_arch``. + + Falls back to the ``default`` arch in ``rocm-pin.json`` when ``gpu_arch`` + is None or has no explicit entry. + """ + default_arch, pins = read_rocm_pins(path) + if gpu_arch: + norm = gpu_arch.strip().lower() + if norm in pins: + return pins[norm] + return pins[default_arch] + + def _fetch_therock_rocm_libraries_commit( therock_commit: str, repo_url: Optional[str] = None ) -> str: @@ -1250,7 +1314,7 @@ def _resolve_rocm_libraries_ref( except OSError: pass return ref, "quartz", therock_commit - pin = read_rocm_pin() + pin = read_rocm_pin(self.gpu_arch or self.gpu_arch_override) return pin.rocm_libraries_commit or "", pin.source, pin.therock_commit def ensure_rocm_libraries_checkout(self) -> None: @@ -1949,7 +2013,7 @@ def select_rocm_build(self, arch: str) -> RocmBuild: return select_quartz_nightly(platform_name, arch, self.torch_index_url) if self.rocm_version: if ROCM_PIN_FILE.is_file(): - pin = read_rocm_pin() + pin = read_rocm_pin(arch) if pin.rocm_version == self.rocm_version: return dataclasses.replace( pin, @@ -1960,7 +2024,15 @@ def select_rocm_build(self, arch: str) -> RocmBuild: ) if self.torch_index_url: return RocmBuild("", self.torch_index_url, "--torch-index-url") - return read_rocm_pin() + default_arch, pins = read_rocm_pins() + norm_arch = arch.strip().lower() + if norm_arch in pins: + return pins[norm_arch] + print( + f"{ROCM_PIN_FILE.name} has no entry for {arch}; " + f"using default ({default_arch})." + ) + return pins[default_arch] def install_rocm_torch(self, build: RocmBuild, arch: str) -> None: """Install ROCm PyTorch and the ROCm SDK wheels of ``build``.""" diff --git a/tests/unit/test_setup_env.py b/tests/unit/test_setup_env.py index 90f0e336..fc2d3176 100644 --- a/tests/unit/test_setup_env.py +++ b/tests/unit/test_setup_env.py @@ -628,14 +628,23 @@ def rocm_libraries(setup_env, tmp_path, monkeypatch): repo = tmp_path / "repo" repo.mkdir() pin_file = repo / "rocm-pin.json" + entry = { + "rocm_version": _RECORDED_ROCM_VERSION, + "build_date": "20261115", + "therock_commit": "62d1ac21a0eda4df3871c6c8d4570cb0ee9a4637", + "rocm_libraries_commit": _head(src), + "index_url": setup_env.ROCM_TORCH_INDEX_URL, + } pin_file.write_text( json.dumps( { - "rocm_version": _RECORDED_ROCM_VERSION, - "build_date": "20261115", - "therock_commit": "62d1ac21a0eda4df3871c6c8d4570cb0ee9a4637", - "rocm_libraries_commit": _head(src), - "index_url": setup_env.ROCM_TORCH_INDEX_URL, + "default": "gfx950", + "archs": { + "gfx90a": entry, + "gfx942": entry, + "gfx950": entry, + "gfx1151": entry, + }, } ) + "\n" @@ -1586,7 +1595,7 @@ def test_rocm_install_defaults_to_rocm_pin_without_network( setup_env, tmp_path, monkeypatch, rocm_libraries ) -> None: # The autouse guard fails on any Quartz or TheRock network call. - pin = setup_env.read_rocm_pin() + pin = setup_env.read_rocm_pin("gfx950") setup, pip_calls = _fresh_rocm_setup( setup_env, tmp_path, monkeypatch, arch="gfx950" ) @@ -1616,26 +1625,98 @@ def test_rocm_install_defaults_to_rocm_pin_without_network( assert _head(rocm_libraries) == pin.rocm_libraries_commit +def test_read_rocm_pin_selects_per_arch_and_falls_back_to_default( + setup_env, tmp_path, monkeypatch, capsys +) -> None: + pin_file = tmp_path / "rocm-pin.json" + pin_file.write_text( + json.dumps( + { + "default": "gfx950", + "archs": { + "gfx90a": { + "rocm_version": "10.3.0a20261120", + "build_date": "20261120", + "therock_commit": "a" * 40, + "rocm_libraries_commit": "b" * 40, + "index_url": setup_env.ROCM_TORCH_INDEX_URL, + }, + "gfx950": { + "rocm_version": "10.3.0a20261123", + "build_date": "20261123", + "therock_commit": "c" * 40, + "rocm_libraries_commit": "d" * 40, + "index_url": setup_env.ROCM_TORCH_INDEX_URL, + }, + }, + } + ) + ) + monkeypatch.setattr(setup_env, "ROCM_PIN_FILE", pin_file) + + pin_90a = setup_env.read_rocm_pin("gfx90a") + assert pin_90a.rocm_version == "10.3.0a20261120" + assert pin_90a.rocm_libraries_commit == "b" * 40 + + pin_950 = setup_env.read_rocm_pin("gfx950") + assert pin_950.rocm_version == "10.3.0a20261123" + assert pin_950.rocm_libraries_commit == "d" * 40 + + # Unlisted arch falls back to default (gfx950) and prints a note. + setup, _ = _fresh_rocm_setup(setup_env, tmp_path, monkeypatch, arch="gfx1201") + fallback = setup.select_rocm_build("gfx1201") + assert fallback.rocm_version == "10.3.0a20261123" + assert fallback.rocm_libraries_commit == "d" * 40 + assert "no entry for gfx1201; using default (gfx950)" in capsys.readouterr().out + + def test_read_rocm_pin_rejects_missing_or_invalid_fields( setup_env, tmp_path, capsys ) -> None: missing = tmp_path / "missing.json" with pytest.raises(SystemExit) as exc: - setup_env.read_rocm_pin(missing) + setup_env.read_rocm_pin(path=missing) assert exc.value.code == 1 assert "cannot read ROCm pin file" in capsys.readouterr().err - bad = tmp_path / "bad.json" - bad.write_text( + bad_commit = tmp_path / "bad-commit.json" + bad_commit.write_text( json.dumps( - {"rocm_version": "10.3.0a20261123", "rocm_libraries_commit": "short"} + { + "default": "gfx950", + "archs": { + "gfx950": { + "rocm_version": "10.3.0a20261123", + "rocm_libraries_commit": "short", + } + }, + } ) ) with pytest.raises(SystemExit) as exc: - setup_env.read_rocm_pin(bad) + setup_env.read_rocm_pin(path=bad_commit) assert exc.value.code == 1 assert "invalid rocm_libraries_commit" in capsys.readouterr().err + bad_default = tmp_path / "bad-default.json" + bad_default.write_text( + json.dumps( + { + "default": "gfx942", + "archs": { + "gfx950": { + "rocm_version": "10.3.0a20261123", + "rocm_libraries_commit": "a" * 40, + } + }, + } + ) + ) + with pytest.raises(SystemExit) as exc: + setup_env.read_rocm_pin(path=bad_default) + assert exc.value.code == 1 + assert "invalid default arch" in capsys.readouterr().err + def test_reused_venv_refuses_rocm_version_latest( setup_env, tmp_path, monkeypatch, capsys @@ -1649,30 +1730,26 @@ def test_reused_venv_refuses_rocm_version_latest( assert "--rocm-version latest" in capsys.readouterr().err -def test_select_quartz_nightly_for_archs_requires_every_arch(setup_env, quartz) -> None: - # On 20261116, rocm build is in_progress; on 20261115, gfx950 passes but - # gfx942 fails rocm tests; on 20261119 both gfx942 and gfx950 pass. - quartz.latest = "20261119" - build = setup_env.select_quartz_nightly_for_archs("linux", ("gfx942", "gfx950")) - assert build.build_date == "20261119" - - # Make 20261119 fail gfx950 pytorch tests -> must walk back to 20261118. - doc = _quartz_document("20261119") - doc["pipelines"]["pytorch"]["test"]["linux"]["gfx950-dcgpu"]["status"] = "failure" - quartz.documents["20261119"] = doc - build = setup_env.select_quartz_nightly_for_archs("linux", ("gfx942", "gfx950")) - assert build.build_date == "20261118" +def test_find_quartz_nightly_per_arch_and_extra_platform_builds( + setup_env, quartz +) -> None: + # On 20261116, rocm build is in_progress; on 20261115, gfx950 passes while + # gfx942 fails rocm tests -> per-arch lookup picks 20261115 for gfx950 and + # returns None for gfx942 (no passing nightly in recorded window). + quartz.latest = "20261116" + assert setup_env.find_quartz_nightly("linux", "gfx950").build_date == "20261115" + assert setup_env.find_quartz_nightly("linux", "gfx942") is None - # require_platform_builds checks that the extra platform's builds and wheels - # succeeded (without rejecting on test failures): on 20261119 Windows - # pytorch build is in_progress, so requiring Windows gfx1151 builds walks - # back to a nightly where Windows finished building. - quartz.documents.clear() - build = setup_env.select_quartz_nightly_for_archs( + # require_platform_builds checks extra platform builds/wheels without + # failing on flaky tests: on 20261119 Windows pytorch build is in_progress, + # so requiring Windows gfx1151 builds walks back to 20261118. + quartz.latest = "20261119" + build = setup_env.find_quartz_nightly( "linux", - ("gfx942", "gfx950"), + "gfx950", require_platform_builds=(("windows", setup_env.WINDOWS_DEFAULT_GPU_ARCH),), ) + assert build is not None assert build.build_date == "20261118" From 65aec3e2809183229721d0d9990487782dd789e2 Mon Sep 17 00:00:00 2001 From: Samuel Reeder Date: Tue, 24 Nov 2026 16:16:53 +0000 Subject: [PATCH 4/4] refactor(setup): extract tools/bump_rocm_pin.py and make workflow manual-dispatch Extract per-arch Quartz pin resolution into tools/bump_rocm_pin.py (with unit tests in tests/unit/test_bump_rocm_pin.py) so both manual GitHub Actions dispatches and local scheduled automation share one script. Remove the schedule trigger from .github/workflows/bump-rocm-pin.yml to avoid racing local cron bumps while keeping workflow_dispatch available. --- .github/workflows/bump-rocm-pin.yml | 197 +---------------- docs/setup.md | 14 +- tests/unit/test_bump_rocm_pin.py | 182 ++++++++++++++++ tools/bump_rocm_pin.py | 325 ++++++++++++++++++++++++++++ 4 files changed, 522 insertions(+), 196 deletions(-) create mode 100644 tests/unit/test_bump_rocm_pin.py create mode 100755 tools/bump_rocm_pin.py diff --git a/.github/workflows/bump-rocm-pin.yml b/.github/workflows/bump-rocm-pin.yml index 9fc37806..4dc2f806 100644 --- a/.github/workflows/bump-rocm-pin.yml +++ b/.github/workflows/bump-rocm-pin.yml @@ -4,10 +4,6 @@ name: bump-rocm-pin on: - schedule: - # Mondays and Wednesdays at 16:00 UTC (~12:00 America/New_York), matching - # the submodule cadence in dependabot.yml. - - cron: '0 16 * * 1,3' workflow_dispatch: inputs: rocm_version: @@ -50,186 +46,11 @@ jobs: REQUESTED_VERSION: ${{ inputs.rocm_version || '' }} REQUESTED_ARCHS: ${{ inputs.archs || '' }} run: | - python - <<'PY' - import importlib.util - import json - import os - from pathlib import Path - - spec = importlib.util.spec_from_file_location("setup_env", "setup_env.py") - setup_env = importlib.util.module_from_spec(spec) - spec.loader.exec_module(setup_env) - - # Memoize Quartz HTTP fetches across arch checks. - _real_fetch = setup_env.fetch_quartz_text - _fetch_cache: dict[str, str | None] = {} - - def _cached_fetch(url: str) -> str | None: - if url not in _fetch_cache: - _fetch_cache[url] = _real_fetch(url) - return _fetch_cache[url] - - setup_env.fetch_quartz_text = _cached_fetch - - # Per-arch Quartz gate: (primary_platform, extra_build_only_platforms). - # Linux datacenter archs gate on Linux build+tests; gfx1151 gates on - # Windows build+tests plus Linux wheel builds. - arch_gates: dict[str, tuple[str, tuple[tuple[str, str], ...]]] = { - "gfx90a": ("linux", ()), - "gfx942": ("linux", ()), - "gfx950": ("linux", ()), - "gfx1151": ("windows", (("linux", "gfx1151"),)), - } - - pin_path = Path("rocm-pin.json") - default_arch, current_pins = setup_env.read_rocm_pins(pin_path) - - requested = os.environ.get("REQUESTED_VERSION", "").strip() - if requested: - requested = setup_env._rocm_version(requested) - is_manual = bool(requested and requested != "latest") - - archs_raw = os.environ.get("REQUESTED_ARCHS", "").strip() - if archs_raw: - target_archs = [a.strip().lower() for a in archs_raw.split(",") if a.strip()] - unknown = [a for a in target_archs if a not in current_pins] - if unknown: - setup_env.fail( - f"Unknown arch(s) in inputs.archs: {', '.join(unknown)}.", - f"Expected a subset of: {', '.join(current_pins)}.", - ) - else: - target_archs = list(current_pins) - - therock_cache: dict[str, str] = {} - - def resolve_rl(therock_commit: str) -> str: - if therock_commit not in therock_cache: - therock_cache[therock_commit] = ( - setup_env.resolve_therock_rocm_libraries_commit(therock_commit) - ) - return therock_cache[therock_commit] - - new_archs_data: dict[str, dict[str, str | None]] = {} - bumped_archs: list[str] = [] - bumped_versions: set[str] = set() - rows: list[str] = [] - - for arch, current in current_pins.items(): - current_entry = { - "rocm_version": current.rocm_version, - "build_date": current.build_date, - "therock_commit": current.therock_commit, - "rocm_libraries_commit": current.rocm_libraries_commit, - "index_url": current.index_url, - } - if arch not in target_archs: - new_archs_data[arch] = current_entry - rows.append( - f"| `{arch}` | skipped | `{current.rocm_version}` | " - f"`{(current.rocm_libraries_commit or '')[:12]}` |" - ) - continue - - plat, extra_builds = arch_gates.get(arch, ("linux", ())) - if is_manual: - build = setup_env.describe_rocm_version(requested, "", plat, arch) - else: - build = setup_env.find_quartz_nightly( - plat, arch, require_platform_builds=extra_builds - ) - - if build is None: - new_archs_data[arch] = current_entry - rows.append( - f"| `{arch}` | unchanged (no passing nightly in {setup_env.QUARTZ_LOOKBACK_DAYS}d) | " - f"`{current.rocm_version}` | `{(current.rocm_libraries_commit or '')[:12]}` |" - ) - continue - - if not build.therock_commit: - if is_manual: - setup_env.fail( - f"Quartz has no therock_commit for ROCm {build.rocm_version}." - ) - new_archs_data[arch] = current_entry - rows.append( - f"| `{arch}` | unchanged (no therock_commit) | " - f"`{current.rocm_version}` | `{(current.rocm_libraries_commit or '')[:12]}` |" - ) - continue - - current_date = current.build_date or "" - new_date = build.build_date or "" - # Scheduled bumps only move forward; manual dispatch may pin any version. - if not is_manual and current_date and new_date and new_date < current_date: - new_archs_data[arch] = current_entry - rows.append( - f"| `{arch}` | unchanged (newest passing {new_date} < pinned {current_date}) | " - f"`{current.rocm_version}` | `{(current.rocm_libraries_commit or '')[:12]}` |" - ) - continue - - rl_commit = resolve_rl(build.therock_commit) - entry_changed = ( - build.rocm_version != current.rocm_version - or rl_commit != current.rocm_libraries_commit - or build.therock_commit != current.therock_commit - ) - if entry_changed: - new_archs_data[arch] = { - "rocm_version": build.rocm_version, - "build_date": build.build_date, - "therock_commit": build.therock_commit, - "rocm_libraries_commit": rl_commit, - "index_url": build.index_url, - } - bumped_archs.append(arch) - bumped_versions.add(build.rocm_version) - rows.append( - f"| `{arch}` | **bumped** | `{current.rocm_version}` -> `{build.rocm_version}` | " - f"`{(current.rocm_libraries_commit or '')[:12]}` -> `{rl_commit[:12]}` |" - ) - else: - new_archs_data[arch] = current_entry - rows.append( - f"| `{arch}` | unchanged | `{current.rocm_version}` | " - f"`{(current.rocm_libraries_commit or '')[:12]}` |" - ) - - changed = bool(bumped_archs) - if changed: - pin_path.write_text( - json.dumps({"default": default_arch, "archs": new_archs_data}, indent=2) - + "\n", - encoding="utf-8", - ) - if len(bumped_versions) == 1: - ver = next(iter(bumped_versions)) - title = f"chore(deps): bump ROCm pin ({', '.join(bumped_archs)} -> {ver})" - else: - title = f"chore(deps): bump ROCm pin ({', '.join(bumped_archs)})" - body_lines = [ - "Bump per-arch entries in `rocm-pin.json` to the newest passing Quartz nightly (archs without a newer passing nightly stay untouched):", - "", - "| Arch | Status | ROCm / PyTorch | rocm-libraries |", - "|---|---|---|---|", - *rows, - "", - ] - body_path = Path(os.environ["RUNNER_TEMP"]) / "bump-rocm-pin-body.md" - body_path.write_text("\n".join(body_lines), encoding="utf-8") - else: - title = "" - - out = Path(os.environ["GITHUB_OUTPUT"]) - with out.open("a", encoding="utf-8") as f: - f.write(f"changed={'true' if changed else 'false'}\n") - f.write(f"title={title}\n") - - print("\n".join(rows)) - print(f"changed={changed}") - PY + python3 tools/bump_rocm_pin.py \ + --rocm-version "${REQUESTED_VERSION}" \ + --archs "${REQUESTED_ARCHS}" \ + --body-file "${RUNNER_TEMP}/bump-rocm-pin-body.md" \ + --github-output "${GITHUB_OUTPUT}" - name: Open or update bump PR if: steps.resolve.outputs.changed == 'true' @@ -247,7 +68,7 @@ jobs: remote="https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git" # Skip pushing when the open bump branch already carries this exact - # pin, so scheduled runs do not trigger redundant GPU CI or overwrite + # pin, so repeated runs do not trigger redundant GPU CI or overwrite # manual fix-up commits on the bump PR. if git fetch --quiet "${remote}" "refs/heads/${branch}" 2>/dev/null; then if git show FETCH_HEAD:rocm-pin.json 2>/dev/null | cmp -s - rocm-pin.json; then @@ -265,9 +86,9 @@ jobs: pr_number=$(gh pr list --repo "${REPO}" --head "${branch}" --state open --json number --jq '.[0].number // empty') if [ -n "${pr_number}" ]; then - gh pr edit "${pr_number}" --repo "${REPO}" \ - --title "${PR_TITLE}" \ - --body-file "${body_file}" + gh api -X PATCH "repos/${REPO}/pulls/${pr_number}" \ + -f title="${PR_TITLE}" \ + -F body=@"${body_file}" >/dev/null echo "Updated PR #${pr_number}" else pr_url=$(gh pr create --repo "${REPO}" --base main --head "${branch}" \ diff --git a/docs/setup.md b/docs/setup.md index 64b69472..b1dd61dd 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -220,8 +220,8 @@ matching `rocm-libraries` commit checked into `rocm-pin.json` (falling back to its `default` entry for unlisted architectures). This keeps the ROCm PyTorch wheels, MIOpen and `miopen-provider` in lockstep without reading Quartz on every setup run, lets each architecture advance independently as its Quartz -tests pass, and isolates upstream regressions to scheduled bump PRs -(`.github/workflows/bump-rocm-pin.yml`). +tests pass, and isolates upstream regressions to gated bump PRs +(`tools/bump_rocm_pin.py` and `.github/workflows/bump-rocm-pin.yml`). To pull the newest passing nightly directly from [Quartz](https://github.com/ROCm/Quartz), pass `--rocm-version latest`: @@ -300,14 +300,12 @@ Result files copy the build fields to `environment.rocm_build_version`, CI (`setup.yml` gpu-test and `check-deserialize.yml`) uses `rocm-pin.json`. To test another build in CI, set the `ROCM_VERSION` repository variable (for example `latest` or a specific version). Each job prints the ROCm build and -`rocm-libraries` commit in its log and in the job summary. The scheduled -`.github/workflows/bump-rocm-pin.yml` workflow checks each architecture in +`rocm-libraries` commit in its log and in the job summary. +`tools/bump_rocm_pin.py` (also runnable manually via +`.github/workflows/bump-rocm-pin.yml`) checks each architecture in `rocm-pin.json` independently (`gfx90a`, `gfx942`, `gfx950` on Linux; `gfx1151` on Windows + Linux builds), advances only the architectures whose -Quartz tests pass, leaves failing architectures untouched, and opens a bump PR -with squash auto-merge enabled. When the `ROCM_PIN_BUMP_TOKEN` repository -secret is configured, GitHub runs `gpu-tests` and `check-deserialize` on each -bump PR automatically. +Quartz tests pass, and leaves failing architectures untouched. ## rocm-libraries source diff --git a/tests/unit/test_bump_rocm_pin.py b/tests/unit/test_bump_rocm_pin.py new file mode 100644 index 00000000..947256eb --- /dev/null +++ b/tests/unit/test_bump_rocm_pin.py @@ -0,0 +1,182 @@ +# Copyright Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT +"""Unit tests for tools/bump_rocm_pin.py.""" + +from __future__ import annotations + +import importlib.util +import json +import sys +from pathlib import Path + +import pytest + +_REPO_ROOT = Path(__file__).resolve().parents[2] +_QUARTZ_NIGHTLY = Path(__file__).resolve().parent / "data" / "quartz" / "nightly" + + +@pytest.fixture(scope="module") +def bump_mod(): + spec = importlib.util.spec_from_file_location( + "bump_rocm_pin", _REPO_ROOT / "tools" / "bump_rocm_pin.py" + ) + mod = importlib.util.module_from_spec(spec) + sys.modules[spec.name] = mod + spec.loader.exec_module(mod) + return mod + + +@pytest.fixture(scope="module") +def setup_env(bump_mod): + return bump_mod.load_setup_env(_REPO_ROOT) + + +def _write_pin(path: Path, archs: dict, default: str = "gfx950") -> Path: + path.write_text( + json.dumps({"default": default, "archs": archs}, indent=2) + "\n", + encoding="utf-8", + ) + return path + + +def _entry(date: str, therock: str, rl: str) -> dict: + return { + "rocm_version": f"10.3.0a{date}", + "build_date": date, + "therock_commit": therock, + "rocm_libraries_commit": rl, + "index_url": "https://nightly.repo.amd.com/rocm/whl-next/", + } + + +def _serve_recorded_quartz(setup_env, monkeypatch, latest: str, overrides: dict): + fetched: list[str] = [] + + def fetch(url: str): + fetched.append(url) + if url.endswith("/latest.json"): + return f"{latest}/status.json\n" + day = url.removesuffix("/status.json").rsplit("/", 1)[-1] + if day in overrides: + return json.dumps(overrides[day]) + recorded = _QUARTZ_NIGHTLY / day / "status.json" + return recorded.read_text(encoding="utf-8") if recorded.is_file() else None + + monkeypatch.setattr(setup_env, "fetch_quartz_text", fetch) + return fetched + + +def test_bump_pins_advances_passing_archs_and_leaves_failing_untouched( + bump_mod, setup_env, tmp_path, monkeypatch +) -> None: + # Recorded 20261115: gfx950 passes, gfx942 fails rocm tests. + # Recorded 20261116: rocm build is in_progress for all archs. + fetched = _serve_recorded_quartz(setup_env, monkeypatch, "20261116", {}) + rl_calls: list[str] = [] + + def fake_resolve(therock_commit: str, repo_url=None, *, required=True): + rl_calls.append(therock_commit) + return "f" * 40 + + monkeypatch.setattr( + setup_env, "resolve_therock_rocm_libraries_commit", fake_resolve + ) + + pin_path = _write_pin( + tmp_path / "rocm-pin.json", + { + "gfx942": _entry("20261114", "1" * 40, "a" * 40), + "gfx950": _entry("20261114", "1" * 40, "a" * 40), + }, + ) + + res = bump_mod.bump_pins(setup_env, pin_path) + + assert res.changed is True + assert res.bumped_archs == ("gfx950",) + assert res.title == "chore(deps): bump ROCm pin (gfx950 -> 10.3.0a20261115)" + saved = json.loads(pin_path.read_text(encoding="utf-8")) + # gfx942 had no passing nightly -> untouched + assert saved["archs"]["gfx942"]["rocm_version"] == "10.3.0a20261114" + assert saved["archs"]["gfx942"]["rocm_libraries_commit"] == "a" * 40 + # gfx950 bumped to 20261115 + assert saved["archs"]["gfx950"]["rocm_version"] == "10.3.0a20261115" + assert saved["archs"]["gfx950"]["rocm_libraries_commit"] == "f" * 40 + assert len(rl_calls) == 1 + # Quartz URLs were memoized across the two arch loops (each URL fetched once). + assert len(fetched) == len(set(fetched)) + + +def test_bump_pins_never_downgrades_on_automatic_run( + bump_mod, setup_env, tmp_path, monkeypatch +) -> None: + _serve_recorded_quartz(setup_env, monkeypatch, "20261119", {}) + monkeypatch.setattr( + setup_env, + "resolve_therock_rocm_libraries_commit", + lambda *_a, **_kw: (_ for _ in ()).throw(AssertionError("should not resolve")), + ) + + pin_path = _write_pin( + tmp_path / "rocm-pin.json", + {"gfx950": _entry("20261123", "2" * 40, "b" * 40)}, + ) + + res = bump_mod.bump_pins(setup_env, pin_path) + + assert res.changed is False + assert res.bumped_archs == () + assert res.title == "" + assert any("newest passing 20261119 < pinned 20261123" in r for r in res.rows) + + +def test_bump_pins_dry_run_does_not_modify_file( + bump_mod, setup_env, tmp_path, monkeypatch +) -> None: + _serve_recorded_quartz(setup_env, monkeypatch, "20261119", {}) + monkeypatch.setattr( + setup_env, + "resolve_therock_rocm_libraries_commit", + lambda *_a, **_kw: "e" * 40, + ) + pin_path = _write_pin( + tmp_path / "rocm-pin.json", + {"gfx950": _entry("20261118", "1" * 40, "a" * 40)}, + ) + before = pin_path.read_text(encoding="utf-8") + + res = bump_mod.bump_pins(setup_env, pin_path, dry_run=True) + + assert res.changed is True + assert res.bumped_archs == ("gfx950",) + assert pin_path.read_text(encoding="utf-8") == before + + +def test_bump_pins_caches_therock_lookup_across_archs( + bump_mod, setup_env, tmp_path, monkeypatch +) -> None: + _serve_recorded_quartz(setup_env, monkeypatch, "20261119", {}) + rl_calls: list[str] = [] + + def fake_resolve(therock_commit: str, repo_url=None, *, required=True): + rl_calls.append(therock_commit) + return "c" * 40 + + monkeypatch.setattr( + setup_env, "resolve_therock_rocm_libraries_commit", fake_resolve + ) + pin_path = _write_pin( + tmp_path / "rocm-pin.json", + { + "gfx942": _entry("20261118", "1" * 40, "a" * 40), + "gfx950": _entry("20261118", "1" * 40, "a" * 40), + }, + ) + + res = bump_mod.bump_pins(setup_env, pin_path) + + assert res.changed is True + assert res.bumped_archs == ("gfx942", "gfx950") + assert res.title == "chore(deps): bump ROCm pin (gfx942, gfx950 -> 10.3.0a20261119)" + # Both archs landed on 20261119 (same therock_commit) -> only 1 TheRock lookup. + assert len(rl_calls) == 1 diff --git a/tools/bump_rocm_pin.py b/tools/bump_rocm_pin.py new file mode 100755 index 00000000..f1313f44 --- /dev/null +++ b/tools/bump_rocm_pin.py @@ -0,0 +1,325 @@ +#!/usr/bin/env python3 +# Copyright Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT +"""Advance per-arch ROCm + rocm-libraries pins in rocm-pin.json from Quartz. + +Each architecture in rocm-pin.json is checked independently against Quartz +(walking back up to QUARTZ_LOOKBACK_DAYS days, never downgrading on automatic +runs). Architectures without a newer passing nightly stay untouched. + +Used by both `.github/workflows/bump-rocm-pin.yml` (manual dispatch) and +scheduled automation. +""" + +from __future__ import annotations + +import argparse +import dataclasses +import importlib.util +import json +import sys +from pathlib import Path +from types import ModuleType +from typing import Dict, List, Optional, Sequence, Tuple + +REPO_ROOT = Path(__file__).resolve().parent.parent + +# Per-arch Quartz gate: (primary_platform, extra_build_only_platforms). +# Linux datacenter archs gate on Linux build+tests; gfx1151 gates on Windows +# build+tests plus Linux wheel builds. Unlisted archs default to ("linux", ()). +ARCH_GATES: Dict[str, Tuple[str, Tuple[Tuple[str, str], ...]]] = { + "gfx90a": ("linux", ()), + "gfx942": ("linux", ()), + "gfx950": ("linux", ()), + "gfx1151": ("windows", (("linux", "gfx1151"),)), +} + + +@dataclasses.dataclass(frozen=True) +class BumpResult: + changed: bool + title: str + body: str + bumped_archs: Tuple[str, ...] + rows: Tuple[str, ...] + payload: Dict[str, object] + + +def load_setup_env(repo_root: Path = REPO_ROOT) -> ModuleType: + setup_path = repo_root / "setup_env.py" + spec = importlib.util.spec_from_file_location("setup_env", setup_path) + if spec is None or spec.loader is None: + raise RuntimeError(f"cannot load {setup_path}") + module = importlib.util.module_from_spec(spec) + sys.modules[spec.name] = module + spec.loader.exec_module(module) + return module + + +def bump_pins( + setup_env: ModuleType, + pin_path: Path, + *, + requested_version: str = "", + requested_archs: Sequence[str] = (), + dry_run: bool = False, +) -> BumpResult: + default_arch, current_pins = setup_env.read_rocm_pins(pin_path) + + requested = requested_version.strip() + if requested: + requested = setup_env._rocm_version(requested) + is_manual = bool(requested and requested != "latest") + + if requested_archs: + target_archs = [a.strip().lower() for a in requested_archs if a.strip()] + unknown = [a for a in target_archs if a not in current_pins] + if unknown: + setup_env.fail( + f"Unknown arch(s) in --archs: {', '.join(unknown)}.", + f"Expected a subset of: {', '.join(current_pins)}.", + ) + else: + target_archs = list(current_pins) + + # Memoize Quartz HTTP fetches across arch checks without leaking global state. + orig_fetch = setup_env.fetch_quartz_text + fetch_cache: Dict[str, Optional[str]] = {} + + def cached_fetch(url: str) -> Optional[str]: + if url not in fetch_cache: + fetch_cache[url] = orig_fetch(url) + return fetch_cache[url] + + therock_cache: Dict[str, str] = {} + + def resolve_rl(therock_commit: str) -> str: + if therock_commit not in therock_cache: + therock_cache[therock_commit] = ( + setup_env.resolve_therock_rocm_libraries_commit(therock_commit) + ) + return therock_cache[therock_commit] + + new_archs_data: Dict[str, Dict[str, Optional[str]]] = {} + bumped_archs: List[str] = [] + bumped_versions: set[str] = set() + rows: List[str] = [] + + setup_env.fetch_quartz_text = cached_fetch + try: + for arch, current in current_pins.items(): + current_entry: Dict[str, Optional[str]] = { + "rocm_version": current.rocm_version, + "build_date": current.build_date, + "therock_commit": current.therock_commit, + "rocm_libraries_commit": current.rocm_libraries_commit, + "index_url": current.index_url, + } + cur_rl_short = (current.rocm_libraries_commit or "")[:12] + + if arch not in target_archs: + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | skipped | `{current.rocm_version}` | " + f"`{cur_rl_short}` |" + ) + continue + + plat, extra_builds = ARCH_GATES.get(arch, ("linux", ())) + if is_manual: + build = setup_env.describe_rocm_version(requested, "", plat, arch) + else: + build = setup_env.find_quartz_nightly( + plat, arch, require_platform_builds=extra_builds + ) + + if build is None: + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | unchanged " + f"(no passing nightly in {setup_env.QUARTZ_LOOKBACK_DAYS}d) | " + f"`{current.rocm_version}` | `{cur_rl_short}` |" + ) + continue + + if not build.therock_commit: + if is_manual: + setup_env.fail( + f"Quartz has no therock_commit for ROCm {build.rocm_version}." + ) + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | unchanged (no therock_commit) | " + f"`{current.rocm_version}` | `{cur_rl_short}` |" + ) + continue + + current_date = current.build_date or "" + new_date = build.build_date or "" + # Scheduled/latest bumps only move forward; explicit version may pin any build. + if not is_manual and current_date and new_date and new_date < current_date: + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | unchanged " + f"(newest passing {new_date} < pinned {current_date}) | " + f"`{current.rocm_version}` | `{cur_rl_short}` |" + ) + continue + + rl_commit = resolve_rl(build.therock_commit) + entry_changed = ( + build.rocm_version != current.rocm_version + or rl_commit != current.rocm_libraries_commit + or build.therock_commit != current.therock_commit + ) + if entry_changed: + new_archs_data[arch] = { + "rocm_version": build.rocm_version, + "build_date": build.build_date, + "therock_commit": build.therock_commit, + "rocm_libraries_commit": rl_commit, + "index_url": build.index_url, + } + bumped_archs.append(arch) + bumped_versions.add(build.rocm_version) + rows.append( + f"| `{arch}` | **bumped** | " + f"`{current.rocm_version}` -> `{build.rocm_version}` | " + f"`{cur_rl_short}` -> `{rl_commit[:12]}` |" + ) + else: + new_archs_data[arch] = current_entry + rows.append( + f"| `{arch}` | unchanged | `{current.rocm_version}` | " + f"`{cur_rl_short}` |" + ) + finally: + setup_env.fetch_quartz_text = orig_fetch + + payload: Dict[str, object] = {"default": default_arch, "archs": new_archs_data} + changed = bool(bumped_archs) + if changed: + if not dry_run: + pin_path.write_text( + json.dumps(payload, indent=2) + "\n", + encoding="utf-8", + ) + if len(bumped_versions) == 1: + ver = next(iter(bumped_versions)) + title = f"chore(deps): bump ROCm pin ({', '.join(bumped_archs)} -> {ver})" + else: + title = f"chore(deps): bump ROCm pin ({', '.join(bumped_archs)})" + body = ( + "\n".join( + [ + "Bump per-arch entries in `rocm-pin.json` to the newest passing " + "Quartz nightly (archs without a newer passing nightly stay untouched):", + "", + "| Arch | Status | ROCm / PyTorch | rocm-libraries |", + "|---|---|---|---|", + *rows, + ] + ) + + "\n" + ) + else: + title = "" + body = "" + + return BumpResult( + changed=changed, + title=title, + body=body, + bumped_archs=tuple(bumped_archs), + rows=tuple(rows), + payload=payload, + ) + + +def parse_args(argv: Optional[Sequence[str]] = None) -> argparse.Namespace: + parser = argparse.ArgumentParser( + description="Update per-arch ROCm + rocm-libraries pins in rocm-pin.json." + ) + parser.add_argument( + "--pin-file", + type=Path, + default=REPO_ROOT / "rocm-pin.json", + help="Path to rocm-pin.json (default: repo root rocm-pin.json).", + ) + parser.add_argument( + "--rocm-version", + default="", + help=( + "Optional ROCm nightly version (e.g. 10.3.0a20261123); blank or " + "'latest' advances each arch independently from Quartz." + ), + ) + parser.add_argument( + "--archs", + default="", + help="Optional comma-separated arch keys to update (default: all).", + ) + parser.add_argument( + "--dry-run", + action="store_true", + help="Resolve and print changes without modifying rocm-pin.json.", + ) + parser.add_argument( + "--body-file", + type=Path, + default=None, + help="Write the Markdown PR body here when changes are found.", + ) + parser.add_argument( + "--github-output", + type=Path, + default=None, + help="Append changed and title outputs in GitHub Actions format.", + ) + parser.add_argument( + "--json-out", + type=Path, + default=None, + help="Write structured JSON result (changed, title, bumped_archs, rows).", + ) + return parser.parse_args(argv) + + +def main(argv: Optional[Sequence[str]] = None) -> int: + args = parse_args(argv) + setup_env = load_setup_env() + requested_archs = [a for a in args.archs.split(",") if a.strip()] + result = bump_pins( + setup_env, + args.pin_file, + requested_version=args.rocm_version, + requested_archs=requested_archs, + dry_run=args.dry_run, + ) + if result.changed and args.body_file is not None: + args.body_file.write_text(result.body, encoding="utf-8") + if args.github_output is not None: + with args.github_output.open("a", encoding="utf-8") as handle: + handle.write(f"changed={'true' if result.changed else 'false'}\n") + handle.write(f"title={result.title}\n") + if args.json_out is not None: + args.json_out.write_text( + json.dumps( + { + "changed": result.changed, + "title": result.title, + "bumped_archs": list(result.bumped_archs), + "rows": list(result.rows), + }, + indent=2, + ) + + "\n", + encoding="utf-8", + ) + print("\n".join(result.rows)) + print(f"changed={result.changed}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())