Repository navigation
serve: a model whose own context is beyond the machine gets the largest one that fits with room (#2986) - #3013
Conversation
…st 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]>
…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]>
|
VERDICT at head: READY — the honest labelling is what makes it mergeable without a 16 GB machine, and three asks, one of which decides whether the rule applies to a config or only to its first model. The shape is right: 1. Only 2. The binary search assumes the plan is monotone in 3. The 4096 floor still depends on the gate below it. Two notes, not asks. The table's own caption — "the machine figures are assumed values in the unit test, not measured machines" — and "A real 16 GB machine has not confirmed any of this" are exactly the right labels. That is why this is READY: the claim is scoped to what was run. When a 16 GB box does confirm it, the row that matters is the |
|
VERDICT: READY at Reviewed by running it and by checking the pins against the source of truth, not the description. What I verified
Three notes, none blocking
Merge when the queue allows. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 7762393: READY
Compiled and ran the test suite at this head: 57 ok, 0 fail, PASS (g++ -std=c++20 -O1 -Iapp -Itests tests/mem_admit_test.cpp), and the four rows in the description reproduce from the run's own output. Two documentation details to fix, neither of which changes behaviour.
What the run says
16 GB machine (GTT 8 GiB, 11 GiB available): model ctx 262144 needs 5.88 GiB -> ctx 58112 needs 2.50 GiB (roomy 1)
16 GB machine, busier (GTT 8 GiB, 6 GiB available): -> ctx 4096 needs 1.60 GiB (roomy 0)
16 GB machine, explicit --ctx-size 262144: need 5.88 GiB, ceiling 6.00 GiB -> refused
and the arms that matter, all green: the chosen context is roomy and 256 more is not (so the search lands on the largest, not merely a working one), the model's own context is kept when it is roomy (ctx == 0 on the 32 GB and strixhalo fixtures), an explicit --ctx-size is left alone, and a 2 GiB pool passes the floor through for the normal refusal to name.
I checked the three things that would have made this a trap rather than a feature:
- Case:
default_ctxdetects the device withrfind("HRX", 0), and serve inserts--device HRX0(serve.cpp:1133) — the same conventionmem_admit.h:327already uses. Not a mismatch. - An explicit context cannot be overridden: serve only ever emits
-cas two tokens and only wheno.ctx_size > 0(serve.cpp:1134), the parser accepts-c/--ctx-sizewith a separate value (:3335), anddefault_ctxreturns immediately on either. There is no-c512form in this argv, so the "user's word, then a second-cappended" failure cannot happen. - The floor cannot silently replace a context that would have worked: if the model's own context fits, then so does 4096 (the weights dominate the need), so "nothing is roomy" and "the model's context fits" cannot both hold for the same box — the 4096 branch is reached only when even the floor is not roomy, which is the case the refusal is for.
Two documentation details
- The same paragraph quotes two numbers for the same context: the example line says the model's own ctx "needs 5.88 GiB", and three lines later an explicit
--ctx-size 262144is refused because "6.38 GiB would land past its 6.00 GiB ceiling". The test prints 5.88 GiB, so 6.38 is 5.88 + the 0.5 GiB already in use — a different quantity. Say which one the sentence means, or the reader concludes the two paths disagree. -c 0(or--ctx-size 0) is a no-op in serve's parser (ctx_sizestays 0, no-creaches argv), so the new code treats it as "unset" and chooses a context — while llama.cpp reads 0 as "the model's own". Nobody writes-c 0on purpose to mean "shrink me", but the doc's "an explicit--ctx-sizeis never changed" is one word stronger than the code.
Merge notes
app/mem_admit.h is also touched by #3012 (gtt_reserve_bytes) and docs/serve.md by #3012 and #3007's neighbours — the hunks are in different regions, so a rebase should be clean, but whoever merges second should expect the file-level overlap and re-read the docs/serve.md reserve paragraph rather than taking either side.
No device needed, no change on CPU, --no-mem-check, or a box that does not report its memory — the three arms cover it.
|
A commit on this branch is not on
The PR merged at 18:30:19Z, eight minutes after this commit was authored, and its 49 added lines are absent from
So this is not a rebase casualty in the "branch was behind" sense — it is a review-response commit that arrived before the merge and did not land in it. What recovers it: the branch is alive at that commit, so a new PR from I am not re-posting a verdict here: |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Refs #2986, #2918.
Default context
On HRX with no
--ctx-size, serve now keeps the model's own context only when its plan leaves room: it fits, plus the 1 GiB reserve, plus 4 GiB for the program cache. Otherwise it passes the largest context that does, in 256-token steps, or 4096 if none does, and says so in one line. An explicit--ctx-sizeis never changed, and is still refused when it does not fit. CPU backends,--no-mem-checkand boxes that do not report memory are left alone.For LFM3-1.7B (plan numbers from
tests/mem_admit_test.cpp; the machine figures are assumed values in the unit test, not measured machines):--ctx-size 262144docs/serve.mddescribes the rule and corrects the reserve text, which still said a flat 16 GiB.Second commit: the #2956 follow-ups
models/pins.json: LiquidAI/LFM3-1.7B-GGUF at commit cd0c74c5, the one file we hold (oid 3793e1e6, 1,099,627,808 bytes, template f45005c5).docs/models.md: the LFM3-1.7B row with its licence: LFM Open License v1.0, commercial use licensed only below US$10M annual revenue, so not an OSI licence.Checked
mem_admit_test57 cases pass;pre-pr-checksgreen (3 skips: no submodules or gpu-kernels tree in the worktree); copyright check 0;pin_watch.py --self-testok.Not run
The full engine ctest and
mem_admit_route.sh(needs a1bitbinary): CI covers them. One simulated run before this branch (a budget cap on the 120 GiB box, older pin): at ctx 58112 the planner said 2.50 GiB and the measured GPU-memory peak was 2.82 GiB plus 1.43 GiB host RSS; the 4 GiB margin covers that gap. A real 16 GB machine has not confirmed any of this.🤖 Generated with Claude Code