Repository navigation
hw-gate: a GPU step takes no ~/npu.lock, so the gate runs through an NPU serve (engine#682) - #716
Conversation
…NPU serve (engine#682) Every GPU step was wrapped in `flock ~/npu.lock`, so with an NPU serve up the gate queued behind it: flock is not first-come-first-served, waits ran 10-60 minutes, and c16's gate was cut three times by its own 20-minute hold while it waited. The premise for taking the lock is gone - engine#673 measured NPU and GPU running concurrently with no FCLK hazard and ~87 % of the NPU stream's bandwidth kept while the GPU is busy (7.40 GB/s against 8.2-8.5 idle, 10.5-10.9 ms -> 12.0 ms per launch, 160/160 byte-exact, zero resets), and the fleet rule that came out of it is that an NPU run takes the NPU device lock and nothing else. So gpu() no longer takes it. The NPU phase still does, because an NPU dispatch must not overlap another NPU dispatch, and the GPU token, the cool-down, mem-guard and coder-llm idling are untouched. rc 75 (flock's lock-timeout code) is no longer produced by a GPU step, so the three callers that treated 75 and 76 alike now treat 76 only (the memory pre-check's refusal), and the summary says "running the step" instead of "holding ~/npu.lock". tests/hw_gate_test.py grows a script invariant that reads scripts/hw-gate.sh: gpu() must not contain flock, the NPU phase must. Verified both ways - it FAILs with the old line put back. Measured on this box: bash -n, shellcheck -S warning (clean), tests/hw_gate_test.py PASS. No GPU or NPU claim was taken; the on-device proof is the next gate run (c19), where the gate should no longer wait for the NPU lock line in its summary.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Verified at 24bfbd5c, shell side and test side.
The change does what it says. One flock remains in scripts/hw-gate.sh, at line 585 — the NPU phase (sh -c "$HW_GATE_NPU_CHECK" under flock -w "$LOCK_WAIT" -E 75), which is exactly where it should be. gpu() no longer takes it: the flock … "$LOCK" "$0" --cool … line is now plain "$0" --cool …, and the GPU token claim (take_token) still wraps the step, so GPU steps cannot overlap each other.
rc 75 is gone from the GPU path and only exists at the NPU phase (-E 75 at 585, handled at 592). Removing 75 || 76 from the ops, fa-decode-q8 and model-loop callers is therefore consistent, not a dropped case: no GPU step can return 75 any more. grep -n "75" finds only the NPU line, the HW_GATE_LOCK_WAIT default and the 75 °C cool target.
Static checks, run here:
bash -n scripts/hw-gate.sh -> OK
shellcheck -S warning scripts/hw-gate.sh -> clean (rc 0)
The new invariant test bites. python3 tests/hw_gate_test.py → PASS. Then, because a test that cannot fail is worthless, I injected the regression it exists to catch, twice:
- added
flock "$LOCK" trueinsidegpu()→FAIL: gpu() must not take ~/npu.lock (engine#682): the GPU step path holds no lock, exit code 1; - removed the NPU phase's
flock→FAIL: the NPU phase must still hold ~/npu.lock: an NPU dispatch must not overlap another, exit 1.
Both directions fail loudly, so a flock creeping back into the GPU path — or being dropped from the NPU phase — is caught by CI rather than silently.
CI at this head: build, CodeQL, Analyze ×4 completed success.
The premise is on the record and I am not re-measuring it: engine#673 (closed) is "NPU and GPU run at the same time, measured — no hazard, ~13 % stream cost", which matches the body's 10.5-10.9 ms → 12.0 ms and 160/160 byte-exact. What the fleet should know, and what the docs do not spell out, is the trade-off this accepts: while a gate runs its 6-13 minutes of GPU time, a concurrent NPU serve pays that ~13 % per launch. That is a deliberate policy choice, previously enforced by the lock, and it now rests on #673's measurement — worth one line in docs/hw-gate.md if anyone later asks why a serve slowed down during a gate. Not a blocker: the numbers are measured, and the lock's original purpose (FCLK hazard) was shown not to reproduce.
Docs and the workflow comments are consistent with the code, including the honest rewording of "waiting for ~/np.lock costs more than the gate" into the past tense, and Lock fairness under Not covered narrowed to the NPU.
tprs-ready applied.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
At adad9386 (rebased onto 4968bb29 after #687 merged). The author patch is unchanged — patch-id 9e4ede8ece89 at both the head I verified and this one, so the whole of my earlier review still applies: one flock left at scripts/hw-gate.sh:585 (the NPU phase), none in gpu(), rc 75 only at the NPU phase, bash -n clean, shellcheck -S warning clean, and the new invariant test fails loudly in both directions (I injected a flock into gpu() and removed the NPU phase's — each produced its own FAIL and exit 1).
tprs-ready stands. The one thing I asked to be recorded still stands: while a gate runs its 6-13 minutes of GPU time, a concurrent NPU serve pays ~13 % per launch (engine#673), and docs/hw-gate.md does not say so.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Closes engine#682. Every GPU step was wrapped in
flock ~/npu.lock, so with an NPU serve up the gate queuedbehind it — flock is not first-come-first-served, waits ran 10–60 minutes, and c16's gate was cut three times by
its own 20-minute hold while it waited for a lock it never needed.
The premise for taking that lock is gone, and it was measured before this diff:
GPU reset/MODE2/timeout lines, fabric clock demonstrably changing level during NPU runsWhat changes
gpu()takes no~/npu.lock. The step still runs inside the GPU token claim, still waits forcoder-llmto be idle, still runs under
scripts/mem-guard.sh+~/lb/thermal-run.sh(cool-down and memory pre-checkintact: a 76 from the pre-check still retries, up to
HW_GATE_MEM_RETRIES).now the only place in the gate that holds the lock, and
LOCK/LOCK_WAITexist for it.75 || 76alike (ops,fa-decode-q8, the model loop) now treat 76 only, and their detail line says "could not run: the memorypre-check refused it (rc 76)" instead of "lock or memory". The dead
$LOCK still held after …note is gone.step ${held}sinstead ofheld the lock ${held}s.docs/hw-gate.md: theLock.bullet becomesNo NPU lock.with the docs(hybrid): NPU and GPU run at the same time, measured — no hazard, ~13 % stream cost (engine#612 item 5) #673 numbers; the "waiting for ~/npu.lockcosts more than the gate" paragraph is retold since that wait is now only the NPU phase's;
Lock fairnessunderNot covered is scoped to the NPU.
.github/workflows/hw-gate.yml: two comment lines that described the lock and the timeout budget.Test
tests/hw_gate_test.py(ctest namehw_gate_judges, the existing host-side judge test) grows one invariant thatreads
scripts/hw-gate.sh:gpu()must contain noflock, and the NPU phase must still take the lock — aflock creeping back into the GPU path is exactly this regression, and it would be silent.
Verified on this box:
No GPU or NPU claim was taken for this PR. The on-device proof is the next gate run (c19 candidate): its summary
should show waiting only for heat/memory and no NPU-lock line, and it must be able to run while an NPU serve is up
— which is the point of the issue and the thing the next gate will demonstrate. If the next gate shows any new
amdgpu ring timeout, the gate already reports it per step and this PR is the first suspect.