Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@ add_python_test(registry_loss_check_test ${CMAKE_SOURCE_DIR}/tests/registry_loss
# engine#2406 puts "audit those on a pin bump" on the f16 ratchet's green line; this is that audit
# for the HIP add-on's kernels, which the ratchet cannot see (it walks *.loom).
add_python_test(hip_f16_audit_self ${CMAKE_SOURCE_DIR}/tools/ci/hip_f16_audit.py --self-test)
# engine#2416: the audit itself, not just its --self-test. The engine has no gpu-kernels submodule, so the row audits
# $GPU_KERNELS_DIR (or third_party/gpu-kernels) against config/gpu-kernels.config's pin, refuses a tree at any other
# commit, and with no tree prints "the add-on f16 audit did NOT run" and is reported as skipped (77), not passed.
add_test(NAME hip_f16_audit COMMAND ${Python3_EXECUTABLE}
${CMAKE_SOURCE_DIR}/tools/ci/hip_f16_audit.py --find ${CMAKE_SOURCE_DIR})
set_tests_properties(hip_f16_audit PROPERTIES SKIP_RETURN_CODE 77)
# engine#2398: the stale-branch test, which `tests_referenced` refuses to leave unregistered -- a test no
# runner names is a test nobody runs.
add_python_test(branch_stale_check_test ${CMAKE_SOURCE_DIR}/tests/branch_stale_check_test.py)
Expand Down
5 changes: 3 additions & 2 deletions docs/pre-pr-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Ten commands, all host-side, none needing a device or a build. Every one of them

Run them from the repository root on the branch you are about to hand over.

**`scripts/pre-pr-checks.sh` runs the first nine**, one line each (`--base <ref>` for the registration check, `--list` to see the
**`scripts/pre-pr-checks.sh` runs the first ten**, one line each (`--base <ref>` for the registration check, `--list` to see the
commands; a check that cannot run says `skip` and why, and an unresolvable `--base` is a usage error rather than a skip). The
eighth is an **author's check**, true or false exactly once — when you add a page — so it is not in the runner, and the section
eleventh is an **author's check**, true or false exactly once — when you add a page — so it is not in the runner, and the section
below says why. The table's order is the runner's order: cheapest and most common first, and the check that needs a revision
(`registration_loss_check --base`) last.

Expand All @@ -38,6 +38,7 @@ below says why. The table's order is the runner's order: cheapest and most commo
| `python3 tools/ci/registration_loss_check.py --check --base origin/main` | your branch would drop rows `main` has |
| `python3 tools/ci/registry_loss_check.py --base origin/main` | a reviewed class, a `coverage` counter or a test's mention of a class that the base has is gone at the merge, not only at the endpoint (engine#2385, #2391) |
| `python3 tools/ci/branch_stale_check.py --base origin/main` | the merge with the base conflicts, or would not keep a base change the branch never touched; a branch that is only behind gets a note (the merge keeps the base's copy, but the branch's tests ran on the older one) (engine#2398, #2410) |
| `python3 tools/ci/hip_f16_audit.py --find .` | a HIP add-on kernel accumulates in f16, or the gpu-kernels tree is not at the pinned commit; `skip` (the audit did NOT run) when there is no tree: set `GPU_KERNELS_DIR` to a checkout at the pin |
| `git grep -l -F "$(basename <your new page>)" -- '*.md'` | nothing links to the page you just added — measured tonight: 45 docs, one with no inbound link, and it was the page whose whole subject is pre-merge checks |

Two more, for the moments they are for:
Expand Down
9 changes: 9 additions & 0 deletions scripts/pre-pr-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ checks=(
"tools/ci/registration_loss_check.py --check --base $base"
"tools/ci/registry_loss_check.py --base $base"
"tools/ci/branch_stale_check.py --base $base"
# engine#2416: the HIP add-on's f16 audit over $GPU_KERNELS_DIR (or third_party/gpu-kernels) at the pin; with no
# tree it exits 77 and is listed as `skip`, never `ok`
"tools/ci/hip_f16_audit.py --find ."
)

# The page and this list drift apart, and it has happened twice in one night: the page said the runner "runs the first six"
Expand Down Expand Up @@ -108,6 +111,12 @@ for c in "${checks[@]}"; do
name=${c%% *}
out=$(python3 $c 2>&1); rc=$?
last=$(printf '%s\n' "$out" | grep -v '^$' | tail -1)
if [ $rc -eq 77 ]; then
# 77 is the repo's "cannot run here" (ctest SKIP_RETURN_CODE): counted as a skip with the tool's own
# reason, so the summary still says something did not run
printf 'skip %-42s %s\n' "$name" "$last"
skipped=$((skipped + 1)); continue
fi
if [ $rc -eq 0 ]; then
# `submodule_pin_check --check` exits 0 having compared NOTHING when submodules are declared but
# none is checked out -- `0 submodule(s) at their pinned commit, N not initialised` -- which would
Expand Down
50 changes: 50 additions & 0 deletions tools/ci/hip_f16_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import argparse
import json
import os
import re
import sys
from pathlib import Path
Expand Down Expand Up @@ -224,6 +225,29 @@ def chk(want, got, what):
chk(False, sha_matches(None, at), "a tree with no commit never matches, not even a guess")
chk(False, sha_matches(at, ""), "an empty expectation is not a wildcard")

# --find (engine#2416): where the ctest row looks, and that "nothing found" is a skip, never a clean pass
with tempfile.TemporaryDirectory() as tmp:
engine = Path(tmp) / "engine"
(engine / "third_party").mkdir(parents=True)
explicit = Path(tmp) / "gk"
explicit.mkdir()
chk(None, find_tree(engine, env={}), "no $GPU_KERNELS_DIR and no submodule: nothing found")
chk(str(explicit), find_tree(engine, env={"GPU_KERNELS_DIR": str(explicit)}), "$GPU_KERNELS_DIR is used")
chk(None, find_tree(engine, env={"GPU_KERNELS_DIR": str(Path(tmp) / "missing")}),
"a $GPU_KERNELS_DIR that is not a directory is not a tree")
(engine / "third_party" / "gpu-kernels").mkdir()
chk(str(engine / "third_party" / "gpu-kernels"), find_tree(engine, env={}), "the submodule path is used")
chk(str(explicit), find_tree(engine, env={"GPU_KERNELS_DIR": str(explicit)}),
"$GPU_KERNELS_DIR wins over the submodule")
empty = Path(tmp) / "empty-engine"
empty.mkdir()
saved = os.environ.pop("GPU_KERNELS_DIR", None)
try:
chk(SKIPPED, main(["--find", str(empty)]), "--find with no tree exits 77 (skipped), not 0")
finally:
if saved is not None:
os.environ["GPU_KERNELS_DIR"] = saved

if problems:
for problem in problems:
print("FAIL " + problem)
Expand All @@ -232,6 +256,19 @@ def chk(want, got, what):
return 0


SKIPPED = 77 # ctest SKIP_RETURN_CODE: the same convention as hrx_f16_narrowing's "skip: no .loom corpus"


def find_tree(engine_root, env=None):
"""The gpu-kernels checkout --find audits: $GPU_KERNELS_DIR, else <engine>/third_party/gpu-kernels. None when
neither is a directory -- the engine has no gpu-kernels submodule, so a plain checkout has none (engine#2416)."""
env = os.environ if env is None else env
for candidate in (env.get("GPU_KERNELS_DIR"), str(Path(engine_root) / "third_party" / "gpu-kernels")):
if candidate and Path(candidate).is_dir():
return candidate
return None


def main(argv):
ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
ap.add_argument("--dir", help="a gpu-kernels checkout (must contain addons/hip-hrx/kernels)")
Expand All @@ -241,10 +278,23 @@ def main(argv):
ap.add_argument("--expect-sha", help="audit THIS commit (7..40 hex characters), for a candidate pin that has not "
"merged yet; overrides --config-root. An audit of the wrong tree reads as "
"clean, so the commit audited has to be asserted, not remembered")
ap.add_argument("--find", metavar="ENGINE_ROOT",
help="the ctest row (engine#2416): audit $GPU_KERNELS_DIR or ENGINE_ROOT/third_party/gpu-kernels "
"against ENGINE_ROOT's pin; with neither, say the audit did NOT run and exit 77 (skipped)")
ap.add_argument("--self-test", action="store_true")
a = ap.parse_args(argv)
if a.self_test:
return self_test()
if a.find:
tree = find_tree(a.find)
if tree is None:
print("SKIPPED: hip_f16_audit found no gpu-kernels tree ($GPU_KERNELS_DIR unset, no "
f"{Path(a.find) / 'third_party' / 'gpu-kernels'}) - the add-on f16 audit did NOT run; set "
"GPU_KERNELS_DIR to a gpu-kernels checkout at the pin in config/gpu-kernels.config to run it")
return SKIPPED
a.dir = tree
if not a.expect_sha:
a.config_root = a.find
if not a.dir:
print("hip_f16_audit: --dir is required (the gpu-kernels checkout to audit)", file=sys.stderr)
return 2
Expand Down
Loading