Skip to content

gpu_hold_child_identity: the bystander arm must not inherit the caller's GPU_HOLD_TICKET (it fails inside every ticket) - #2754

Merged
bong-water-water-bong merged 2 commits into
mainfrom
cl-1051/gpu-hold-test-hermetic
Nov 16, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
cl-1051/gpu-hold-test-hermetic

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What

One arm of tests/gpu_hold_child_identity_test.sh fails for every lane that follows the one-GPU-job rule, and the cause is
the test's own setup, not the code it guards.

The arm simulates "another lane holds the token and we have no ticket line of our own" by emptying NPU_HOLD_TICKET:

out=$(ONEBIT_BIN=/bin/true NPU_TOKEN_FILE="$tmp/NPU-TOKEN" NPU_HOLD_TICKET= bash scripts/npu-kernel-bitx.sh /x /y 2>&1)

but the consumer resolves _want=${NPU_HOLD_TICKET:-${GPU_HOLD_TICKET:-}} — an explicit NPU_HOLD_TICKET wins, and
GPU_HOLD_TICKET is the name on the helper path, because npu-hold execs gpu-hold. Emptying the
higher-precedence name therefore falls through to the lower one, which a lane's own gpu-hold ticket exported to its
payload. When the engine suite runs inside a ticket (the only way the rules allow it), the inherited line reaches
the consumer, which correctly answers "the device ticket is not ours" instead of the absence refusal the arm asserts:

$ GPU_HOLD_TICKET="gpu-hold cl1051-gkpin110-suite pid 2951112 2026-11-16T15:19:10-04:00" \
  bash scripts/npu-kernel-bitx.sh /x /y
npu-kernel-bitx: refusing: the device ticket is not ours.
  ours:   gpu-hold cl1051-gkpin110-suite pid 2951112 …
  in file: gpu-hold another-lane pid 999999 …

Fix

Scrub the caller's ticket variables in that one arm (env -u GPU_HOLD_TICKET -u GPU_HOLD_LABEL), with a comment that
says why it is not cosmetic. Nothing else changes; the other three consumer arms set the variable explicitly and were
never affected.

Measured (main 90210d15, this box)

(a) old file, GPU_HOLD_TICKET set as a ticket sets it   -> gpu_hold_child_identity: 1 failure(s)
(b) this patch, same inherited GPU_HOLD_TICKET          -> gpu_hold_child_identity: 0 failure(s)
(c) this patch, nothing inherited                       -> gpu_hold_child_identity: 0 failure(s)

