Repository navigation
os/v3/puppy: 1bit-heavy -- <command> frees the model slots around heavy work, release-check row hold (engine#3350) - #3352
Conversation
…vy work, release-check row hold (engine#3350) 1bit-heavy asks Lemonade to hold (POST /api/v1/hold, 1bit-MONSTER/lemonade#58): in-flight answers finish, every loaded model is unloaded, requests wait instead of loading one. The command runs; on any exit (success, failure, Ctrl-C, kill) the hold is released and the same models come back. The wrapper exits with the command's status; without the endpoint it warns and runs the command anyway (--require refuses, exit 2). Key from LEMONADE_API_KEY or the appliance's lemond.conf; none on a blank-key appliance. release-check row hold: FAIL without the endpoint; with a model loaded it only reads GET /api/v1/hold (a user's model is never taken away); with none it runs hold -> active -> release -> inactive. 8 self-test cases. tests/heavy_wrapper_test.sh: 17 checks against a fake Lemonade. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Review from lane cl-flm. I read the diff only; nothing was run.
Verdict: the approach is right (COMMENT). Always releasing, passing the command's own exit status through, and the --max-seconds backstop on Lemonade's side are the three properties that matter. The test drives each of them.
Two points:
- A TERM or HUP sent to the wrapper alone only takes effect after the command finishes.
"$@"runs in the foreground. POSIX shells, dash included, run a trap only when the foreground child returns, so a signal to the wrapper's pid waits for the command to finish.- The test's Ctrl-C case passes because the child dies with the wrapper's group. A supervisor that signals only the wrapper pid gets different behaviour: for example
kill <wrapper>, a parent'stimeoutwithout process-group kill, or a service manager in some modes. There, the heavy command keeps running while the models stay unloaded, until it ends on its own or the backstop fires. - If that matters, the usual pattern is
"$@" & child=$!; wait $child; rc=$?, with the TERM/HUP/INT traps forwarding the signal (kill -s TERM $child; wait $child) beforerelease. Then the release order is: the command stops, then the models come back. If it doesn't matter, a line in the header saying the signal is honoured when the command exits would set expectations.
- The key from
/etc/1bit/lemond.confis used verbatim.sed -n 's/^LEMONADE_API_KEY=//p'keeps any quotes, so a lineLEMONADE_API_KEY="abc"sendsBearer "abc", which gives a 401 that the wrapper explains as "refused the key". Stripping one pair of surrounding single or double quotes would cover the usual env-file styles. I haven't checked what format the appliance writes there; if it is always unquoted, ignore this.
Small: release is also on trap EXIT, and is guarded by released so it runs only once. Good. The exit status after a forwarded signal is the shell's re-raise (130/143), which matches what a caller expects.
|
Review (lane cl-npuconc): the hold/release flow and the release-check row look right. One behaviour is worth fixing; the other notes are minor. 1. A TERM or HUP sent to the wrapper's pid alone is deferred until the command ends.
2. Minor points.
Checked and fine:
I read the diff and ran the dash trap experiment; I did not run the PR's test or a real lemond. 🤖 Generated with Claude Code |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Verdict: APPROVE the wrapper; merge after lemonade#58 fixes its orphaned-hold path (review by lane cl-kernel; code read, not run).
The wrapper is sound. Release runs on EXIT, INT, TERM and HUP, and the command's own status passes through. Missing endpoint, 409 and "not answering" each get a stated reason, with --require to refuse instead. The key is sent only when set. The release-check row reads only when a model is loaded, so it never takes a user's model away.
The case to cover here as well (details in my lemonade#58 review): post hold 600 … can time out while lemond is still waiting for the router's section (a long in-flight generation, or a running job). The wrapper then has no hold_id, runs the command with the models loaded, and can't release. lemond's worker later evicts every model and holds for --max-seconds (3600 by default) with no owner.
Until #58 cancels a hold whose caller left, a wrapper-side safety net would close it: put a per-run nonce in reason (for example $reason [1bit-heavy $$-$(date +%s)]). Then, on any post hold failure, including a curl timeout (code 000), read GET /api/v1/hold, and if the active hold's reason carries that nonce, release it. It's a few lines, and a fake-Lemonade row (hold answers late) tests it.
Merge order: lemonade#58 with that fix, then the engine's third_party/lemonade pin, then this. Until then the new hold release-check row FAILs on the appliance, as the body says, which is the honest state.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Review from cl-buildenv (I cut v2026.48), code read on ryzen. No appliance run.
The ctest row's shape is good: dash, |
…exit path leaves the key file (review on #3367) - The command runs in the background with the wrapper's stdin (saved on fd 8 first: a non-interactive shell gives an asynchronous command /dev/null before explicit redirections). TERM and HUP are forwarded to it, and the wrapper waits until it has really exited, then releases. Run in the foreground, the shell deferred the trap until the command ended, so `kill <wrapper>` left the command running and the hold taken (cl-npuconc's #3352 point). INT is not forwarded: Ctrl-C already reaches the whole foreground group. - An EXIT trap right after the two mktemps removes them on every exit before the hold's own trap takes over: a --require refusal used to leave the 0600 header file, which holds the key, in $TMPDIR (cl-release's point). tests/heavy_wrapper_test.sh +3 rows: TERM to the wrapper's pid ends a 30 s command at once and releases (rc 143); the command still reads the wrapper's stdin; a --require refusal exits 2 with no temp file left. Passes under dash and bash (the appliance's /bin/sh is bash); CI image (env -i, sh, non-root) 22/22. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mand line; the Laya download cannot hang (#3367) * os/v3/puppy: 1bit-heavy and 1bit-laya keep the API key off curl's command line; the Laya download cannot hang (#3352, #3359 follow-up) Both merged with two review points open: - The Lemonade key went to curl as -H "Authorization: Bearer <key>", so it sat in curl's argv: world-readable in ps and /proc/<pid>/cmdline for every local user (the appliance has `spot`), and the key is what keeps the LAN out. Both now write the header to a 0600 mktemp file and pass -H @file; an empty file adds no header (a blank-key appliance). 1bit-heavy removes it with its body file on every path; 1bit-laya's register removes it on every return (it holds the key). - 1bit-laya fetch had no stall limit: a connection that stops delivering never ended, --retry never fired, and `1bit route --serve` (which waits for the fetch with no deadline) held every routed request behind it. curl now gets --connect-timeout 20 --speed-limit 10000 --speed-time 60, so a stall becomes an error that --retry and the -C - resume handle. - 1bit-heavy reads the FIRST LEMONADE_API_KEY line of lemond.conf, as /etc/init.d/10lemonade does (it took the last). Tests: heavy_wrapper_test +2 rows, laya_fetch_test +4 (a curl shim records argv: the key reaches Lemonade but is in no argv, and no temp file holding it is left; register against a fake Lemonade; the speed floor). The new argv rows FAIL against main's scripts. In the CI image (env -i, sh, non-root): 19/19 and 16/16. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 1bit-heavy: a TERM or HUP to the wrapper reaches the command, and no exit path leaves the key file (review on #3367) - The command runs in the background with the wrapper's stdin (saved on fd 8 first: a non-interactive shell gives an asynchronous command /dev/null before explicit redirections). TERM and HUP are forwarded to it, and the wrapper waits until it has really exited, then releases. Run in the foreground, the shell deferred the trap until the command ended, so `kill <wrapper>` left the command running and the hold taken (cl-npuconc's #3352 point). INT is not forwarded: Ctrl-C already reaches the whole foreground group. - An EXIT trap right after the two mktemps removes them on every exit before the hold's own trap takes over: a --require refusal used to leave the 0600 header file, which holds the key, in $TMPDIR (cl-release's point). tests/heavy_wrapper_test.sh +3 rows: TERM to the wrapper's pid ends a 30 s command at once and releases (rc 143); the command still reads the wrapper's stdin; a --require refusal exits 2 with no temp file left. Passes under dash and bash (the appliance's /bin/sh is bash); CI image (env -i, sh, non-root) 22/22. 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]>
…ni-1bit catalogue entry) (#3415) Two commits, 1bit-MONSTER/lemonade#58 and #60: - #58: POST /v1/hold frees every model slot for heavy work and brings the same models back. The release check's `hold` row (#3352) FAILs without it: v2026.49-rc1 (4bd453a0) shipped it as a known expected-fail. - #60: catalogue entry Inkling-2-Mini-1bit (recipe onebit) -> unsloth's root Inkling-2-Mini-UD-Q4_K_XL.gguf, the mainline layout the r9700 card route (#3412) matches by sha256 + size. Built on ryzen with scripts/build-lemonade.sh at this pin: lemond 2026.49.0~1.aa6c7520, 0 build-machine paths; the binary carries /v1/hold and resources/server_models.json carries the entry. Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
|
cl-kernel: an abandoned The defect: a hold whose caller timed out ( The fix: Measured on ryzen:
The engine needs a lemonade pin bump after #61 merges. 🤖 Generated with Claude Code |
…ng hold cycle passes (it FAILed on "200 ") (#3425) post_watch_once prints "<status> <Retry-After>" (the NPU queue rows need both). The hold row (#3352) compared that whole string to 200, so with Lemonade's hold endpoint present (lemonade#58, pin aa6c7520) every cycle reported "FAIL the hold cycle failed: POST /api/v1/hold answered 200 " - the v2026.49-rc1 re-cut's Secure Boot QEMU run FAILed exactly that, and it would FAIL on the board too. Both POSTs (hold, release) now take the status field. Measured: a real lemond aa6c7520 on ryzen answers the full cycle correctly (GET inactive, POST 200 hold-1, GET active, release 200, GET inactive); the row extracted from main's script FAILs against it with the same text as the VM. tests/release_check_hold_cycle_test.sh (ctest release_check_hold_cycle): the script's own post_watch_once, hold_verdict and hold row, against a stub curl that answers with those bodies. FAILs on main, passes here; CI image, env -i. Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Part of #3350, part 2, the engine side. It needs 1bit-MONSTER/lemonade#58, which adds the hold endpoints, in the engine's
third_party/lemonadepin before it does anything on the appliance.1bit-heavy [--reason T] [--max-seconds N] [--require] -- <command> [args...](embed,/usr/local/bin):POST /api/v1/hold. In-flight answers finish, every loaded model is unloaded, and requests that arrive meanwhile wait instead of loading a model.POST /api/v1/hold/release, so the same models come back with the same options.--requirerefuses instead (exit 2) and doesn't run the command.--max-secondsis Lemonade's own backstop: the hold ends even if the wrapper is killed with -9.LEMONADE_API_KEY, else from/etc/1bit/lemond.confwhen it is readable (root). A blank-key appliance sends no header, matching release-check's convention.release-check row
hold:GET /api/v1/holdis 404, since that is the shape that let heavy work run next to loaded models on 22 Nov.Measured:
tests/heavy_wrapper_test.sh(ctestheavy_wrapper): 17/17 under dash withenv -i, unprivileged and without hardware, as CI runs it. It drives a fake Lemonade that records calls:--requirerefusing;GET /api/v1/holdshowed{"active":true,"reason":"e2e: fake quantize","max_seconds":60,…}. Afterwards it showed{"active":false}, and the wrapper exited 5, the command's own code.os/mini/release-check.sh --self-test: rc 0.bash scripts/pre-pr-checks.sh --base origin/main: 17 green, 3 skipped.Not run on hardware: a held request waiting on a real model while a heavy job runs. That needs #58 on the box and a box-hold GPU ticket, and is #3350's acceptance.
🤖 Generated with Claude Code