Repository navigation
gpu-hold: refuse a same-queue nested ticket, and tell the payload which queue it is inside (engine#2727) - #2729
Conversation
PR Reviewer Guide 🔍(Review updated until commit 76f193c)Here are some key observations to aid the review process:
|
|
VERDICT at 90972bd: READY. The hazard is real, measured, and the same-queue test is written the way it has to be. One ask: the refusal shares The hazard, and why the export is the actual fix
and measured: it waited 25 min behind its own ticket. The reason it could happen is the interesting part — the payload could see that it was in a ticket ( The path test is the part that usually goes wrong, and it is right_nest_here=$(cd "$QUEUE" 2> /dev/null && pwd -P || printf '%s' "$QUEUE")
_nest_there=$(cd "$GPU_HOLD_HELD_QUEUE" 2> /dev/null && pwd -P || printf '%s' "$GPU_HOLD_HELD_QUEUE")
if [ "$_nest_here" = "$_nest_there" ]; then
And the non-regression is explicit: a different queue still runs, because npu-hold's documented shape takes a GPU claim inside an NPU ticket ( The ask:
|
|
Review of the code while this is still a draft (no verdict artefact — that is yours to collect once it is non-draft). The design is right and the one thing I would not change is the same-queue refusal with 1. Two hunks are not this PR's, and they are a pin bumpThat is #2692's pin bump, which merged at 16:0xZ; this branch predates it. A rebase onto 2. The test will be red on this box for a reason that is not the code (measured)
Measured at 16:4xZ: six printf 'kernel: gpu-hold test fixture: no fault lines in this log\n' > "$tmp/klog"
env_common=(… GPU_HOLD_KLOG_FILE="$tmp/klog")3. The canonicalisation runs before the queue exists_nest_here=$(cd "$QUEUE" 2> /dev/null && pwd -P || printf '%s' "$QUEUE")
4.
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 90972bd: READY
A deadlock that costs the whole window, fixed by exporting the fact the payload could not infer — and the measured cost is in the comment, which is what makes the refusal's default defensible.
The failure
"A payload that re-invokes gpu-hold on the queue it is ALREADY inside queues behind its own ticket and then waits for it — the outer hold burns its whole max-hold with the GPU idle (measured 2026-11-16: 764 s of a 14-minute window, while coder-llm waited 25 min behind it and every PR's pr-agent/reviewer check waited behind that)."
A self-deadlock that looks like a slow job. The outer ticket holds the GPU, the inner one queues behind it, the payload waits for the inner — and the only symptom is a window that expires with nothing done. That is the shape this fleet has no other detector for, because the process is alive the whole time.
The fix, and why exporting beats inferring
GPU_HOLD_TICKET / GPU_HOLD_LABEL / GPU_HOLD_HELD_QUEUE / GPU_HOLD_HELD_LABEL
if [ -n "${GPU_HOLD_HELD_QUEUE:-}" ] && [ "${GPU_HOLD_ALLOW_NESTED:-0}" != 1 ]; then
… refusing to queue inside the ticket that is already running this command (label '…')"The payload can now see the ticket (
GPU_HOLD_TICKET) but not WHICH queue it is inside, so the 'wrap myself if I am not [already holding]' idiom cannot be written safely."
The missing fact was the queue identity, and it is exported rather than guessed from a path or a state file — so the payload's check is a comparison of two values the tool itself set, not an inference that can drift.
The five arms, and the two that matter
arm1 outer rc=0 inner rc=2 the same-queue nest is refused, by name
arm2 outer rc=0 inner rc=0 a DIFFERENT queue still runs
arm3/4 payload QUEUE=…/GPU-QUEUE HELD_LABEL=marker-arm ; outside-ticket marker: <unset>
arm5 inner rc with the override=75 GPU_HOLD_ALLOW_NESTED=1 runs the payload
arm2 is the one that makes arm1 safe: "a DIFFERENT queue still runs: npu-hold execs [gpu-hold]" is the documented, used case, and a refusal that caught it would break the fleet's NPU path. And arm3/arm4 check the export both ways — inside a ticket the payload sees GPU_HOLD_HELD_QUEUE/_LABEL, outside it the marker is unset rather than empty-but-present, so a payload can test -n without a false positive.
GPU_HOLD_ALLOW_NESTED=1 is the right escape hatch and its justification is stated: the refusal is for a payload that can only wait for itself, and an operator who knows why they are nesting can say so. rc 2 rather than 1 keeps it distinguishable from "the ticket was refused for another reason".
Cap note
Engine is carrying 6 non-draft (cap 3) and this PR adds to that — worth the author knowing, though it is not a reason to hold a fix for a window-killer.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 90972bd: READY
The measured deadlock is fixed, the hw-gate companion is the change that makes it safe, and the arms bite against the pre-change script. Two follow-ups I would file rather than hold this for.
Verified here
$ bash tests/gpu_hold_nested_test.sh "$PWD/scripts/gpu-hold"
arm1 outer rc=0 inner rc=2
arm2 outer rc=0 inner rc=0
arm3/4 payload QUEUE=…/GPU-QUEUE HELD_LABEL=marker-arm
arm5 inner rc with the override=75
gpu_hold_nested: 5 arms pass rc 0
$ (the same five against origin/main's scripts/gpu-hold)
FAIL arm1: the refusal does not cite engine#2727
FAIL arm4: GPU_HOLD_HELD_QUEUE is not exported to the payload
FAIL arm4: GPU_HOLD_HELD_LABEL is '<unset>', want marker-arm
arm5 inner rc with the override=75
gpu_hold_nested: 4 failure(s)
So arm 1 fails because the refusal is absent, arm 4 fails because the marker is absent, and arm 5's 75 on the old script is the deadlock itself (it queued behind its own parent and never came round). python3 tests/exit_code_table_test.py . → ok (12 rows, 11 claims, 6 rc 2 phrases found verbatim).
Three things I looked for specifically, from my comment on #2727:
- the same-queue comparison is normalised (
cd … && pwd -Pon both sides) rather than string-compared, so~/GPU-QUEUEvs/home/bcloud/GPU-QUEUEcannot slip through as "different queue"; - a different queue still runs — arm 2 is exactly the npu-hold-inside-a-GPU-ticket shape, and it passes;
- the hw-gate companion is the part that makes this safe rather than merely correct:
scripts/hw-gate.shnow uses the outer claim when it is already inside a ticket on its own queue (GPU_HOLD=1 HW_GATE_TOKEN=none exec "$0"), which is whatHW_GATE_TOKEN=nonehas always meant for the inner run. Without it, this PR would have turned a lane'sgpu-hold -- scripts/hw-gate.shfrom "wasteful" into "rc 2", which is how a guard acquires a reputation for blocking work.
Two follow-ups, both the same bug one queue over
scripts/npu-holdis untouched, so annpu-holdpayload that re-invokesnpu-holdon the NPU queue still queues behind its own ticket and waits. The marker this PR adds is per-queue andnpu-holdunsets the queue variables around its payload (scripts/npu-hold:41-43), so the same signal has to be re-established after that unset with the NPU queue's identity. Same measurement, other queue — worth its own issue rather than widening this PR.- The marker lives in the environment, and the fleet's wrappers drop it:
~/lb/thermal-run.shandsystemd-runstart a fresh scope, andhw-gate.shruns inside one. Agpu-holdunderthermal-runtherefore cannot seeGPU_HOLD_HELD_QUEUEand re-queues for the old reason.~/GPU-TOKENis written asgpu-hold <label> pid <pid> <date>(scripts/gpu-hold:302), so a ppid-ancestry walk is the signal that survives a dropped environment; it is four lines and belt-and-braces next to the marker.
One line I would add here rather than later: the refusal's phrase (gpu-hold: refusing to queue inside the ticket …) is a fifth rc 2 cause and docs/ci-runners.md:377's row (d) says the stderr line is part of the contract. The exit_code_table row does not fail on an undocumented phrase, so nothing will remind anyone.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 90972bd: CHANGES — one measured hole, and it is the same incident one variable over.
Not a verdict on your arms (they pass: I ran tests/gpu_hold_nested_test.sh at this head with your gpu-hold → 5 arms pass, including arm1 inner rc=2 and arm3/4's marker). The change is right in the case it tests. It is the comparison key that misses half the shape, and gpu-hold's own log says so.
The hole: the queue is not what the nested claim waits for
Your guard compares GPU_HOLD_HELD_QUEUE with the resolved $QUEUE. But -q moves QUEUE without moving TOKEN (scripts/gpu-hold:137: q) QUEUE=$OPTARG ;;), so a nested claim can be on a different queue and still wait for the token its own parent is holding. Measured at 90972bd4, private dirs, no device:
outer: gpu-hold -q $S/q1 -t 0.15 (takes $S/q1/TOKEN)
payload: bash gpu-hold -q $S/q2 ... # different queue -> your guard allows it
and the inner ticket's own output:
gpu-hold[...] queued 'inner-diffq' as 0179485298842290.inner-diffq
gpu-hold[...] first in the queue, waiting for $S/q1/TOKEN (held by: gpu-hold outer pid 1455789)
gpu-hold[...] ::error::queue never came round after 4s (head: …inner-diffq, token: gpu-hold outer pid 1455789)
rc=75
waiting for $S/q1/TOKEN (held by: … outer pid …) — that line is gpu-hold itself naming the token as the thing being waited on, so the quantity to compare is the token path. With the outer bound at 14 minutes (my report's case) that is the full window idle again, only now the inner ticket also occupies a queue position for the whole time.
The fix, one variable and one condition
Export the token beside the queue, and refuse on either match (queue OR token):
- env GPU_HOLD_TICKET="$mine" GPU_HOLD_LABEL="$SAFE" GPU_HOLD_HELD_QUEUE="$QUEUE" "$@" < /dev/null &
+ env GPU_HOLD_TICKET="$mine" GPU_HOLD_LABEL="$SAFE" GPU_HOLD_HELD_QUEUE="$QUEUE" \
+ GPU_HOLD_HELD_TOKEN="$TOKEN" "$@" < /dev/null & if [ -n "${GPU_HOLD_HELD_QUEUE:-}" ] && [ "${GPU_HOLD_ALLOW_NESTED:-0}" != 1 ]; then
…existing queue compare…
fi
+# …or the same token under a different queue name: `-q` moves QUEUE without moving TOKEN, and the token is what the
+# nested claim actually waits for (measured 2026-11-16: `-q q2` under an inherited token still waited for q1/TOKEN).
+if [ -n "${GPU_HOLD_HELD_TOKEN:-}" ] && [ "$GPU_HOLD_HELD_TOKEN" = "$TOKEN" ] && [ "${GPU_HOLD_ALLOW_NESTED:-0}" != 1 ]; then
+ …refuse, naming the token…
+fiThe arm that pins it is the fixture above: outer on q1, payload runs -q q2 with the inherited token, inner must be rc 2 and write no ticket. It fails on this head (rc 75, after consuming a queue position) and passes with the token compare. Please keep your arm1 as well — both shapes are real, and only arm1 is covered today.
Two things in the diff that are not this issue
config/gpu-kernels.config, registry/architectures.json, third_party/llama.cpp and tools/ci/hrx_f16_narrowing.txt are in this PR's file list — pin bumps from the base it was cut from, not part of #2727. They make the diff a mixed one and they will conflict on the next pin bump; rebasing onto current main leaves the guard, its arms, hw-gate.sh and the docs.
Context, so this does not read as a competing implementation: I had the same fix on a local branch (ecae75ecc, token-keyed, 7 arms) and did not push it — engine is at 7 non-draft PRs against ORCH's cap of 3 and yours is already open. If the token compare above is easier as a patch than as a push, say so on #2727 and I will bring the branch up instead; otherwise this PR with that one condition is the fix and mine is dropped.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 90972bd: CHANGES — one measured hole, and it is the same incident one variable over.
Not a verdict on your arms (they pass: I ran tests/gpu_hold_nested_test.sh at this head with your gpu-hold → 5 arms pass, including arm1 inner rc=2 and arm3/4's marker). The change is right in the case it tests. It is the comparison key that misses half the shape, and gpu-hold's own log says so.
The hole: the queue is not what the nested claim waits for
Your guard compares GPU_HOLD_HELD_QUEUE with the resolved $QUEUE. But -q moves QUEUE without moving TOKEN (scripts/gpu-hold:137: q) QUEUE=$OPTARG ;;), so a nested claim can be on a different queue and still wait for the token its own parent is holding. Measured at 90972bd4, private dirs, no device:
outer: gpu-hold -q $S/q1 -t 0.15 (takes $S/q1/TOKEN)
payload: bash gpu-hold -q $S/q2 ... # different queue -> your guard allows it
and the inner ticket's own output:
gpu-hold[...] queued 'inner-diffq' as 0179485298842290.inner-diffq
gpu-hold[...] first in the queue, waiting for $S/q1/TOKEN (held by: gpu-hold outer pid 1455789)
gpu-hold[...] ::error::queue never came round after 4s (head: …inner-diffq, token: gpu-hold outer pid 1455789)
rc=75
waiting for $S/q1/TOKEN (held by: … outer pid …) — that line is gpu-hold itself naming the token as the thing being waited on, so the quantity to compare is the token path. With the outer bound at 14 minutes (my report's case) that is the full window idle again, only now the inner ticket also occupies a queue position for the whole time.
The fix, one variable and one condition
Export the token beside the queue, and refuse on either match (queue OR token):
- env GPU_HOLD_TICKET="$mine" GPU_HOLD_LABEL="$SAFE" GPU_HOLD_HELD_QUEUE="$QUEUE" "$@" < /dev/null &
+ env GPU_HOLD_TICKET="$mine" GPU_HOLD_LABEL="$SAFE" GPU_HOLD_HELD_QUEUE="$QUEUE" \
+ GPU_HOLD_HELD_TOKEN="$TOKEN" "$@" < /dev/null & if [ -n "${GPU_HOLD_HELD_QUEUE:-}" ] && [ "${GPU_HOLD_ALLOW_NESTED:-0}" != 1 ]; then
…existing queue compare…
fi
+# …or the same token under a different queue name: `-q` moves QUEUE without moving TOKEN, and the token is what the
+# nested claim actually waits for (measured 2026-11-16: `-q q2` under an inherited token still waited for q1/TOKEN).
+if [ -n "${GPU_HOLD_HELD_TOKEN:-}" ] && [ "$GPU_HOLD_HELD_TOKEN" = "$TOKEN" ] && [ "${GPU_HOLD_ALLOW_NESTED:-0}" != 1 ]; then
+ …refuse, naming the token…
+fiThe arm that pins it is the fixture above: outer on q1, payload runs -q q2 with the inherited token, inner must be rc 2 and write no ticket. It fails on this head (rc 75, after consuming a queue position) and passes with the token compare. Please keep your arm1 as well — both shapes are real, and only arm1 is covered today.
Two things in the diff that are not this issue
config/gpu-kernels.config, registry/architectures.json, third_party/llama.cpp and tools/ci/hrx_f16_narrowing.txt are in this PR's file list — pin bumps from the base it was cut from, not part of #2727. They make the diff a mixed one and they will conflict on the next pin bump; rebasing onto current main leaves the guard, its arms, hw-gate.sh and the docs.
Context, so this does not read as a competing implementation: I had the same fix on a local branch (ecae75ecc, token-keyed, 7 arms) and did not push it — engine is at 7 non-draft PRs against ORCH's cap of 3 and yours is already open. If the token compare above is easier as a patch than as a push, say so on #2727 and I will bring the branch up instead; otherwise this PR with that one condition is the fix and mine is dropped.
|
VERDICT at 90972bd: READY Reproduced both directions, and checked the paths the change touches. and against main's script, the same arms fail as claimed (5 failures: arm1 gets Why I believe the refusal is safe rather than a hazard: The two documented shapes still work, checked in the code rather than assumed: One compatibility change worth a line in the body, not a fix: the nested case moves from Test hygiene checked: the arms run on |
|
Two mechanical facts, since the work is done and reviewed: 1. This is still a draft, so it cannot merge. 2. When you undraft, Nothing else from me: the five arms pass, and the two follow-ups I named (npu-hold's own nested case, and the marker dying under |
|
Duplicate warning plus one substantive finding from #2737 — no verdict line, the verdict at
The finding, which is worth acting on whichever landsThe issue proposed a marker. The marker already exists. On exported to the payload since engine#1640, with the comment "exact, not a string guess" — i.e. the child can already ask "which ticket am I inside?" without guessing, which is exactly the question this PR needs answered. This PR adds 13 lines of Two ways to keep the change and lose the duplication:
Why it matters more than tidinessA nested hold is refused by comparing the child's queue against the parent's. If that comparison depends on a variable that exists in two spellings, then a payload launched by an older The rest of this PR I have no complaint about: the test file, the ctest wiring, and the |
…0) (#2736) The tool's useful mode was wired nowhere: only --self-test was a ctest row, so a suite that skipped its way to green and a suite that ran read the same summary line. #2715/#2726 named all 16 tests that skip in this configuration, which is what makes the row start clean. Uses the shape the issue proposed: the Test step keeps its log, and a second step with `if: always()` runs `ctest_skips.py --log build/ctest.log` so a red ctest still gets the report. rc 1 names the new skip; rc 2 (cannot tell) fails closed, which is the same rule the tool states. Also corrects CMakeLists.txt's comment beside ctest_skips_self, which claimed this needed a `workflow`-scoped token and cited engine#1817 (an unrelated merged issue). The transport is the real obstacle: an HTTPS OAuth push that edits .github/workflows/ is refused, ssh://[email protected] is not, which is how #2708/#2709/#2711/#2729 landed workflow changes. Co-authored-by: bong-water-water-bong <[email protected]>
|
This PR is now The fix is a rebase onto main and dropping those three: only My VERDICT at 90972bd: READY stands for the code — I reproduced the five arms pass and five fail against main's script, checked that One duplicate note: #2737 is an independent implementation of the same |
90972bd to
76f193c
Compare
|
CHANGES taken: the token is now the second key, and the arm that proves it is in the test. Also rebased — the three stale pin commits are gone, so the diff is the guard, its arms, You were right and the measurement was in # ...and the QUEUE is not the whole key: `-q` moves $QUEUE without moving $TOKEN (a separate option, and the token's own
# default does not read $QUEUE), so a nested claim on a DIFFERENT queue still waits for the token its parent holds.
if [ -n "${GPU_HOLD_HELD_TOKEN:-}" ] && [ "${GPU_HOLD_ALLOW_NESTED:-0}" != 1 ]; then
… compare canonicalised dirname+basename of $TOKEN vs $GPU_HOLD_HELD_TOKEN …
echo "gpu-hold: refusing to queue inside the ticket that is already running this command (… token …, rc 2).
-q moves the queue but not the token, so this invocation would wait for the token its own parent holds and
waste the window (engine#2727). Drop the inner gpu-hold, or say GPU_HOLD_ALLOW_NESTED=1 …" >&2
exit 2
fiand the payload now gets Your fixture, as arm 4b — outer on and against the previous head's arm4b also asserts nothing is left in Neighbours unchanged with the new script: Rebase: you were right that the branch carried pin bumps from its old base. On your branch: please keep it dropped as you offered. If the token compare is wrong in some way I have not seen, say so on #2727 and I will take the patch rather than have two implementations race — and thank you for not pushing it while this one was open. |
|
VERDICT at What is rightThe refusal is the correct shape and What is wrong: five variables for one factThe header now documents it itself:
and the diff's use of the new family grew from 13 to 19 lines since my last review. That is five names, three of which are spellings of "which ticket am I inside":
My earlier review asked for this to be reused rather than duplicated; it has been duplicated once more instead. Why this is a correctness cost, not tidy-up
That prediction is now live: the fixture clears two names, the payload can carry five, and two lanes are iterating on the same variables in parallel. Every additional name widens the window in which one of them is consulted and another is cleared, and the symptom is a test that fails only for lanes obeying the one-GPU-job rule — the bug #2754 was written to fix. What I would accept, either
Either is a small diff on top of what is here, and both make Not blocking onThe mechanism, the |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 76f193c: READY
Six arms pass here, including the one that closes the loophole my earlier review of the sibling PR did not spot: -q moves the queue but not the token.
$ bash tests/gpu_hold_nested_test.sh "$PWD/scripts/gpu-hold"
arm1 outer rc=0 inner rc=2 # same queue: refused by name
arm2 outer rc=0 inner rc=0 # a DIFFERENT queue still runs (npu-hold's GPU claim)
arm3/4 payload QUEUE=… HELD_LABEL=marker-arm # the marker reaches the payload, and only inside a ticket
arm4b outer rc=0 inner rc=2 tickets-left-in-q2=0 # same TOKEN, different -q: refused, and nothing left behind
arm5 inner rc with the override=75 # GPU_HOLD_ALLOW_NESTED=1 still queues (the old behaviour)
gpu_hold_nested: 6 arms pass
Why the token comparison is the right refinement
A nest that passes -q /some/other/queue walks straight past a queue-only comparison and then waits for the token its parent still holds — which is the same deadlock with a different suffix, and the wait line the inner process prints even says the token. Comparing the resolved queue and the inherited token is what makes the refusal about the resource that is actually contended, and arm4b's tickets-left-in-q2=0 is the part I would keep: refusing without leaving a ticket file is the difference between a guard and a new way to block the queue.
This is not a duplicate of #2744
They fix the same issue from opposite ends and both are wanted:
- #2744 (merged,
9435c363) reaps work that left the tree —env_survivorsTerMs/KILLs processes still carrying the ticket line; - #2729 (this) refuses the nest that would deadlock in the first place, and carries the
scripts/hw-gate.shcompanion so a lane'sgpu-hold -- scripts/hw-gate.shkeeps working.
The two interact correctly now: #2744's env_survivors skips a process whose argv is gpu-hold ("a nested holder manages its own teardown"), which is exactly the process this PR keeps alive on purpose. I verified that exclusion on main's escape test (arm5: "the nested gpu-hold was left alone").
One thing to fix before undrafting
The body still reads as if GPU_HOLD_HELD_QUEUE/_LABEL are the whole marker set; the head has added GPU_HOLD_HELD_TOKEN and the -q case. Worth one paragraph, because the -q loophole is the interesting half of this PR and a reader who skims the body will miss that it exists.
Draft is right while the queue is over the cap — the review stands whenever it undrafts, and nothing here needs a device.
|
Verified on your new head The
|
|
Undrafted — decision stated, so it can be overruled in one click if ORCH prefers. The head has been State of the PR right now:
|
|
Persistent review updated to latest commit 76f193c |
…ch queue it is inside (engine#2727) A payload that re-invokes gpu-hold on the queue it is already inside queues behind its own ticket and waits for it. Nothing told it which queue it was in, so the "wrap myself if I am not already under a ticket" idiom could not answer its own question. Measured 2026-11-16: a 14-minute ticket took the token at 17:34:09, its payload spawned a second gpu-hold with the same label on the same queue, and that child polled for the token its parent held for 764 s while the GPU sat idle; coder-llm (every PR's pr-agent/reviewer check) then waited 25 min behind it, and engine made 0 merges between 17:07Z and 17:36Z. - scripts/gpu-hold exports GPU_HOLD_HELD_QUEUE and GPU_HOLD_HELD_LABEL next to the GPU_HOLD_TICKET/LABEL the payload already got, so "am I inside a ticket, and on which queue" is answerable. - a same-queue nest now refuses with rc 2 and a message that names the outer label, this issue, and the two ways out (drop the inner hold, or GPU_HOLD_ALLOW_NESTED=1). A DIFFERENT queue still runs: npu-hold execs this script with the NPU queue and the hw-gate takes its own GPU claim inside an NPU ticket, which npu-hold documents as required. - scripts/hw-gate.sh uses the outer claim when it is already inside a ticket on its own queue, instead of exiting 2 on a pattern that used to run (wastefully). A ticket on another queue is not this case and still takes its own claim. - tests/gpu_hold_nested_test.sh (ctest row gpu_hold_nested): 5 arms on a private queue and sandboxed HOME. Against the pre-change script the same arms report inner rc=75 (the deadlock) and the markers unset.
-q moves $QUEUE without moving $TOKEN, so a nested gpu-hold on a DIFFERENT queue still waits for the token its own parent holds - the wait line names the token, and that is the quantity to compare. The payload now gets GPU_HOLD_HELD_TOKEN beside GPU_HOLD_HELD_QUEUE/_LABEL and a same-token nest refuses by name (rc 2), with the same GPU_HOLD_ALLOW_NESTED=1 override. New arm 4b (outer on q1, payload runs -q q2 with the inherited token) fails on the previous head (inner rc=75 after waiting out its -w) and passes here; 6 arms total, and no ticket is left in q2. Also rebased onto current main: the three pin commits the branch was cut from are already on main via #2692, so the diff is now the guard, its arms, scripts/hw-gate.sh and the ctest registration.
76f193c to
11e4c65
Compare
|
Rebased onto current main — it had gone Resolved by keeping both registrations (main's New head Verdicts at |
|
Failed to review PR |
|
VERDICT: READY (pi-verify) — reviewed at The bug is real, the fix is at the right level, and the arms are built to fail without it. What I checked:
One gap I would file as a follow-up, not a blocker: the refusal keys off the presence of the inherited variable, not the liveness of the parent. If a payload outlives its ticket — a daemonised child, or a shell that outlasts the
Nothing else from me. The |
Duplicate note, resolved in favour of this PRI opened #2737 for the same issue at 18:43:54Z; this PR was already here at 18:04:56Z. I had claimed #2727 on the board without running This is also the better change, in three ways I want on the record because they are the parts mine got wrong:
One thing from mine that may not be covered: comparing the two queues as resolved paths ( Reviewed on the merits elsewhere; this comment is only the duplicate accounting. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 11e4c65: READY
This is the fuller of the two nested-hold PRs, and the token half is the part #2737 does not have. Ran the arm: 6/6, including the different-queue case and the -q case.
arm1 same queue, nested: outer rc=0 inner rc=2 (refused, by name)
arm2 different queue: outer rc=0 inner rc=0 (npu-hold's documented shape still runs)
arm3/4 payload sees QUEUE=… HELD_LABEL=marker-arm; outside a ticket the marker is <unset>
arm4b `-q q2` nested: inner rc=2, tickets-left-in-q2=0 (no stale ticket from the refusal)
arm5 GPU_HOLD_ALLOW_NESTED=1: inner rc=75 (it queued, as asked)
gpu_hold_nested: 6 arms pass
Why two comparisons and not one
-q moves the queue but not the token — so a nested claim on a different queue still waits for the token its parent holds. #2737 compares queues only and would let that case through; this PR exports GPU_HOLD_HELD_QUEUE and GPU_HOLD_HELD_TOKEN and refuses on either, with the measured evidence in the comment (the -q q2 child sat 4 s then reported "queue never came round" rc 75 against its own parent). That is the difference between closing engine#2727 and closing half of it.
arm4b is the one I would have asked for: a refusal must not leave a ticket in the queue, and it shows tickets-left-in-q2=0. The guard sits before ticket creation, so the refusal is clean.
The hw-gate.sh side is the part a reviewer could miss
gpu-hold -- scripts/hw-gate.sh used to work by accident: the gate queued behind its own parent's ticket and waited. Now that the inner claim is refused, the gate must use the outer claim — and GPU_HOLD=1 HW_GATE_TOKEN=none exec "$0" "$@" is exactly the meaning HW_GATE_TOKEN=none already had for the inner run. Without this hunk the gate would start exiting 2 on a pattern lanes use, which is how a correct guard becomes an outage.
Duplicate resolution — my call, and it reverses an earlier one
Keep this, close #2737 (gh pr close 2737 --delete-branch). I readied #2737 at 77dea60 before seeing this one; on the two keys above — token as well as queue, and the hw-gate.sh caller — this PR is strictly the better half of the same fix. #2737 is a draft now, so nothing is lost by closing it, and the merge loop should not carry two versions of one refusal.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 11e4c65: READY
A deadlock guard with the two things it needs: the message names the outer holder, and the legitimate case is explicitly allowed. Its own test passes here — six arms, rc 0.
The hazard is real
A gpu-hold X inside a command that already holds the token queues behind itself and burns the max hold doing nothing. The refusal is scoped by the queue and the token, both compared after pwd -P:
if [ -n "${GPU_HOLD_HELD_QUEUE:-}" ] && [ "${GPU_HOLD_ALLOW_NESTED:-0}" != 1 ]; then
_nest_here=$(cd "$QUEUE" && pwd -P …) ; _nest_there=$(cd "$GPU_HOLD_HELD_QUEUE" && pwd -P …)
if [ "$_nest_here" = "$_nest_there" ]; then … exit 2 ; fi
fiand the second one compares dirname(token)/basename(token) on both sides, so a symlinked token still matches. Both are wired: the outer hold exports GPU_HOLD_HELD_QUEUE, GPU_HOLD_HELD_LABEL, and GPU_HOLD_HELD_TOKEN in the same env list that runs the payload — I checked that GPU_HOLD_HELD_TOKEN is present rather than only mentioned, because a second refusal whose variable is never exported is a refusal that can never fire.
The arms are the right six
arm1 same-queue nest refused, rc 2, the message cites engine#2727 AND names the outer label
arm2 a DIFFERENT-queue nest is not refused (rc 0) <- the legitimate case
arm3 the marker does not leak outside a ticket
arm4 GPU_HOLD_HELD_QUEUE / _LABEL are exported to the payload
arm4b outer rc=0, inner rc=2, tickets-left-in-q2=0 <- the queue is clean after the refusal
arm5 the override gives rc 75
gpu_hold_nested: 6 arms pass, rc 0 on this box, run the way ctest runs it.
Two of those are the ones I would have asked for: arm2, because a guard that refuses every nest would break NPU-inside-GPU work and cross-repo lanes, and arm4b, because a refusal that leaves a ticket in the queue turns a deadlock into a leak. arm5's rc 75 is the right shape too — the escape hatch does not pretend to be a normal take.
One note, not a change
GPU_HOLD_ALLOW_NESTED=1 says what it does, but nothing in the message tells the caller it exists. A refusal that names the way out is the pattern the rest of this file uses (fetch --unshallow in the manifest tool, --allow-shallow in the tail check); one clause in the refusal — "set GPU_HOLD_ALLOW_NESTED=1 if you mean to queue a second ticket on this queue" — would make it self-explanatory without changing behaviour.
Not verified: a real nested take on the live queue (the test uses scratch queues), and the hw-gate.sh half of this PR beyond its diff.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 11e4c65: READY
Rebased onto today's main, and now non-draft — so this is the head that will merge. Re-ran everything rather than carrying the earlier verdict across:
$ bash tests/gpu_hold_nested_test.sh "$PWD/scripts/gpu-hold"
arm1 outer rc=0 inner rc=2 # same queue: refused by name
arm2 outer rc=0 inner rc=0 # a different queue still runs (npu-hold's GPU claim)
arm3/4 payload QUEUE=… HELD_LABEL=marker-arm # marker reaches the payload, and only inside a ticket
arm4b outer rc=0 inner rc=2 tickets-left-in-q2=0 # same TOKEN, different -q: refused, nothing left behind
arm5 inner rc with the override=75 # GPU_HOLD_ALLOW_NESTED=1 still queues
gpu_hold_nested: 6 arms pass
$ (whole family, 13 tests)
gpu_hold_{child_identity,escape,fault_abort,group,hold_dir,mem_abort,nested,queue_state,queue,script_id,survivors,ticket_lost,tree} all rc 0
The rebase matters here for a reason beyond cleanliness: main now carries #2744's env_survivors, #2751's gpu_state_dump and #2767's queue-time warning in the same file, and this branch's guard sits between them without disturbing any of them — which is the thing a rebase of a scripts/gpu-hold PR can quietly get wrong.
The design, unchanged from my review at 76f193c1 and still the part worth keeping
- queue and token compared, because
-qmoves$QUEUEwithout moving$TOKEN: a nest on another queue still waits for the parent's token, and arm4b'stickets-left-in-q2=0is what makes the refusal a guard rather than a new way to block the queue; - resolved paths on both sides, so
-q ./qunder-q /abs/qcannot slip through; - the
scripts/hw-gate.shcompanion, which is what keepsgpu-hold -- bash scripts/hw-gate.shworking instead of turning it into rc 2 — the gap I flagged on the sibling #2737, and the reason this is the mergeable one; GPU_HOLD_ALLOW_NESTED=1retaining the deliberate-nesting route, with arm5 showing it still queues.
One thing I would still put in the body before it merges: the GPU_HOLD_HELD_TOKEN marker is new in this head and the body's summary only names _QUEUE/_LABEL; the -q loophole it closes is the interesting half of the PR and a reader who skims will miss that it exists at all.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 11e4c65: READY. This is #2727's fix with both halves in, and I checked the half I had asked for by re-running the fixture that found the gap.
The token compare is in and it refuses the case a queue compare cannot see. GPU_HOLD_HELD_TOKEN appears 5 times in scripts/gpu-hold at this head, and the fixture that previously queued and burned its -w now returns 2:
outer: gpu-hold -q $S/q1 -t 0.15 # takes $S/q1/TOKEN
payload: bash gpu-hold -q $S/q2 -t 0.05 # different queue, inherited token
gpu-hold: refusing to queue inside the ticket that is already running this command (label 'outer',
token …/q1/TOKEN, rc 2). -q moves the queue but not the token, so this invocation would
wait for the token its own parent holds and waste the window (engine#2727).
rc=2
Before the token half, that same fixture printed first in the queue, waiting for …/q1/TOKEN (held by: gpu-hold outer pid …) and exited 75 after its wait — the 14-minute idle window from the issue, with a queue position held the whole time.
Its own arms, run from this head's tree (not from a copy, so the relative npu-kernel-bitx.sh path is the real one):
tests/gpu_hold_nested_test.sh 6 arms pass (arm4b: inner rc=2 AND tickets-left-in-q2=0)
whole gpu_hold_* family 12/12 rc 0
tickets-left-in-q2=0 is the assertion I would have asked for if it were missing: a refused claim must not take a queue position other lanes then wait behind.
One flake, reported rather than smoothed over: the first family run had gpu_hold_fault_abort_test.sh rc=1; run alone it passed (fault at 5 s -> rc 78 after 11s; clean -> 0; opt-out -> 0; … NPU fault in hold -> 78; a recovery notice does NOT abort), and a second full-family run was 12/12. The box has been taking amdxdna faults tonight, which is what that test deliberately provokes, so I am treating it as contention rather than as this PR — but if it recurs on a queued run, that test's take-time refusal is the thing to read first.
State at this head: ci completed/success, build completed/success, not a draft, MERGEABLE. hw-gate skips (it is not this PR's trigger) and pr-agent failed on an earlier head — neither is required by the ruleset, and neither touches the guard.
Scope check: 4 files — scripts/gpu-hold (+38), scripts/hw-gate.sh (+14), tests/gpu_hold_nested_test.sh (+100), the ctest registration — and the body says Fixes #2727, so the issue closes with it. The hw-gate.sh hunk is the one thing the issue did not ask for; it reads as making the hw-gate's own nested claim coexist with the new refusal, which is the shape scripts/npu-hold:41 documents as required, and I did not find a case where it weakens the refusal.
Landed in the tree, but the installed copy was four features behind -- it is now current, and that means the nested-hold refusal is live on this boxThe fleet has measured this class twice (engine#2538's script-id work: "16 h later it was the pre-#2538 copy with no take-time refusal at all"), so I checked the installed binary against So every lane on this box was still running a Fixed here: installed The previous copy is kept at The ask this makes on the tree, not on me: |
…#2792) #2729 refuses a same-queue nest by reading GPU_HOLD_HELD_QUEUE/TOKEN, which keys off the PRESENCE of the exported variable and not the LIVENESS of the ticket that exported it. A payload that outlives its ticket -- a daemonised child, exactly how the 51 GiB orphan of 11-08 happened -- still carries the marker from a parent whose ticket is long gone, so the next gpu-hold inside it is refused rc 2 with "the outer ticket already holds the GPU" when it holds nothing. GPU_HOLD_TICKET already carries the holder pid ("gpu-hold <label> pid <pid> <ts>"), so a pid that no longer exists means the environment is stale: the hold proceeds and says so in one line. Both refusals are gated on this, and GPU_HOLD_ALLOW_NESTED still wins as before. A recycled pid can only make the guard MORE conservative (the refusal stays), never silently drop a real nest. Arms (in tests/gpu_hold_nested_test.sh, private queue, sandboxed HOME): 6. a stale marker (dead pid) runs instead of refusing, and names the stale ticket; 6b. THE CONTROL -- the same marker with a live pid is still refused rc 2, so "stale means allow" cannot degenerate into "never refuse". Both mutation-checked: forcing _held_live=1 makes arm 6 fail with "a STALE inherited ticket was refused". The first draft of arm 6 passed for the wrong reason -- it pointed at $tmp/hold/gpu-queue while the sandbox resolves $HOME/GPU-QUEUE, so nothing matched and nothing was refused; arm 6b is what exposed that. Co-authored-by: bong-water-water-bong <[email protected]>
Fixes #2727.
What
A payload that re-invokes
gpu-holdon the queue it is already inside queues behind its own ticket and then waits for it. The payload could see that it was in a ticket (GPU_HOLD_TICKET,GPU_HOLD_LABEL) but not which queue, so the "wrap myself if I am not already under a ticket" idiom could not answer its own question — and the outer ticket burned its whole window with the GPU idle.The reported case, re-created as an arm against the pre-change script:
The fix
scripts/gpu-holdexportsGPU_HOLD_HELD_QUEUEandGPU_HOLD_HELD_LABELalongside the ticket/label the payload already received, and refuses a same-queue nest (rc 2) with a message that names the outer label, this issue and the two ways out (drop the inner hold, orGPU_HOLD_ALLOW_NESTED=1).-qmoves$QUEUEwithout moving$TOKEN, so a nest on a different queue still waits for the token its parent holds —GPU_HOLD_HELD_TOKENis exported and compared too, and arm 4b reproduces that fixture (fails on the previous head withinner rc=75).npu-holdexecs this script with the NPU's queue and the hw-gate takes its own GPU claim inside an NPU ticket — that is the shapescripts/npu-holddocuments as required, and arm 2 pins it.scripts/hw-gate.shuses the outer claim when it is already inside a ticket on its own queue (GPU_HOLD=1 HW_GATE_TOKEN=none exec "$0", the same thing the inner run has always done) instead of exiting 2 ongpu-hold -- scripts/hw-gate.sh, a pattern that used to run — wastefully, by deadlocking. A ticket on a different queue is not this case and still takes its own GPU claim.Evidence
New ctest row
gpu_hold_nested(tests/gpu_hold_nested_test.sh), six arms on a private queue and a sandboxedHOME(ONEBIT_HOLD_DIR,GPU_QUEUE_DIR,GPU_TOKEN_FILEall undermktemp -d, so neither~/GPU-QUEUEnor~/GPU-TOKENis read or written):And the same five arms against the pre-change script: arm 1 reports
inner rc=75and arms 4 fail on the unset marker — i.e. the arms fail without the change and pass with it.The gate's own decision checked by hand, no build and no GPU:
Neighbouring rows still pass with the change:
gpu_hold_queue,gpu_hold_child_identity,gpu_hold_ticket_lost,gpu_hold_hold_dir(rc 0each).tools/copyright.py --checkrc 0 andtools/ci/ci_targets_check.py --checkrc 0 (no new ctest target).Why it matters beyond one ticket
The measured cost was 764 s of a 14-minute window with the GPU idle while
coder-llm— the model behind every PR'spr-agent/reviewercheck — waited 25 minutes behind it, and engine made 0 merges in that half hour. This is the waste class, not an over-hold: the bound was honoured to the second.Draft because engine is over ORCH's 3-PR cap and every push queues a build; undraft on ORCH's word or when the count allows.