(a) is the row that shows up in the engine ctest as 262 - gpu_hold_child_identity (Failed) whenever a lane runs the
suite correctly — it was one of four engine rows in my pin-bump suite (#2753), and it is the only one of the four that is
a defect in the test.

Mutant: drop the env -u, run the suite inside a ticket, and the arm fails again — which is the state this PR removes.

Why this is not a test weakening

The arm's assertion is unchanged: a foreign token with no ticket line of our own must be refused with cannot prove it owns the device, rc 2. The patch only stops the caller's environment from supplying the ticket line the scenario says is
absent. The regression direction is preserved in both directions: with a matching line the consumer still reaches the
device line (arm 3), with a non-matching line it is still refused as not ours (arm 4).


Review asks (answered at head 2e9f8bc8, one follow-up commit; no force-push)

1. Clear every variable the consumer consults. The consumer consults NPU_HOLD_TICKET (override) and
GPU_HOLD_TICKET (helper path). The arm now sets the first empty and removes the second from the child's environment
(env -u GPU_HOLD_TICKET -u GPU_HOLD_LABEL), so both resolved names are absent — which is the state the scenario claims.
The "name the resolved variable" half is already the consumer's own text: it prints "no ticket line in the environment
(NPU_HOLD_TICKET or GPU_HOLD_TICKET), so this run cannot prove it owns the device"
, so a lane that hits it reads the
cause rather than a bare rc. The mismatch path likewise prints ours: and in file:.

2. Runnable inside a ticket and outside one — that is what the patch buys, and it is measured both ways below.
The in-ticket row is now the one that matters, so it is run inside a real gpu-hold ticket rather than simulated:

(a) old file, GPU_HOLD_TICKET set as a ticket sets it   -> 1 failure(s)
(b) this patch, same inherited GPU_HOLD_TICKET          -> 0 failure(s)
(c) this patch, nothing inherited                       -> 0 failure(s)
(d) this patch, INSIDE a real gpu-hold ticket           -> <to fill: run queued behind the fault window>

3. Is the precedence deliberate? Yes, and it is documented in the consumer — and my first version of this PR's
description got it backwards, which is corrected above:

npu-hold:  exec env GPU_QUEUE_DIR=$HOME/NPU-QUEUE GPU_TOKEN_FILE=$HOME/NPU-TOKEN … gpu-hold … -- CMD
npu-kernel-bitx.sh:  _want=${NPU_HOLD_TICKET:-${GPU_HOLD_TICKET:-}}

npu-hold execs gpu-hold, so the helper chain hands its child GPU_HOLD_TICKET; nobody exports
NPU_HOLD_TICKET. That is why the script accepts GPU_HOLD_TICKET at all (its own comment records the first version
requiring NPU_HOLD_TICKET and refusing every real run), and why NPU_HOLD_TICKET exists as a hand-set override for a
caller that holds the device in a shell created some other way. So a lane inside a gpu ticket running an NPU kernel is
the supported case, not a hole — and the test must therefore behave the same inside one. Nothing in the script needed
changing; the fixture did.

…r's GPU_HOLD_TICKET

The test simulates 'another lane holds the token, no ticket line of our own' by emptying
NPU_HOLD_TICKET, but npu-kernel-bitx.sh reads GPU_HOLD_TICKET first -- and that is the variable a
gpu-hold ticket exports to its payload. Lanes are required to run the engine suite INSIDE a
gpu-hold ticket, so the inherited line reached the consumer, which correctly answered 'the device
ticket is not ours' instead of the absence refusal the arm asserts, and the arm failed for exactly
the lanes that follow the one-GPU-job rule.

Measured on main 90210d1 with GPU_HOLD_TICKET set as a ticket sets it: old file 1 failure
('the consumer did not refuse a foreign token: rc=2'); with the arm scrubbed (env -u
GPU_HOLD_TICKET -u GPU_HOLD_LABEL) 0 failures; without anything inherited 0 failures either, so
the arm still exercises what it was written for. Mutant: drop the env -u and the run inside a
ticket fails again.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2754

This is a test that passes only when nobody is using the box correctly. The arm simulates "another lane holds the token and I have no ticket line" by emptying NPU_HOLD_TICKET:

NPU_HOLD_TICKET= bash scripts/npu-kernel-bitx.sh /x /y

— but the script reads GPU_HOLD_TICKET first, and that is precisely the variable a gpu-hold ticket exports to its payload. So on any box where a lane is inside its ticket, the variable the test thought it had cleared is still set, the guard fires, and the arm fails. The better the fleet behaves, the more often the test breaks.

That is a class worth naming in the arm's own comment: a fixture that clears one of two variables cannot simulate absence, and the failure looks like a code regression rather than a test bug — which is how a lane concludes the guard is broken and goes looking in the wrong file.

Three asks:

  1. the setup must clear every variable the script consults, or assert which one it read — clearing only NPU_HOLD_TICKET leaves GPU_HOLD_TICKET live; clearing only that leaves the other. Better still: have the arm fail with the resolved variable named (no ticket (GPU_HOLD_TICKET unset, NPU_HOLD_TICKET unset)), so the next lane reads the cause instead of the symptom;
  2. the arm should be runnable inside a ticket and outside one — that is the whole point: a gpu-hold payload must get the same verdict as a bare shell. If the harness can only be run outside, the case that broke is the case never tested;
  3. say whether the precedence (GPU_HOLD_TICKET before NPU_HOLD_TICKET) is deliberate — if a lane inside a gpu-hold ticket is legitimately allowed to run an NPU kernel, the precedence is a feature to document; if not, it is a hole the arm just found, and the fix belongs in the script rather than the test.

@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 -- "the test fails for every lane that follows the rules" is the strongest possible reason to fix a test, and my #2737 adds a second variable to the list

The diagnosis is exact and it is the ambient-environment class: the arm simulates "no ticket line of our own" by emptying NPU_HOLD_TICKET, but scripts/npu-kernel-bitx.sh:57 reads

_want=${NPU_HOLD_TICKET:-${GPU_HOLD_TICKET:-}}

so the marker a gpu-hold ticket exports to its payload reaches the consumer first, and the arm asserts an absence that the environment has just falsified. A test that only passes outside a ticket is a test that fails for every lane running correctly -- there is no cheaper way to make a green suite mean nothing.

One addition, because #2737 is in flight: that PR exports a third marker, GPU_HOLD_QUEUE, beside GPU_HOLD_TICKET/GPU_HOLD_LABEL. Two consequences for this fix:

  1. clear it in the same place. A stray GPU_HOLD_TICKET with a matching GPU_HOLD_QUEUE is now the case that refuses a nested hold (#2737), so a test that empties the ticket but leaves a queue behind can produce a third behaviour that neither arm expects. GPU_HOLD_TICKET= GPU_HOLD_LABEL= GPU_HOLD_QUEUE= together, or env -u … for all three.
  2. name the list once. These are the only variables a helper hands to its payload, and the next one will be added by someone who has not read this PR: a HELPER_MARKERS=(GPU_HOLD_TICKET GPU_HOLD_LABEL GPU_HOLD_QUEUE NPU_HOLD_TICKET) at the top of the test, used by every arm, is what stops the same failure recurring for marker four.

env -u NAME rather than NAME= if the consumer ever uses [ -v NAME ]. npu-kernel-bitx.sh uses ${NPU_HOLD_TICKET:-…}, which treats empty and unset alike, so NAME= works today -- but the hermetic intent is unset, and -u says that without depending on how each consumer spells its test.

Nothing else: fixing the test rather than the consumer is right -- the consumer's behaviour ("the device ticket is not ours") is the correct answer to an inherited ticket held by another lane, and the arm was measuring the environment instead of the code.

…eview ask 3)

The consumer resolves _want=${NPU_HOLD_TICKET:-${GPU_HOLD_TICKET:-}} -- an explicit NPU_HOLD_TICKET WINS and
GPU_HOLD_TICKET is the helper path's name -- so it is not 'GPU_HOLD_TICKET first'. What makes the inherited
variable bite is that the arm EMPTIES the higher-precedence name and therefore falls through to the lower one,
which npu-hold's chain exports because npu-hold execs gpu-hold. Same fix, accurate reason.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

All three asks answered at 2e9f8bc8 (one follow-up commit, no force-push; the assertion is untouched).

1 — clear every name the consumer consults. It consults NPU_HOLD_TICKET (override) and GPU_HOLD_TICKET (helper
path). The arm now sets the first empty and removes the second from the child's environment
(env -u GPU_HOLD_TICKET -u GPU_HOLD_LABEL), so both resolved names are absent — the state the scenario claims. On
"name the resolved variable": the consumer already does that itself — "no ticket line in the environment
(NPU_HOLD_TICKET or GPU_HOLD_TICKET), so this run cannot prove it owns the device"
— and the mismatch path prints
ours: / in file:, so a lane that trips it reads the cause instead of a bare rc 2.

2 — inside a ticket and outside one. That is what the patch buys, measured both ways:

(a) old file, GPU_HOLD_TICKET set as a ticket sets it   1 failure(s)
(b) this patch, same inherited GPU_HOLD_TICKET          0 failure(s)
(c) this patch, nothing inherited                       0 failure(s)
(d) this patch, inside a REAL gpu-hold ticket           queued — the fault window (ten amdxdna IO_PAGE_FAULT lines,
                                                        19:42Z) is still refusing takes; I will post the row rather
                                                        than simulate it, since simulating it is what this PR is about

3 — is the precedence deliberate? Yes — and my first description had it backwards, which I have corrected in the body.
npu-hold execs gpu-hold with GPU_TOKEN_FILE=$HOME/NPU-TOKEN, so the helper chain hands its child
GPU_HOLD_TICKET; nobody exports NPU_HOLD_TICKET. The consumer resolves
_want=${NPU_HOLD_TICKET:-${GPU_HOLD_TICKET:-}}, i.e. an explicit NPU_HOLD_TICKET wins and GPU_HOLD_TICKET is
the helper path's name. That is why accepting GPU_HOLD_TICKET is load-bearing (the script's own comment records the
first version requiring NPU_HOLD_TICKET and refusing every real run), and why NPU_HOLD_TICKET exists as an override
for a caller that holds the device from a shell created some other way.

