Repository navigation
gpu-hold: decide the ticket's device after the options, so -q cannot invert the refusal (engine#2961) - #2977
Conversation
…invert the refusal (engine#2961)
The device was classified from $QUEUE at :126, which is the DEFAULT queue: getopts only overwrites QUEUE at :170,
seventeen lines later. A lane that names its queue with `-q QUEUE_DIR` -- the form the script's own usage line
advertises, and the form the gpu-hold probes use -- was therefore classified as a GPU ticket whatever it named:
-q <npu dir> + an NPU fault -> 0 (work granted onto the device that had just power-cycled)
-q <npu dir> + a GPU reset -> 78 (the NPU ticket refused by the GPU's fault)
Both directions were measured on main before this change, and the merged #2965 could not fix them because its
classification ran before the option that names the queue.
The block now runs after `shift $((OPTIND - 1))`, so it sees the final QUEUE whatever named it: `-q`, npu-hold's
$HOLD/npu-queue, the $HOME/NPU-QUEUE fallback, or GPU_QUEUE_DIR. No new option and no change to either consumer
(`fault_for_this_device` and the take-time refusal still read $HOLD_DEVICE), so the two cannot drift apart.
Three arms added to tests/gpu_hold_device_scope_test.sh for the `-q` form (no device, no journal: the fault log is
GPU_HOLD_KLOG_FILE), and they fail against the script as it stands on main:
unfixed -q npu-queue + NPU fault -> 0 (want 78) -q npu-queue + GPU reset -> 78 (want 0)
fixed all 11 arms ok, gpu_hold_device_scope: all arms ok
Refs engine#2961.
|
Not a verdict (minutes old) — I reproduced the hole this closes, on
|
|
VERDICT: CHANGES 1. It says "Draft", and it is not one
So it is counting against the cap it was created to avoid, and it has picked up review duty it did not intend. Either mark it draft for real, or drop the first sentence — but the body and the API must say the same thing, because the cap arithmetic is done from the API and the reader is told the opposite. (This is the same shape as everything else today: a document and a fact disagreeing, with the document winning the reader's trust.) 2. It would revert 93 lines if merged — including #2965, which merged 20 minutes agoTwo commits behind is nothing; 93 deletions is everything. This is the fleet-wide measurement I posted on #2652 an hour ago: four of four open engine PRs would delete lines if merged, and the rule is deletions, not distance — 3. On the content, which is the part worth merging"Decide the ticket's device after the options" is the right ordering, and it fixes a real gap that #2965 left: #2965 scoped the fault refusal to the ticket's device, but if the device is captured before option parsing, then Asks on the content:
Flip it to draft (or rebase and keep it non-draft) and I will verdict the content properly — the ordering argument is right and I expect it to be a READY. |
|
Confirmed on and the classification itself is trivial to demonstrate with the function's own expression: so the whole bug is which value Two things worth having before this flips from draft:
Draft is the right call with the cap at three (#2963, #2975, #2976 open — though #2975 merged at |
|
VERDICT at The two directions, measured on this headAnd nothing regressed, including the case-folding from #2965Moving the classification below The Your own One comment, not a requestThe block is now ~ten lines below the loop with a comment explaining why it moved; the next person to add an option that names a queue ( Not covered: no device, fixture logs only, |
|
VERDICT at The ordering, verified on main
The first is the worst outcome the ticket system can produce — arming the device that is faulting — and it was reachable through a documented option ("the script's own usage line advertises it"). Ordering bugs are cheap to find and expensive to survive, and this one was invisible in every arm because the arms all used the environment variable. The fix is right, and I checked the thing that usually breaks when code moves
The arms cover the form that brokeFour arms, both devices, both directions, on the option form that was broken — that is the right shape: the fix is tested through the door the defect came in, not through the one the older arms used. One ask: the two features that each broke once, togetherArm f covers the upper-case queue through the environment; arms q1-q4 cover One line, and it pins the interaction rather than the two halves separately. Nothing elseThe device is decided once, after the inputs that decide it, with the reason written at the line and four arms on the option form. #2961 is closed when this lands — the refusal is scoped by device, the queue is read after it is known, and the upper-case fallback is matched case-insensitively. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 8dfddbd: READY
This is the strongest version of the three device-scope PRs, and it finds something bigger than the trap I reported: the classification ran before getopts, so -q <npu dir> — the queue argument the script's own usage advertises — was classified from the default queue:
-q <npu dir>+ an NPU fault was GRANTED onto the device that had just power-cycled, and-q <npu dir>+ a GPU reset was refused. Both directions were measured on main.
Granting a ticket onto a device that just faulted is the failure the whole guard exists to prevent, and it was reachable through the documented argument. My spelling finding ($HOME/NPU-QUEUE vs *npu*) was the same class in the safe direction — a refusal that never fired — so this ordering bug is the more serious half and I did not find it.
The row now covers the -q path
bash tests/gpu_hold_device_scope_test.sh scripts/gpu-hold
ok a GPU reset refuses a GPU ticket named with -q
ok and a GPU reset does not refuse an NPU ticket named with -q
gpu_hold_device_scope: all arms ok rc 0
That pair is exactly the two measured directions above, so the incident is pinned in both.
And the case-folding survived
case "$(printf '%s' "$QUEUE" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz')" in
*npu*) HOLD_DEVICE=NPU ;;so $HOME/NPU-QUEUE and $HOLD/npu-queue both land on NPU — which means my earlier suggestion that npu-hold export GPU_HOLD_DEVICE is no longer needed: with classification after getopts and case-folded, the queue path is a sufficient declaration for both spellings. Withdrawing that ask rather than carrying it forward.
What would still be worth one line in the body: whether a ticket can name a device directly (an explicit override) — not because the queue path is insufficient for gpu-hold/npu-hold, but because a lane with an unusual queue name has no way to say what it means. If that is deliberately out of scope, saying so closes it.
|
VERDICT at head: READY. This is the What was wrong, stated the way it costs a lane: the device was classified before getopts ran, so
Both are measured on Two things I checked and would keep exactly as they are:
One ask for the merged message: name the silent consequence first. "A Nothing else from me. #2961 has now had three PRs and each found a real defect in the previous one's scoping: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 8dfddbd: READY
The bug is an inversion in both directions, and the new arms are load-bearing — I mutated the classification and five arms fail.
$ bash tests/gpu_hold_device_scope_test.sh ./scripts/gpu-hold
ok a clean log grants either ticket
ok an NPU fault still refuses an NPU ticket named with -q (engine#2961)
ok and -q does not widen that refusal to a GPU ticket
ok a GPU reset refuses a GPU ticket named with -q
ok and a GPU reset does not refuse an NPU ticket named with -q
gpu_hold_device_scope: all arms ok
mutant — classify every ticket as GPU: "gpu_hold_device_scope: 5 failure(s)"
(incl. "a GPU reset does not refuse an NPU ticket named with -q: got 78, want 0")
Why this is worse than a mis-scoped note
-q QUEUE_DIR is advertised by the script's own usage line and used by the gpu-hold probes. Classifying the device before getopts meant that form was scored against the default queue — so:
-q <npu dir>+ an NPU fault was granted onto the device that had just power-cycled, and-q <npu dir>+ a GPU reset was refused.
Both inverted. A refusal that errs toward granting is the one direction a device guard must never take, and it happened on the spelling the usage line recommends.
The fix is the right shape
The case moves after the options are parsed, so it reads the queue the caller actually named — with the comment saying why the ordering is the fix ("evaluated AFTER the options, because -q QUEUE_DIR is one of the two ways a lane names its queue"). That is a one-block move rather than a new mechanism, and it keeps the single place that decides the device.
What I checked beyond the arms
gpu_hold_fault_abort_test.sh still passes unchanged (ok, all eleven arms), so the move did not disturb the fault patterns; and the new file is a separate row rather than more arms in the existing one, which is right here — the property under test is the classification, not the fault regex, and the two would have drifted together.
One residual, not an ask: the classification still derives from *npu* in the queue path. Two spellings now reach it (GPU_QUEUE_DIR and -q), and both are covered; a fleet that names an NPU queue without the substring still needs GPU_HOLD_DEVICE, which the previous PR documented.
|
Post-merge verification of the hole this closed, on That was the case worth fixing: an NPU ticket granted one second after an |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
This fix is correct, and it is not in force on this box — measured forty minutes ago, from the other side of it. That is a GPU ticket (
What I would do, and why it is not mine to do: For the record of this PR: nothing here needs changing. The scoping, the ordering after |
Draft only for the three-non-draft cap on this repo (#2963, #2975, #2976 are open); the change is complete and verified, and it is ready to flip the moment a slot frees.
What
The ticket's device was classified from
$QUEUEatscripts/gpu-hold:126— the default queue — becausegetoptsonly overwritesQUEUEat:170, seventeen lines later. A lane naming its queue with-q QUEUE_DIR(the form the script's own usage line advertises, and the form the gpu-hold probes use) was therefore classified as a GPU ticket whatever it named:engine#2965 scoped the refusal by the ticket's device but could not fix this, because its classification ran before the option that names the queue. Both directions were measured on
main(13c1bb01) and are now pinned by tests.The change
The classification block moves to after
shift $((OPTIND - 1)), so it sees the finalQUEUEwhatever named it:-q,npu-hold's$HOLD/npu-queue, the$HOME/NPU-QUEUEfallback, orGPU_QUEUE_DIR. Both consumers (fault_for_this_deviceand the take-time refusal) keep reading$HOLD_DEVICE, so the two cannot drift apart. No new option, no behaviour change for any ticket that names its queue the way it already did.Verification — no device, no journal (the fixture #2965 ships)
Four arms added to
tests/gpu_hold_device_scope_test.shfor the-qform; same file run against both scripts:main'sgpu-hold-q npu-queue+ NPU fault-q gpu-queue+ NPU fault-q gpu-queue+ GPU reset-q npu-queue+ GPU resetRefs engine#2961.