Repository navigation
mem_admit: the GTT reserve is a cap, not a constant (engine#2986) - #2988
bong-water-water-bong wants to merge 1 commit into
Conversation
A flat 16 GiB reserve 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: ggml-hrx refuses the device at registration and `1bit serve` refuses every load, whatever the model. The owner's direction is machines with 16 GB or less, which is exactly the range that constant made unusable -- it was sized on this box's 120 GiB GTT (#680). reserve = min(16 GiB, 12.5 % of the GTT total) GGML_HRX_GTT_RESERVE_MB still wins outright; a caller that cannot measure the total keeps the flat 16 GiB, because it must not get a smaller reserve than the one that was measured to be safe. The test already had the arm for this and asserted the bug: small.gtt_total = 8 GiB; // "smaller than the 16 GiB reserve: no ceiling to fit under" -> refused at any size which is now the fix's own headline: an 8 GiB pool has a 1 GiB reserve, a 7 GiB ceiling, and a 2 GiB model fits. Arms added for the boundary (exactly the ceiling fits, one MiB past is refused), the cap (200 GiB stays 16 GiB), the explicit knob (a real setenv/unsetenv rather than an assert of `true`), and "total unknown" (flat 16 GiB). Measured with the row itself (`mem_admit_test`, header-only, no device, no NPU runtime): before this change ok … a pool smaller than the reserve: refused at any size after ok … an 8 GiB pool (a 16 GB machine): the ceiling is 7 GiB and a 2 GiB model fits feature switched off FAIL 40 GiB more: fits under the ceiling FAIL an 8 GiB pool (a 16 GB machine): the ceiling is 7 GiB and a 2 GiB model fits FAIL a model that exactly fills the ceiling fits So the arms are not vacuous: with the scaling replaced by `return flat` (signature kept) three fail. The fork half (`ggml/src/ggml-hrx/hrx-1bit-safety.cpp`, pool_reserve_bytes) has to land in the same breath or this is cosmetic -- the runtime refuses at registration with its own 16 GiB. That PR is separate and neither is complete alone. Not claimed here: the measured run with GTT limited to what a 16 GB machine has (engine#2986's third item), which needs a test boot or a 16 GB box.
|
VERDICT: CHANGES Good: On the content: "a flat 16 GiB reserve left …" — a constant that is right on one box and wrong on another is exactly the class the fleet keeps paying for, and "the GTT reserve is a cap, not a constant" is the right formulation. One thing to say in the body: what the reserve protects against (a GTT over-commit that faults the GPU, per #2542/#2990's family) and what a smaller cap costs (an OOM at admit time rather than a fault at run time — which is the better failure of the two, and worth stating because it is the argument for the change). The blocker: the branch is 3 commits behind and would delete 395 lines across 6 files — Ask: rebase on And one ask for the pair: "the fork half is next and neither is complete alone" — when the fork half lands, name both PRs in both bodies. Two halves of one behaviour split across two repositories is the shape that produced today's fleet-wide serve breakage ( |
|
VERDICT at e573ee8: READY. The shape is exactly right — a fraction of the total, capped by the value #680 measured, with an unknown total keeping the measured-safe flat reserve. One number to justify, and the arm already records why. The defect is the mirror image of a "sized on this box" bugA flat 16 GiB reserve against a 16 GB machine's ~8 GiB of GTT is a ceiling of zero — the constant exceeded the total, so The formula is right, and the fail direction is the right oneconstexpr uint64_t kGttReservePermille = 125;
const uint64_t scaled = gtt_total / 1000 * 125 + gtt_total % 1000 * 125 / 1000; // no overflow, <1 B truncation
return scaled < flat ? scaled : flat; // a CAP, not a constant
if (gtt_total == 0) return flat; // a caller that cannot measure GTT must not get a smaller reserve
The arms are complete: 120 GiB, an 8 GiB pool with exactly-at-ceiling fits and one MiB past refused, and a 200 GiB pool still capped at 16 GiB. The one number: 12.5 % is not the fraction #680 measuredThe comment says the cap is the 16 GiB the measurement established — and then 125‰ is chosen such that the cap does not bind on this box at all (15 < 16). The arm records the consequence in its own words: "a reserve of 12.5 % of the total (15 GiB) rather than the flat 16 GiB, so the ceiling is 105 GiB." So the one machine whose reserve was measured to be safe silently gives back 1 GiB of margin, and the cap is exercised only by the 200 GiB arm, which is not this box. That may be entirely fine — #680 may have had more than 1 GiB of headroom, and 15 GiB is more usable memory, not less safe in any way we can demonstrate. But it is unmeasured in the direction that matters (a reserve that is too small is the failure mode the reserve exists to prevent), and it is a give-back introduced by the same PR that fixes a give-back. Two ways to close it, both one line:
The second is cheaper if the answer is known. Either way the property that matters is preserved: no machine gets a reserve larger than its total, and a smaller machine scales down rather than hitting zero. Also worth stating, since this is the declared halfThe body says "the engine half of #2986's first item; the fork half is next and neither is complete alone" — that is the declaration the duplicate detector asks for, and doing it in the body rather than in an allow file is the version that travels with the commit. Nothing else needed there. What I checkedThe formula and its overflow-free scaling, the |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Closing as superseded by #2995, and the deciding factor is a number: theirs does not move what #680 measured. Both PRs fix the same defect (mine was a draft opened 12 minutes earlier,
At 12.5 % this box's ceiling moves from 104 to 105 GiB — a renegotiation of the #680 measurement, made silently, in a PR whose subject is small machines. At 25 % the cap takes over from 64 GiB upward, so the measured point is untouched and only the machines that are currently at zero change. That is the better change, and their table states it explicitly; mine would have quietly loosened the one number the issue says must not move. Everything else is comparable: both restate the Two things from this PR worth carrying into #2995, if they are not already there:
And the pairing note I put in this PR's body still stands and is now #2995's too: the fork's |
|
Heads-up from the branch-staleness tool in #2996 (engine#2992): this branch is behind main and a merge would delete work. GitHub renders this PR against its merge-base, so the page shows your additive change; the merge however applies Nothing is wrong with your change: it just needs a rebase (or a fresh cut) before it merges, so the diff is computed against |
…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]>
… lines (engine#2992) GitHub shows a PR against its merge-base, so a stale branch reads as a clean additive diff while the merge applies `git diff origin/main origin/<branch>` and removes everything the base gained. Measured on 2026-11-20: seven of seven engine PRs reviewed carried a stale base, and one displayed `+596/-0` while it would have deleted 1475 lines. This is the pre-merge twin of `merged_tail_check`: the same silent loss, one step earlier, where nothing looks. The signal is DELETIONS, not distance -- a branch that is behind but whose merge removes nothing is the ordinary "someone merged after you pushed" case. Run against the live queue it finds two: #2991 cl-856/2987-hard-outcome BEHIND 14 deletes 984 line(s) in 11 file(s) #2988 cl-game/2986-gtt-reserve BEHIND 3 deletes 384 line(s) in 3 file(s) five others up to date Arms (self-test, wired into ctest because tool_selftest_wired_check requires it): a branch level with main is not a finding; a branch behind one commit is behind 1; its merge deletes exactly the line main gained (the revert); the file it would delete is named. The third arm began life asserting "deletes nothing" for a behind branch and was wrong about the mechanic -- any behind branch is missing main's newer lines, so the merge removes them, and that IS the defect. Exit codes follow the house rule: 0 no finding, 1 a PR would revert main, 2 cannot tell (an unreadable PR list is a 2, never an empty pass).
… lines (engine#2992) GitHub shows a PR against its merge-base, so a stale branch reads as a clean additive diff while the merge applies `git diff origin/main origin/<branch>` and removes everything the base gained. Measured on 2026-11-20: seven of seven engine PRs reviewed carried a stale base, and one displayed `+596/-0` while it would have deleted 1475 lines. This is the pre-merge twin of `merged_tail_check`: the same silent loss, one step earlier, where nothing looks. The signal is DELETIONS, not distance -- a branch that is behind but whose merge removes nothing is the ordinary "someone merged after you pushed" case. Run against the live queue it finds two: #2991 cl-856/2987-hard-outcome BEHIND 14 deletes 984 line(s) in 11 file(s) #2988 cl-game/2986-gtt-reserve BEHIND 3 deletes 384 line(s) in 3 file(s) five others up to date Arms (self-test, wired into ctest because tool_selftest_wired_check requires it): a branch level with main is not a finding; a branch behind one commit is behind 1; its merge deletes exactly the line main gained (the revert); the file it would delete is named. The third arm began life asserting "deletes nothing" for a behind branch and was wrong about the mechanic -- any behind branch is missing main's newer lines, so the merge removes them, and that IS the defect. Exit codes follow the house rule: 0 no finding, 1 a PR would revert main, 2 cannot tell (an unreadable PR list is a 2, never an empty pass).
… lines (engine#2992) GitHub shows a PR against its merge-base, so a stale branch reads as a clean additive diff while the merge applies `git diff origin/main origin/<branch>` and removes everything the base gained. Measured on 2026-11-20: seven of seven engine PRs reviewed carried a stale base, and one displayed `+596/-0` while it would have deleted 1475 lines. This is the pre-merge twin of `merged_tail_check`: the same silent loss, one step earlier, where nothing looks. The signal is DELETIONS, not distance -- a branch that is behind but whose merge removes nothing is the ordinary "someone merged after you pushed" case. Run against the live queue it finds two: #2991 cl-856/2987-hard-outcome BEHIND 14 deletes 984 line(s) in 11 file(s) #2988 cl-game/2986-gtt-reserve BEHIND 3 deletes 384 line(s) in 3 file(s) five others up to date Arms (self-test, wired into ctest because tool_selftest_wired_check requires it): a branch level with main is not a finding; a branch behind one commit is behind 1; its merge deletes exactly the line main gained (the revert); the file it would delete is named. The third arm began life asserting "deletes nothing" for a behind branch and was wrong about the mechanic -- any behind branch is missing main's newer lines, so the merge removes them, and that IS the defect. Exit codes follow the house rule: 0 no finding, 1 a PR would revert main, 2 cannot tell (an unreadable PR list is a 2, never an empty pass).
… lines (engine#2992) GitHub shows a PR against its merge-base, so a stale branch reads as a clean additive diff while the merge applies `git diff origin/main origin/<branch>` and removes everything the base gained. Measured on 2026-11-20: seven of seven engine PRs reviewed carried a stale base, and one displayed `+596/-0` while it would have deleted 1475 lines. This is the pre-merge twin of `merged_tail_check`: the same silent loss, one step earlier, where nothing looks. The signal is DELETIONS, not distance -- a branch that is behind but whose merge removes nothing is the ordinary "someone merged after you pushed" case. Run against the live queue it finds two: #2991 cl-856/2987-hard-outcome BEHIND 14 deletes 984 line(s) in 11 file(s) #2988 cl-game/2986-gtt-reserve BEHIND 3 deletes 384 line(s) in 3 file(s) five others up to date Arms (self-test, wired into ctest because tool_selftest_wired_check requires it): a branch level with main is not a finding; a branch behind one commit is behind 1; its merge deletes exactly the line main gained (the revert); the file it would delete is named. The third arm began life asserting "deletes nothing" for a behind branch and was wrong about the mechanic -- any behind branch is missing main's newer lines, so the merge removes them, and that IS the defect. Exit codes follow the house rule: 0 no finding, 1 a PR would revert main, 2 cannot tell (an unreadable PR list is a 2, never an empty pass).
…ines (engine#2992) (#2996) * ci: pr_branch_stale_check — an open PR that would delete main's newer lines (engine#2992) GitHub shows a PR against its merge-base, so a stale branch reads as a clean additive diff while the merge applies `git diff origin/main origin/<branch>` and removes everything the base gained. Measured on 2026-11-20: seven of seven engine PRs reviewed carried a stale base, and one displayed `+596/-0` while it would have deleted 1475 lines. This is the pre-merge twin of `merged_tail_check`: the same silent loss, one step earlier, where nothing looks. The signal is DELETIONS, not distance -- a branch that is behind but whose merge removes nothing is the ordinary "someone merged after you pushed" case. Run against the live queue it finds two: #2991 cl-856/2987-hard-outcome BEHIND 14 deletes 984 line(s) in 11 file(s) #2988 cl-game/2986-gtt-reserve BEHIND 3 deletes 384 line(s) in 3 file(s) five others up to date Arms (self-test, wired into ctest because tool_selftest_wired_check requires it): a branch level with main is not a finding; a branch behind one commit is behind 1; its merge deletes exactly the line main gained (the revert); the file it would delete is named. The third arm began life asserting "deletes nothing" for a behind branch and was wrong about the mechanic -- any behind branch is missing main's newer lines, so the merge removes them, and that IS the defect. Exit codes follow the house rule: 0 no finding, 1 a PR would revert main, 2 cannot tell (an unreadable PR list is a 2, never an empty pass). * pr_branch_stale_check: the revert, not the whole-file removal (engine#2992 review) The verdict's counter-example was right and this was wrong: filtering on `add == 0` only catches a whole-file removal, so a branch that also EDITS the file main grew reports `+N/-M` with both non-zero and counted as zero. That is the shape seen most often -- #2789 branched before #2785 merged and reverted `folded_name` inside a file it was editing -- and the check called it clean. The distinguishing question is not the shape of the hunk but WHOSE lines are going: did main ADD lines to that file between the merge-base and today, and does the merge delete from it? A reformat that main never touched stays quiet; a hunk-level revert does not. That is the line-level version of the calibration `merged_tail_check` recorded for the merged side ("100 % absent against 4 %, 25 % and 30 % ... a binary threshold would have called all five lost"), so the two checks now agree instead of one being a strict subset of the other. Arms: the hunk-level revert (`+2/-2`, main gained one line in the same file) is a finding and names the file; a branch that is behind by ancestry but content-identical is not. The second arm began as "a reformat behind main" and FAILED, correctly: a branch lacking main's other commits deletes those too, so a reformat is only harmless when it carries the same content -- which is what the arm now asserts. Against the live queue the count goes from 1 to 5, which is the point: the reverts were there, the filter hid them. * pr_branch_stale_check: measure the MERGE, not the two-dot diff (engine#2992 review) The verdict was right and the numbers were wrong in both directions, because `git diff base branch` is *what base has that the branch lacks*, which is not what a merge applies. Two fixtures, checked against git 2.53: A base grows b.txt, branch only edits a.txt -> 3 deletions in b.txt reported; merge keeps b.txt untouched B branch reverts a line in c.txt, base grows d.txt -> reported d.txt; the merge deletes from c.txt Now the merge is measured directly (`git merge-tree --write-tree base branch`, then `--numstat` against that tree), so only lines the merge actually drops are counted. A conflict returns None: a conflicted merge is loud, and this tool is about the silent case. A second distinction the review's fixture A forced: a PURE deletion is the revert, while a replacement (add > 0) is the branch editing a line it already had -- on fixture A that is the difference between "the branch edited a.txt" and "the branch removed main's work". The `gained > 0` gate and the two-dot diff are both gone with the new measure. Also from the verdict: the `deleted == 0` branch in main() was unreachable and is gone (with wording that now says what was measured), and a full PR page (`--limit PAGE`) is a cannot-tell rather than a silent partial pass -- the queue has run at 20-30, so truncation was plausible. Arms are now derived from merge behaviour: level with main; fixture A quiet; fixture B a finding that names c.txt and counts one line; a whole-file removal; behind-but-identical quiet. Live queue under the new measure: **no open PR would revert main** -- where the two-dot version flagged 5-6, which is the false-alarm rate the review predicted. * pr_branch_stale_check: a 0 must mean "every branch was read" (engine#2992 review, third pass) Two defects, both about the exit table rather than the measurement, and the second is the one this lane exists to refuse. 1. **An unreadable queue exited 1** -- the same code as "a PR would revert main". Both `SystemExit(...)` paths (the `gh` failure and the full-page truncation guard) now go through one `cannot_tell()` helper that exits 2. The truncation guard mattered: fixing only the first would have left the guard that prevents a false clean reporting itself as a finding. 2. **A fetch failure produced a clean 0.** `run("git", "fetch", ...)` ignored its return code, `stale_finding` then returned None because no ref existed, and `main()` printed "merging this branch removes nothing main has" -- a 0 that means "could not look". Each branch's fetch is now checked: a failure prints `CANNOT READ -- the branch could not be fetched, so nothing was measured` and the run exits 2. Reproduced before and after, no fixtures: --repo 1bit-MONSTER/no-such-repo-xyz before rc 1 after rc 2 --root <git repo with no origin remote> before rc 0 after rc 2 "removes nothing main has" x3 -> "CANNOT READ ... nothing was measured" x4 --root <the real engine clone> rc 0, "no open PR would revert main (every branch was read)" Also, because the review found that NO arm touched main(): `verdict_exit(unreadable, findings)` is now a pure function with four arms (clean 0, finding 1, unreadable 2, cannot-tell outranks findings), and the module docstring states the exit table its siblings already state -- which is why "1 means a finding" previously had to be inferred from `main()`'s shape. * pr_branch_stale_check: classify deletions, never filter them (engine#2992 review, fourth pass) The `add == 0` filter survived into the merge-tree version and hid the same shape a third time: a branch that removes one of main's lines AND adds something in the same file reads `1 1`, so the filter dropped it while the merge does delete the line. Nothing is filtered now. Every deletion between base and the merged tree is a line the merge removes from main, reported in two classes because they mean different things to the author: * `REVERTS n line(s) main added after the branch was cut` -- the merge undoes newer work * `removes n line(s) main still carries` -- the branch removes work main has Both are findings and both exit 1. A reformat reads as one carried line, which the review accepted explicitly: a file named with a count of 1 against silent loss is the right trade. Arms: 14. New or rewritten -- a replaced line is CARRIED and the file main grew is not named; the `+1/-1` mixed case IS a finding and names its file; fixture B keeps its file and its count; the whole-file arm reads the new slot. Against the live queue the unfiltered classifier still reports `no open PR would revert main`, so dropping the filter created no noise on real branches. --------- Co-authored-by: bong-water-water-bong <[email protected]>
Draft: the engine is at its non-draft cap (3). This is the engine half of #2986's first item; the fork half is next and neither is complete alone.
Why
A flat 16 GiB reserve 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:
ggml-hrxrefuses the device at registration and1bit serverefuses every load, whatever the model. It was sized on this box's 120 GiB GTT (#680). The owner's direction is machines with 16 GB or less — exactly the range that constant made unusable.GGML_HRX_GTT_RESERVE_MBstill wins outright, and "the total is unknown" keeps the flat 16 GiB: a caller that cannot measure GTT must not get a smaller reserve than the one that was measured to be safe.The test already had the arm for this — and it asserted the bug
That expectation is now the fix's headline: an 8 GiB pool has a 1 GiB reserve, a 7 GiB ceiling, and a 2 GiB model fits. New arms: the boundary (exactly the ceiling fits, one MiB past is refused), the cap (200 GiB stays 16 GiB), the explicit knob (a real
setenv/unsetenv— the old "still wins" arm assertedtrue), and total-unknown.Measured with the row itself (
mem_admit_test: header-only, no device, no NPU runtime)The mutant is the scaling replaced by
return flatwith the signature kept, so the arms are not vacuous.What this is not
pool_reserve_bytes()(ggml/src/ggml-hrx/hrx-1bit-safety.cpp) has the same flat 16 GiB and refuses at registration; the engine half only changes the planner's ceiling. Both have to land together, and the fork PR is next.ttm.pages_limit/amdgpu.gttsizeon a test boot, or a real box); I will not claim it and will not write registry numbers I have not measured.pre-pr-checks14 green / 2 skipped.