… gate
Agents on the gate box race each other for ~/GPU-TOKEN, and the race has starved work all day: the token is a
single file that whoever manages a noclobber open takes, so an agent can lose it for hours, a killed holder
leaves it behind, and nothing orders the waiters. The hardware gate's own wait gave up at 3600 s more than
once while other jobs cycled through the token.
scripts/gpu-hold runs one GPU job under a fair claim:
1. it enqueues a ticket ~/GPU-QUEUE/<epoch-ns>.<label> (pid and command inside the ticket), so queue order is
file-name order and the oldest ticket runs first, whoever arrived first;
2. it creates ~/GPU-TOKEN only when its ticket is the oldest live ticket, the token is absent, the die is at
or below the start gate (75 C), and its label has waited RELEASE_WAIT s (180) since it last released;
3. it runs the command under that hold with a max-hold deadline (default 14 min) and a watchdog that aborts the
command at 93 C;
4. it always releases the token and removes its ticket, however it exits (EXIT/INT/TERM/HUP traps);
5. it drops tickets, and tokens, whose owner process is gone, so a killed agent cannot block the queue.
The token file is unchanged for everyone else: one file whose content names its holder. A wrapper that predates
this script simply makes the queue wait, and a queue holder makes a legacy wrapper wait, so the migration can
happen one agent at a time.
scripts/hw-gate.sh uses it when it is installed: the whole gate then runs inside one claim (label
"hw-gate run <id> pid <pid>", hold HW_GATE_HOLD_MINUTES default 45, queue wait HW_GATE_TOKEN_WAIT default
5400). HW_GATE_GPU_HOLD=0 keeps the old behaviour, and without the helper nothing changes. The inner run gets
GPU_HOLD=1 and HW_GATE_TOKEN=none, so it does not try to take the token a second time.
Tested with fake holders (sleeps) in an isolated queue, no GPU work: three claims made one second apart are
served A, B, C in arrival order, each waiting for the previous; a ticket whose owner pid is gone is dropped and
the queue moves on; a token left by a dead holder is reaped; a label that released waits its release window
before holding again while another claim goes first; the max hold cuts a long command short (exit 124); the
start gate refuses a hot die (no acquisition while the fake sensor reads 80 C against a 75 C gate); the abort
kills the command at 94 C (exit 143); and afterwards the queue and the token are empty. Two real defects were
found and fixed by that test: the watchdog was started before the command, so it held an empty pid and neither
the abort nor the max hold stopped anything.
The protocol is written down for the other agents in ~/amd-oss/GPU-TOKEN.md on the box.
Co-Authored-By: Claude Opus 5 <[email protected]>
PR body — 1bit-MONSTER/engine, branch
1bit/gpu-hold, sha 7a65912Title: serve: a fair FIFO GPU queue (scripts/gpu-hold), used by the hardware gate
Why
~/GPU-TOKENhas been a barenoclobberopen for a year, and that has two failure modes that cost real time onthe gate box: waiters race (no order — an agent can be passed over for hours) and a holder that dies leaves the
file behind (nothing reaps it, so the box looks busy for ever). On 2026-10-21 both happened repeatedly: agents
lost the token for one to three hours, and the hardware gate's own wait gave up at 3600 s while other jobs
cycled through the token.
The change
New
scripts/gpu-hold— one GPU job under a fair claim:~/GPU-QUEUE/<epoch-ns>.<label>written before waiting, pid and command inside it. Queue orderis file-name order (fixed-width nanosecond stamps), so the oldest ticket runs first — arrival order.
~/GPU-TOKENis created only when the ticket is the oldest live ticket, the token is absent, thedie is at or below the start gate (75 C), and the label has waited its release window (180 s) since its own
last release. The label goes into the token.
aborts at 93 C. Exit is the command's, 124 if the deadline cut it short, 75 if the queue never came round.
holder costs one poll interval instead of the rest of the day.
scripts/hw-gate.shuses it when installed: the whole gate runs inside one claim (labelhw-gate run <id> pid <pid>,HW_GATE_HOLD_MINUTESdefault 45, queue waitHW_GATE_TOKEN_WAITdefault5400).
HW_GATE_GPU_HOLD=0keeps the old path, and a box without the helper behaves exactly as before. Theinner run gets
GPU_HOLD=1andHW_GATE_TOKEN=none, so it does not take the token twice.The token file itself is unchanged — one file whose content names its holder — so the fleet can migrate one
wrapper at a time:
gpu-holdusers queue fairly among themselves and still wait for legacy holders; a legacywrapper does not see the queue and can still cut in front, it just is not fair. The protocol for the other
agents is written down in
~/amd-oss/GPU-TOKEN.mdon the box, including the one-line migration of a wrapper.Testing
Fake holders, isolated queue, no GPU work (
/tmp/qtest.sh,/tmp/qtest2.sh, log/tmp/gpu-qtest*.log):dropped stale ticket …)dropped stale token (holder pid 999999 gone))-t 0.05(3 s) withsleep 30holding off: die at 80C), exit 75 after its queue waitABORT die at 94C), token releasedThat suite found two real defects in the first cut, both fixed: the watchdog was started before the command, so
it held an empty pid and neither the thermal abort nor the max hold stopped anything.
End to end on the real token,
scripts/hw-gate.sh --models qwen3-0.6b --phases kat,placement: the gatequeued (
gpu-hold[2127680] queued 'hw-gate pid 2127680' as 01792634292882393174.hw-gate_pid_2127680), saw thetoken held by a legacy holder (
held by: hw-gate run 39707855652 pid 1846734 …), waited 38 s, took it, rankat qwen3-0.6b PASSandplacement qwen3-0.6b PASS(153 graphs), released, and left no ticket behind — whichis the backward-compatibility case the fleet actually needs while other agents still race.
bash -non both scripts andpython3 tools/copyright.py --check(exit 0) pass.🤖 Generated with Claude Code