Skip to content

gpu-hold: reap a token that names no holder - #2880

Merged
bong-water-water-bong merged 3 commits into
mainfrom
ci/gpu-hold-unreadable-token
Nov 19, 2026
Merged

bong-water-water-bong merged 3 commits into
mainfrom
ci/gpu-hold-unreadable-token

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

What broke

~/GPU-TOKEN was a 0-byte file on strixhalo (mtime from a crash cycle). gpu-hold could not take it and could not say why:

  • the grant path writes the token under set -o noclobber, so the write simply fails against an existing file;
  • reap_token() only reaps a token whose content names a dead pid, and an empty file names nobody.

So every take polled a 2 s loop in silence, forever. Measured: ticket ab2 sat 4828 s, nine take attempts logged nothing but their retry line, and the next poll after rm -f ~/GPU-TOKEN granted in 0 s.

Fix

reap_token() now reaps an unreadable token once it has been unchanged for GPU_HOLD_TOKEN_GRACE seconds (default 5):

age=$(( $(date +%s) - $(stat -c %Y "$TOKEN" 2> /dev/null || date +%s) ))
if [ "$age" -ge "$TOKEN_GRACE" ]; then
    rm -f "$TOKEN"
    log "dropped unreadable token (no holder pid, unchanged for ${age}s): ${content:-<empty>}"
fi

The grace is the safety: a holder writes its token once, so a fresh unreadable file may be mid-write and is left alone; an unreadable file that has not moved for 5 s is a leftover, not a claim. A token that names a live holder is still left alone, and one that names a dead pid is still reaped immediately — the previous two arms are untouched.

Tests

tests/gpu_hold_stale_token_test.sh gains three arms, and all five pass:

ok   a token left by a dead foreign holder is reaped and the ticket is taken
ok   a LIVE foreign holder's token is left alone (rc=75, waited out -w as it should)
ok   an empty token that names no holder is reaped and the ticket is taken
ok   a truncated token that names no holder is reaped and the ticket is taken
ok   a fresh unreadable token is left alone until the grace passes

The other 13 tests/gpu_hold_*_test.sh are unchanged and green, except gpu_hold_fault_abort_test.sh, which times out here on the unmodified script too (git show HEAD:scripts/gpu-hold → rc=124), i.e. pre-existing on this host and not a regression from this change.

Not fixed here

A host-side kill (bg_kill on the orchestrator, a dropped ssh) does not signal the far-side gpu-hold: its payload keeps the device and keeps faulting until someone kills it on the box. That is harness discipline rather than a gpu-hold bug, but the next lane has to notice it — the escaped-process sweep only runs at release.

