Repository navigation
serve: refuse a load that would land past the GTT ceiling (engine #680) - #764
Conversation
PR Reviewer Guide 🔍(Review updated until commit ba763bb)Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
At f36606d7 — first review, build green. app/mem_admit.h, app/serve.cpp, docs/serve.md, tests/mem_admit_test.cpp.
Ran the test, and it exercises exactly the new rule:
$ g++-16 -std=c++17 -O1 -I app tests/mem_admit_test.cpp -lgtest -lgtest_main && ./a.out
ok 45 GiB more: refused by the ceiling although 60 GiB is free
ok the refusal names the ceiling and the reserve
ok 1 GiB more: fits, no ceiling note
ok a pool smaller than the reserve: refused at any size
PASS
That first row is the whole point: refused although 60 GiB is free. The old rule was "refuse only when the need exceeds what is free", which could never catch #680 — a gfxhub page fault plus MODE2 reset at 106.5 GiB of 120 with 13.5 GiB of headroom still showing, because the runtime's own allocations land after the admission check. Refusing on a ceiling (GTT total minus a 16 GiB reserve) is the right invariant, since it bounds where the load will end up rather than what is currently free.
Two details that make it safe rather than merely stricter:
- the reserve reads
GGML_HRX_GTT_RESERVE_MB, the same knob ggml-hrx reads (fork PR #166), so "the pre-launch refusal and the allocation-time backstop cannot disagree about where the wall is" — that is the property that stops this becoming two walls with a gap between them; - the graph-program cache and #315's 95 GiB zone still only warn inside the ceiling, because they grow after load — so the change refuses the case that kills the machine and leaves the advisory cases advisory.
The refusal message names the ceiling and the reserve, which is what makes a refused load diagnosable instead of mysterious.
Not verified: a real load near the ceiling on the box (needs the GPU and a model that reaches ~100 GiB of GTT). The arithmetic is unit-tested; the physical claim behind the 16 GiB reserve is #680's.
tprs-ready applied.
Free memory was the only wall serve checked, and it is not the wall that hurts: #680 is a gfxhub page fault plus a MODE2 reset at GTT 106.5 GiB of 120, twice, i.e. 13.5 GiB of headroom was not enough once the runtime's own allocations landed. The admission verdict now also carries an absolute ceiling - GTT total minus a 16 GiB reserve - and refuses a load whose landing (GTT in use now + the estimate) would cross it, even when the free memory test alone would admit it. Same reserve knob ggml-hrx charges its own allocations against (GGML_HRX_GTT_RESERVE_MB, fork PR #166), so the pre-launch refusal and the allocation-time backstop cannot disagree. The refusal prints one line with both sets of numbers and exits 3, the same code Lemonade already reads as a failed load, so nothing downstream changes. Measured on strixhalo (120 GiB pool, 52 GiB of GTT in use by another serve, MemAvailable 57.9 GiB), Qwen3-4B-Q4_K_M --device hrx: default reserve (16 GiB): fits - need 8.45 GiB, free 57.96 GiB, ceiling 104 GiB, lands at 60.5 GiB GGML_HRX_GTT_RESERVE_MB=61440 (ceiling 60 GiB): refused, exit 3 - 'GTT after this load would reach 60.6 GiB of the 60.0 GiB ceiling (120.0 GiB total, 60.0 GiB reserve, GGML_HRX_GTT_RESERVE_MB), where engine #680 faulted' i.e. a load the box had plenty of free memory for is refused on the ceiling alone, which is the behaviour #680 asked for. ctest mem_admit covers the arithmetic (120 - 16 = 104; a 105 GiB landing refused while 60 GiB is free; a pool smaller than the reserve refused at any size; RAM-only refusals still RAM-only), and docs/serve.md 'Will it fit?' documents the rule, the knob and the two consequences (the >= 95 GiB warning now only covers the 95-104 GiB band, and the program-cache warning only fires when MemAvailable is the binding limit).
f36606d to
0fdd4ef
Compare
|
Persistent review updated to latest commit 0fdd4ef |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
At 0fdd4ef9 — re-confirmed after the waiter moved the head: build green, and I re-ran the gate at this content rather than assuming the rebase was inert.
tests/mem_admit_test.cpp → PASS, including "45 GiB more: refused by the ceiling although 60 GiB is free" — the row that proves a ceiling rule catches #680 where a free-memory rule structurally cannot. The reserve still reads GGML_HRX_GTT_RESERVE_MB, the same knob fork #166 reads (verified across both PRs), so the pre-launch refusal and the allocation-time backstop cannot disagree.
tprs-ready stands.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
At 70dd3c94 — build green, and I re-ran the gate at this content rather than assuming the rebase was inert.
tests/mem_admit_test.cpp → PASS, including "45 GiB more: refused by the ceiling although 60 GiB is free" — the row that proves a ceiling rule catches #680 where a free-memory rule structurally cannot. The reserve still reads GGML_HRX_GTT_RESERVE_MB, the same knob fork #166 reads (verified across both PRs).
tprs-ready stands.
|
Persistent review updated to latest commit ba763bb |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Confirmation at ba763bbc, not a re-derivation: the tip is a Merge branch 'main' into 1bit/i680-gtt-guardrail-engine
with the author commit unchanged (0fdd4ef, same sha I reviewed), origin/main an ancestor, own diff still the
same 4 files (+129 −16).
Re-ran the gate at the tip anyway, because the tree it compiles against has moved (main is 5f8045e):
$ g++-16 -std=c++26 -O1 -Iapp tests/mem_admit_test.cpp -o /var/tmp/mem_admit_764 && /var/tmp/mem_admit_764
ok Qwen3-0.6B KV at 4096: 448.0000 MiB (want 448.0000) … 31 rows …
ok 45 GiB more: refused by the ceiling although 60 GiB is free
ok the refusal names the ceiling and the reserve
PASS
The row that matters is still the one that distinguishes this rule from a free-memory rule: 45 GiB more is refused by
the ceiling with 60 GiB free. tprs-ready stays; no GPU was used (nothing here needs one).
…ing does not cover it) (#773) * hyperloom custom: refuse the drafter at long context until #764 lands The drafter at long context is the arm that faulted the HRX graph on this box (27B, 18.8k ctx, the 2026-11-01 11:13 MODE2 reset), so the box rule forbids it until engine#764's GTT admission guardrail is merged. A candidate that asks for HL_DFLASH with HL_LONGCTX>0 now exits before loading anything, so the tuner scores it zero with the reason instead of measuring a shape nobody may measure. The short-prompt drafter arm is untouched: it is the +13.8% winner. * hyperloom custom: refuse the long-context drafter before anything resolves The guard ran after the model and binary checks, so a refused candidate still failed later than it had to. It is now the first statement in main(), which is where a box rule belongs. Refusal proof (CPU-only, nothing loaded): HL_LONGCTX=18800 HL_DFLASH=1 python3 tools/hyperloom/custom/benchmark.py -> refusing HL_DFLASH with HL_LONGCTX>0: ... --------- Co-authored-by: bong-water-water-bong <[email protected]>
Engine-side half of #680. The fork half (ggml-hrx charging its own allocations against the same ceiling) is 1bit-MONSTER/llama.cpp#166.
The finding in #680 is not "memory ran out". The device faulted and reset (gfxhub fault + MODE2 reset) at GTT 106.5 GiB of 120, twice: 13.5 GiB of headroom was not enough once the runtime's own allocations landed.
serveonly refused loads that did not fit in free memory, so a load could be admitted into that zone whenever the box looked free at launch time.The rule now:
Same reserve knob
ggml-hrxcharges against (fork #166), so the pre-launch refusal and the allocation-time backstop cannot disagree about where the wall is. The refusal reuses the existing path Lemonade already handles: one line with both sets of numbers, exit 3.Measured on strixhalo (120 GiB pool, 52 GiB of GTT in use by another serve, MemAvailable 57.9 GiB),
Qwen3-4B-Q4_K_M --device hrx:fits: need 8.45 GiB … free 57.96 GiB (GTT 67.8 of 120.0 GiB free, MemAvailable 58.0 GiB)— lands at 60.5 GiBGGML_HRX_GTT_RESERVE_MB=61440(ceiling 60 GiB)does not fit: need 8.45 GiB … free 57.89 GiB; GTT after this load would reach 60.6 GiB of the 60.0 GiB ceiling (120.0 GiB total, 60.0 GiB reserve, GGML_HRX_GTT_RESERVE_MB), where engine #680 faulted; free GTT or raise the reserve; free memory, lower --ctx-size, or pass --no-mem-checkThe second row is the point: the box had 57.9 GiB free and the load still refused, because the landing crossed the ceiling. That is the "refuse before it faults" behaviour.
ctest mem_admitextended (tests/mem_admit_test.cpp): 120 − 16 = 104 GiB; a 105 GiB landing refused while 60 GiB is still free; a pool smaller than the reserve refused at any size; a RAM-only refusal stays a RAM-only refusal. Full local run:mem_admit,mem_admit_route,smoke_serve,think_split,gguf_metaall pass;tools/copyright.py --checkandtools/check_pins.py origin/mainpass.Two consequences documented in
docs/serve.md("Will it fit?" -> new "The GTT ceiling: refused, not faulted"): with a 120 GiB pool and the default reserve at most 104 GiB is ever planned, so #315's >= 95 GiB warning now only covers the 95-104 GiB band, and the graph-program-cache warning only fires when MemAvailable is the binding limit.--no-mem-check/ONEBIT_MEM_CHECK=0still skips all of it.Built and tested on the rebuilt strixhalo (Ubuntu 26.04.1, kernel 7.3.0-rc4-1bit-perfopt+, CMake
-j4under thermal-run). PR-READY.