Repository navigation
fix(init): pull built-in NPU/FLM model by name, not recipe (#1655) - #1658
Conversation
gaia init --profile npu failed at the download step with HTTP 400: Lemonade rejects a /pull call that carries a recipe unless the model name uses the user. prefix — that rule is for registering new user models. But gemma4-it-e2b-FLM is a built-in Lemonade model, so passing recipe=flm was wrong; it should be pulled by name. Switch the download path to ensure_model_downloaded (pull by name), which also pre-checks for an already-downloaded model. The recipe is baked into the built-in model and applied at load time, so NPU inference is unaffected.
SummaryThis is a tight, correct fix for a broken setup path: Issues Found🟢 Minor — display label still advertises The (If you'd rather keep it as an at-a-glance hint of how the model loads, leaving it is fine too — just flagging the mismatch.) Strengths
VerdictApprove. No blocking issues. The lone minor note (the |
…aths #1655 shipped because every test ran against a warm model cache and mocked the Lemonade client, so the fresh-pull 400 never surfaced. Add a Testing Philosophy rule covering the two failure modes — test setup/download paths from a cold state (runtime-verified != setup-verified), and assert external API call shape rather than trusting a mocked 200 — with #1655 as the canonical example.
The cold-state and call-validity rules apply to any change, not just setup/download paths. Reframe around the two underlying failure modes — hidden-state masking (empty cache/DB/session, first run, expired token, zero results) and mocks asserting invocation rather than validity (any HTTP/subprocess/SQL/IPC/file boundary) — with #1655 kept as the canonical example of both.
|
🟡 After the fix, …which implies the recipe is being applied during the pull — the exact bug this PR just fixed. The dead read + misleading display should be removed together: (Drop the |
Real-world verification on NPU hardware ✅Reproduced the bug and confirmed the fix end-to-end on AMD Ryzen AI MAX+ 395 (Strix Halo), Ubuntu 24.04, XDNA NPU ( 1. Root cause at the API layer 2. Pre-fix init flow ( 3. Post-fix init flow (this PR, 4. NPU inference confirmed (not a CPU/llama.cpp fallback): chat completion returns correctly via the FastFlowLM backend ( Note: post-fix still prints the cosmetic One unrelated observation: the Agent UI frontend build failed during init because the test box has Node.js 18 (Vite needs 20+). Pre-existing environment limitation, independent of this fix — init still completed (exit 0). |
Why this matters
gaia init --profile npuwas dead on arrival: it failed at the model-download step withHTTP 400before any NPU user could get set up (#1655). The init flow pulledgemma4-it-e2b-FLMwithrecipe=flm, but Lemonade only allows arecipe/checkpointon/pullwhen registering a new user model (which must carry auser.prefix).gemma4-it-e2b-FLMis a built-in Lemonade model, so it must be pulled by name only. After this fix the NPU profile downloads, verifies, and runs inference on the NPU.Root cause was a wrong assumption added in #1252 that FLM models need their recipe at pull time. They don't — the recipe is baked into the built-in model and applied at load time. The fix routes the download through
ensure_model_downloaded(pull by name, with an already-downloaded pre-check), same as every other profile.This PR also adds a CLAUDE.md testing rule so the class of bug can't recur silently: #1655 passed every test only because they ran against a warm model cache and a mocked client, so the fresh-pull 400 never surfaced. The rule requires (1) testing setup/download paths from a cold state — runtime-verified ≠ setup-verified — and (2) asserting external-API call shape rather than trusting a mocked
200.Test plan
Validated on real XDNA2 hardware (AMD Ryzen AI MAX+ PRO 395, FLM npu backend v0.9.39, Lemonade 10.4.0):
POST /pull {"model_name":"gemma4-it-e2b-FLM","recipe":"flm"}→400 ... must include the user. prefix; withoutrecipe→200 {"status":"success"}.gaia init --profile npu --yes --force-models— model is deleted then re-pulled successfully (no 400) and passes inference verification (gemma4-it-e2b-FLM - OK (ctx: 4096)).gemma4-it-e2b-FLMreturns correctly with the model loaded ondevice: npu, recipe: flm; the UI device resolver mapsnpu → gemma4-it-e2b-FLM (ctx 4096).test_npu_profile_pulls_builtin_model_without_recipe) — regression guard that the npu profile pulls by name and never callspull_model(recipe=...). FullTestDownloadModelssuite green.Fixes #1655