Repository navigation
repro-hostgemm-lock: stop orphaning a forward-serve on the NPU (the setsid/$! trap) - #2472
Conversation
engine#374 is why this exists: model_buffer_from_mmap() retagged a CPU buffer as mapped_buft while leaving its context a CPU context, and the result was correct output at 8.4 t/s instead of 31.3 — a 3.7x regression that no correctness test caught, because every test watching that buffer was watching the assertion it satisfied, not the speed it satisfied it at. hrx-buffer-test went red much later, on an alignment assert. A rate floor measures the thing users feel and fails in the direction a correctness check cannot: a run that is 3x too slow still emits the right tokens. Values named on failure, SKIP (77) when the log carries no rate at all — a missing rate is not a pass. Four arms in --self-test, the second being #374's own before/after pair (31.3 passes a 20 floor, 8.4 fails it). Wired as a ctest row so it cannot become a checker with no caller; the device mode is --log <llama-cli output> --floor N.
…inimum of three runs Both from the review's asks, both from measurements this box already made: - JUDGED <subject> before the verdict. A floor is a number tied to a model, quant, context and box; without the subject a pasted 'below_floor: 8.4' is a recollection, not evidence. Same lesson engine#2426 landed for AUDITED <sha> tonight. - The usage now says to set the floor below the MINIMUM of >=3 interleaved runs, and says why with the number: four identical 128-token decode runs on engine#679 measured 7.94 / 11.78 / 10.39 / 12.57 t/s -- median 11.09, spread 1.58x. A floor judged on one sample flaps for reasons unrelated to a regression, and a flapping row gets ignored. Judging a range instead (tools/ci/medians.py's disjoint-ranges A/B) is more correct and more work; not done here, named as the better next step. Fifth arm pins that every verdict carries its subject.
…ce 15:16Z) The file carried '# Copyright' and '# SPDX-License-Identifier' but not the licence block, so copyright.py reported 'missing copyright notice' and the build failed at the configure/check step. The sequence matters and the first advice on the PR was wrong: --fix on the partial header inserts 14 lines that DUPLICATE those two, producing 'copyright notice duplicated inside the header window' -- one red row traded for another. Delete the two partial lines first, then --fix inserts the 12-line block and --check returns rc=0. Verified locally: copyright.py --check rc=0, --self-test 5 arms 0 failed.
…aying 'not a failure' Two asks from the review at 1a5785d, both right: 1. --log had no caller. One ctest row ran --self-test; the mode that would have caught engine#374 was invoked by nothing in the tree -- engine#2418's defect (arms green, never applied) in the tool written to catch that class. tools/ci/token_rate_floor_device.sh judges one real 1bit serve rate inside a gpu-hold ticket and exits 77, naming the missing prerequisite, when it cannot run. 2. below_floor printed '-- a slowdown, not a failure' while exiting 1: the status said failed and the sentence said not. It now prints the multiplier -- 'correct output, 2.4x below the floor' -- which is the number that made engine#374 worth measuring.
… NPU `setsid "$BIN" forward-serve ... &" makes $! the setsid pid, so the trap's `kill $PID` kills a process that has already exited and never reaches the server: it survives with PPID 1 and holds the NPU hardware context. That is not hypothetical — on 2026-11-15 a `flm-real serve` left by an `npu-model-chart.sh` run with this same line held every NPU context for 22 h 44 min, and cl-npuperf and cl-flm got -19 on every hwctx create. The chart is fixed (setsid removed, port-scoped pkill at every kill site) and this is the same fix in the repo copy. Dropping setsid makes $! the server, so the existing trap works as written; the port-scoped pkill is the belt for when it does not. `bash -n` clean, 0 setsid left.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
…llow-up to #2472) (#2477) #2472 removed `setsid` and its comment says setsid "makes `$!` the setsid pid". In this script that is not what happens: util-linux setsid forks only when the caller is a process-group leader, and a `&` job in a non-interactive script (no `set -m`) is not one, so setsid execs in place and `$!` IS the server. non-interactive: setsid sleep 301 & -> $! comm=sleep, kill $! -> gone with set -m: setsid sleep 302 & -> $! is the forking parent, kill $! -> sleep survives Removing setsid is still right, for the other reason: it put the server in its own session, so a script killed without its EXIT trap left the server with no SIGHUP and PPID 1. The comment now says that, so a later reader does not "fix" the trap and bring setsid back. Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
|
READY. This is the orphaned-server defect that has cost this fleet the most, diagnosed at the exact line, and the NPU_INFER_HOST_GEMM=1 setsid "$BIN" forward-serve ... &
PID=$!
trap 'kill $PID 2>/dev/null; wait $PID 2>/dev/null' EXIT
Three things that make the fix right rather than merely different:
And the gap it exposes is the finding I would keep: " One ask: the 22 h orphan and the Not verified by me: the |
My own 22 h orphan, found in a repo script. The line is identical:
setsidmakes$!the setsid pid, so the trap kills a process that has already exited and never reachesforward-serve. That server then survives with PPID 1, no ticket, holding the NPU hardware context.Why I know exactly what it does
On 2026-11-15 a
flm-real serve lfm3:1.7b -p 8199left by annpu-model-chart.shrun with this same line held every NPU context for 22 h 44 min.cl-npuperfandcl-flmgot -19 on every hwctx create for most of a day. The chart is fixed (setsid removed at 3 launch sites, port-scopedpkillat all 7 kill sites) and this is the same fix in the repo copy.The change
setsiddropped —$!becomes the server, so the existingtrap/waitworks as written, andkill -0 $PIDin the readiness loop now watches the process that matters.pkill -f "forward-serve .* -p $PORT"in the trap — the belt, because cleanup should not depend on$!being the server. That dependency is the whole bug.bash -nclean,copyright.py --checkrc=0.The gap this exposes, which is bigger than the line
tests/gpu_hold_tree_test.shalready exists and asserts exactly the property that was violated — "0 = the tree died with the ticket, 1 = something survived". It testsgpu-hold's own tree, so it could not see my~/bin/npu-model-chart.sh, and it cannot see a script like this one either.Scripts in
~/binare outside every check this repo runs. That is where the 22 h orphan lived, and it is why the fleet's carefully built tree-death test did not catch it. The durable fix is not more discipline in~/bin: it is that anything that launches a server belongs inscripts/, wheregpu_hold_tree_test.shandtests_referenced_checkcan see it.npu-model-chart.shis a candidate to move; I have not moved it in this PR because it lives outside the tree and the move deserves its own review rather than riding along with a bug fix.