Repository navigation
hrx: refuse to run when the residency budget is below the working set (engine #788) - #173
Conversation
… (engine ggml-org#788) Owner decision 2026-11-01 22:22: a budget below the model's per-execution working set must refuse with the numbers, not exceed the bound and not corrupt. Today it does neither: at GGML_HRX_HOST_WEIGHT_LIMIT_MB=1024 on Qwen3-4B the cache evicts and re-materialises once per token (36 'arena is full after eviction' lines in one run), the failed acquisitions never surface as an error, and the run ends in 'NaN logits: 151936 of 151936' or garbage tokens. HostWeightCache now latches the first weight it cannot serve at the budget after evicting everything evictable - recording need, resident and *parked* bytes, the last of which is why a sub-working-set budget cannot work: parked slots are held for the running execution and cannot serve the next weight. Every later acquire fails immediately with the same numbers, so the run stops at the first ubatch instead of churning, and the refusal is printed at the point of refusal (GGML_LOG_ERROR) because a caller demonstrably drops the returned status. Measured on the merged #172 tip, 4B, -dev HRX0 -ngl 0, one gpu-hold ticket: budget 1024 -> 'refusing to run: ... a 304 MiB weight does not fit with 0 MiB resident and 839 MiB parked ... Raise it to at least 1144 MiB or unset it', then 'llama_decode: failed to decode, ret = -3' / 'Error: Compute error.' (was: NaN logits 151936/151936 and a SIGABRT) budget 256 -> refusal naming a 5 MiB weight, 191 resident, 60 parked, 'at least 259 MiB' (was: garbage tokens) budget 4096 -> unchanged: 'Okay, the user is asking', refusal never fires 0.6B 4096 -> unchanged: 'Okay, the user is asking' No NaN, no garbage and no abort in any arm; the refusal only fires when the budget genuinely cannot hold the working set.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Compiled at the head and reproduced the measured case on this box, which is the strongest form this one can take.
Ran (one gpu-hold -l "pi prs" ticket per arm, the ggml-org#715 trio exported, Qwen3-4B-Q4_K_M -dev HRX0 -ngl 0 -c 256 --temp 0):
budget 1024: E arena_reserve: host weight arena is full after eviction: 0.0 MiB of 1024.0 MiB resident,
184.9 MiB free in 2 blocks, 304.3 MiB wanted
E hrx: refusing to run: GGML_HRX_HOST_WEIGHT_LIMIT_MB=1024 MiB cannot hold this model's per-execution
working set - a 304 MiB weight does not fit with 0 MiB resident and 839 MiB parked for the running
execution. Raise it to at least 1144 MiB or unset it (engine #788).
E llama_decode: failed to decode, ret = -3 … srv decode: Compute error. ret = -3
arena_reserve spam: 1 line (the body measured 36 before the patch)
budget 4096: no refusal (grep count 0), 22.0/11.9 t/s, prompt answered -> unchanged
So all three claims hold here: the refusal names the numbers (304 MiB wanted, 0 resident, 839 parked, "at least
1144 MiB"), it is latched (exactly one arena_reserve line, so the run stops at the first ubatch instead of
re-materialising the model once per token), and the run ends in ret = -3 / "Compute error." rather than NaN logits + SIGABRT.
The adequate-budget arm is unaffected, which is the half that a "refuse loudly" patch most often gets wrong.
As code: the latch is budget_refusal_ under mutex_, set once with refusal_need_/refusal_resident_/refusal_parked_,
and every later acquire returns early with the recorded numbers before arena_reserve — so the failure cannot degrade into
per-token eviction churn. The recommended figure is a ceiling division of need + resident + parked, stated as "at least", which
is honest: it is the first failing weight's arithmetic, not an upper bound on the working set. And the reasoning is sound — parked
bytes are the slots an in-flight execution still binds (the #169/#172 mechanism), which is exactly why a sub-working-set budget
can never be satisfied however much it evicts.
build is green at this head; the one compiler warning in the file is the dead size_t freed that #172 left in
arena_make_room (host-memory.cpp:1559) — still there, one line to delete whenever this file is next touched.
Not mine to run: the 0.6B and 256-budget rows, and the pre-patch "was: NaN + SIGABRT" baseline (that needs the merged tip without
this patch). tprs-ready applied.
… (engine ggml-org#674, PR #174 review) Comment only. The review's finding is right for the command the PR printed: on llama-cli at its default verbosity the host-weight arena refuses the model during load (1.2 s in), device_supports_op is never asked, and the guard that this PR adds says nothing. The same binary at -v or -lv 2 reserves at 0.17 s, logs the two 128 MiB lines, and reaches #173's refusal later at the first execution (8.99 s); 3/3 runs each way, both ending in Compute error. So silence in that log is not evidence that no node moved - it can mean the run never got as far as the split, and the reviewer's arm and mine were the same build measured at two points of one race. Also notes the process-static dedupe (a second model in the same process logs nothing), per the same review.
…visible (engine ggml-org#674) (#174) * hrx: log a residency decline, so a budget that reshapes the graph is visible (engine ggml-org#674) host_weight_exceeds_residency() decides placement in device_supports_op, and it was silent: a budget that moved nodes off HRX looked identical in the log to one that changed nothing, because the only witness was the GGML_HRX_REPORT placement census. A placement decision that can change the graph has to be greppable. One line per distinct (weight, op) pair, eight pairs, then one line saying the rest are suppressed - de-duplicated because device_supports_op is queried repeatedly per node (reserve and compute passes), so a plain cap spends the whole budget on the same decision (measured: 8 lines for 2 nodes at a 128 MiB budget, and at 8 MiB the 109 declined tensors would never have been visible). The predicate stays pure and behaviour is unchanged - measured on the pin, Qwen3-4B -ngl 0, ggml-org#715 trio, one gpu-hold ticket per arm set: budget unset -> 0 lines, census 288 off HRX, `Okay, the user is asking`, +4055M GTT budget 128 -> 2 lines (GET_ROWS + MUL_MAT on token_embd, 304 MiB > 128 MiB), census 290, `Compute error.` budget 8 -> 8 lines + suppression notice, census 469 off HRX (MUL_MAT 181, ADD 35, GLU 36), `Compute error.` The header records the invariant this makes testable: no placement change may reintroduce the weightless-op/weight-op split. At this pin the bisected corrupting pair {MUL_MAT, MUL} is not expressible at any whole-MiB budget (norm scales are 512 B - 10 KiB, the knob's floor is 1 MiB) and every budget that declines a node also refuses to run, so no declined placement executes. Instrument only - no fix and no behaviour change; engine ggml-org#674's row is the owner's to close. * hrx: say where the placement guard can fire, and why it can be silent (engine ggml-org#674, PR #174 review) Comment only. The review's finding is right for the command the PR printed: on llama-cli at its default verbosity the host-weight arena refuses the model during load (1.2 s in), device_supports_op is never asked, and the guard that this PR adds says nothing. The same binary at -v or -lv 2 reserves at 0.17 s, logs the two 128 MiB lines, and reaches #173's refusal later at the first execution (8.99 s); 3/3 runs each way, both ending in Compute error. So silence in that log is not evidence that no node moved - it can mean the run never got as far as the split, and the reviewer's arm and mine were the same build measured at two points of one race. Also notes the process-static dedupe (a second model in the same process logs nothing), per the same review. --------- Co-authored-by: bong-water-water-bong <[email protected]>
Owner decision 2026-11-01 22:22 for engine ggml-org#788: when
GGML_HRX_HOST_WEIGHT_LIMIT_MBis below the model'sper-execution working set, refuse with the numbers - do not exceed the bound, do not crash. This is that refusal.
Why a status return alone was not enough
On the merged #172 tip,
Qwen3-4B-Q4_K_M -dev HRX0 -ngl 0withGGML_HRX_HOST_WEIGHT_LIMIT_MB=1024produced 36arena_reserve: host weight arena is full after evictionlines in one run, zero propagated errors (nograph_compute:line, nore-materialize resident host weight … failedline ever appeared) and ended inNaN logits: 151936 of 151936+ SIGABRT. The failing acquisition is given a failingStatus; the run continuesanyway. So the refusal is both latched (fail fast, no per-token churn) and printed where it happens.
The change (
host-memory.{h,cpp}, +43)HostWeightCachelatches the first weight it cannot serve at the budget after evicting everything evictable, andrecords
need,residentand parked bytes. Parked is the number that explains the whole class: evictionmid-execution frees slots that must stay reserved for the running execution, so a sub-working-set budget cannot be
satisfied no matter how much it evicts.
acquirefails immediately with the same numbers, so the run stops at the first ubatch instead ofre-materialising the model once per token.
GGML_LOG_ERROR, greppable and actionable:hrx: refusing to run: GGML_HRX_HOST_WEIGHT_LIMIT_MB=<budget> MiB cannot hold this model's per-execution working set - a <need> MiB weight does not fit with <resident> MiB resident and <parked> MiB parked for the running execution. Raise it to at least <sum> MiB or unset it (engine #788).Measured (merged
ba4fdf01bb2+ this patch, onegpu-holdticket, ggml-org#715 trio,-fit off -ngl 0 -c 256 --temp 0)Qwen3-4B, budget 1024refusing to run … a 304 MiB weight does not fit with 0 MiB resident and 839 MiB parked … Raise it to at least 1144 MiB->llama_decode: failed to decode, ret = -3->Error: Compute error.was: NaN logits + SIGABRTQwen3-4B, budget 256ret = -3was: garbage tokensQwen3-4B, budget 4096Okay, the user is asking, refusal never fires (unchanged)Qwen3-0.6B, budget 4096Okay, the user is asking, refusal never fires (unchanged)No NaN, no garbage and no abort in any arm. The refusal only fires when the budget genuinely cannot hold the working
set, and a budget that fits behaves exactly as before.
Together with #172 this closes engine ggml-org#788: #172 makes the budget mean the budget, this makes an impossible budget say
so. The pin bump to
ba4fdf01bb2+thisis pi-release's, and until it lands the engine pin still builds the pre-#172backend.
Lane pi-i669 - the residency cache is my code (#169).