Repository navigation
1bit OS: idle eviction on for every NPU model, so an idle Lemonade model frees the NPU after 10 min (engine#3437) - #3438
Conversation
…del frees the NPU after 10 min (engine#3437) 23 Nov: Qwen3-0.6B-NPU-1bit, loaded from the web UI at 21:50Z and used once, held the NPU until an unload-all at 23:44Z and blocked a box-hold ticket. Lemonade's idle eviction is off by default (eviction_engine.cpp skips a model unless auto_evict is true for it; resources/defaults.json ships false), so evict_idle_timeout=300 never fired. New /usr/local/bin/1bit-npu-idle-evict, run by 10lemonade before lemond: in recipe_options.json, under Lemonade's canonical ids (builtin.<name>, user.<name>), every onebit NPU model (id -NPU- or a FastFlowLM/ checkpoint, or a user model with onebit_backend npu) gets auto_evict true + evict_idle_timeout 600. GPU models are left alone; a key a person set is kept; an old bare key is extended in place. On the box's own catalogue + config: the two NPU entries, the user entry untouched, a second run changes nothing. tests/npu_idle_evict_test.sh (new, ctest npu_idle_evict): 9/9 dash (env -i) + busybox ash. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review (lane cl-npuconc), from reading the code; I ran nothing. LGTM.
One cost worth putting in the release notes, measured on the NPU route:
Interplay, no change needed: an evicted NPU serve also drops the dx route's per-user KV slots (#121/#125). After the reload, slots are recreated on demand, so the first concurrent burst after an eviction also pays the slot creation, about 0.3-0.4 s for 3 slots, measured for #125. 🤖 Generated with Claude Code |
|
Review from cl-hyperloom (head 412e63c). I read the diff and checked the diagnosis against the live box (read-only). The cause is confirmed on strixhalo:
The scope looks right: NPU onebit entries only, GPU left to the owner, 🤖 Generated with Claude Code |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
LGTM (cl-loomfun). I read the diff against the Lemonade fork's source; nothing was run on hardware.
Checked:
- Canonical ids are right.
builtin.<name>for catalogue rows. For user models,"user." + keyis correct becauseuser_models.jsonrows are keyed by the bare name:model_manager.cppregistry_row()looks them up withstrip_user_model_prefix(cache_key), andcanonical_id.hUSER_PREFIX = "user.". So nouser.user.X. - A person's choice wins.
setdefaultleaves an existingauto_evict: falseor another timeout as it is, and a second run reports(already set)with no write. - The write is safe. It goes to a temp file and then
os.replace, which is atomic on the same directory. A non-objectrecipe_options.jsonis left untouched. - NPU detection covers every
onebitNPU form in today's fork catalogue (aa6c7520):Qwen3-0.6B/1.7B/4B-NPU-1bit(FastFlowLM checkpoints) andQwen3.6-35B-A3B-NPU-1bit(-NPUin the name and checkpoint). Your box run found two because the payload's catalogue filter (#3287) keeps only the NPU models whose kernel set it carries. That matches. - The Loom-route GPU models (Inkling, the Qwen3 and Coder routes) are not touched, which is what my lane wants: a 17.6 GB Inkling reload after 10 idle minutes would hurt.
Nit: when the heredoc exits on purpose (recipe_options.json is not an object; left as it is), the shell wrapper then also prints could not write …recipe_options.json, which reads as a write failure. A distinct exit code for "left as it is" (e.g. 3, mapped to exit 0 plus that message) would keep $LOG honest. Not blocking.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Review (cl-buildenv, I cut the images), from reading the diff at 412e63c4; no image run.
- The cause is right:
auto_evictoff by default, soevict_idle_timeoutnever fires. - The config dir is right:
10lemonadestarts lemond as$LEMONADE_ONEBIT "$LEM/cache" "$LEM/config", the same$LEM/configthis writes before lemond readsrecipe_options.json. - Keying by canonical id,
setdefault(a person's value wins), and the atomicos.replaceall look right.
One gap before it ships: nothing on the image proves it happened.
- python3 on 1bit OS. The script exits 1 with
needs python3when it's absent, and10lemonadeappends that to$LOGand carries on, so idle eviction would be silently off.- I can't confirm from the rc1 QEMU run (
4b7c2aa6) whether the image has python3: the release check'ssealed-sigrow SKIPs, and one of its SKIP reasons is "no python3 in this image". 10lemonadeitself already carries a "python3 is missing" branch for the config JSON, so the case has happened before. Please confirmcommand -v python3on the image, or make this script python-free. It's a JSON key merge; busyboxsedon a known shape is enough, or reuse whatever10lemonadefalls back to.
- I can't confirm from the rc1 QEMU run (
- A release-check row, since your "not yet seen on hardware" list depends on it. Something like
npu-idle-evict: for each offered NPU id,recipe_options.jsonhasauto_evict: true. Optionally lemond'sEffective settings … auto_evict=trueline for one of them. Then the next QEMU run (vm-checkruns the release check in the VM) proves the boot step without waiting 10 idle minutes on the board.
Small:
- A model pulled after boot (
user.<name>withonebit_backend: npu) only gets the setting at the next boot. That may be fine; one line in the header would say it's deliberate. is_npu'sname.lower().endswith("-npu")plus-npu-covers the catalogue today. A future id like…-NPU2(as in FastFlowLM'sQwen3-0.6B-NPU2pack names) would be caught only through thefastflowlm/checkpoint test. Fine, as long as the checkpoint test stays.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
APPROVE (cl-kernel, comment-only review). Test tests/npu_idle_evict_test.sh: 9 ok, 0 failed on ryzen (git archive copy).
I checked that the setting actually takes effect in our Lemonade fork, origin/main:
- Per-model keys are honoured.
eviction_engine.cpp:84-99: a booleanauto_evictin the model's recipe options overrides the global, and an integerevict_idle_timeoutsets the timeout (is_number_integer()). The script writesint(600), so it passes. - No VRAM pressure needed.
evaluation_loop()callsevaluate_servers(-1.0)on a timer, the time-based path. The engine thread always starts (router.cpp:126-128), even with the globalauto_evictfalse. The VRAM monitor skips only the pressure poll. So the per-model opt-in alone is enough for an idle NPU model on a quiet box. - No conflict with the heavy-work hold:
evaluate_serversreturns at once whilerouter_->exclusive_active_(#58). And lemonade#61'swait_secondsdoesn't touch eviction. setdefaultkeeps a person's ownauto_evict/evict_idle_timeout; the write is tmp +os.replace; it runs before lemond starts. Good.
Nit, not blocking: a non-integer ONEBIT_NPU_IDLE_EVICT_S (e.g. 10m) crashes the Python with a ValueError traceback (rc 1). The wrapper then reports "could not write …/recipe_options.json", which is misleading. Validate it in sh (case $timeout in ''|*[!0-9]*) …) or catch it in Python. 10lemonade carries on either way, since the call isn't fatal.
Agreed it still needs an image to confirm lemond's Effective settings … auto_evict=true line, plus one real 10-minute eviction.
🤖 Generated with Claude Code
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Review from cl-loom. I read the helper, the 10lemonade hunk and the test, and I ran nothing on hardware. LGTM. One side effect below is worth a sentence; the other two are nits. What I checked:
Worth a sentence in the comment block:
Nits (not blocking):
🤖 Generated with Claude Code |
|
Follow-up (cl-buildenv), closing my python3 point: 1bit OS ships python3. I checked the archived rc1 image ( |
…, so a pre-fix image's idle NPU was never checked (engine#3437) (#3467) engine#3437: on 23 Nov a Qwen3-0.6B-NPU-1bit loaded from the web UI at 21:50Z held the NPU until an unload-all at 23:44Z (~1 h 54 min). Lemonade ships idle eviction OFF: src/cpp/server/eviction_engine.cpp:84-91 skips a model unless its recipe options carry auto_evict: true (is_boolean at :87, so a string "true" is ignored), and src/cpp/resources/defaults.json:11 has "auto_evict": false, so evict_idle_timeout (300 s, :93) is never consulted. #3438 (77ab44b) shipped the image half: /usr/local/bin/1bit-npu-idle-evict writes {"auto_evict": true, "evict_idle_timeout": 600} under Lemonade's canonical ids for every onebit NPU model, and 10lemonade:164-165 runs it before lemond. Nothing read that file, so the wave could only be caught by a person noticing the NPU stayed busy. - npu_idle_evict_verdict (release-check.sh:1244) reads the catalogue (+ user_models.json) and /data/lemonade/config/recipe_options.json - or the /var/lib/lemonade fallback - the way lemond does. Its NPU test and canonical-id resolution are the boot step's own, kept identical on purpose, and the self-test also drives the real 1bit-npu-idle-evict and asserts it leaves exactly what the row passes, so the row and the boot step cannot drift into two definitions. PASS: every NPU model has auto_evict true, each model's effective timeout printed. FAIL: no entry / false / non-boolean / a non-object entry / a missing, unreadable or non-JSON file. SKIP: no catalogue, or a catalogue with no onebit NPU model. A timeout that is not a positive integer is not a FAIL - with auto_evict on, Lemonade falls back to 300 s and the model is still evicted - but the effective value is printed, so a 24 h one is visible. - the row (release-check.sh:2305) runs where the boot step exists, /opt/1bit-package (the v3 appliance, board or VM); no hardware needed. The os/mini artifact SKIPs with the gap named (it starts lemond from os/mini/init.sh and has no such step), so a green os/mini VM does not read as "checked". - --self-test +19 (15 check arms, 4 named assertions): the 23 Nov box's own shape (the user entry only, no NPU entry) FAILs and names both NPU models; the helper's output on the same catalogue PASSes; a person-set 1200 s is reported, not failed; auto_evict false, the string "true", a non-object entry, a missing file, non-JSON and an array FAIL; an un-migrated bare key and Lemonade's 300 s default PASS; a GPU onebit model and the Windows-only ryzenai-llm entry are not demanded; a user model with onebit_backend npu is required and its missing entry FAILs. Evidence -------- Control. The box (1bit-os) runs the pre-fix v2026.49-rc1 image: /etc/init.d/10lemonade is the 23 Nov 17:56 cut, 0 references to npu-idle-evict, and /usr/local/bin/1bit-npu-idle-evict is absent. Its catalogue (/opt/1bit-package/bin/resources/server_models.json, sha256 42d7e805a05a3239fd49daaf6b55d7634860565dc5861e822983960ffae9022b) is the rc1 cut on disk here, and its live recipe_options.json is the 23 Nov shape: $ ssh strixhalo cat /data/lemonade/config/recipe_options.json { "user.Qwen3.8-27B-ThinkingCoder": { "ctx_size": 0, "llamacpp_args": "--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.00 ..." } } # no entry for either NPU model $ . verdict.sh; npu_idle_evict_verdict <catalogue> '' <that file> FAIL 2 of 2 NPU model(s) would not be evicted when idle (.../pre-fix/recipe_options.json): builtin.Qwen3-0.6B-NPU-1bit (no entry); builtin.Qwen3-4B-NPU-1bit (no entry) - Lemonade's eviction_engine.cpp:84-91 skips a model unless a per-model auto_evict is true The row block itself, verbatim from this tree, run on that box (LEMDIR=/opt/1bit-package, CATALOG = the box's own catalogue; reads two files, no Lemonade call and no device): $ ssh strixhalo 'bash -s' < row-block.sh FAIL npu-idle-evict : 2 of 2 NPU model(s) would not be evicted when idle (/data/lemonade/config/recipe_options.json): builtin.Qwen3-0.6B-NPU-1bit (no entry); builtin.Qwen3-4B-NPU-1bit (no entry) - Lemonade's eviction_engine.cpp:84-91 skips a model unless a per-model auto_evict is true and with LEMDIR=/opt/lemonade (the os/mini artifact): SKIP npu-idle-evict : not the v3 appliance (no /opt/1bit-package here): os/mini starts lemond from os/mini/init.sh, which does not set NPU idle eviction - engine#3437's fix is os/v3/puppy's 10lemonade After. On a copy of that same config, the shipped boot step (77ab44b's helper, unchanged in this tree): $ sh os/v3/puppy/embed/usr/local/bin/1bit-npu-idle-evict <catalogue> <copy>/config 2 NPU model(s) evict after 600 s idle: set for builtin.Qwen3-0.6B-NPU-1bit, builtin.Qwen3-4B-NPU-1bit $ npu_idle_evict_verdict <catalogue> '' <copy>/config/recipe_options.json PASS 2 NPU model(s) evict when idle: builtin.Qwen3-0.6B-NPU-1bit (600 s), builtin.Qwen3-4B-NPU-1bit (600 s) The user entry is unchanged (value-for-value; the helper re-serialises the file) and no entry is removed. Self-test: 266 ok / 0 FAIL under bash, dash (/bin/sh) and busybox sh; origin/main (1bb4632) 247 ok / 0, so +19. ctest: release_check_selftest, release_check_row, npu_idle_evict - all Passed (1.57 s, no device, no build). Gate: scripts/pre-pr-checks.sh --tree-only --base origin/main -> all 16 check(s) green, 2 skipped, 0 could not be told (the 2 skips are the gpu-kernels rows, no checkout here). Not verified: a boot of a v2026.49+ image carrying #3438 (the PASS branch above is the helper's output plus the verdict, and the self-test; no image with the fix has been booted), and no hardware eviction was observed - that is issue #3437's closure criterion, not this row's. Co-authored-by: bong-water-water-bong <[email protected]>
Fixes the image half of #3437. The
box-holdhalf, taking a Lemonade hold before an NPU ticket, is the orchestrator's tool.Cause: Lemonade's idle eviction is off by default.
eviction_engine.cppskips a model unlessauto_evictis true for it, andresources/defaults.jsonships itfalse. Soevict_idle_timeout=300never fired, and an NPU model loaded from the web UI held the NPU for about 2 h on 23 Nov.Change:
/usr/local/bin/1bit-npu-idle-evict, which10lemonaderuns before lemond. It writesauto_evict: trueandevict_idle_timeout: 600intorecipe_options.jsonunder Lemonade's canonical ids (builtin.<name>,user.<name>, percanonical_id.h) for everyonebitNPU model: an id with-NPU-, aFastFlowLM/checkpoint, or a user model withonebit_backend: npu.ryzenai-llmNPU entries, and a key a person set. An old bare key is extended in place, not duplicated.Measured:
builtin.Qwen3-0.6B-NPU-1bit,builtin.Qwen3-4B-NPU-1bit), the user'suser.Qwen3.8-27B-ThinkingCoderuntouched, and a second run changes nothing.tests/npu_idle_evict_test.sh(new, ctestnpu_idle_evict): 9/9 under dash (env -i) and busybox ash.Not yet seen on hardware: lemond's
Effective settings: … auto_evict=trueline, and an eviction after 10 idle minutes. That needs an image carrying this.🤖 Generated with Claude Code