bong-water-water-bong added 3 commits November 19, 2026 13:20
…s (engine#2875)

The 2026-11-19 watcher run alerted `!! UNCOVERED HYV4FlashForConditionalGeneration
(new class)` (autotrust/hy4-flash-concise, a re-wrap of atakans/Hy4-flash-NVFP4,
itself a quantisation of tencent/Hy4-flash).

The class is Hy v4 Flash, a vision+text MoE: a HYV4FlashForConditionalGeneration
wrapper plus a HYV4FlashForCausalLM trunk (hidden 3072, 42 layers, 32/32 heads,
head_dim 64, vocab 120832, 1M ctx, 16 experts/token, moe_intermediate 1536) whose
layer_types alternate deepseek_sparse_attention with sliding_attention under a
compressed indexer (compress_ratio 4, indexer head_dim 128, gated key pooling),
with engram_* embedding fields on top.

The pinned backend registers exactly one hy class, HYV4ForCausalLM -> hy_v4
(conversion/__init__.py:145, conversion/hy_v4.py:24 class HYV4Model(DeepseekV2Model),
src/llama-arch.cpp:140) -- the text-only Deepseek-v2-shaped model. There is no
hy_v4_vl anywhere in it (0 hits for hy_v4_vl in conversion/__init__.py and
src/llama-arch.cpp at pin 8d26add2cf9a), and HYV4FlashForCausalLM is unknown to it,
so neither the wrapper class nor the Flash trunk converts. Upstream transformers
main does ship hy_v4 and hy_v4_vl, which is why the watcher read the class as
native rather than `. REMOTE-CODE`; support in the reference implementation is not
support in a backend this engine can call.

- registry/significant.json: the entry, `watch: "report"`.
- docs/arch-gaps.md: the dated note with the config, the upstream checks and why
  mapping the name would advertise a family the engine cannot serve.
- registry/census.json: declined_architectures 24 -> 25 (derived by
  tools/census.py from significant.json); declined_models stays 465 because the
  class has no models in the 2026-11-18 raw sweep.

tests/census_watch_test.py, tests/registry_gaps_test.py,
tests/registry_content_test.py, tools/registry_build.py --check-gaps and
tools/copyright.py --check pass.
…(engine#2875)

The 2026-11-19 watcher reported the pinned vllm-project/semantic-router moved
(e7c0f99c90cd -> 9db290309815) with watched paths changed, and one d3 repo not in
the list.

Read the window (100 commits, six touching a watched path):

- The System One HTTP contract gains a family and nothing it already says moves.
  6179d1bcd (#6840) adds vela3_pico to the family lists in
  config/schemas/systemone/vllm-sr-5.0.extensions.yaml (roles, preset, head and
  the rest; 13 lines, all list extensions) and one line of
  src/model-runtime/vllm_srun/api/openapi.yaml. No field is added, removed or
  retyped, src/model-runtime/vllm_srun/systemone.py does not move, and the wire
  protocol string stays vllm-sr/systemone@1.
- The five other watched commits change what the upstream d3 runtime answers, not
  how it is called: 2cdb4e494 (#5940) shares one state encode across equal-state
  requests of a burst; b14924cbd (#6997) reads control tokens typed in the request
  text as text; 8faa6efa9 (#7000) keeps whole entities under a raised span
  threshold and fixes span edges; 34c2c14c2 (#7001) has a span question read the
  user part of a state without a description; bba8a629a (#7002) validates Vela 3.0
  question types, span labels and image-only states.

None of it reaches npu/systemone.h, which copies the pack's d3_format.py /
d3_runtime.py prompts and answers. A parity check against upstream (engine #653)
should expect the answer-side differences on vela3-mini / vela3-flash spans.

vllm-sr/d3.1-nano (created 2026-11-12, 236 downloads) is a real d3 pack --
d3_format.py, d3_engine.py, d3_compose.py and MODEL_MANIFEST.json in the repo --
fine-tuned from Qwen/Qwen3.5-2B, so it is a new pack on the way, not a derivative
of a listed repo, and it is now in d3_sources.known.

tests/census_watch_test.py, tests/registry_content_test.py,
tests/registry_gaps_test.py, tools/registry_build.py --check-gaps and
tools/copyright.py --check pass.
A token that names no holder is invisible to reap_token()'s dead-pid arm, and the
grant path cannot overwrite it either: the write is `set -o noclobber`, so it fails
silently against the existing file and the poll says nothing. Every ticket on the
box then spins for as long as the file exists.

Measured 2026-11-19 on strixhalo: a crash cycle left a 0-byte ~/GPU-TOKEN, and
ticket ab2 waited 4828 s on it while nine takes logged nothing but their 120 s
retry line. The next poll after `rm -f ~/GPU-TOKEN` granted in 0 s.

An unreadable token is now reaped once it has been unchanged for
GPU_HOLD_TOKEN_GRACE seconds (default 5). The grace is what keeps a holder that is
mid-write from being robbed: a holder writes its token once.

tests/gpu_hold_stale_token_test.sh gains three arms: an empty token, a truncated
token ("gpu-hold waste pi", what a crash writes), and a fresh unreadable token that
must be left alone -- 5/5 green here. The file's other 13 tests are unchanged and
still green.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Token Reap Logic

The new logic in reap_token() introduces a grace period for unreadable tokens that do not name a holder. This prevents a scenario where a 0-byte token left by a crash cycle would indefinitely block ticket acquisition. The fix correctly handles the case where a token is unreadable (empty or truncated) and has been unchanged for the grace period, ensuring it is reaped while preserving live tokens that are still being written.

    # exact token was never reaped: measured on 2026-11-16, a ticket waited 246 s behind
    # "npu-serve-keeper pid 298235" whose pid was already gone, and every NPU ticket on the box would have run
    # to -w the same way. The pid is the identity; the prefix is not.
    pid=$(printf '%s' "$content" | sed -n 's/.* pid \([0-9][0-9]*\) .*/\1/p' | head -n 1)
    if [ -n "$pid" ]; then
        if ! kill -0 "$pid" 2> /dev/null; then
            rm -f "$TOKEN"
            log "dropped stale token (holder pid $pid gone): $content"
        fi
        return 0
    fi
    # A token that names NO holder is invisible to the arm above, and the grant path cannot take it either: the
    # write is `set -o noclobber`, so it fails silently against the existing file and the poll says nothing, which
    # leaves every ticket on the box spinning for as long as the file exists. Measured 2026-11-19: a 0-byte
    # ~/GPU-TOKEN left behind by a crash cycle parked ticket ab2 for 4828 s, and the very next poll after
    # `rm -f ~/GPU-TOKEN` granted in 0 s. The grace is what keeps a live holder mid-write from being stolen: a
    # holder writes its token once, so an unreadable token unchanged for $TOKEN_GRACE seconds is a leftover. A
    # holder that stamps no ` pid N ` at all cannot be told apart from a crash leftover; the grace bounds what
    # that costs it (one grant), where leaving the file alone costs every later lane the wait it sets.
    age=$(( $(date +%s) - $(stat -c %Y "$TOKEN" 2> /dev/null || date +%s) ))
    if [ "$age" -ge "$TOKEN_GRACE" ]; then
        rm -f "$TOKEN"
        log "dropped unreadable token (no holder pid, unchanged for ${age}s): ${content:-<empty>}"
    fi
}
Test Coverage

The test suite now includes coverage for the new behavior of reaping unreadable tokens. It verifies that empty and truncated tokens are reaped after the grace period, and that fresh unreadable tokens are left alone, ensuring the fix works as intended and doesn't interfere with live token usage.

# Arms 3 and 4: a token that names no holder -- the state a crash leaves behind -- is a leftover, not a claim.
for shape in empty truncated; do
    if [ "$shape" = empty ]; then body=-; else body="gpu-hold waste pi"; fi
    out=$(run_ticket "$body" "$shape" old)
    if ! printf '%s' "$out" | grep -q "dropped unreadable token"; then
        echo "FAIL $shape-token: an unreadable token that names no holder was not reaped -- every ticket spins on it"
        echo "  log: $(printf '%s' "$out" | tail -3 | tr '\n' ' ')"
        fail=1
    elif ! printf '%s' "$out" | grep -q "rc=0"; then
        echo "FAIL $shape-token: token reaped but the ticket was not taken: $(printf '%s' "$out" | tail -2 | tr '\n' ' ')"
        fail=1
    else
        echo "ok   a$([ "$shape" = empty ] && echo "n empty" || echo " truncated") token that names no holder is reaped and the ticket is taken"
    fi
done

# Arm 5: the grace. A holder writes its token once; a fresh unreadable file may be mid-write, so it is left alone.
out=$(run_ticket - fresh-write 30 4)
if printf '%s' "$out" | grep -q "dropped unreadable token"; then
    echo "FAIL fresh-token: a token written seconds ago was reaped -- a holder mid-write can be robbed"
    fail=1
else
    echo "ok   a fresh unreadable token is left alone until the grace passes"
fi

exit "$fail"

@bong-water-water-bong
bong-water-water-bong merged commit 8d8e25e into main Nov 19, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the ci/gpu-hold-unreadable-token branch November 19, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant