ttx(slot): reclaim a claim whose process is gone (one idled the box for 4h47m) #91

Closed
Grok wants to merge 3 commits from ttx-slot-stale-reclaim into ttx
Owner

What happened

On 2026-09-26 a card claim outlived its process by 4 h 47 m. Three agents queued behind it on a box with load average 0.06, zero running containers and no tt-metal process alive. One of the blocked waiters was my own load probe, which timed out REFUSED having measured nothing.

Record: bench/runs/ttx-slot-stale-claim-20260926T022000Z.jsonl (includes the verification done before releasing anything — owner file, container list, process list, loadavg — because releasing another agent's claim on a hunch is preemption).

Cause — not the one you would guess

Not a missing trap, though a trap helps too. Killing a driver does not kill an acquire that is already in flight. ttx slot acquire polls over ssh on the box, so a local pkill leaves the remote waiter alive. Mine won the mesh slot two hours after its parent died, and by then nothing existed to release it.

Fix

acquire now reclaims a stale claim, and says so loudly. All three must hold:

  1. the container named on the owner line is not running (or none was named),
  2. no container occupies that card's device node,
  3. the claim is older than --max-idle (TTX_MAX_IDLE_S, default 1800 s).

The pid is deliberately not the test

This is the part worth reviewing. The owner line already records pid@host, so checking it is the obvious fix — and a bad one. A slot is designed to outlive the ssh session that took it (slot.sh's own header says so), which means that pid is dead moments after a perfectly healthy acquisition. Reclaiming on pid liveness would evict every live job on the box.

What a real claim owns is a container. Age only guards the gap between acquire and docker run, and a cold weight load is minutes, not half an hour.

Tests

24 pass. The negative controls matter more than the positive one, because a reclaim that can evict a live job is worse than the bug it fixes:

  • an aged claim is KEPT while its own container runs;
  • an aged claim is KEPT while any foreign container holds the device node;
  • a claim inside the grace window is never reclaimed.

Skill

.claude/skills/tt-card-slot/SKILL.md gains §5a: the trap every slot-holding driver should carry, and the procedure for killing a driver whose acquire may be in flight — the orphan lives on cfx-llm2, so a local pkill is not enough:

tools/ttx/ttx slot status
pkill -f my-driver.sh
ssh cfx-llm2 'pkill -f "acquire .*<your owner string>"'
tools/ttx/ttx slot release --card mesh --owner <owner>

It also says what to do when you believe a claim is stale but it is younger than the grace window: check, and say so, rather than releasing it.

Refs #70.

🤖 Generated with Claude Code

## What happened On 2026-09-26 a card claim outlived its process by **4 h 47 m**. Three agents queued behind it on a box with load average 0.06, zero running containers and no tt-metal process alive. One of the blocked waiters was my own load probe, which timed out `REFUSED` having measured nothing. Record: `bench/runs/ttx-slot-stale-claim-20260926T022000Z.jsonl` (includes the verification done *before* releasing anything — owner file, container list, process list, loadavg — because releasing another agent's claim on a hunch is preemption). ## Cause — not the one you would guess Not a missing trap, though a trap helps too. **Killing a driver does not kill an `acquire` that is already in flight.** `ttx slot acquire` polls over ssh *on the box*, so a local `pkill` leaves the remote waiter alive. Mine won the mesh slot two hours after its parent died, and by then nothing existed to release it. ## Fix `acquire` now reclaims a stale claim, and says so loudly. All three must hold: 1. the container named on the owner line is not running (or none was named), 2. no container occupies that card's device node, 3. the claim is older than `--max-idle` (`TTX_MAX_IDLE_S`, default 1800 s). ### The pid is deliberately not the test This is the part worth reviewing. The owner line already records `pid@host`, so checking it is the obvious fix — and a bad one. A slot is *designed* to outlive the ssh session that took it (`slot.sh`'s own header says so), which means that pid is dead moments after a perfectly **healthy** acquisition. Reclaiming on pid liveness would evict every live job on the box. What a real claim owns is a **container**. Age only guards the gap between `acquire` and `docker run`, and a cold weight load is minutes, not half an hour. ## Tests 24 pass. The **negative** controls matter more than the positive one, because a reclaim that can evict a live job is worse than the bug it fixes: - an aged claim is KEPT while its own container runs; - an aged claim is KEPT while any foreign container holds the device node; - a claim inside the grace window is never reclaimed. ## Skill `.claude/skills/tt-card-slot/SKILL.md` gains §5a: the `trap` every slot-holding driver should carry, and the procedure for killing a driver whose `acquire` may be in flight — the orphan lives on cfx-llm2, so a local `pkill` is not enough: ```bash tools/ttx/ttx slot status pkill -f my-driver.sh ssh cfx-llm2 'pkill -f "acquire .*<your owner string>"' tools/ttx/ttx slot release --card mesh --owner <owner> ``` It also says what to do when you believe a claim is stale but it is younger than the grace window: check, and say so, rather than releasing it. Refs #70. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A claim outlived its process by 4 h 47 m on 2026-09-26 and three agents queued
politely behind a corpse on a box with load average 0.06, zero containers and no
tt-metal process alive. One of the blocked waiters was the same agent's own load
probe, which then timed out REFUSED having measured nothing.

The cause is not a missing trap, though a trap would also have helped. Killing a
driver does not kill an `acquire` that is already in flight: `ttx slot acquire`
polls over ssh ON THE BOX, so a local pkill leaves the remote waiter alive. It won
the mesh slot two hours later, and by then no parent existed to release it.

acquire now reclaims a stale claim, conservatively. All three must hold:
(a) the container named on the owner line is not running, (b) no container occupies
that card's device node, (c) the claim is older than --max-idle (default 1800 s).
It says so loudly: "RECLAIMED cardN from '<owner>' -- idle Ns ...".

The pid is deliberately NOT the test, and this is the part worth reading. The owner
line already records pid@host, so checking it is the obvious fix — and a bad one. A
slot is designed to outlive the ssh session that took it, which this file's own
header says; that pid is therefore dead moments after a perfectly HEALTHY
acquisition, and reclaiming on pid liveness would evict every live job on the box.
What a real claim owns is a container. Age only guards the gap between `acquire` and
`docker run`, and a cold weight load is minutes, not half an hour.

The negative controls are the point of the tests, more than the positive one: an
aged claim is KEPT while its container runs, and KEPT while any foreign container
holds the device node. A reclaim that can evict a live job is worse than the bug.
24 tests pass.

SKILL.md gains section 5a: the trap to put on every driver that holds a slot, and
the procedure for killing a driver whose acquire may be in flight — the orphan lives
on cfx-llm2, so a local pkill is not enough.

Refs #70.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Owner

verdict: approve
tier: T1

rationale: The fix is a small, self-contained change to the single owner of the card lock (tools/ttx/lib/slot.sh), and the reclaim is correctly conservative: all three must hold (owner container not running, nothing on the device node, claim older than --max-idle). It runs under the existing .flock, touches only the lock file (never a container), and fails closed on an unparsable timestamp. The pid-as-staleness trap is reasoned through correctly and avoided.

concerns:

  • [nit] tools/ttx/tests/test_slot.py:25 — removed the setUp guard that reported which of bash/flock/awk was missing. CI pins the tools (fe5fbbc), so CI is fine, but a local runner without flock now fails with a cryptic 127. Worth a one-line comment rather than deleting the guard, since the failure is unactionable without it. Not a block.
  • [nit] bench/runs/*.jsonl evidence records added to the tracked bench/ — consistent with AGENTS.md ("bench/ is tracked on purpose"), just flagging it's a net-new addition to that dir.
**verdict:** approve **tier:** T1 **rationale:** The fix is a small, self-contained change to the single owner of the card lock (`tools/ttx/lib/slot.sh`), and the reclaim is correctly conservative: all three must hold (owner container not running, nothing on the device node, claim older than `--max-idle`). It runs under the existing `.flock`, touches only the lock file (never a container), and fails closed on an unparsable timestamp. The pid-as-staleness trap is reasoned through correctly and avoided. **concerns:** - [nit] `tools/ttx/tests/test_slot.py:25` — removed the setUp guard that reported which of `bash/flock/awk` was missing. CI pins the tools (fe5fbbc), so CI is fine, but a local runner without flock now fails with a cryptic `127`. Worth a one-line comment rather than deleting the guard, since the failure is unactionable without it. Not a block. - [nit] `bench/runs/*.jsonl` evidence records added to the tracked `bench/` — consistent with AGENTS.md ("bench/ is tracked on purpose"), just flagging it's a net-new addition to that dir.
Second window lost to this. tenstorrent-serving.service cold-boots the FP8 snapshot
on both cards while holding no ttx slot, so every polite waiter queues behind
something `ttx slot status` did not mention. It cannot be `systemctl disable`d from
the host -- read-only Nix store -- so it comes back on any reboot.

`status` now warns per card, naming the containers on the device node that no slot
accounts for, and pointing at the usual source. The owner's own container is
excluded, so a healthy held slot stays quiet.

This is not the fix. Masking the unit through nixos-llm is; there is no production
on TT and the unit is a nuisance. But a window lost to a cause nobody can see is
worse than one lost to a cause named on the status line.

Three tests, including the two that keep it quiet: the slot owner's own container
never warns, and a clear box never warns. 36 pass.

Refs #70.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A release-only trap orphans the container: my own ttx-pool-1048576
outlived its driver because the trap released the slot and stopped
nothing. The card then reads as free while a container still holds its
device node, so the next agent's boot fails on a card the slot protocol
told them was theirs -- which looks like preemption rather than a leak.

Order matters: slot release refuses (exit 4) while the owner line's
container runs, so a release-first trap does not even report the
problem, it silently leaves both. Two statements, down then release,
each with its own 2>/dev/null so neither can stop the other running.

Also points at the UNSLOTTED-container warning this branch adds, which
is what caught the orphan.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member

Closing: every commit on this branch (head ebbfa399, base ttx) is already on master f30ab09. The follow-up dead-owner reap is #205. Triage 2026-10-09.

Closing: every commit on this branch (head ebbfa399, base `ttx`) is already on master f30ab09. The follow-up dead-owner reap is #205. Triage 2026-10-09.
tenstorrent closed this pull request 2026-10-09 10:53:59 +02:00
Author
Owner

agent-gateway closeout (closed): cleared agent:* labels.
Hermes kanban card (if any) is left for Hermes to archive/complete.

agent-gateway closeout (closed): cleared `agent:*` labels. Hermes kanban card (if any) is left for Hermes to archive/complete.

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitpartner/tt-stack!91
No description provided.