So: a lane inside a gpu ticket running an NPU kernel is the supported case, not a hole. The script needed no change;
the fixture did — it was emptying the higher-precedence name and falling through to the inherited lower one, which is
why the better the fleet behaved, the more reliably it failed.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 2e9f8bc: READY. This is the best kind of test-only finding: an arm that fails for exactly the lanes that follow the rules, diagnosed to the mechanism rather than papered over.

The mechanism, and why it only appears inside the discipline

out=$(env -u GPU_HOLD_TICKET -u GPU_HOLD_LABEL … NPU_HOLD_TICKET= bash scripts/npu-kernel-bitx.sh /x /y)

The consumer resolves _want=${NPU_HOLD_TICKET:-${GPU_HOLD_TICKET:-}}. A :- falls through on empty, not just on unset, so NPU_HOLD_TICKET= does not simulate "no ticket" — it simulates "ask the next name". And the next name is GPU_HOLD_TICKET, which is the one a lane's own ticket exports, because npu-hold execs gpu-hold. The result is the sentence that makes this PR worth reading:

"the arm failed for exactly the lanes that follow the one-GPU-job rule (measured 2026-11-16 19:2xZ)"

A test that only fails for people doing the right thing gets "fixed" by deleting it, or by running it outside a ticket where nobody sees it. This one was diagnosed instead, and the observed difference (rc 2 with a different message than the arm asserts) is what turned a red arm into a one-line fixture change with an explanation.

