Skip to content

hyperloom: the entrypoint waits for GTT room before claiming the GPU, and re-checks inside the claim (#1438) - #1439

Merged
bong-water-water-bong merged 2 commits into
mainfrom
1bit/hyperloom-gtt-room
Nov 8, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
1bit/hyperloom-gtt-room

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #1438.

Root cause

custom_strixhalo.sh ends with exec gpu-hold -l hyperloom -t <min> -- python3 benchmark.py. gpu-hold admits a measurement on the die's temperature and the FIFO's order — it knows nothing about GTT. The engine's guardrail (ggml_hrx, #680) does check, and refuses correctly, but only after the claim is ours. So a measurement can be granted a claim it provably cannot use.

Measured before/after

A real long-context hyperloom optimize session (27B UD-Q4_K_XL, 20,480 ctx) on strixhalo, 2026-11-08. Two claims in a row, both granted, both wasted:

attempt die at grant GTT in use outcome
04:41 48.88 C 89.27 GiB llama-bench failed (rc=1, rows=[]), score 0.0
04:59 59.88 C 89.48 GiB same
ggml_hrx: HRX0 guardrail: ... in use 89.6 GiB, ceiling 104.0 GiB (reserve 16.0 GiB), pool budget 14.4 GiB
llama_model_load: error loading model: unable to allocate HRX0 buffer

Both artifacts are missing longctx, placement, serve_tok_s, score_geomean — the record says the workload is broken, when the entrypoint had taken a claim for work that could not fit, at ~5 min of device time each with other lanes queued behind it.

After the fix, the same box state refuses instead of loading, and says why:

[1bit-hl] REFUSING: GTT 88 GiB in use + 24 GiB needed = 112 GiB > 88 GiB, and it did not clear in 0s --
          not claiming a measurement the engine would refuse (HL_GTT_NEED_GIB / HL_GTT_RULE_GIB / HL_GTT_ROOM_WAIT)

exit 3, no claim taken, nothing loaded.

What changed

  • waits until GTT in use + HL_GTT_NEED_GIB <= HL_GTT_RULE_GIB before claiming (HL_GTT_ROOM_WAIT, default 1800 s bounds the wait);
  • runs the same check again inside the claim, before anything loads — the box moves while queued, which is the 2026-11-05 lesson that made the window harness do it in two places instead of one;
  • a refusal names the numbers and the variables, so a session reports no room rather than workload broken;
  • defaults 24 GiB needed / 95 GiB rule (this box's rule) / 1800 s, all overridable and documented in the README, because the need is a property of the model and context.

Verification

Device-free, with a stand-in for gpu-hold so no claim is taken and no load runs — three paths:

case result
rule too small for the real GTT refuses before claiming, exit 3
rule passes but shrinks inside the claim (box filling while queued) refuses after the grant, exit 3, nothing loaded
both pass workload reached, exit 0

bash -n clean, python3 tools/copyright.py --check rc=0. 2 files, +49/−1.

… and re-checks inside the claim

`custom_strixhalo.sh` exec'd straight from `gpu-hold` into the workload. `gpu-hold` admits on the die's
temperature and the FIFO's order and knows nothing about GTT; the engine's guardrail (ggml_hrx, #680)
refuses a load that does not fit -- correctly, but only after the claim is ours.

Measured 2026-11-08 on a long-context `hyperloom optimize` session (27B UD-Q4_K_XL, 20,480 ctx): two
claims in a row granted at die 48.88 / 59.88 C while other lanes held 89.27 / 89.48 GiB of GTT, both
dying in the first leg:

  HRX0 guardrail: ... pool budget 14.4 GiB - a launch that needs more is refused here
  llama_model_load: error loading model: unable to allocate HRX0 buffer

and both artifacts recorded `llama-bench failed (rc=1, rows=[])` with score 0.0 -- the record blaming the
workload for a claim taken on work that could not fit, at ~5 minutes of device time each, with other lanes
queued behind it.

Fix: wait until `GTT in use + HL_GTT_NEED_GIB <= HL_GTT_RULE_GIB` before claiming, and run the same check
again inside the claim before anything loads, because the box moves while queued -- the window harness
learned that on 2026-11-05 (a pre-claim check alone is a race). Refusal is `exit 3` with the numbers and
the variable names in the message, so a session reports "no room" instead of "workload broken". Defaults
24 GiB needed / 95 GiB rule (this box's rule) / 1800 s wait; all three overridable and documented in the
README, since the need is a property of the model+context.

Proved device-free with a stand-in for `gpu-hold` (no claim taken, no load run), three paths: rule too
small -> refuses before claiming, exit 3; rule passes but shrinks inside the claim -> refuses after the
grant, exit 3, nothing loaded; both pass -> the workload is reached, exit 0. `bash -n` clean,
`copyright --check` rc=0.

Closes #1438
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#1439 ready for review at d633247 — one entrypoint, one README row. Reproducer is two real tuner measurements from this box (04:41 and 04:59 today, both granted at 48.9/59.9 C with 89 GiB of other lanes' GTT held, both recorded as llama-bench failed (rc=1, rows=[])). Both gates proved device-free with a gpu-hold stand-in — no claim taken, no load run. Closes #1438; pi-prs pinged.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at d633247e4c0d8107f7af935d1ef7f3d637adc9af

This is the right fix for #1438: gpu-hold admits on temperature and FIFO order only, so the entrypoint has to ask "will it fit" itself, and do it twice.

  • Once before claiming, bounded by HL_GTT_ROOM_WAIT.
  • Again inside the claim, before anything loads. That's the step that matters, because the box moves while queued. The bash -c '…' _ "$HERE/benchmark.py" form passes the script as $1 and execs it, so the claim still wraps exactly the measurement.

A refusal now says "no room" with the numbers and the variables, instead of a score-0.0 artifact that reads as a broken workload. That's what makes this worth shipping.

Checked at this head:

  • bash -n passes on custom_strixhalo.sh, and tools/copyright.py --check is rc 0;
  • HL_GTT_NEED_GIB and HL_GTT_RULE_GIB are exported before the exec, so the inner bash -c sees them;
  • on this box /sys/class/drm/card0/device/mem_info_gtt_used is the amdgpu device (89 GiB in use right now, so this would correctly refuse a 24 GiB need against a 95 GiB rule), and benchmark.py:73 uses the same card0 path, so the guard and the measurement read the same counter.

Two small notes, not blocking:

  • It fails open. An unreadable mem_info_gtt_used counts as 0 GiB in use ("unreadable sysfs must not be read as full"), so if the GPU ever isn't card0 (a second GPU, or simpledrm taking card0 on another box), the guard silently admits everything. Resolving the card that has mem_info_gtt_used with a glob, or at least printing "[1bit-hl] GTT unreadable at …, not checking", would make that visible.
  • / 1073741824 floors, so 88.9 GiB counts as 88. With a 24 GiB need and a 9 GiB gap to the engine's 104 ceiling that's harmless, but rounding up would make "≤ rule" mean what it says.

No device run on my side; your three stand-in paths cover the logic.

@bong-water-water-bong
bong-water-water-bong merged commit 86ec88d into main Nov 8, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/hyperloom-gtt-room branch November 8, 2026 10:18
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

1438 - Partially compliant

Compliant requirements:

  • Fix the issue where custom_strixhalo.sh grants GPU claims without checking GTT room, leading to wasted claims and incorrect workload failure records
  • Implement a pre-claim GTT room check before executing gpu-hold
  • Implement a re-check inside the claim to ensure the box hasn't filled up while queued
  • Use environment variables HL_GTT_NEED_GIB, HL_GTT_RULE_GIB, and HL_GTT_ROOM_WAIT to configure the GTT room checking behavior
  • Update documentation to reflect the new admission control behavior

Non-compliant requirements:

  • None

Requires further human verification:

  • None

680 - Partially compliant

Compliant requirements:

  • Address the GTT exhaustion issue that leads to page faults and GPU resets
  • Implement a guardrail to prevent launches that would exceed GTT limits
  • Ensure the guardrail is checked before a claim is granted

Non-compliant requirements:

  • None

Requires further human verification:

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

Potential Race Condition in GTT Check

The GTT room check in custom_strixhalo.sh occurs before the claim is made, but the re-check inside the claim happens after the claim is granted. If the system state changes between these two checks, there's a potential race condition where a workload could be started that later fails due to GTT exhaustion, even though the initial check passed. The re-check is good, but it's not sufficient to prevent all race conditions.

waited=0
while :; do
  g=$(gtt_gib)
  if [ $(( g + GTT_NEED )) -le "$GTT_RULE" ]; then
    echo "[1bit-hl] room ok: GTT ${g} GiB in use + ${GTT_NEED} GiB needed = $(( g + GTT_NEED )) GiB <= ${GTT_RULE} GiB rule"
    break
  fi
  if [ "$waited" -ge "$GTT_WAIT" ]; then
    echo "[1bit-hl] REFUSING: GTT ${g} GiB in use + ${GTT_NEED} GiB needed = $(( g + GTT_NEED )) GiB > ${GTT_RULE} GiB, and it did not clear in ${GTT_WAIT}s -- not claiming a measurement the engine would refuse (HL_GTT_NEED_GIB / HL_GTT_RULE_GIB / HL_GTT_ROOM_WAIT)" >&2
    exit 3
  fi
  echo "[1bit-hl] waiting for room: GTT ${g} GiB + ${GTT_NEED} GiB = $(( g + GTT_NEED )) GiB > ${GTT_RULE} GiB (${waited}s of ${GTT_WAIT}s)"
  sleep 20; waited=$((waited + 20))
done

# Inside the claim the same check runs again, before the workload loads anything: whatever the queue
# promised, the box is shared and the grant can arrive into a pool that has since filled up.
exec "$GPU_HOLD" -l hyperloom -t "$HOLD_MIN" -- bash -c '
  f=/sys/class/drm/card0/device/mem_info_gtt_used
  g=$([ -r "$f" ] && echo $(( $(cat "$f") / 1073741824 )) || echo 0)
  if [ $(( g + ${HL_GTT_NEED_GIB} )) -gt "${HL_GTT_RULE_GIB}" ]; then
    echo "[1bit-hl] REFUSING after the grant: GTT ${g} GiB + ${HL_GTT_NEED_GIB} GiB = $(( g + ${HL_GTT_NEED_GIB} )) GiB > ${HL_GTT_RULE_GIB} GiB; releasing the claim instead of starting a load the engine will refuse" >&2
    exit 3
  fi
  echo "[1bit-hl] room ok inside the claim: GTT ${g} GiB in use"
  exec python3 "$1"
' _ "$HERE/benchmark.py"
Error Handling in GTT Check

The script exits with code 3 when GTT room is insufficient, but it doesn't provide detailed information about why the check failed. It would be more helpful to include the actual GTT usage and needed space in the error message to aid debugging.

  if [ "$waited" -ge "$GTT_WAIT" ]; then
    echo "[1bit-hl] REFUSING: GTT ${g} GiB in use + ${GTT_NEED} GiB needed = $(( g + GTT_NEED )) GiB > ${GTT_RULE} GiB, and it did not clear in ${GTT_WAIT}s -- not claiming a measurement the engine would refuse (HL_GTT_NEED_GIB / HL_GTT_RULE_GIB / HL_GTT_ROOM_WAIT)" >&2
    exit 3
  fi
  echo "[1bit-hl] waiting for room: GTT ${g} GiB + ${GTT_NEED} GiB = $(( g + GTT_NEED )) GiB > ${GTT_RULE} GiB (${waited}s of ${GTT_WAIT}s)"
  sleep 20; waited=$((waited + 20))
done

bong-water-water-bong added a commit that referenced this pull request Nov 8, 2026
…tes, not a round 24 (#1472)

#1439 added the room gate with `HL_GTT_NEED_GIB` defaulting to 24 GiB -- a round number nobody measured.
The workload publishes its own requirement, and `1bit serve` prints it at load:

  need 20.21 GiB (weights 16.35 + KV/state 1.40 + compute 0.50; draft 1.96)

Measured 2026-11-08, a long-context optimize session on this box, three attempts, zero measurements: two
were refused by the gate itself, and one of those refusals was wrong --

  06:26  GTT 57 -> 75 at grant   refused (75+24=99 > 95)   20.21 says 95.21 > 95  -> correct
  08:18  GTT 64 -> 74 at grant   refused (74+24=98 > 95)   20.21 says 94.21 <= 95 -> FITS, refused anyway

and the engine's own guardrail had 30 GiB of budget free at that moment (104 GiB ceiling - 74 in use), so
both the box's rule and the engine said yes while this adapter said no.

Default 21 GiB (measured figure plus a hair, with the basis in the comment so it is not rounded again),
rule unchanged at 95. The two-place check and the refusal path are unchanged; their three-path proof
stays as in #1439.

Closes #1471

Co-authored-by: bong-water-water-bong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant