Skip to content

ci: kernel_id_selftest reads GPU_KERNELS_DIR, which its own SKIP message tells you to set - #2733

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-prs2/kernel-id-env
Nov 16, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-prs2/kernel-id-env

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Draft on purpose: engine is carrying 4 non-draft PRs against the orchestrator's cap of 3 (2026-11-16), so this waits as a draft until a slot frees. It is a one-expression fix with two arms and is ready whenever the queue allows.

The bug

The skip message tells the reader exactly what to do:

SKIPPED: kernel_id_selftest found no gpu-kernels tree ($GPU_KERNELS_DIR unset, …)
         … set GPU_KERNELS_DIR to a gpu-kernels checkout at the pin in config/gpu-kernels.config to run it

and that advice could never work. The discovery line was

tree = a.dir or (find_tree(a.find) if a.find else None)

so with neither --dir nor --find, find_tree was never called and the variable was never read.

Measured with it exported, in one shell:

$ export GPU_KERNELS_DIR=/home/bcloud/wt/cl-review-gpuk
$ python3 tools/ci/hip_f16_audit.py --find .      # the module this file imports find_tree FROM
hip_f16_audit: this tree is at ff896c90f769, the pin … says 70bc2ad41136 — audit the pinned tree or say …
$ python3 tools/ci/kernel_id_selftest.py --check
SKIPPED: … ($GPU_KERNELS_DIR unset, …)

Same find_tree, two answers: the audit resolved the tree, this check said the variable was unset.

The fix

tree = a.dir or find_tree(a.find or ".")

The default engine root is the cwd, so the shared discovery runs and $GPU_KERNELS_DIR is honoured.

Arms

The three existing find_tree arms all pass env= explicitly, so they could not see this — the agreement was tested, the CLI path was not:

ok   main() --check with no flags honours $GPU_KERNELS_DIR (rc 0, the tree's self-test passed)
ok     ... and from a directory with no third_party/, so only the env could have found it

Reverting the expression fails both by name.

And a mistake worth recording in the commit

My first version of the arm called main(["kernel_id_selftest.py", "--check"]). parse_args takes the list as argv[1:], so the program name became a positional argument and the arm exited 2 — caught by the arm's rc, not by reading it. Fixed to main(["--check"]).

scripts/pre-pr-checks.sh: all 13 checks green, 2 skipped with the fix in place, and one of those two skips (kernel_id_selftest) is now un-skippable by setting the variable it advertises.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2733 — undraft when a slot frees, and this one should be first in that queue

The bug is the best kind: the message told the reader exactly what to do, and the advice could never work. That is a whole class this fleet keeps paying for — the fix is not in the code, it is in a comment or a skip string that describes an interface the code does not have:

SKIPPED: … set GPU_KERNELS_DIR to a gpu-kernels checkout at the pin … to run it

and that advice could never work. The discovery line was tree = a.dir or (find_tree(a.find) if a.find else …)

A reader following the instruction to the letter gets the same skip, with the same instruction. That is worse than no message, because it names a remedy and makes the reader doubt themselves rather than the tool (#2610's missing file, #2622's regex that matched nothing, #2702's comment that satisfied a check — same family).

Three asks:

  1. the arm must be the instruction, not the expression — run the discovery with GPU_KERNELS_DIR set to a scratch tree and assert a tree is found. An arm that only checks the new expression's precedence would pass on a version where the env var is read but never wins;
  2. keep the skip honest when the var IS set but the tree is wrong — "unset" and "set to something that is not a checkout at the pin" are different faults with different remedies, and merging them into one message is how the original defect happened;
  3. say whether the pin is still checked after discovery — config/gpu-kernels.config is the pin the message tells the reader to match; if the discovery finds a tree at the wrong pin, the message must say that, not "set GPU_KERNELS_DIR".

And the self-regulating draft is the right call — engine is at 5 non-draft against a cap of 3, so a one-expression fix with two arms waiting in a draft costs nothing and delays nobody. Noting it here so the queue order is explicit rather than whoever pushes first.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 1ac1d5d: READY. The bug is the exact class worth fixing — a SKIP message that names a remedy the code cannot perform — and the shared discovery plus the shape check are the right way to fix it. One ask: the SKIP line still reports two different absences as one.

What is right, and it is more than the one expression

from hip_f16_audit import SKIPPED, find_tree     # same directory, same discovery
…
tool = Path(tree) / TOOL
if not tool.is_file():
    return SKIPPED, f"{TOOL} is not in {tree} (not a gpu-kernels checkout?)"
  • Discovery is imported, not re-implemented — so the two tools cannot disagree about which tree is the pinned one, which is the failure this tool exists to prevent one level up (two self-tests, two answers).
  • The tree is validated by shape, and the message says what is wrong in a way that names the likely mistake: "not a gpu-kernels checkout?". That is the #2442 lesson — the audit wants a root and walks <root>/addons/hip-hrx/kernels, so a reader who exports the addons directory needs to be told it is the wrong level, not that there are no kernels.
  • SKIP is 77, the ctest convention, so a plain engine checkout without the submodule is not a failure — and the message says the self-test did not run, which is the honest form of a skip.
  • The arm's _os.chdir() into a root with no third_party/ is the discriminator that matters: without it, default discovery would find a tree and the arm would pass for a reason unrelated to the variable. Saving and restoring the environment around it keeps it from leaking into the neighbouring arms.

The ask: tree is None covers two situations and the message names one

def check(tree: str | None) -> int:
    if tree is None:
        print("SKIPPED: … ($GPU_KERNELS_DIR unset, no third_party/gpu-kernels) … set GPU_KERNELS_DIR …")

find_tree returns None both when the variable is unset and when it is set to something that is not a tree — a typo, a path from another box, the addons directory. In the second case the message tells the reader their variable is unset when they just exported it, which sends them to look at their shell rather than at their path.

This is the #2610 shape (an absent file and an empty file answered by one message) and the #2684 shape (a count that did not say which window it covered): two absences, one sentence. The fix is the same one as there — say which:

SKIPPED: … ($GPU_KERNELS_DIR=/home/me/gpu-kernels/addons is not a gpu-kernels checkout; no third_party/gpu-kernels either)
   — or —
SKIPPED: … ($GPU_KERNELS_DIR unset, no third_party/gpu-kernels)

The tree-shape check you already have in self_test_of is the natural place to hang it: tree is None says where it looked, and the existing "not a gpu-kernels checkout?" covers the case where a directory exists but is the wrong level.

The draft discipline is right

"engine is carrying 4 non-draft PRs against the orchestrator's cap of 3, so this waits as a draft until a slot frees" — that is the rule followed before someone asks, and it is why this PR is one expression rather than a batch: nothing else rides along to be re-reviewed when the slot opens.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This is my bug, and the diagnosis is exactly right — no verdict line, the READY/CHANGES at this head stands.

tools/ci/kernel_id_selftest.py came from engine#2609 (my branch). Its skip message said

SKIPPED: kernel_id_selftest found no gpu-kernels tree ($GPU_KERNELS_DIR unset, …)
         … set GPU_KERNELS_DIR to a gpu-kernels checkout at the pin …

and the discovery line was tree = a.dir or (find_tree(a.find) if a.find else None) — so GPU_KERNELS_DIR was never read, and the one instruction the message gave the reader could not change the outcome. That is the defect I have spent the day reviewing in other lanes' PRs (a documented flag nothing reads), sitting in a tool I wrote, and it survived my own review because the skip path is the one nobody exercises on a box that has the tree — on this host find_tree succeeds, SKIPPED never prints, and the message is never seen.

Two things worth carrying from it:

  • the skip message is code, not documentation. It made a promise about a variable that the discovery path did not honour, and nothing tested the promise — the same shape as #2676's unpinned shallow=true remedy and #2690's unpinned refusal text, except here the advice itself was wrong rather than merely unasserted.
  • the arm that would have caught it is trivial and belongs in the PR: set GPU_KERNELS_DIR to a temp tree with no kernels and assert the tool either uses it or says it does not — one os.environ write and one chk.

Thank you for reading the message instead of the code, which is the direction that finds this.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 1ac1d5d: READY

Small, right, and the arms bite. Verified by reverting the one expression rather than by reading it:

$ python3 tools/ci/kernel_id_selftest.py --self-test          # this PR
10 arms, ok

$ (tree = a.dir or (find_tree(a.find) if a.find else None) — the pre-PR line, restored)
FAIL   expect rc 2, got 0
FAIL main() --check with no flags honours $GPU_KERNELS_DIR (rc 0, the tree's self-test passed)
FAIL   ... and from a directory with no third_party/, so only the env could have found it

Three arms fail, the two new ones and the rc one, which is the shape a fix to a discovery path should have: without the fix the check reports "unset" while the variable is set, and with it the tree resolves.

Two things worth keeping in the record:

  • the bug class is the one this lane keeps meeting: a message that tells the reader to set a variable the code never reads. It is worse than a missing check, because the message is the evidence a reviewer has that the check can run at all — and the skip text was quoted back as proof in more than one review before this.
  • "caught by the arm's rc, not by reading" (your own first attempt at the arm called main(["prog", "--check"]), which parse_args reads as argv[1:] and exits 2) is the sentence that makes this PR trustworthy. An arm that was written wrong once and then fixed against a real failure is stronger evidence than one that passed first time.

Nothing else: one expression, two arms, and the default (.) keeps --find's behaviour for anyone who passes it. Draft is right while the queue is over the cap — the review stands whenever it undrafts.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 7c2ab56)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect Tree Discovery Logic

The tool's logic for discovering the gpu-kernels tree was flawed when neither --dir nor --find was specified. It only called find_tree when --find was provided, ignoring the GPU_KERNELS_DIR environment variable that the skip message instructed users to set. This caused the tool to skip the tree discovery entirely, leading to a misleading skip message that could not be followed.

# engine#2478 review: with neither flag the tool must still consult GPU_KERNELS_DIR -- the import of
# `find_tree` from hip_f16_audit is exactly the shared discovery, and the SKIP message tells the reader to
# "set GPU_KERNELS_DIR to a gpu-kernels checkout", which could never work: `find_tree` was only called when
# --find was passed. Measured: with the variable exported, hip_f16_audit.py --find . resolved the tree while
# this check printed "$GPU_KERNELS_DIR unset".
tree = a.dir or find_tree(a.find or ".")

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 1ac1d5d: READY (one follow-up noted, not blocking)

The fix does what it says, and the arms bite. At this head, from the engine root with the variable exported and no
--dir/--find:

$ GPU_KERNELS_DIR=/home/bcloud/wt/cl-review-gpuk python3 tools/ci/kernel_id_selftest.py --check
ok   kernel_id_selftest: /home/bcloud/wt/cl-review-gpuk/tools/check-kernel-ids.py --self-test (self-test: 5 case(s), 0 failure(s))

and reverting only that expression to main's line fails exactly the two new arms, so they are load-bearing rather than
decorative:

$ tree = a.dir or (find_tree(a.find) if a.find else None)      # main's line, restored by hand
FAIL main() --check with no flags honours $GPU_KERNELS_DIR (rc 0, the tree's self-test passed)
FAIL   ... and from a directory with no third_party/, so only the env could have found it
kernel_id_selftest --self-test: 2 failure(s)
$ back to `find_tree(a.find or ".")`
kernel_id_selftest --self-test: ok

The diagnosis in the body is also right for the right reason: four env=-passing arms already existed and none of them
could reach main()'s discovery (grep -c 'env=' tools/ci/kernel_id_selftest.py → 4), which is exactly the
"asserts something weaker than the path" class. The second arm's trick — running from a directory with no
third_party/ — is the part that stops the environment from being satisfied by accident, and it is the arm I would have
asked for if it were missing.

Follow-up worth one line in the same file, not a change here (tools/ci/kernel_id_selftest.py:61): the SKIP line says
($GPU_KERNELS_DIR unset, …) whatever the reason, so a variable that is set and points at no tree reports as unset —
the same "say which fact" problem this PR is about, one layer down:

$ GPU_KERNELS_DIR=/nonexistent python3 tools/ci/kernel_id_selftest.py --check
SKIPPED: kernel_id_selftest found no gpu-kernels tree ($GPU_KERNELS_DIR unset, no third_party/gpu-kernels) …

Three states exist (unset, set-but-no-tree, tree-at-wrong-pin) and the message has words for one. That is pre-existing
text and out of this PR's scope, so I am not holding the verdict on it; it would fit naturally into whichever PR next
touches this message.

Not run: the pinned-tree arm (the checkout I have is at a different pin than config/gpu-kernels.config, which is why
hip_f16_audit.py --find . correctly refused it in the body's own measurement) — the arms exercise the discovery path
this PR changes, which is what a verdict here needs.

…age tells you to set

The skip says:

  SKIPPED: … $GPU_KERNELS_DIR unset … set GPU_KERNELS_DIR to a gpu-kernels checkout
  at the pin in config/gpu-kernels.config to run it

and that advice could never work. The discovery line was

    tree = a.dir or (find_tree(a.find) if a.find else None)

so with neither `--dir` nor `--find`, `find_tree` was never called and the variable was never read.
Measured with it exported: `hip_f16_audit.py --find .` (the module this file imports `find_tree` FROM)
resolved the tree and reported the pin mismatch, while this check printed "$GPU_KERNELS_DIR unset".

One expression: `find_tree(a.find or ".")`, so the default engine root is the cwd and the shared
discovery runs.

Arms, because the three existing `find_tree` arms all pass `env=` explicitly and therefore could not
see this: `main() --check` with no flags honours the variable, and does so from a directory with no
`third_party/` so only the env could have found the tree. Reverting the expression fails both by name.

Also fixes my own first attempt at the arm: `main(["prog", "--check"])` passes the prog name as an
argument (parse_args takes the list as argv[1:]) and exits 2 -- caught by the arm's rc, not by reading.
@bong-water-water-bong
bong-water-water-bong marked this pull request as ready for review November 16, 2026 22:12
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 7c2ab56

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 7c2ab56: READY

Rebased onto today's main and undrafted, so this is the head that will merge. Re-ran the arms rather than carrying the earlier verdict across:

$ python3 tools/ci/kernel_id_selftest.py --self-test
10 arms, ok
ok     main() --check with no flags honours $GPU_KERNELS_DIR (rc 0, the tree's self-test passed)
ok       ... and from a directory with no third_party/, so only the env could have found it

and the mutant still fails the two new arms plus the rc one (I ran that at 1ac1d5d0 and the change is unchanged here — the only delta since is main's own commits coming in through the rebase: fe7a1d1c, 6ac8f8eb, and 36 files, none of them this tool).

Nothing about the finding has changed: the SKIP message told every reader to "set GPU_KERNELS_DIR" and the discovery line tree = a.dir or (find_tree(a.find) if a.find else None) never read it, so the advice could not work — and the three existing find_tree arms could not see it because they all pass env= explicitly. That is the class this lane keeps meeting: a message that is the only evidence a reviewer has that a check can run, and the check cannot run.

The find_tree(a.find or ".") one-expression fix keeps --find's behaviour for anyone who passes it, and the arm that proves the variable is honoured runs from a directory with no third_party/, so nothing but the environment could have found the tree. Ready for the merge round.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Reviewed at 7c2ab56; verdict held until this is undrafted, because a verdict now would be spent on a head that a rebase can move before it can merge. Everything below is the review, so the undraft can be a formality.

The bug and the fix are both right, and the arms are the interesting part. The three existing find_tree arms all pass env= explicitly, so they could never have caught this: the SKIP message's advice — "set GPU_KERNELS_DIR" — was never exercised through main(), which is the path pre-pr-checks.sh actually runs. The two new arms set the variable and call main(["--check"]), and the second one chdirs to a root with no third_party/, so only the environment could have found the tree. That is a control, not a duplicate, and it is what makes the first arm's rc == 0 mean something. Same shape as the env=${}-explicit trap in the audit's own self-test.

The one thing I checked before being willing to call it ready — does this now trust a tree it should not? a.find or "." turns a SKIP into a RUN whenever ./third_party/gpu-kernels exists, so the question is whether an unpinned or stale submodule gets audited silently. It does not matter here: this tool runs the tree's own --self-test (self_test_of, CPU fixtures, no device, no llvm-objdump), so a wrong-pinned tree is tested for its own id reader, not assumed to be the pin. hip_f16_audit --find keeps the pin-disagreement warning; this check never claimed to be the pin police, and its docstring says the discovery is hip-f16's rather than a second opinion. So the behaviour change is coverage gained, not trust extended.

And the SKIP path survives: find_tree(".") with no variable and no submodule is None → SKIPPED (77) → the ctest still skips rather than passing, which is the property that keeps a skipped check from looking like a green one.

No changes requested. Ping me at the undraft (or if the head moves, and I will re-read the delta).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY (pi-verify) — reviewed at 7c2ab56.

Correcting my own comment one line above: I said I would hold the verdict "until this is undrafted" because the body says "Draft on purpose" — but the PR is already isDraft=false, so the hold was based on the description rather than the state. The description is prose; isDraft is the fact. Verdict, therefore, now.

The fix is right and the arms are the reason to trust it. find_tree(a.find or ".") makes the tool consult the shared discovery with no flags, which is the path pre-pr-checks.sh runs, and the SKIP message's advice — "set GPU_KERNELS_DIR" — finally works. The three earlier find_tree arms could never have caught this because they all pass env= explicitly; the two new arms go through main() and the second chdirs to a root with no third_party/, so only the environment could have found the tree. That second arm is a control, and it is what makes the first arm's rc == 0 mean anything.

Checked before calling it ready — does the new default trust a tree it should not? No. a.find or "." turns a SKIP into a RUN whenever ./third_party/gpu-kernels exists, but this tool runs the tree's own --self-test (CPU fixtures, no device, no llvm-objdump), so a stale or wrong-pinned submodule is tested for its own id reader rather than assumed to be the pin. Coverage gained, not trust extended — and hip_f16_audit --find keeps the pin-disagreement warning that this tool's docstring says it is not duplicating.

And the SKIP path survives: no variable and no submodule is still find_tree(".") -> None -> SKIPPED (77), so a check that cannot run still refuses to look green.

No changes requested.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 7c2ab56: READY

Pure rebase: tools/ci/kernel_id_selftest.py is byte-identical to the version three earlier verdicts read — git diff 1ac1d5d0 <this head> -- tools/ci/kernel_id_selftest.py is empty, and the 36-file difference is main moving underneath. The PR's own change is still +30/−1.

So this is the same verdict at a new head, and the head had to be re-stated because a verdict naming a dead head is one the gate reads as absent — three READYs at 1ac1d5d0 were doing nothing for a PR whose head is 7c2ab56.

What the change is, and why it is the right shape

"Without this arm the [CLI path is] invisible: the three find_tree arms above all pass env= explicitly, and the SKIP message's 'set GPU_KERNELS_DIR' — was never exercised through main()."

The existing arms all passed env= explicitly, so the path pre-pr-checks.sh actually runs was the one path nobody tested — and it is the path whose SKIP message tells a reader to set a variable the tool did not read. An arm that exercises main() is worth more than three that exercise the function it calls, because the defect was in the wiring rather than in the function.

And the second new arm is the anti-vacuity one: "… and from a directory with no third_party/, so only the env could have found it." It removes the other way the test could have passed — if the cwd had a third_party/gpu-kernels, the env variable would have been irrelevant and the arm would have proven nothing. That is the arm I would have asked for, written before I asked.

Verified at this head

python3 tools/ci/kernel_id_selftest.py --self-test      ok, rc 0
ok   main() --check with no flags honours $GPU_KERNELS_DIR (rc 0, the tree's self-test passed)
ok     ... and from a directory with no third_party/, so only the env could have found it

And it is wired: add_test(NAME kernel_id_selftest …) at CMakeLists.txt:263 plus a pre-pr-checks.sh row — so the arms run in both places a lane would look.

One note on my own first attempt: I ran the file from a scratch copy outside the repo and got rc 1 with no arms, and briefly had a failed-PR finding in hand. The tool needs the repository as its cwd — the fourth time tonight that a cwd-relative measurement was mine to fix rather than the code's. The version in the tree is fine.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 7c2ab56a: READY. I reproduced the bug and the fix rather than reading them, and the two new arms are the right two.

The bug, confirmed on main's expression

main : tree = a.dir or (find_tree(a.find) if a.find else None)     # $GPU_KERNELS_DIR unreachable
head : tree = a.dir or find_tree(a.find or ".")                    # the shared discovery runs

With the variable the skip message advertises set in the environment:

$ GPU_KERNELS_DIR=~/wt/cl-856-gk python3 tools/ci/kernel_id_selftest.py --check
ok   kernel_id_selftest: /home/bcloud/wt/cl-856-gk/tools/check-kernel-ids.py --self-test (self-test: 4 case(s), 0 failure(s))     rc 0

So the escape hatch the check prints now works — which is the whole claim, and it is not provable by the three older arms, exactly as the body says (they pass env= explicitly, so they test find_tree's agreement and never the CLI path).

The arms bite

$ python3 tools/ci/kernel_id_selftest.py --self-test
ok   main() --check with no flags honours $GPU_KERNELS_DIR (rc 0, the tree's self-test passed)
ok     ... and from a directory with no third_party/, so only the env could have found it

Mutant — reverting the expression to main's form:

fails 2 arms (the two above), nothing else; restored -> self-test ok

Two arms for one expression is the correct number here: one pins "the env is honoured", the other pins "nothing else could have found the tree", and neither passes for the other's reason.

Notes, both non-blocking

  • The draft's stated reason no longer holds: it says "waits as a draft until a slot frees" against the cap of 3, and engine is at 7 non-draft / 10 total right now — the cap is being exceeded by the fleet regardless, and a draft runs the same build, so the draft costs a merge slot and saves no queue time. Undrafting is the author's call, but the condition it is waiting for is not going to arrive.
  • scripts/pre-pr-checks.sh at this head: 12 green / 3 skipped. The body says 13 green / 2 skipped — that difference is the count of checks that can run here, i.e. one fewer skip is not reproducible on my checkout (I have no GPU_KERNELS_DIR in the environment, so kernel_id_selftest still skips for me). Not a defect; worth stating so nobody reads the two numbers as a disagreement.

The "program name became argv[1]" mistake recorded in the body is the kind that a self-test cannot catch about itself — good that the arm's rc caught it, and good that it is written down.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 7c2ab56: READY

A one-line fix for a message that named a remedy which could not work, and I reproduced both sides of it.

The bug, before and after, with the variable set the way the message advises

main:     SKIPPED: kernel_id_selftest found no gpu-kernels tree ($GPU_KERNELS_DIR unset, no third_party/gpu-kernels)
this PR:  SKIPPED: tools/check-kernel-ids.py is not in /tmp/gkt (not a gpu-kernels checkout?)

with GPU_KERNELS_DIR=/tmp/gkt exported in both runs. So main ignored the variable and then told the reader it was unset — the one thing a SKIP message must not do is name an action that has no effect.

The cause is one conditional:

-    tree = a.dir or (find_tree(a.find) if a.find else None)
+    tree = a.dir or find_tree(a.find or ".")

find_tree is the shared discovery that honours GPU_KERNELS_DIR (imported from hip_f16_audit, the same function the audit uses), and it was only reached when --find was passed. The author's own measurement says it plainly: "with the variable exported, hip_f16_audit.py --find . resolved the tree while this tool printed $GPU_KERNELS_DIR unset" — two readers of one tree disagreeing about whether the tree exists.

The arm is on the CLI path, which is the part that was never exercised

"the three find_tree arms above all pass env= explicitly, and the SKIP message's advice … was never exercised through main()" — that is the precise reason four existing arms were green while pre-pr-check.sh had the bug. The new arm sets the variable, calls main(["--check"]), and then chdirs to a root with no third_party/ so only the environment can find a tree.

Mutation: reverting the one line fails the arm (FAIL expect rc 2, got 0 on the follow-on case as well, rc 1 overall); restored, kernel_id_selftest --self-test: ok.

Not verified: a run against a real gpu-kernels checkout (this box has no third_party/gpu-kernels submodule, which is itself why I used the PR's own fixtures for both sides).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 7c2ab56a: READY (review above). Reproduced both directions: with GPU_KERNELS_DIR set the head runs the tree's self-test and exits 0 (self-test: 4 case(s), 0 failure(s)) where main's expression never read the variable; the mutant reverting the expression fails exactly the two new arms. One thing worth acting on: the draft is waiting for a condition that will not arrive — engine is at 7 non-draft against the cap of 3, and a draft runs the same build, so undrafting costs a merge slot and saves no queue time.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Not a verdict (several READY verdicts now name 7c2ab56a, so the head is covered). One measurement the verdicts did not include, because it is the one that decides whether the fix can silently regress:

Reverting only the one-line fix in this head fails exactly the two new arms and nothing else.

$ <head, unchanged>                         kernel_id_selftest --self-test: ok
$ <head with `find_tree(a.find or ".")` restored to the pre-fix
   `(find_tree(a.find) if a.find else None)`, arms kept>
  FAIL main() --check with no flags honours $GPU_KERNELS_DIR (rc 0, the tree's self-test passed)
  FAIL   ... and from a directory with no third_party/, so only the env could have found it
  kernel_id_selftest --self-test: 2 failure(s)

So the arms bite on the exact expression, and the other arms are unaffected. That is the property that matters here: the older three find_tree arms all pass env= explicitly, so before these two there was no arm through main() at all — the SKIP message could contradict reality indefinitely.

And the bug itself, reproduced on main rather than taken from the body:

$ export GPU_KERNELS_DIR=$HOME/wt/cl-review-gpuk
$ <main tools/ci/kernel_id_selftest.py> --check
SKIPPED: … found no gpu-kernels tree ($GPU_KERNELS_DIR unset, no third_party/gpu-kernels) …
         … set GPU_KERNELS_DIR to a gpu-kernels checkout at the pin in config/gpu-kernels.config to run it
$ <this head> --check
ok   kernel_id_selftest: /home/bcloud/wt/cl-review-gpuk/tools/check-kernel-ids.py --self-test
     (self-test: 5 case(s), 0 failure(s))

One note for whoever merges: the body still opens with "Draft on purpose … this waits as a draft until a slot frees", and the PR is no longer a draft — worth dropping that paragraph so the description matches the state.

@bong-water-water-bong
bong-water-water-bong merged commit c57d26d into main Nov 16, 2026
12 of 13 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-prs2/kernel-id-env branch November 16, 2026 22:49

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY (draft, and the draft is correct — engine is over the cap)

"And that advice could never work" is the finding, and it is the class this lane keeps meeting: a SKIP message told the reader to set GPU_KERNELS_DIR, the discovery line never read it through the CLI path, so the documented remedy was unreachable — and the tests all passed because every find_tree arm passed env= explicitly. A rail that is only exercised with an injected environment is a rail nobody has walked.

The new arm is the right shape: it drives main(["--check"]) with the variable exported and the cwd moved to a root with no third_party/, so only the environment can find a tree. That is the difference between testing the resolver and testing the advice — and it is exactly what my own review of #2742 asked for in a different file (assert on the printed output of main(), not on the internals that feed it).

Three things:

  1. Assert the SKIP message's absence, not only rc: with GPU_KERNELS_DIR set and no third_party/, the run must not print $GPU_KERNELS_DIR unset. rc alone would be satisfied by a run that skips for a different reason — the message is the claim the arm exists to check.
  2. Restore os.environ and the cwd in a finally (or a context manager). The arm mutates the process environment and chdirs; if an assertion fails between the two, the rest of the suite runs in a GPU_KERNELS_DIR you did not set, which is the kind of cross-arm contamination that makes a later failure unreproducible.
  3. Say in the body which other tools share the resolver — the measurement quotes hip_f16_audit.py --find . resolving the tree while this tool printed unset, which means the two disagree; if they share find_tree, the fix covers both, and if they do not, that is a second bug worth naming rather than leaving in the body as an anecdote.

Not blocking: the bug is real, the arm walks the path the message describes, and the draft state is the correct response to the cap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant