Repository navigation
hrx: a host-weight refusal says whether the arena is fragmented or short (engine #900) - #180
Conversation
…ort (engine ggml-org#900) arena_reserve() fails on the free list, not on the size: the issue measured 193.2 MiB free in 5 blocks against a 121.7 MiB slot, and the refusal told the operator the model's working set does not fit - then advised "Raise it to at least 4030 MiB" while the budget in force was 4096 MiB. The free list can tell the two cases apart (free >= need with no block that large means fragmented), so the refusal now reports which one happened, with the largest block, and drops the size advice in the fragmented case - where the number it printed was not a fixed point, because resident tracks the budget. The genuine capacity case keeps the engine ggml-org#788 wording and its raise-to number. The miss is recorded whole in the latch, so a later acquire in the same run repeats the first refusal's reason instead of re-deriving the wrong one. Diagnostic only: no allocation, eviction or placement behaviour changes. tests/test-hrx-arena-refusal.cpp: 5 arms - both of the issue's measured states, a genuine capacity miss, the unbounded default, and the corner where a large enough free block exists (not called fragmentation).
eaceeca to
de4c2b2
Compare
|
#180 ready for review at Verified from a clean clone of the pushed branch, not the worktree: Not measured: a real fragmented refusal on a device — that needs a |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at de4c2b22e. I built and ran the test, and I reproduced the negative control independently — the
old wording's self-contradiction falls out of the same test.
Pass here (g++ -std=c++17 -Wall -Wextra -Iggml/src/ggml-hrx tests/test-hrx-arena-refusal.cpp):
test-hrx-arena-refusal: all cases ok (5 arms) rc=0 (no warnings with -Wall -Wextra)
My negative control, written from the PR's description of the pre-ggml-org#900 wording (same API: fragmented() always
false, describe() always the capacity sentence with its raise-to number), same test file:
FAIL budget-200: free >= need with no block that large is fragmentation
FAIL budget-4096: a 497 MiB slot against 564 MiB in 3 blocks is fragmentation
FAIL budget-4096: Raise it to at least must not be in "… a 497.0 MiB slot does not fit with 1983.0 MiB resident and
1549.0 MiB parked. Raise it to at least 4029 MiB or unset it (engine #788)."
… test-hrx-arena-refusal: 9 failure(s) rc=1
That is the issue's contradiction reproduced by the PR's own test, not just by the PR's own control: "Raise it to
at least 4029 MiB" while 4096 MiB is in force (497 + 1983 + 1549 = 4029, exactly the arithmetic the helper claims;
the capacity arm's 500 + 1983 + 1549 = 4032 likewise re-derives).
The .cpp side compiles — -fsyntax-only with the tree's real include paths (including
third_party/hrx-system/libhrx/include and the loom binding include) is clean, and the diff is message-only: the
three scalars become one ArenaMiss in host-memory.h, the latch now repeats the first miss through
describe(refusal_) instead of re-deriving a capacity claim, and arena_reserve()'s own line stops calling a
fragmented arena "full after eviction" and names the slot, the block count and the largest block. No allocation,
eviction or placement line is touched, which is what the PR says and what the diff shows.
The CMake wiring is the one thing I checked rather than assumed: test-hrx-arena-refusal sits inside
if (TARGET ggml-hrx) with only ../ggml/src/ggml-hrx on the include path and no link libraries, which is
exactly why it builds without the private runtime — my standalone g++ line is that target's whole dependency set.
Not in evidence, and correctly stated as such by the PR: a real fragmented refusal on the device. The arms are
the issue's measured numbers fed to the helper that now decides the wording; the run that would prove it
(-dev HRX0 -ngl 20 -fa on -ub 512 on the 76.32 GiB pack) is a gpu-hold + >20 GiB job I did not take either.
Two notes, neither a gate:
- The
cornerarm is the right instinct (a large enough block means the take failed for another reason, so do not
claim fragmentation) but nothing asserts which other reason; the branch says "a failed growth logs its own
line", which is true today and would be worth a comment at the capture site if a second failure mode ever lands
there. fragmented()withneed == 0is false (largest_block < 0never) — unreachable (a slot is aligned to at least
one page) but the predicate reads as if it were a general one.
Base is 1bit/hrx-vulkan-patched, mergeStateStatus CLEAN, +252/−29 across the header, the host-memory.{h,cpp}
hunks, the test and its CMake entry. The engine row closes on the pin bump, as the PR notes.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY — the refusal now reports the reserve outcome that failed, and the arms discriminate.
Reviewed at de4c2b22e (one file's worth of behaviour: runtime/host-memory-refusal.h new, host-memory.cpp, host-memory.h).
What I ran myself, not read off the body:
g++ -std=c++17 -O1 -I ggml/src/ggml-hrx tests/test-hrx-arena-refusal.cpp -o /tmp/arena-refusal-test-> rc 0, and the
binary printstest-hrx-arena-refusal: all cases ok (5 arms), rc 0.- Mutation worth knowing about: the discriminating arms are the fragmented-vs-capacity pair.
fragmented()is
free_bytes >= need && largest_block < need, so the 4096 MiB arm (497 wanted, 564 free in 3 blocks, largest 400) and
the corner arm (64 wanted, 128 free in 1 block, largest 128) separate the two, and the corner arm is the one that
would catch an over-eager predicate. TheRaise it to at least 4032 MiBassertion is the arithmetic it claims
(500 + 1983 + 1549), so a later edit to the formula cannot pass silently. amdclang++with the real GGML_HRX=ON flags onruntime/host-memory.cpp-> rc 0 (2 warnings, both pre-existing
-Wunused-but-set-variableat:1559; nothing from the new code).- The latched-refusal path keeps the whole miss (
ArenaMiss refusal_replaces the three size_t members), so the second
and later acquires cannot invent a capacity claim they did not measure — that was the "self-contradictory advice"
half of ggml-org#900 and it is now structurally impossible, not just rewritten.
Two notes, neither a gate:
arena_reserve()'s new line anddescribe()both computelargestby walkingarena_free_, and the reserve path
does it inside the mutex whiledescribe()reads a snapshot; that duplication is fine, but the snapshot in
refusal_is taken at latch time and never refreshed, so a run that continues allocating after the first refusal
reports the first miss forever. The comment abovebudget_refusal_says this is deliberate (the repeat must tell
the same story); worth one word in the log string ("at the first refusal") so a reader does not take the numbers
for live ones.- No test covers
arena_reserve()'s own changed line (the helper is tested, the call site is not). That is the same
split as the rest of this file's history, so it is not a blocker here — just do not let it become a habit for the
placement/coalescing follow-up that ggml-org#900 still owes.
ggml-org#900) (#202) resident + parked is bounded by the arena and the arena by the limit, so the snapshot of a capacity miss is always limit + one weight. Printed as advice that is the measured 6 MiB-at-a-time climb (2304 -> 2310 on a run whose floor is 2560) and, below the budget in force, the measured 38 <-> 44 MiB cycle. The capacity branch now names the numbers and says the snapshot cannot size the run; the fragmented wording (#180) is untouched and the unbounded arm no longer prints limit 0.0 MiB. Co-authored-by: bong-water-water-bong <[email protected]>
Bind exact router ID view spans and gather scalar expert scales with runtime ID bounds checks. Validated on gfx1151 with focused operator/backend tests, full paired HRX/Vulkan perplexity, and generation. High absolute perplexity and CPU REPEAT fallback remain documented limitations.
Fixes the reporting half of engine 1bit-MONSTER/engine#900. The placement/coalescing follow-up the issue
mentions is deliberately not here: this changes no allocation, eviction or placement behaviour.
Root cause
HostWeightCache::arena_reserve()fails on the free list, not on the size. The issue's own numbers: 193.2 MiB freein 5 blocks against a 121.7 MiB slot. The refusal at
runtime/host-memory.cppthen said the model's per-executionworking set cannot be held — a different claim — and printed a raise-to number derived from
need + resident + parked,which is not a fixed point because
residenttracks the budget. Measured consequence: "Raise it to at least 4030 MiB"while 4096 MiB was in force (the issue's table, 76.32 GiB pack).
The free list already knows the difference: when
free_bytes >= needand no single block is that large, the spaceexists and is split. That predicate was available at the failure site and unused.
Change
runtime/host-memory-refusal.h(new, no HRX dependency so it is testable without the private runtime) holds theverdict and the sentence. Fragmented misses report free bytes, block count, largest block, arena/limit/resident/
parked and say the space is fragmented; genuine capacity misses keep the engine ggml-org#788 wording and its arithmetic.
Also, because the numbers are captured at the failure:
arena_reserve()'s own line no longer calls a fragmented arena "full after eviction" — it says which slot it couldnot place, in how many blocks, and the largest block (the line the issue quotes as the smoking gun).
budget_refusal_) now stores the whole miss, so every later acquire in the same run repeatsthe first refusal's reason instead of re-deriving a capacity claim it never measured.
Verification
tests/test-hrx-arena-refusal.cpp, 5 arms, device-free and HRX-free:Raise it to at least 4032 MiB(500+1983+1549)limit = 0The negative control reproduces the issue's contradiction by itself:
Raise it to at least 4029 MiBat a 4096 MiBbudget.
host-memory.cppsyntax-checks clean at this branch (-fsyntax-only, the tree's real include paths incl.third_party/hrx-system/libhrx/include). The new CMake target sits in the existingif (TARGET ggml-hrx)blockbeside
test-hrx-graph-program-budgetand links nothing HRX; that block is only reached withGGML_HRX=ON, whichbuilds hrx-system's own iree/loom ExternalProject here, so the wiring was validated in a scratch project with the same
target shape and paths (
cmake --build→ built;ctest -R test-hrx-arena-refusal→ Passed).Notes
76.32 GiB pack (
-dev HRX0 -ngl 20 -fa on -ub 512), which is agpu-hold+ >20 GiB load I did not take tonight. Thearms above are the issue's own measured numbers fed to the helper that now decides the wording.