Repository navigation
Description
What happened (measured, 2026-11-06 00:02–00:50 AST, strixhalo)
A 1bit serve --device npu from an aborted install-test run was left running as an orphan (ppid 1) with no clients:
pid 2689658 ~/wt/payload-c28/opt/1bit-package/1bit/1bit serve -m <FastFlowLM Qwen3-0.6B-NPU2> \
--port 8111 --device npu --ctx-size 32768 started 00:02:24, ppid 1
It held /tmp/1bit-npu-device.lock for ~32 minutes. Two lanes' npu-hold tickets were granted the NPU token in that window
and could not use the device:
- my
1bit forward-serveprinted[npu] waiting for the exclusive device lock (/tmp/1bit-npu-device.lock)...and then sat
there for the whole 1375 s ticket; the logprobs harness reportedserve never became readyon both binaries of an A/B
pair, i.e. a device-ticket was spent and measured nothing; - a retry that pressed on produced 72 kernel errors in ~10 s —
aie2_alloc_resource: Allocate AIE resource failed, ret -19→aie2_hwctx_init→amdxdna_drm_create_hwctx_ioctl.
The engine surfaced that asnpu runtime: device error (code 102): No such devicefromI8Ctx::init_elf. Nothing in that
message says "another process owns the device", so it reads as a broken device/ELF/container; - another lane reported the same pid blocking three of its servers in the same window.
Stopping the orphan cooperatively (SIGTERM, per NPU-LANE-RULE-20261104.md rule 4 — no -9) freed the lock and port in 2 s
and the very next ticket ran clean.
Why the lock itself is not the bug
app/npu_device_lock.h uses flock(2), so the lock dies with its holder: there is no stale lock to reap. The failure mode
is a live orphan, and the engine has no diagnostic for it and no way out of the wait:
std::fprintf(stderr, "[npu] waiting for the %s device lock (%s)...\n", ...);
if (::flock(fd, op) != 0) { ... } // blocks indefinitely, prints nothing furthergpu-hold reaps dead tickets, and npu-serve-keeper stops/reaps the owner's serve; neither looks at the lock, so a leaked
serve is invisible to the fleet's own coordination until someone runs fuser.
Proposed cures (small, and each one converts a 30-minute stall into a 5-second diagnosis)
- Name the holder. After ~2 s of a blocking wait, print the pid(s) that hold the flock —
/proc/locksgives
FLOCK ADVISORY ... <pid> <maj>:<min>:<ino>for the file, so match the lock file'sst_dev/st_inoand print the pids with
theircmdline(truncated). Repeat at most once a minute. One line like
[npu] device lock held by pid 2689658 (1bit serve --device npu ...) for 41 swould have replaced an hour of guessing. - The same line on the refusal path. When a dispatch fails with
code 102, say whether the lock is held by another pid —
No such devicefor "somebody else owns the array" is the single most misleading message this route can emit (it sent me
looking at container/ELF generation first). - Optional bounded wait.
ONEBIT_NPU_LOCK_WAIT_MAX(seconds, default unlimited) so a gate/harness can fail fast with the
holder's name instead of consuming a device ticket. Unlimited must stay the default: a shared box's normal contention is
exactly what the wait is for. - Not proposed: reaping the orphan automatically. Killing another lane's live NPU client is the box-crashing path
(NPU-LANE-RULE-20261104.mdrule 4), so a diagnostic is the right shape for an engine fix.
Separate, related, and mine to fix in the harness
scripts/npu-window11.sh via ~/.p4-gate/repeat-window11.sh hardcodes --port $((8110 + r % 2)) and never checks the port is
free; the leaked serve above was listening on :8111, so round 1 of my A/B block was answered by that process (3
transcripts, 0 prof rows, another build's text shape). A bind() failure that says so, or a free-port check, belongs in that
harness — it is on the #808 gate lane, not here.
Activity