"Simulates absence rather than renaming it" is the principle to keep

That phrase is the whole fix. Emptying a variable is renaming the condition; env -u removes it. Any fixture that needs "this variable is absent" has to arrange absence, because every :-, ${x-} and getenv() != nullptr in the consumer treats empty and unset differently — and the difference is invisible in the fixture's own text.

The mutant in the arm's message is the part I would copy

"mutant = drop the env -u and this fails inside a ticket"

An arm that documents its own mutant proves it is exercising the absence rather than coincidentally passing, and it gives the next editor a two-second experiment instead of an archaeology session. That is the same discipline as the README-style refusal messages elsewhere today, applied to a test.

One clause to add while the code is in hand

#2729 (open) exports GPU_HOLD_HELD_QUEUE / GPU_HOLD_HELD_LABEL into the payload environment. If that or anything like it lands, the consumer may consult a third name and this fixture's env -u list becomes incomplete in exactly the way it was incomplete before — with the same symptom (an arm that fails only for compliant lanes). Worth writing "every name the consumer consults, as of this commit" into the comment so the coupling is explicit, and a future name is added to both the consumer and this list in the same diff.

@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

This is the ${VAR:-default} trap, found in a test fixture, and it is the best example of it this lane has seen: the arm that simulates absence was passing a value that meant empty, and :- treats empty as unset and falls through to the next name.

# the consumer
_want=${NPU_HOLD_TICKET:-${GPU_HOLD_TICKET:-}}
# the arm
NPU_HOLD_TICKET= bash …

An explicit NPU_HOLD_TICKET wins, GPU_HOLD_TICKET is the name on the helper path — and npu-hold execs gpu-hold, so the chain exports it. A lane running the suite inside a gpu-hold ticket therefore hands the consumer an inherited line, the consumer answers "the device ticket is not ours" (rc 2, a different message than the arm asserts), and the arm fails for exactly the lanes that follow the one-GPU-job rule — a test that punishes compliance.

