Repository navigation
serve: the save-area trio belongs in the printed plan, or Lemonade never gets it (engine#715) - #816
Conversation
…ver gets it (engine#715) b5cbe2f (#794) made `auto` place the CWSR save area in GTT and put the trio into serve's *own* environment, so every child serve starts inherits it. That closed engine#715 for serve's own backends, but not for the two spawn paths that start the backend from what serve *prints*: Lemonade's one hop (the JSON `env` of --print-backend) and scripts/lemonade-hrx (the NAME=VALUE lines of --print-backend-env). Cause: both build their env from l.env, which does carry the trio (app/serve.cpp:1032, 1207, 1728), through a filter that leaves out every variable already present in serve's environment ("a value the caller set wins", app/serve.cpp:1561-1566). apply_cwsr_env_to_self runs earlier (main, ~2841) and exports the trio to ourselves, so by the time the plan is built getenv() finds it and the filter drops it. Measured on the 2026-11-01b package's own 1bit (amdgpu cwsr_enable=0), trio unset in the caller: $ 1bit serve -m Qwen3-0.6B-Q4_K_M.gguf --device hrx --print-backend-env GGML_HRX_REPORT=1 GGML_HRX_STRICT=1 IREE_HAL_AMDGPU_LIBHSA_PATH=.../libhsa-runtime64.so.1 <- no trio # stderr: HRX: CWSR save area placed in GTT by default (engine#315; amdgpu cwsr_enable=0; ...) Same for the plan's env, same with --hrx-cwsr-placement=on, and the shipped launcher exports nothing, so both Lemonade paths ran the backend without the variables that keep ROCr from page-faulting on the first graph replay -- the configuration engine#715 is about. Fix: do not self-export in the print modes. They start no backend here; the caller starts it from the plan, and the same filter still lets a value the caller set win. tests/print_backend.sh and tests/lemonade_hrx.sh now assert the trio in both outputs (and the HRX_SVM=1 opt-out). On the shipped binary those four assertions fail today; with this change the plan carries HSA_USE_SVM=0 HSA_USERPTR_FOR_PAGED_MEM=0 HRX_ALLOW_NO_SVM=1.
PR Reviewer Guide 🔍(Review updated until commit 4ec1837)Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 84c1d0f (tprs-ready applied)
The red half reproduces exactly, on the shipped package and its own binary. Extracted
work/out/lemonade-onebit-rc-2026-11-01b-linux-x86_64.tar.zst to /var/tmp and ran both test files from this head
against …/1bit/1bit:
tests/print_backend.sh -> 3 FAIL, everything else ok
FAIL hrx plan: the save-area trio is in env (exit 0)
FAIL --print-backend-env: the trio as NAME=VALUE lines (exit 0)
FAIL hrx plan: a trio value the caller set is left out, the other two still arrive (exit 0)
ok hrx plan: HRX_SVM=1 keeps the trio out of the plan too (exit 0)
… 27 further assertions ok, including the three GGML_HRX_STRICT ones and the whole MTP/warmup set
tests/lemonade_hrx.sh -> 1 FAIL, everything else ok
FAIL the save-area trio reaches the exec'd llama-server (engine#715)
… 9 assertions ok, including `GGML_HRX_STRICT=1 from 1bit serve`
So the four new assertions are the only red, on the binary that ships, and the surrounding suite is green on the same
binary — the harness is not the reason they fail.
The mechanism, read in the code rather than trusted:
--print-backend-envsetso.print_backendas well (app/serve.cpp:2801), so one condition covers both print modes.- the plan does carry the trio from the decision, not from the environment:
hrx_cwsr_env(o)→l.env
(:1032,:1207,:1728). - the filter that drops it is
if (!std::getenv(key.c_str())) env[key] = …(:1561-1566), and the self-export ran at
:2841— before the plan was built. Skipping the export in print mode is therefore the whole bug and the whole fix. - nothing else in the print path reads
HSA_USE_SVM/HSA_USERPTR_FOR_PAGED_MEM/HRX_ALLOW_NO_SVM
(grepoverapp/,npu/,tools/: only the help text,app/hrx_cwsr.h's own definitions, and two scripts), so
no other behaviour depended on serve having exported them to itself. - the deliberate-opt-out refusal stays where it was (
:2828, before the changed line) and still throws for
--hrx-cwsr-placement=off/HRX_SVM=1withoutONEBIT_HRX_NO_TRIO_OK=1, and the announce line is still the
stored decision (#813'shrx_cwsr_decision()), so nothing about that message changes.
What I did not reproduce: the green half. It needs an ONEBIT_HRX=ON 1bit and this box is at 88 °C with another
lane's llama-bench holding all eight cores — my configure froze immediately under thermal-run earlier today and a
previous attempt of mine was killed at 93 °C. I also did not copy another lane's build tree, for the reason your body
already gives. So the four green lines are not mine; they are the release build's ctest (print_backend and
lemonade_hrx are exactly the two scripts the candidate gate runs, which is how c20 caught hrx_cwsr_route), and that
gate is downstream of this merge either way. Residual risk is confined to the two print modes: 30 of the 34 assertions
above are green pre-patch and would have to stay green, and the one assertion that guards the "a value the caller set
still wins" rule is red today for the right reason.
Nothing else in the diff to object to: app/serve.cpp is +8/−1 with the reason inline, the two test files are where the
suite already lives, and both new blocks skip cleanly on a build whose hrx-system has no HRX_ALLOW_NO_SVM gate
(the no HRX_ALLOW_NO_SVM gate stderr idiom tests/hrx_cwsr_route.sh already uses).
|
Persistent review updated to latest commit 87c6cbf |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 87c6cbff6 (post-update-branch head; tprs-ready already on)
87c6cbf merges main 1346398 (#820) into fix/print-backend-cwsr-trio. Checked at the new head:
- the change is the same bytes: own diff is still
app/serve.cpp(+8/−1),tests/print_backend.sh(+33),
tests/lemonade_hrx.sh(+12), and all three files are byte-identical to the head I reviewed (84c1d0f); - re-ran both scripts at this head against the shipped c20 binary
(lemonade-onebit-rc-2026-11-01b/1bit/1bit): 36 assertionsokand exactly the four intended reds —
hrx plan: the save-area trio is in env,--print-backend-env: the trio as NAME=VALUE lines,hrx plan: a trio value the caller set is left out, the other two still arrive,the save-area trio reaches the exec'd llama-server (engine#715). The surrounding suite is green on the same binary, so the harness is not why they fail; - CI on this head:
build,CodeQL, all fourAnalyzejobs andpr_agentsuccess,hw_gateskipped.
The one thing that is still not mine, unchanged from my first verdict: the green half needs an ONEBIT_HRX=ON
1bit, which the candidate gate's own ctest (print_backend, lemonade_hrx) is what runs — so it lands one gate
downstream of this merge, exactly as hrx_cwsr_route did for c20.
|
Persistent review updated to latest commit b8656f1 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at b8656f1b2 (re-updated head, merges main a914271; tprs-ready already on)
Second head on this PR, content unchanged and re-checked:
- own diff is still
app/serve.cpp(+8/−1),tests/print_backend.sh(+33),tests/lemonade_hrx.sh(+12), and all
three files are byte-identical to the head I reviewed (84c1d0f); - re-ran both scripts at this head against the shipped c20 binary: 36 assertions
okplus exactly the four
intended reds (the save-area trio is in env,--print-backend-env: the trio as NAME=VALUE lines,a trio value the caller set is left out, the other two still arrive,the save-area trio reaches the exec'd llama-server); - CI on this head:
build,CodeQL, all fourAnalyzejobs andpr_agentsuccess,hw_gateskipped;
mergeable_state=clean.
Unchanged caveat, so it is not lost in the merge: the green half of these tests needs an ONEBIT_HRX=ON 1bit and is
run by the candidate gate's own ctest (print_backend, lemonade_hrx) one gate downstream — the same place c20's
hrx_cwsr_route red was caught.
|
Persistent review updated to latest commit 4ec1837 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 4ec1837cf (head after #815 merged; tprs-ready already on)
4ec1837 merges main 193ab12 (#815). Third head, same content, re-checked at it:
- own diff is still
app/serve.cpp(+8/−1),tests/print_backend.sh(+33),tests/lemonade_hrx.sh(+12); all three
files byte-identical to the head I reviewed (84c1d0f); - both scripts against the shipped c20 binary at this head: 36 assertions
ok, four intended reds
(the save-area trio is in env,--print-backend-env: the trio as NAME=VALUE lines,a trio value the caller set is left out, the other two still arrive,the save-area trio reaches the exec'd llama-server); - CI:
build,CodeQL, fourAnalyze,pr_agentsuccess (284 s),hw_gateskipped;mergeable_state=clean.
The green half is still the candidate gate's ctest (print_backend, lemonade_hrx), not mine — unchanged caveat,
unchanged location.
…s backend (engine#715, #816) (#825) The trio is only in serve's printed plan, so a grep on --print-backend-env is the whole check. Both packages on the box today print 0, for two different reasons: rc-2026-10-31c predates #794/#813 (its log still says the placement is unchanged) and rc-2026-11-01b exports the trio into serve's own environment before building the plan, which is what #816 fixes. Co-authored-by: bong-water-water-bong <[email protected]>
…ard boots (trio check 1; suite exit 0) (#946) * docs/lemonade: the save-area trio check passes on the release after #816 (1, was 0) The paragraph's own check (print the backend env with the trio unset in the shell and grep for HRX_ALLOW_NO_SVM=1) ended at c20, where it printed 0 because serve exported the trio into its own environment before building the plan and the plan's env filter keeps only names the caller does not already have -- the bug #816 removes. Measured on Strix Halo, shipped lemonade-onebit-rc-2026-11-03-c22 (engine 98fb79d5, i.e. built after #816 merged), amdgpu cwsr_enable=0, trio unset in the caller: --print-backend-env -> HRX_ALLOW_NO_SVM=1, HSA_USERPTR_FOR_PAGED_MEM=0, HSA_USE_SVM=0 (grep -c = 1) --print-backend plan.env -> the same three, plus GGML_HRX_STRICT=1/REPORT=1, IREE_HAL_AMDGPU_LIBHSA_PATH caller GGML_HRX_STRICT=0 -> that line disappears, the other two still arrive (the filter still works) and the one-hop path end to end: the shipped lemond-onebit launcher (trio not exported by it) started llama-server pid 62493 on HRX0, whose /proc/<pid>/environ carries all three: HRX_ALLOW_NO_SVM=1, HSA_USERPTR_FOR_PAGED_MEM=0, HSA_USE_SVM=0 (it served 48 completion tokens). Doc-only; no code, no catalogue, no pin change. * docs/lemonade: the embedding checklist's HRX row is the package the board boots Re-ran the suite the row cites on the shipped lemonade-onebit-rc-2026-11-03-c22 payload (engine 98fb79d5, the same tarball cycle 20 booted), lemond started through its own lemond-onebit launcher on an isolated cache/config, nothing exported in the caller: test/server_llm.py --wrapped-server onebit --backend hrx -> exit status 0, 104 s The two skips are the declared capability gaps, unchanged in test/utils/capabilities.py for the onebit recipe (echo_parameter: False, generation_parameters: False). Every backend was the package's own 1bit/hrx/llama/bin/llama-server in the one-hop path (23 'one hop' starts) and HRX0 initialised (10 ggml_hrx HRX0 lines, e.g. 'HRX0 guardrail: GTT total 120.0 GiB, in use 31.7 GiB, ceiling 104.0 GiB'), so the row is not a CPU-stand-in measurement. The row keeps the same 29/29 + 2-skip shape; only the package and date move, because a reader asking 'does this hold on what ships' should not have to date-check a week-old tarball. Doc-only. --------- Co-authored-by: bong-water-water-bong <[email protected]>
What this fixes
b5cbe2f(#794) closed engine#715 for serve's own backends:autonow places the CWSR save area in GTT andapply_cwsr_env_to_selfputsHSA_USE_SVM=0 HSA_USERPTR_FOR_PAGED_MEM=0 HRX_ALLOW_NO_SVM=1into serve's ownenvironment, so every child it spawns inherits the trio.
It does not reach the two spawn paths that start the backend from what serve prints:
LEMONADE_ONEBIT_ONE_HOP, the default)1bit serve --print-backend→ the JSONenv, which lemond uses to startllama-serverllamacpp-hrxrecipe /scripts/lemonade-hrx1bit serve --print-backend-env→export "${kv}"→ execllama-serverBoth take their variables from
l.env, which does carry the trio (app/serve.cpp:1032,:1207,:1728), through afilter that leaves out every name already present in serve's environment — “a value the caller set wins”
(
app/serve.cpp:1561-1566).apply_cwsr_env_to_selfruns earlier, inmain(~:2841), so by the time the plan isbuilt
getenv()finds the trio and the filter drops it.Net: with the shipped launcher (which exports nothing) the backend runs without the trio — the exact
configuration #715 says page-faults on this box's nightly libhsa.
Measured end to end on hardware, same package,
lemonade-onebit-rc-2026-11-01b/lemond-onebitstarted with the trioexplicitly unset, one chat on
Qwen3-0.6B-1bit(0.6B,gpu-hold):i.e. the process that initialises HRX0 gets the strict/report pair from the plan and nothing else.
Measured on the shipped binary (not a reading of the code)
~/wt/release-rc/work/out/lemonade-onebit-rc-2026-11-01b-linux-x86_64.tar.zst→ its own1bitandbin/lemond(
2026.46.0~1.ef0f3b49),amdgpu cwsr_enable=0, trio unset in the caller (env -u HSA_USE_SVM -u HSA_USERPTR_FOR_PAGED_MEM -u HRX_ALLOW_NO_SVM -u HRX_SVM):Same for the JSON plan's
env; same with--hrx-cwsr-placement=on; and the filter itself is behavioural, notinferred —
GGML_HRX_STRICT=0in the caller's environment makes theGGML_HRX_STRICT=1line disappear from theprinted env, which is the same rule that swallows the trio.
The change
One condition, plus the reason for it in a comment:
The print modes start no backend here — they hand the plan to the caller — so there is nothing to inherit from. A
value the caller set still wins through the unchanged filter below.
Tests (red today, green with this change)
tests/print_backend.sh— 4 assertions: the trio is in the plan'senv; the same three asNAME=VALUElines from--print-backend-env; a trio value the caller set is left out while the other two still arrive;HRX_SVM=1keepsthe trio out of the plan too.
tests/lemonade_hrx.sh— 1 assertion: thellama-serverthe wrapper execs has the trio in its environment(the test's stand-in records
env), i.e. the end of the path #715 is about.Both are gated on the build having the
HRX_ALLOW_NO_SVMgate (detected from serve's own “no HRX_ALLOW_NO_SVM gate”line, the idiom
tests/hrx_cwsr_route.shalready uses), so a stub build prints the note and skips.Against the shipped (unpatched) binary on this box:
while the same two test files at
origin/mainare otherwise green on that binary (print_backend.shrc=0,lemonade_hrx.shrc=0), so the new assertions are the only red.Not run here, and why: the green half needs an
ONEBIT_HRX=ON1bit. I tried to build one out of anotherlane's idle c20 tree (copy
~/wt/hl-engine+hl-engine-build-c20, move the copy toorigin/main, age the sourcesso ninja reuses the object files):
ABORT at 93C, whole-box Tctl, four minutes of79-85 C pauses) while it was still copying;
llama_hrxexternal project: itreconfigures its nested tree in a copy and the HRX HIP kernel objects rebuild without the ROCm device library
(
clang++: error: cannot find ROCm device library …) — the flag the original c20 build had is not in the copiedcache, so that path became a full llama.cpp + loom rebuild (2745 steps) instead of a relink.
What I did verify by compiling:
app/serve.cppat this commit builds clean with CI's own command(
g++-16 … -fsyntax-only, exit 0, no diagnostics), so the change is a compile-time non-event; only the two shelltests need the linked binary.
Both copies are deleted; nothing of another lane's tree was written to. So the green half stays with a build that has
the release's own environment — the release build's ctest runs exactly these two scripts, which is how
c20's gatecaught
hrx_cwsr_route. If you want it measured before then, a rebuild on an idle box withONEBIT_HRX=ONand theTheRock env is all it takes (
ctest -R "print_backend|lemonade_hrx"), and I will hold the window.Blast radius
--print-backend/--print-backend-envare Lemonade-facing only (docs/serve.md, “One hop from Lemonade”;docs/lemonade.md). Serve's own launch path is untouched: it still exports the trio to itself, so its children are
unchanged, and the announce line still prints exactly once (
tests/hrx_cwsr_route.shkeeps asserting that).