Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-deserialize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,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"

Expand Down
14 changes: 9 additions & 5 deletions dockerfiles/Dockerfile.dnn-benchmark-performance-linux
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,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 \
Expand Down Expand Up @@ -48,6 +43,15 @@ COPY . .
# build keeps the apt layer.
ARG ROCM_VERSION=""

# The build context has no .git (see .dockerignore), so setup_env.py cannot
# resolve the rocm-libraries submodule pin itself. The build script passes the
# rocm-libraries commit matched to ROCM_VERSION's TheRock commit (falling back
# to `git rev-parse HEAD:rocm-libraries` when Quartz has no TheRock commit).
# Empty => setup resolves rocm-libraries from Quartz's therock_commit when
# known, else warns and builds the moving .gitmodules branch. Declared here,
# not at the stage top, so a new nightly keeps the apt layer.
ARG ROCM_LIBRARIES_REF=""

RUN --mount=type=cache,target=/root/.cache/pip <<'EOF'
set -eu

Expand Down
53 changes: 39 additions & 14 deletions dockerfiles/build-dnn-benchmark-performance-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ container_command="docker"
device_target="gfx942"
tag=""
rocm_version=""
rocm_libraries_ref=""
build_args=()

usage() {
Expand All @@ -21,6 +22,10 @@ Options:
10.3.0a20261117. Default: the newest nightly that
Quartz reports as built for the device target,
selected on this host.
--rocm-libraries-ref SHA Full 40-character rocm-libraries commit to build.
Default: the rocm-libraries commit pinned by the
selected ROCm nightly's TheRock commit (falling back
to the local submodule pin if Quartz has none).
-h, --help Show this help.

Examples:
Expand Down Expand Up @@ -53,6 +58,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
Expand Down Expand Up @@ -82,32 +92,47 @@ 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'
# Select the ROCm nightly here, with the same rule as setup_env.py, and resolve
# the matching rocm-libraries commit from its TheRock commit unless the caller
# passed --rocm-libraries-ref. The image then installs and labels that matched
# build even when a newer nightly appears.
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:
build = setup_env.select_quartz_nightly("linux", device_target)
print(build.rocm_version, build.index_url)
if not rocm_libraries_ref and build.therock_commit:
rocm_libraries_ref = setup_env.resolve_therock_rocm_libraries_commit(
build.therock_commit
)
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}"

# Fall back to the local submodule pin when Quartz had no TheRock commit (for
# example a custom --rocm-version unknown to Quartz).
if [[ -z "${rocm_libraries_ref}" ]]; then
rocm_libraries_ref="$(git -C "${repo_root}" rev-parse HEAD:rocm-libraries 2>/dev/null || true)"
fi
if [[ -z "${rocm_libraries_ref}" ]]; then
echo "WARNING: could not resolve a rocm-libraries commit; the image will build its moving branch." >&2
fi
echo "ROCm ${rocm_version} from ${rocm_index_url} (rocm-libraries ${rocm_libraries_ref:-moving})"

DOCKER_BUILDKIT="${DOCKER_BUILDKIT:-1}" "${container_command}" build \
-f "${script_dir}/Dockerfile.dnn-benchmark-performance-linux" \
Expand Down
64 changes: 40 additions & 24 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The setup prints the prefix as `Using hipDNN/ROCm prefix: ...`.
| `--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: the commit pinned by the Quartz nightly's `therock_commit` in `rocm` mode, else the repo's submodule pin. 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. |

Expand Down Expand Up @@ -273,11 +273,12 @@ Quartz.

After the install, setup writes `<workspace>/.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`,
matched `rocm-libraries` commit (added when `rocm-libraries` is resolved 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)).

Expand All @@ -292,18 +293,29 @@ and its untested suites in its log and in the job summary.
`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
- When `rocm-libraries/` is absent, setup does a sparse, blobless clone. 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`), when Quartz supplies a `therock_commit`
for the installed ROCm nightly, the `rocm-libraries` submodule commit
pinned by that `therock_commit` in `ROCm/TheRock`. This keeps
`miopen-provider` and hipDNN in lockstep with the MIOpen libraries in the
ROCm wheel.
3. Otherwise (`--torch-mode cpu`, `--torch-mode none`, a custom
`--torch-index-url` without Quartz, or a `--rocm-version` unknown to
Quartz), the pinned submodule commit (`git rev-parse HEAD:rocm-libraries`).
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.
- Where no git metadata and no Quartz `therock_commit` exist (for example a
source tarball with `--torch-mode cpu`), 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
checkout is not at the expected commit (the Quartz-matched commit in `rocm`
mode, or the pinned commit otherwise). 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.

Expand Down Expand Up @@ -464,19 +476,23 @@ from the local checkout:
| `--device-target TARGET` | `gfx942` | ROCm PyTorch architecture: `gfx90a`, `gfx942`, `gfx950`, `gfx1151` or `gfx1152`. |
| `--tag TAG` | `dnn-benchmark-performance:<device-target>` | Image tag. |
| `--rocm-version VERSION` | newest usable Quartz nightly | ROCm wheel version to install. |
| `--rocm-libraries-ref SHA` | matched to the nightly's `therock_commit` | 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
The script 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`:
names one. Unless `--rocm-libraries-ref` is given, it then resolves the
matching `rocm-libraries` commit from `ROCm/TheRock` at that nightly's
`therock_commit` (falling back to the local submodule pin when Quartz has no
`therock_commit`, because the build context has no `.git`). The host thus
needs `python3`, `git` and HTTPS access to `github.com`. 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 selected build as the `ROCM_VERSION`, `ROCM_LIBRARIES_REF` and
`ROCM_TORCH_INDEX_URL` build arguments. Both `ROCM_VERSION` and
`ROCM_LIBRARIES_REF` are declared after the `apt-get` stage, so a new nightly
reuses the apt layer and rebuilds only the setup layer. The image carries the
ROCm version in the label `com.amd.dnn-benchmark.rocm-version`:

```bash
docker inspect --format \
Expand Down
Loading
Loading