Repository navigation
serve: refuse a model that will not fit, before any backend starts (P1 step 3) - #398
Conversation
ggml-hrx reports free == total, so llama.cpp's --fit sees the whole GTT pool free whatever is loaded, and a load that cannot fit fails late or OOMs the box (ARCH-GAPS G1, goal P1 step 3). app/mem_admit.h estimates each llama-server serve will start from its final command line (-m, -c, -np, -ctk/-ctv, -md, --mmproj, --device) and the GGUF header alone, the method of tools/mem-budget/mem_budget.py: weights (every shard), KV per attention layer (MLA latent, gated delta-net interval, per-layer head arrays, sliding windows), delta-net state, 512 MiB compute, extras. It is refused when the need plus 1 GiB exceeds min(GTT free, MemAvailable) on HRX0 (MemAvailable on the CPU), in one line naming the numbers; the program cache and the #315 95 GiB zone only warn. --no-mem-check / ONEBIT_MEM_CHECK=0 skip it; --mem-check prints the estimate and exits 0 or 3. gguf_meta.h now reads through skipped bytes instead of seeking: a seek drops the stream buffer, so each header scan cost a read + lseek per tokenizer string (3.1M syscalls, 0.8 s per serve start on ZAYA1-8B; now 0.04 s). Tests: mem_admit (header only, KV/state against HRX0 logs, fake /proc and /sys), mem_admit_route (a sparse 4 TiB GGUF refused in ms, skips, dry run). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…decimals - A refused load exits with status 3 (as --mem-check does), so Lemonade's loader logs a distinct exit code next to serve's line. - Sliding-window layers: llama.cpp's per-architecture pattern (gpt-oss and Gemma 2 every other layer, Gemma 3 one full in 6, ...), or a pattern array in the file. gpt-oss-20b at 131072 was 3.02 GiB short of llama-fit-params (all layers counted as windowed); it now matches (3.01 vs 3.02 GiB). - The estimate prints GiB with two decimals. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Reviewer Guide 🔍(Review updated until commit 824749c)Here are some key observations to aid the review process:
|
|
Real serve start on strixhalo, on HRX0, under
Both are within the run-to-run noise (about 1 ms).
|
All conflicts were additive: #398's --mem-check/--no-mem-check options, help text and 'Will it fit?' section sit next to #394's --watchdog options and the 'When a backend hangs' / 'Metrics' sections; both sides kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Persistent review updated to latest commit 824749c |
…399, collapsible M-RoPE claim #401, #400 #402) (#2583) Carries cl-hrxkern's prepared pin (#401: the 27B --dflash draft loads under strict placement) to the fork head. registry "llama.cpp (hrx)" matches. Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Goal P1 step 3 of the 2026-10-12 architecture review (gap G1).
Scope. Owner rule: "What ever we are missing, lemonade provides". This PR only makes the engine refuse a load that cannot fit by itself, and say why with the numbers. Which models stay resident, eviction (
auto_evict) and multi-model admission stay Lemonade's, and none of that is built here.Problem. ggml-hrx reports free memory equal to total. llama.cpp's
--fittherefore sees the whole GTT pool free whatever is loaded, and a load that cannot fit fails late or OOMs the box.Change (
app/mem_admit.h, header only). Before any llama-server starts (hrx, cpu,--embed/--rerank), serve estimates each server's need from its final command line (-m -c -np -ctk/-ctv -md --mmproj --device) and the GGUF header alone. The method is the one intools/mem-budget/mem_budget.py:full_attention_interval, per-layer head arrays, and sliding-window layers (llama.cpp's per-architecture pattern);The load is refused when need + 1 GiB > min(GTT free, MemAvailable) on HRX0, or > MemAvailable on the CPU. The refusal is one line with the numbers, and serve exits 3. The program cache and the #315 95 GiB zone only warn.
--no-mem-check/ONEBIT_MEM_CHECK=0skip the check.--mem-checkprints the estimate and exits 0 or 3.gguf_meta.hnow reads through skipped bytes instead of seeking. A seek dropped the stream buffer, so every header scan cost a read + lseek per tokenizer string: 3.1M syscalls, 0.8 s per serve start on ZAYA1-8B, now 0.04 s.Accuracy (strixhalo, read-only). 15 model/context pairs,
1bit serve --mem-checkvsmem_budget.py model(KV fromllama-fit-params --fit-print), all within 1.1% on weights + KV/state:The first gpt-oss run showed -20.9%, because every layer was counted as windowed. It was fixed with llama.cpp's per-architecture pattern before this PR.
Lemonade compatibility. Tested with our Lemonade fork's
lemondat the pinned 4812a683, on strixhalo, withtests/fake_backend.pyas llama-server and no GPU:user.huge does not fit: need 4096.72 GiB (...) free 56.10 GiB (MemAvailable 56.1 GiB); ...) andllama-server process has terminated with exit code: 3.model_load_error/ "1bit serve failed to start for 'user.huge'".onebit_server.cpp, and that is Lemonade's call.Tests.
mem_admit(header only, in the CI target list): KV/state checked against the HRX0 logs in mem-budget's README, the gpt-oss window pattern, shards, a fake /proc and /sys.mem_admit_route: a 4 TiB model is refused (rc 3) in ms in one line before any backend starts; the skips; the dry run.flock ~/npu.lockfollows in a comment.Docs:
docs/serve.md(new section "Will it fit?", synopsis).Not merged: the release is held until #389/#390/#315 are fixed.
🤖 Generated with Claude Code