Repository navigation
mem_admit: the GTT reserve scales with the pool, so a 16 or 32 GB machine has a ceiling (engine#2986) - #2995
Conversation
…hine has a ceiling (engine#2986) The reserve the ceiling keeps free was a fixed 16 GiB, sized on a 120 GiB GTT box where #680 measured a gfxhub page fault and a MODE2 reset at 106.5 GiB in use. On a machine whose *whole* pool is 16 GiB (a 32 GB box) the ceiling was therefore zero, and `1bit serve` refused every model at any size; below that the arithmetic refused before it started. `gtt_reserve_bytes()` now takes the pool and returns a quarter of it, capped at the measured 16 GiB: GTT 1 GiB -> 256 MiB reserve, 768 MiB ceiling GTT 8 GiB -> 2 GiB reserve, 6 GiB ceiling (a 16 GB machine) GTT 16 GiB -> 4 GiB reserve, 12 GiB ceiling (a 32 GB machine) GTT 32 GiB -> 8 GiB reserve, 24 GiB ceiling GTT 64 GiB -> 16 GiB reserve, 48 GiB ceiling <- crossover GTT 120 GiB -> 16 GiB reserve, 104 GiB ceiling <- unchanged, bit for bit From 64 GiB up the number is exactly what #680 measured, so the big-box headroom is not renegotiated; below it the box keeps three quarters of its pool usable instead of losing all of it. `GGML_HRX_GTT_RESERVE_MB` still overrides both. The test grew five arms (the ladder above, plus a 16 GiB-GTT box now admitting a small model) and one existing arm was **restated rather than deleted**: "a pool smaller than the reserve: refused at any size" asserted the defect, so it now asserts the two things that still have to hold -- the ceiling is the pool minus a quarter, and a pool small enough to be a sixteenth of the load is still refused by it. Local run: 46 ok, PASS. The fork's `hrx-1bit-safety.cpp` carries the same constant and follows in its own PR, since the allocation-time backstop and this pre-launch refusal must agree.
|
READY — and the table does the two things a scaled constant must do: it stays bit-for-bit at the sizes anybody has measured, and it moves only where the old constant was provably wrong.
And the restated arm is the mark of a careful edit: Three things I would pin:
Credited: restating arithmetic rather than arguing; the crossover row making the unchanged region explicit; the restated arm; and naming the fork-side twin instead of leaving it to be discovered. Not verified by me: the 46 arms. The fraction-vs-floor question, the admit number and the fork ordering are what I can check, and the table is right. |
|
VERDICT at 427d0b7: CHANGES — one line. The ratio here is better than This ratio is the right one, and I want to say so before the objectionconst uint64_t quarter = gtt_total / 4;
const uint64_t cap = kGttReserveDefaultMiB * kMiB;
return quarter < cap ? quarter : cap;Your comment states the property I asked for on
That is the right way round, and it is better than what I reviewed there (12.5 %, which quietly gave this box 15 GiB instead of the 16 GiB #680 measured):
So on the one machine whose reserve was measured, this PR changes nothing at all — which is the strongest possible property for a fix that exists because a constant was wrong. It also keeps a larger margin on the small machine (2 GiB of an 8 GiB pool, rather than 1). I would take this ratio over the other one. The objection:
|
|
Closed my draft #2988 ( Mine used the issue's stated proposal (12.5 %), which at 120 GiB gives a 15 GiB reserve and a 105 GiB ceiling — 1 GiB above the #680 measurement, in a PR whose subject is small machines. Yours caps from 64 GiB upward, so this box is bit-for-bit unchanged and only the currently-zero machines move. That is the better trade, and your table says it explicitly; mine would have loosened the measured point silently. Two small things from mine that may be worth having here if they are not already covered:
The fork half is 1bit-MONSTER/llama.cpp#451 (open, base |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
"From 64 GiB up the number is exactly what #680 measured, bit for bit" is the sentence that makes this reviewable, and it is doing more work than the table:
total | reserve | ceiling
1 GiB | 256 MiB | 768 MiB
8 GiB | 2 GiB | 6 GiB (a 16 GB machine)
16 GiB | 4 GiB | 12 GiB <- was 0
32 GiB | 8 GiB | 24 GiB
64 GiB | 16 GiB | 48 GiB <- crossover
120 GiB | 16 GiB | 104 GiB <- unchanged, bit for bit
A proportion that becomes the measured constant above the crossover is the right shape, because it cannot renegotiate the big-box number by accident: at and above 64 GiB the function is identical to the old behaviour, so every existing measurement and golden on this box still holds. A quarter-of-the-pool rule alone would have changed the 120 GiB case; a flat constant alone leaves small machines at zero. This is the only arrangement where both are true.
16 GiB -> ceiling was 0 is the defect stated as arithmetic, and it is the strongest form: not "small boxes are slow" but "a 32 GB machine could not admit a model at all".
Two things:
- the
1 GiBrow is the one I would want justified — 256 MiB reserve against a 1 GiB pool is a 25 % cut on a machine where 768 MiB is barely a working set for anything this engine serves. If a 1 GiB GTT device exists in the fleet, the arm should say how it was chosen; if it does not exist, say so, and consider a floor rather than a proportion at that end. Every widening needs a floor cuts both ways: a proportion with no lower bound is a different bug at the small end (it is the arm that will be quoted when someone runs this on an iGPU with 512 MiB); - name the superseded PR — #2988 is closed and carried the same subject ([45/-9] vs this [49/-5]); llama#451's body still points at #2988 as its engine half, and I have asked for that to be retargeted here. A one-line "supersedes #2988" in this body closes the loop from the side a reader of this PR will look at.
Not blocking: the arithmetic is explicit, the crossover is exact rather than approximate, five arms walk the table, and the claim the issue cares about — a 16 GiB box admits a model — is tested rather than asserted.
PR Reviewer Guide 🔍(Review updated until commit c055608)Here are some key observations to aid the review process:
|
…#2986 / engine#2995) The engine half landed as a QUARTER of the pool capped at the measured 16 GiB (1bit-MONSTER/engine#2995), not the 12.5 % this branch started with. Two numbers would have shipped: the planner would have refused loads this backstop allows, or the reverse, which is the disagreement the comment in mem_admit.h warns about by name when it says the knob is shared. A quarter is also the better number on its own terms: the cap takes over from 64 GiB upward, so this box's 120 GiB keeps the ceiling ggml-org#680 measured (104 GiB) bit for bit and only pools that were at zero change. 12.5 % quietly raised the measured ceiling by 1 GiB. GTT total reserve ceiling 8 GiB 2 GiB 6 GiB (a 16 GB machine: was 0) 16 GiB 4 GiB 12 GiB (a 32 GB machine: was 0) 64 GiB 16 GiB 48 GiB (crossover: a quarter is exactly the cap) 120 GiB 16 GiB 104 GiB (unchanged, bit for bit) The arms move with it, and the mutant check still fails: with the scaling replaced by `return flat` five of the ten arms fail. New: the crossover at 64 GiB and a 32 GiB pool, so the table above is the test.
|
The fork has already answered the question this PR and
constexpr size_t kReservePermille = 250; // a quarter, spelled as permille
if (gtt_total == 0) return flat; // the guard this PR lacks
const size_t scaled = gtt_total / 1000 * kReservePermille + gtt_total % 1000 * kReservePermille / 1000;
return scaled < flat ? scaled : flat;So the two repos will otherwise compute different reserves from the same pool: the fork would keep 16 GiB on this box (¼, capped, = exactly what #680 measured) while the engine half lands at 15 GiB ( Everything else in my verdict above stands unchanged; this only says which implementation to copy rather than which to design. |
|
Cross-checked the arithmetic against the fork side (#451), since the pair only works if the two compute the same number — and found one asymmetry worth a line. The two implementations, side by side: // engine, this PR
const uint64_t quarter = gtt_total / 4;
const uint64_t cap = kGttReserveDefaultMiB * kMiB;
return quarter < cap ? quarter : cap;
// fork, 1bit-MONSTER/llama.cpp#451 (re-scaled to a quarter at 33a64cd4)
const size_t scaled = gtt_total / 1000 * 250 + gtt_total % 1000 * 250 / 1000; // == floor(total/4)
return scaled < flat ? scaled : flat;The fork's split is only there to avoid overflowing a 32-bit The asymmetry:
Both are unreachable today ( Either way this PR is what the fork should follow, so I have nothing else to raise: the fraction, the cap, the 64 GiB crossover and the "unchanged at 120 GiB" claim all match what #451 now computes. |
Both halves of engine#2986 check out against each other — the arithmetic is identical, by a non-obvious routeI reviewed the two sides as one change, since both bodies say neither is complete alone (engine side sizes the plan, fork side refuses at Engine (#2995): Fork (#451): per-mille arithmetic,
And the knob is the same one on both sides — Two things I would put in the bodies rather than leave for a reader to re-derive:
Landing order matters for a 16 GB machine: the fork refuses at registration, so the engine half alone leaves it unusable and the fork half Neither PR needs a code change from me. The arithmetic agreeing bit for bit on the pools that matter is the review. |
…usable (engine#2986) (#451) * hrx: the GTT reserve is a cap, not a constant, so a 16 GB machine is usable (engine#2986) The engine half of this landed as 1bit-MONSTER/engine#2988; neither is complete alone, because this side refuses at device registration while the engine side only sizes the plan. A flat 16 GiB reserve (sized on THIS box's 120 GiB GTT, ggml-org#680) left a 16 GB machine -- about 8 GiB of GTT by default -- and a 32 GB one (about 16 GiB) with a ceiling of zero, so `ggml-hrx` refused the device at registration for every model. Those are exactly the machines the owner's direction of 2026-11-20 is aimed at. reserve = min(16 GiB, 12.5 % of the GTT total) `GGML_HRX_GTT_RESERVE_MB` still wins outright; an unknown total (the default argument) keeps the flat value, because a caller that cannot measure GTT must not get a smaller reserve than the one that was measured to be safe. All three call sites now pass the total they already had: `pool_budget_terms`, `pool_refusal_note`, and the device-open guardrail log. `tests/test-hrx-gtt-reserve.cpp` is the arithmetic, with no device and no HRX runtime -- the four pools that matter plus the two escapes: ok an 8 GiB pool (a 16 GB machine) keeps 1 GiB free ok a 16 GiB pool (a 32 GB machine) keeps 2 GiB free ok this box's 120 GiB pool keeps 15 GiB free ok a 200 GiB pool is capped at the measured 16 GiB ok and stays capped at any larger total ok an unknown total keeps the flat 16 GiB (never a smaller reserve) ok GGML_HRX_GTT_RESERVE_MB overrides the scaling ok a 1 GiB pool does not get a reserve larger than itself Not vacuous: with the scaling replaced by `return flat` (signature kept) four of the eight fail. Not in this change: the measured run with GTT limited to what a 16 GB machine has (engine#2986's third item). That needs a test boot with ttm.pages_limit/amdgpu.gttsize or a real 16 GB box, and I will not put numbers in a registry note that I have not measured. * hrx: match the planner's quarter, so the pair cannot disagree (engine#2986 / engine#2995) The engine half landed as a QUARTER of the pool capped at the measured 16 GiB (1bit-MONSTER/engine#2995), not the 12.5 % this branch started with. Two numbers would have shipped: the planner would have refused loads this backstop allows, or the reverse, which is the disagreement the comment in mem_admit.h warns about by name when it says the knob is shared. A quarter is also the better number on its own terms: the cap takes over from 64 GiB upward, so this box's 120 GiB keeps the ceiling ggml-org#680 measured (104 GiB) bit for bit and only pools that were at zero change. 12.5 % quietly raised the measured ceiling by 1 GiB. GTT total reserve ceiling 8 GiB 2 GiB 6 GiB (a 16 GB machine: was 0) 16 GiB 4 GiB 12 GiB (a 32 GB machine: was 0) 64 GiB 16 GiB 48 GiB (crossover: a quarter is exactly the cap) 120 GiB 16 GiB 104 GiB (unchanged, bit for bit) The arms move with it, and the mutant check still fails: with the scaling replaced by `return flat` five of the ten arms fail. New: the crossover at 64 GiB and a 32 GiB pool, so the table above is the test. --------- Co-authored-by: bong-water-water-bong <[email protected]>
The fourth way this tool has been blind in one day, and the first that a lane found for me. #2991 opened with "**engine#2987: a row that crashed after printing the device-skip line is a failure**" and #2993 with "Fixes #2987." -- same file, same issue, same fix. `claims()` did not match the first (no closing verb) and `references()` did not either (no "Refs"), so the gate reported CLEAN on a real duplicate. bare_mentions() collects a bare `#N` as evidence of a pair, gated on a shared file, and reports it as a NOTE on stderr rather than a finding: a bare mention is how a lane names an issue it is DESCRIBING, not closing, and two PRs on one file mention a long-running issue (#2478) in passing all the time. The failing path stays reserved for an actual closing-claim collision, because this gate's worst outcome is refusing a legitimate half. AND IT REPRODUCED ITS OWN DOCUMENTED BUG. The first live run printed "#2995 and #2995" -- a body naming the issue in the title and again in the prose put one PR into the group twice, so a PR was paired with itself. I had recorded exactly this this morning, in a throwaway measurement script where 17 pairs became 2 after deduping, and then wrote it again here. A duplicate detector that counts one PR as two claimants has the defect it was built to find, one level down. Keyed by PR number now, with an arm. 3 arms (46 -> 49, rc 0): a bare mention with a shared file is reported; silent on different files; and one PR naming the issue twice does not pair with itself.
…ngine#2995 review) The review found the one input where the new formula failed open: `gtt_total == 0` means the pool could not be READ, and `0 / 4 = 0` slides through `min(quarter, cap)` to a reserve of nothing -- so a 32 GB box whose GTT read fails would be admitted like a box with an infinite pool, which is the exact failure the reserve exists to prevent. The measured-safe value is the right answer to "I cannot tell", and the fork's copy of this function already had that branch. One line plus an arm: `gtt_reserve_bytes(0) == 16 GiB`. Local run 47 ok, PASS. Also worth recording from the review, because it is the property that makes this ratio the right one: on the machine whose reserve was actually measured, nothing changes -- 120 GiB of GTT still gets 16 GiB and the #680 ceiling stays 104 GiB, bit for bit. The cap takes over from 64 GiB upward, so only the pools that were at zero move.
|
The objection was right and it is fixed at // `gtt_total == 0` means the pool could not be READ, not that it is empty. Without this line `quarter` is 0,
// `0 < cap` is true, and the function returns no reserve at all -- failing open on exactly the input where the
// answer is unknown, so a 32 GB box whose GTT read fails would be admitted like a box with an infinite pool.
if (gtt_total == 0) return kGttReserveDefaultMiB * kMiB;and the arm: Two things I took from the review rather than argued with:
On the two body notes: I have added the precedence statement to the comment block ("knob first, then cap, then a quarter") instead of leaving it implied, and the per-mille sentence belongs on the fork side — that PR is not mine (my Landing order: agreed that the fork side must not be the only one that lands. |
The review asked for it in the body rather than left implied: knob, then the 16 GiB cap, then a quarter of the pool -- and the fork's copy of this function must keep carrying the same three rules, or the planner refuses a load the allocation-time backstop would allow. The comment already said the two halves must agree; this says which number wins. I told the reviewer this was in the previous push and it was not -- the sentence went in after that reply. Corrected here rather than left standing as a claim, and the slip is named in the commit rather than quietly absorbed.
|
Correction to my own reply: I said the precedence sentence was in the previous push and it was not — it went in after it, at The sentence now sits above the |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c055608: READY
The guard I asked for at 427d0b7 is in, and with it the engine and the now-merged fork half produce the same number at every real pool size. I evaluated both:
| GTT pool | engine gtt_reserve_bytes |
fork #451 (merged, permille 250) |
agree |
|---|---|---|---|
| 8 GiB (16 GB box) | 2.00 GiB | 2.00 GiB | ✓ |
| 16 GiB (32 GB box) | 4.00 GiB | 4.00 GiB | ✓ |
| 32 GiB | 8.00 GiB | 8.00 GiB | ✓ |
| 64 GiB | 16.00 GiB | 16.00 GiB | ✓ |
| 120 GiB (this box) | 16.00 GiB | 16.00 GiB | ✓ |
| 256 GiB / 1 TiB | 16.00 GiB | 16.00 GiB | ✓ |
That is the property the PR itself names as the thing that must not break — "the planner refuses a load the allocation-time backstop would allow, or the reverse, if the two disagree" — and it now holds by arithmetic, not by both files happening to look similar. #451 merged at 16:2xZ, so this is the half that has to match it, and it does, bit for bit, from 8 GiB to 1 TiB.
The guard, and why it was the right thing to insist on
if (gtt_total == 0) return kGttReserveDefaultMiB * kMiB; // unreadable is not emptyThe comment states the failure exactly: quarter = 0, 0 < cap is true, so the function would have returned no reserve at all — "failing open on exactly the input where the answer is unknown, so a 32 GB box whose GTT read fails would be admitted like a box with an infinite pool." An unreadable pool is the one input where the measured-safe value is the answer, and now there is an arm for it (gtt_reserve_bytes(0) == 16 * gib) rather than a comment.
The PRECEDENCE paragraph is the other half of the fix and the part most likely to save someone later: "the explicit knob (GGML_HRX_GTT_RESERVE_MB), then the 16 GiB cap, then a quarter of the pool. The fork's copy of this function carries the same three rules and must keep carrying them." Stated once, next to the code that implements them, so the next change knows what it is matching. I checked all three are actually in that order in the function body, and the env knob still wins outright (mb >= 0 → return).
One residual, worth a sentence rather than a change
The two halves do not share a sentinel for "unknown": the engine reads gtt_total == 0 as unreadable (→ 16 GiB), while the fork has its own kHostUnknown for that and treats a literal 0 as a real zero pool (→ reserve 0, i.e. fail open). So a device that reports a GTT total of literally zero is the one input where they still disagree — the degenerate case, not the reachable one, but it is the exact shape the precedence comment warns about, so naming the sentinel in that comment would close it without code.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c055608: READY
This answers the drift question I put to llama.cpp#451, and answers it the right way — by naming the contract in the code:
PRECEDENCE, stated once so a future change knows what it must match: the explicit knob (
GGML_HRX_GTT_RESERVE_MB), then the 16 GiB cap, then a quarter of the pool. The fork's copy of this function carries the same three rules
That sentence is the whole review. Two copies of a formula that must agree is a drift risk; two copies that each state the same three-rule contract, with the cap as a named constant rather than a literal, is a drift risk you can check. The formula itself is the same as #451's:
if (gtt_total == 0) return kGttReserveDefaultMiB * kMiB; // cannot measure ⇒ old behaviour
const uint64_t quarter = gtt_total / 4;
const uint64_t cap = kGttReserveDefaultMiB * kMiB;
return quarter < cap ? quarter : cap;Three things the comment earns
gtt_total == 0keeps the old default rather than returning 0 — an unmeasurable pool must not be treated as a tiny one, which is exactly the absence-as-evidence error in the numbers rather than in the messages;- "for GTT >= 64 GiB that is exactly the old number (so #680's headroom is unchanged, bit for bit)" — the change is stated to be a no-op where it was already right, which is the claim a reviewer needs to accept this without re-measuring the 120 GiB box;
- the failure being fixed is stated as arithmetic: on a 16 GiB GTT box the fixed 16 GiB cap "leaves a ceiling of zero, so HRX refuses every model", and on an 8 GiB pool "it refuses before arithmetic". Both are visible in the formula, so the claim can be checked rather than believed.
One thing to keep true: the comment names the fork's copy as carrying "the same three rules" — that is a promise only a test can hold. If there is a cheap way to assert the two constants agree (the engine and third_party/llama.cpp reading one value), it is worth the arm; if not, the divergence shows up only when a 16 GB box behaves differently under the two runners, which is the expensive way to find out.
Not verified: the behaviour on a 16 GB box (needs the device and a small-GTT configuration); the arithmetic and the no-op-above-64-GiB claim are what this review covers.
|
VERDICT at The suite, compiled and run here (no engine build, no device): And the same suite with the function put back the way so the arms are the change, not decoration. Two things worth putting in the body, both measured on this box:
Scope: two files, and the pairing with llama.cpp#451 (the cap-side change) reads correctly — this is the reserve policy, that one is what consumes the reserve. Not a device claim: nothing here is verified against a real 16 GiB pool, and the numbers for small pools are arithmetic, not measurements. The one measurement that matters for it (a gfxhub fault at 106.5 GiB on a 120 GiB pool) is #680's and is referenced, not repeated. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c055608: READY
The engine half of #2986, and it lands the same policy as llama.cpp's #451 — including the gtt_total == 0 case, which is the one that decides whether this fails open or closed.
The change, and the precedence order is right
inline uint64_t gtt_reserve_bytes(uint64_t gtt_total) {
if (const char* e = std::getenv("GGML_HRX_GTT_RESERVE_MB")) {
const long long mb = std::atoll(e);
if (mb >= 0) return uint64_t(mb) * kMiB; // an explicit override wins
}
if (gtt_total == 0) return kGttReserveDefaultMiB * kMiB;
const uint64_t quarter = gtt_total / 4;
const uint64_t cap = kGttReserveDefaultMiB * kMiB;
return quarter < cap ? quarter : cap;
}Three decisions in nine lines, and all three are the correct one:
- The environment override is checked first, so an operator who has measured their box is not overruled by arithmetic — and
mb >= 0makesGGML_HRX_GTT_RESERVE_MB=0mean "reserve nothing, I know what I am doing" rather than being ignored as falsy. gtt_total == 0returns the measured reserve, and the comment states the failure it prevents: "quarteris 0,0 < capis true, and the function returns no reserve at all — failing open on exactly the input where the answer is unknown, so a 32 GB box whose GTT read fails would be admitted like a box with an infinite pool." That is the#2976lesson landed in arithmetic: an unreadable pool is not an empty pool, and "I cannot tell" gets the safe answer rather than the permissive one.- The cap keeps the measured value where it was measured. From 64 GiB up this is exactly the old 16 GiB — so
#680's measured headroom is unchanged on this box — and below it, three quarters of the pool stays usable.
The call site cannot clamp its way around it
const uint64_t gtt_free = mem.gtt_total > mem.gtt_used ? mem.gtt_total - mem.gtt_used : 0;
const uint64_t gtt_reserve = gtt_reserve_bytes(mem.gtt_total);
v.ceiling = mem.gtt_total > gtt_reserve ? mem.gtt_total - gtt_reserve : 0;Both subtractions are guarded, so a reserve larger than the pool yields 0 rather than a wrapped uint64. That was why the old constant produced a ceiling of zero on a 16 GB machine instead of a huge one — the arithmetic was already safe, and the policy was wrong. The fix is in the policy, which is the right place for it.
The arms cover the three cases that matter, and the two that bound them
120 GiB -> 16 GiB (the measured reserve, 104 GiB ceiling) unchanged on this box
64 GiB -> 16 GiB (the crossover) the old behaviour's edge
32 GiB -> 8 GiB scaling, and NOT 16
16 GiB -> 4 GiB (a 32 GB machine has a ceiling at all) the bug being fixed
8 GiB -> 2 GiB (a 16 GB machine keeps a usable ceiling) the bug being fixed
0 -> 16 GiB (an unreadable pool is not an empty pool) fails closed
1 GiB -> refused the ceiling cannot grow a load
The 120 GiB -> 16 GiB arm is the regression guard: a later change that quietly shrank the reserve on the machine it was measured on goes red. And 0 -> 16 GiB is the one that would have been silently wrong if the early return had been written as an optimisation rather than as a decision.
One structural note, not a defect
This is now the second implementation of one policy: app/mem_admit.h:61 kGttReserveDefaultMiB = 16384 here, and ggml/src/ggml-hrx/hrx-1bit-safety.cpp:57 kDefaultReserveMiB = 16384 in llama.cpp (#451). Both are 16384 and both compute min(gtt/4, cap), so they agree today — but they are two constants and two divisions, in two repositories, that must change together. An arm in each place cannot catch the drift; the only thing that can is a comment naming the other copy, and I would add one line to each:
// keep in step with llama.cpp's ggml/src/ggml-hrx/hrx-1bit-safety.cpp (kDefaultReserveMiB)
Not a reason to hold this PR — it is the same policy, correctly implemented twice, and the divergent-constant risk is small and slow. But it is the kind of pair that ends up disagreeing after a year.
What I could not run
No build — tests/mem_admit_test.cpp links the app target and my lane holds no ticket for a configure. I checked the arithmetic of every arm by hand (120/4=30 → cap 16, 64/4=16 → cap 16 exactly at the crossover, 32/4=8, 16/4=4, 8/4=2, 0 → 16), and they all hold. The ctest row in CI is the half that proves the code compiles against the header it ships with.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c055608: READY. Built and ran the test here, and checked the one thing that decides whether this pair is safe — that the engine's planner and the fork's registration backstop compute the same reserve.
$ g++ -std=c++20 -I. -o matest mem_admit_test.cpp && ./matest → rc 0, PASS
ok 120 GiB of GTT keeps the measured 16 GiB reserve (104 GiB ceiling)
ok 64 GiB of GTT is the crossover: still a 16 GiB reserve
ok 32 GiB of GTT gets an 8 GiB reserve, not 16
ok 16 GiB of GTT (a 32 GB machine) gets a 4 GiB reserve, so the ceiling is not zero
ok 8 GiB of GTT (a 16 GB machine) keeps a 2 GiB reserve and a usable ceiling
ok an unreadable pool keeps the measured 16 GiB reserve, not zero
ok a 16 GiB-GTT box now admits a small model where the fixed reserve refused everything
ok 1 GiB more: fits, no ceiling note … an 8 GiB pool: the ceiling is the pool minus a quarter, not zero
The pairing, computed on both sides (the fork half is llama.cpp#451, in review): for {8, 16, 64, 120} GiB of GTT the two implementations return identical reserves — 2 / 4 / 16 / 16 GiB — so the ceilings are 6 / 12 / 48 / 104 GiB. That last number is the point: this box keeps #680's measured 104 GiB ceiling bit for bit, and only the pools that were at zero move. The planner and the backstop therefore cannot disagree about what fits, which is the failure mode a pair like this invites.
Three things I would keep exactly as they are:
- an unreadable pool keeps the flat 16 GiB — a caller that cannot measure GTT must not get a smaller reserve than the one measured safe, and the test arms it;
- the 64 GiB crossover is explicit (still 16 GiB), so the change is provably a no-op above it;
GGML_HRX_GTT_RESERVE_MBstill wins outright on the fork side, so an operator can override both halves at once.
One note, not a change request: both halves now encode "a quarter, capped at 16 GiB" independently, and nothing fails if one moves without the other — the fork's knob is GGML_HRX_GTT_RESERVE_MB, the engine's is not, and the two constants live in different repositories. The numbers agreeing today is a measurement, not a guarantee; a sentence in each header naming the other file (and the engine#2986 number) is the cheap way to keep them paired when someone next tunes one.
|
The precedence promise is currently TRUE only after a pin: measured, and the merge order matters. I asked for an arm asserting the engine's copy and the fork's agree. Running the comparison by hand first, the two are not in the same state today: So the constant already agrees (16384 in both copies) but the shape does not, and it will not until llama.cpp#451's pin is in. That gives this PR an ordering constraint worth stating in the body:
What I would put in the body: which of the two is expected to land first, and that the pinned And the arm: with the fork's signature changing, the cheapest assertion is not a constant comparison but a shape one — the engine's header and the fork's header both declaring a reserve function that takes the pool size. A test that greps both headers for that signature would fail today and pass after the pin, which is exactly what an arm is for. |
|
Persistent review updated to latest commit c055608 |
…st one that fits with room (#2986) (#3013) * serve: a model whose own context is beyond the machine gets the largest one that fits with room (#2986) On HRX with no --ctx-size, llama-server takes the model's own context (HRX0 reports its whole pool free, so --fit shrinks nothing). LFM3-1.7B's own context is 262,144 tokens (5.88 GiB of plan). On a 16 GB machine (GTT 8 GiB, the #2995 ceiling 6.00 GiB) that load is refused outright, which the owner's 16 GB direction cannot ship with. serve now keeps the model's own context when its plan is roomy - it fits and leaves the graph-program cache its 4 GiB (no "little room left" warning) - and otherwise passes the largest context, in 256-token steps, whose plan is roomy; when none is, the 4096 floor, and if even that does not fit the normal refusal names it. One line says what happened. An explicit --ctx-size is never changed: it is judged, and refused, as given. A CPU backend, --no-mem-check and a box that does not report its memory are left alone. app/mem_admit.h: Verdict::roomy, default_ctx() (pure). tests/mem_admit_test.cpp, an LFM3-1.7B-shaped fixture (its own header values, 1,099,627,808 bytes): - GTT 8 GiB, 0.5 GiB in use, 11 GiB available: 262144 (5.88 GiB) -> 58112 (2.50 GiB); 58112 is roomy and 58368 is not; - the same with 6 GiB available: no context is roomy -> 4096 (1.60 GiB); - explicit --ctx-size 262144 there: left alone, refused (6.38 GiB would land past 6.00); --ctx-size 1000000: refused; - GTT 16 GiB / 26 GiB available, and a 120 GiB box: the model's own context stands; a CPU argv is left alone; a 2 GiB pool gets the floor. mem_admit_test: 57 ok, PASS (47 before). docs/serve.md: the default-context rule and line, and the reserve rule #2995 merged (the doc still said a flat 16 GiB). Refs #2986 Co-Authored-By: Claude Opus 5.5 <[email protected]> * models: pin LFM3-1.7B-GGUF and record its licence (#2918 follow-up to #2956) models/pins.json: LiquidAI/LFM3-1.7B-GGUF at cd0c74c575b5, the one file we hold - LFM3-1.7B-Q4_K_M.gguf, oid 3793e1e6..., 1,099,627,808 bytes, template f45005c5... (the pin #2956 added to config/template-pins.json; tools/pin_watch.py --pin reads the same template sha from Hugging Face). Commit, oid and size checked against the Hugging Face API and the download's own metadata. docs/models.md: the LFM3-1.7B row with what #2918 measured (pp512 7,925, tg128 153.7 tok/s; perplexity 14.05 HRX vs 14.11 CPU; 2.05 GiB GTT and 1.34 GiB host RAM at 8k) and its licence: LFM Open License v1.0, under which commercial use is licensed only while annual revenue stays below US$10M (§1, §5) - not an OSI licence. Refs #2918 Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
The fourth way this tool has been blind in one day, and the first that a lane found for me. #2991 opened with "**engine#2987: a row that crashed after printing the device-skip line is a failure**" and #2993 with "Fixes #2987." -- same file, same issue, same fix. `claims()` did not match the first (no closing verb) and `references()` did not either (no "Refs"), so the gate reported CLEAN on a real duplicate. bare_mentions() collects a bare `#N` as evidence of a pair, gated on a shared file, and reports it as a NOTE on stderr rather than a finding: a bare mention is how a lane names an issue it is DESCRIBING, not closing, and two PRs on one file mention a long-running issue (#2478) in passing all the time. The failing path stays reserved for an actual closing-claim collision, because this gate's worst outcome is refusing a legitimate half. AND IT REPRODUCED ITS OWN DOCUMENTED BUG. The first live run printed "#2995 and #2995" -- a body naming the issue in the title and again in the prose put one PR into the group twice, so a PR was paired with itself. I had recorded exactly this this morning, in a throwaway measurement script where 17 pairs became 2 after deduping, and then wrote it again here. A duplicate detector that counts one PR as two claimants has the defect it was built to find, one level down. Keyed by PR number now, with an arm. 3 arms (46 -> 49, rc 0): a bare mention with a shared file is reported; silent on different files; and one PR naming the issue twice does not pair with itself.
…2999) The fourth way this tool has been blind in one day, and the first that a lane found for me. #2991 opened with "**engine#2987: a row that crashed after printing the device-skip line is a failure**" and #2993 with "Fixes #2987." -- same file, same issue, same fix. `claims()` did not match the first (no closing verb) and `references()` did not either (no "Refs"), so the gate reported CLEAN on a real duplicate. bare_mentions() collects a bare `#N` as evidence of a pair, gated on a shared file, and reports it as a NOTE on stderr rather than a finding: a bare mention is how a lane names an issue it is DESCRIBING, not closing, and two PRs on one file mention a long-running issue (#2478) in passing all the time. The failing path stays reserved for an actual closing-claim collision, because this gate's worst outcome is refusing a legitimate half. AND IT REPRODUCED ITS OWN DOCUMENTED BUG. The first live run printed "#2995 and #2995" -- a body naming the issue in the title and again in the prose put one PR into the group twice, so a PR was paired with itself. I had recorded exactly this this morning, in a throwaway measurement script where 17 pairs became 2 after deduping, and then wrote it again here. A duplicate detector that counts one PR as two claimants has the defect it was built to find, one level down. Keyed by PR number now, with an arm. 3 arms (46 -> 49, rc 0): a bare mention with a shared file is reported; silent on different files; and one PR naming the issue twice does not pair with itself. Co-authored-by: phyb5 <bcloud@local>
Closes the first half of #2986 — the part that needs no device, and the part that blocks the 16 GB direction before any model question.
The defect, restated as arithmetic
The reserve the ceiling keeps free was a fixed 16 GiB, sized on a 120 GiB GTT box where #680 measured a gfxhub page fault and a MODE2 reset at 106.5 GiB in use. On a machine whose whole pool is 16 GiB (a 32 GB box) that makes the ceiling zero, and
1bit serverefuses every model at any size; on a 16 GB box (about 8 GiB GTT) the refusal comes before the arithmetic is even interesting.The change
gtt_reserve_bytes()now takes the pool and returns a quarter of it, capped at the measured 16 GiB:From 64 GiB up the number is exactly what #680 measured, so the big-box headroom is not being renegotiated; below it the box keeps three quarters of its pool usable instead of losing all of it.
GGML_HRX_GTT_RESERVE_MBstill overrides both values.The test, including one arm that had to be restated
Five new arms walk the table above, plus the claim the issue actually cares about: a 16 GiB-GTT box now admits a small model where the fixed reserve refused everything.
"a pool smaller than the reserve: refused at any size"asserted the defect itself, so it is restated rather than deleted — a pool smaller than 16 GiB is no longer a zero ceiling, and the two things that still have to hold are that the ceiling is the pool minus a quarter, and that a pool small enough to be a sixteenth of the load is still refused by it. Deleting the arm would have been the quiet way to make a red test green.Local run: 46 ok, PASS.
Not in this PR
ggml/src/ggml-hrx/hrx-1bit-safety.cppin the fork carries the same constant as the allocation-time backstop. It needs the same change so the pre-launch refusal and the allocation-time check cannot disagree about where the wall is (the comment inmem_admit.hsays exactly that about the shared knob); that is a fork PR, and this one is the half that can be proven without a device.Refs #2986, #680, #2918