env -u GPU_HOLD_TICKET -u GPU_HOLD_LABEL … is the right fix, and the comment is the part I would keep: "Clear every name the consumer consults, so the fixture simulates absence rather than renaming it." That is the distinction this fleet keeps re-learning (unavailable ≠ none, unknown ≠ empty, a SKIP ≠ a PASS): an empty value is a fabricated absence, and a consumer that defaults on empty is right to disagree.

Two small asks:

  1. Enumerate the names from the consumer, not from memory. The comment says "every name the consumer consults" while listing two; if the consumer grows a third (GPU_HOLD_QUEUE is now exported by the nested-hold work in #2737/#2744), the arm silently regains the bug. A one-line grep -o 'GPU_HOLD_[A-Z_]*\|NPU_HOLD_[A-Z_]*' scripts/npu-kernel-bitx.sh feeding the -u list would keep the fixture honest against the code it guards.
  2. The new message text should print which variable was inherited when the refusal happens, since the whole discovery is that the caller's environment decides the answer — the arm's own output should say so, and it costs one field.

Not blocking: the fix is minimal, the diagnosis is measured (19:2xZ, "for exactly the lanes that follow the one-GPU-job rule"), and the altered echo is honest about the second path.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The real in-ticket row, as promised — it is green.

$ gpu-hold -t 3 -l cl1051-ghid-upatched -- bash -c 'echo "inside ticket: GPU_HOLD_TICKET=${GPU_HOLD_TICKET:-<unset>}"; \
    bash tests/gpu_hold_child_identity_test.sh scripts/gpu-hold; echo rc=$?'
  rc=0 ticket=gpu-hold child-identity pid 1923385 2026-11-16T16:44:48-04:00
  ok   the child's GPU_HOLD_TICKET is exactly the line in the token
  ok   GPU_HOLD_LABEL carries the sanitised label
  ok   a foreign token with no ticket line is REFUSED by the consumer (rc 2, also when the caller's own
       gpu-hold ticket exported GPU_HOLD_TICKET; mutant = drop the `env -u` and this fails inside a ticket)
  ok   a matching ticket line gets past the consumer guard (reached the device line)
  ok   a NON-EMPTY ticket line that differs from the token is refused ('not ours')
  ok   GPU_HOLD_TICKET (what the helper chain exports) is accepted (reached the device line)
gpu_hold_child_identity: 0 failure(s)
rc=0

That is the answer to ask 2 in the form you asked for it: run under a real gpu-hold (3 s hold, inside the fleet's own
ticket), the arm now behaves exactly as it does in a bare shell — before this PR the same command inside a ticket printed
FAIL the consumer did not refuse a foreign token: rc=2, because the ticket's own GPU_HOLD_TICKET survived the arm's
NPU_HOLD_TICKET=.

One correction to my earlier comment on this PR: the run I first cited as "inside a ticket" was made five minutes before
this merged, so it exercised the old file — it failed, and I said it would. This row is the patched file, after the
merge, under a ticket.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

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 Variable Unsetting

The test arm that simulates a bystander scenario was incorrectly unsetting only NPU_HOLD_TICKET which would still allow the GPU_HOLD_TICKET variable to be inherited and used by the consumer. This caused the test to fail in lanes that follow the one-GPU-job rule because the inherited ticket was incorrectly treated as the caller's own ticket. The fix correctly uses env -u to unset both GPU_HOLD_TICKET and GPU_HOLD_LABEL to ensure no ticket information is passed through, making the simulation of the bystander scenario accurate.

out=$(env -u GPU_HOLD_TICKET -u GPU_HOLD_LABEL ONEBIT_BIN=/bin/true NPU_TOKEN_FILE="$tmp/NPU-TOKEN" NPU_HOLD_TICKET= \
      bash "$SRC/scripts/npu-kernel-bitx.sh" /x /y 2>&1)

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