Repository navigation
fix(tui): read the setup plan's NPU verdict in preflight (#6698) - #7124
Conversation
|
Recording a scope decision for review, not a request to change this PR. This line shows the setup plan's On guidance specifically, the server already chooses between those memlock cases itself. The question for reviewers: is guidance parity at the level of the sentence expected here, or is showing the server's English text enough? If the former, the change would be code-aware handling for The acceptance check on real Linux hardware is unaffected either way, and remains outstanding. |
50c615b to
d7b0a14
Compare
|
Verdict: Request changes The TUI's first-run screen now tells apart three NPU cases that used to look the same: no NPU, an NPU that isn't set up yet (with the server's own reason), and a status that couldn't be read. The four-way logic is right and well tested. The problem is how the NPU status is fetched.
Real-world evidenceN/A: no evidence bundle was produced for this run. The change is the Go TUI's first-run screen, and the PR marks every evidence surface N/A and says end-to-end Linux verification hasn't been done. This verdict rests on static review alone. I ran 🔍 Technical details🟡 The NPU read starts the daemon, runs on every check and has a 3 s budget (
Suggested shape: read the verdict only for an FLM model, attach-only: chat, ok := gaiainit.Status{Models: models}.Chat()
var npu setupapi.NPU
known := false
if strings.HasSuffix(strings.ToLower(chat.ID), "-flm") {
npu, known = readNPUVerdict(ctx)
}
return fitLine(capacity, npu, known, chat, ok)Then use 🟢 The plan can itself report "absent" without observing it ( Strengths
|
|
Thanks for turning the review around so cleanly. The probe now attaches to a running daemon instead of starting one, runs only for NPU models, and an unreadable plan keeps the memory verdict with a plain "could not be checked" caveat, so a working NPU no longer loses its "fits" line on a cold first run. Every point in the review is addressed on this head, and tests and lint pass. Suggested order for the three #6698 PRs: #7122 and this one (independent, no conflicts), then #7125 after it drops its copy of the 🔍 Technical details
|
|
One gap left before merge: a GAIA daemon older than v0.25.4 makes an NPU model read as "Lemonade reports none on this PC", even on a PC whose NPU is working. That is the unobserved-absence claim this PR sets out to remove, and before this change the same PC got a memory "fits" verdict. Suggested fix: treat a plan with no 🔍 Technical details
|
…#7122) ## Summary The TUI's setup picker no longer offers an NPU model as a chat choice on a PC that can't run it: the row is hard-blocked, shows the server's reason, and its caption stops claiming the model runs on the NPU. ## Why On a PC whose NPU is absent or not set up, the picker listed the FLM model as a normal chat option and let the user tick it. The download then failed, because Lemonade's `ensure_npu_backend` refuses the pull before any bytes move. The backend already knew: it marks the entry `fits: false` with `fit_code: "npu"` and the reason in `fit_reason`. The TUI dropped `fit_code`, and every warning path in the picker required both memory numbers, which the NPU verdict leaves empty: so the row got a bare "won't fit" chip and stayed selectable. This is the picker's share of amd#6698. It is not the whole issue; see "Scope" below. ## Linked issue Refs amd#6698 ## Changes - `setupapi.CatalogEntry` carries `FitCode`, `fit_code`, the machine-readable reason the backend already sends alongside `fit_reason`. - A row with `fits: false` and `fit_code: "npu"` is hard-blocked rather than acknowledgement-gated, because nothing on this PC can pull it. Memory shortfalls (`fit_code: "memory"`) keep the existing confirm-and-continue path, which can still download a model. `backend` fit is untouched. - The block covers every route to the chat model. `canChat` was not enough on its own: first-run mode picks chat through `pickChat`, and an installed row's toggle sets the chat model directly. Both are now guarded, and `pending()` keeps a blocked model out of the download set even when the plan delivered it ticked. - The blocked row shows the server's `fit_reason` as its own clause: the first letter is capitalised, a final full stop is removed even inside a closing parenthesis, and exactly one stop is appended. The backend's "this Lemonade cannot run flm models" reason no longer reads "it this". - The blocked row's job caption reads "Requires a Ryzen AI NPU that is ready on this PC." instead of implying the model currently runs. - The recommendation star is suppressed on blocked rows. ## Test plan - [x] `gofmt -l .` in `tui/`: no output - [x] `go vet ./...` in `tui/`: exit 0 - [x] `go test ./... -count=1 -race -timeout=15m` in `tui/`: all 29 packages passed on head `99e6dd229` - [x] `golangci-lint run` at v2.12.2 with `GOOS=linux` (as the Lint job runs it): 0 issues on head `c735e789`; not rerun on `99e6dd229` because it is not installed in this environment, so CI's Lint job is the check for the new head Seven tests added in `tui/internal/ui/modelsetup/flow_test.go`, plus fixtures in `helpers_test.go`: - `TestUnreadyNPUModelIsBlockedNotAcknowledged`: chip shown, star suppressed, no memory warning invented - `TestUnreadyNPUModelShowsEachReasonVerbatim`: four server reasons (no NPU, NPU not set up, backend cannot run FLM, and a driver message already ending in a stop) render as a clause with exactly one full stop - `TestUnreadyNPUModelCaptionDoesNotSayItRuns`: caption wording - `TestUnreadyNPUModelIsNeverTheChatModel`: not a chat candidate, and space on an installed row does not make it the chat model - `TestUnreadyNPUModelCannotEnterTheDownloadSet`: space cannot tick it, and it stays out of `pending()` when the plan delivered it already ticked - `TestCloudPickerUnaffectedByNPUBlock`: cloud chat candidates unchanged - `TestMemoryUnfitModelStillAsksAndCanBeConfirmed`: the memory acknowledgement path is unchanged ## Evidence - [ ] **Agent exposed in the Agent UI** (Chat, Email, ...): N/A, no Agent UI change. - [ ] **MCP tools / servers**: N/A, no MCP change. - [x] **CLI**: the setup picker rendered from a stubbed setup plan, both NPU cases: ``` ===== NPU present, not ready (focus on gemma4-it-e2b-FLM) ===== Choose your models step 2 of 2 · part 1 of 3 ──────────────────────────────────────────────────────────────────────────── Chat (•) Gemma-4-E4B-it Verified 6.0 GB * recommended ( ) Qwen3.6-35B-A3B Verified 23.3 GB [!] won't fit [ ] Already in Lemonade (press l to hide) > ( ) gemma4-it-e2b-FLM Untested on PC [!] won't fit NPU Requires a Ryzen AI NPU that is ready on this PC. [!] This model can't be used on this PC: Needs this PC's NPU set up first: Locked-memory limit is too low. Raise the limit. ===== No NPU on this PC (focus on gemma4-it-e2b-FLM) ===== > ( ) gemma4-it-e2b-FLM Untested on PC [!] won't fit NPU Requires a Ryzen AI NPU that is ready on this PC. [!] This model can't be used on this PC: Runs on a Ryzen AI NPU, and Lemonade reports none on this PC. ``` **Not validated on real NPU hardware.** This was developed on macOS, which has no Ryzen AI NPU and no Lemonade server, so the picker was driven against the stub plan in `setupapi/setupapitest` rather than a live Linux NPU machine. A maintainer should confirm the messages on a Linux PC with an NPU before relying on them. - [ ] **HTTP API / REST**, N/A, no endpoint changed. ## Scope This PR fixes the setup model picker only. amd#6698 also names `Capacity.NPU()` (`tui/internal/lemonade/capacity.go`), the local catalog judge (`tui/internal/lemonade/catalog.go`) and the chat preflight (`tui/internal/ui/preflight/chat.go`). Those surfaces still judge an FLM model by memory alone in `main`, but separate PRs now address them: amd#7124 changes the preflight and amd#7125 changes the local catalog. This PR does not touch them, so amd#6698 is not closed here. ## Checklist - [x] I have linked a GitHub issue above (`Refs amd#6698`). - [x] I have described **why** this change is being made, not just what changed. - [ ] I have run linting and tests locally (`python util/lint.py --all`, `pytest tests/unit/`): N/A, this PR changes no Python. The Go gates are in the test plan. - [x] I have attached **real-world evidence matched to the surface I changed**, or marked each surface N/A. - [ ] I have updated documentation if user-visible behavior changed: N/A, the picker's copy is self-describing and no docs describe the old behaviour. --------- Signed-off-by: Niladri Das <[email protected]>
…reflight could only judge an NPU chat model from Lemonade's capacity report, which carries no NPU state at all, so a PC whose NPU was absent and one whose NPU was there but not set up read the same. The daemon's setup plan already answers this in its `npu` field, with the same checks `npu_linux.py` applies, but the TUI's setup client never decoded it. The chat line now reads that verdict, and keeps four states apart that were previously two: an unread plan says the NPU could not be checked, an absent one says Lemonade reports none, one that is present but not ready shows the server's own reason and fix, and a ready one is judged on NPU memory as before. The unreadable case has its own flag rather than a zero struct, because a plan that failed to load is not evidence that the PC has no NPU, and the line must not claim absence it did not observe. The same confusion turned up one branch later: a plan that called the NPU ready plus a capacity report with no NPU memory used to print "reports none on this PC", contradicting the plan it had just read, and now says the memory figure is missing instead. This is the preflight half of the issue; the picker is fixed in amd#7122. Refs amd#6698 Signed-off-by: Niladri Das <[email protected]>
Preflight read the setup plan for every local model, could start a daemon on a first-run screen, and dropped Lemonade's memory verdict whenever the plan was unreadable. The verdict is now read only for FLM models, through an attach-only daemon constructor, and an unreadable plan keeps the memory fit decision with a readiness caveat. Tests cover the non-FLM skip, the attach-only constructor, and the unreadable-plan memory path. Refs amd#6698 Signed-off-by: Niladri Das <[email protected]>
A daemon before v0.25.4 answers the setup plan without an npu field, and the attach-only client accepts such a daemon. The zero-value verdict made a working NPU read as "Lemonade reports none on this PC". The plan's NPU field is now a pointer, so a missing or null field keeps the readiness answer unknown, and the fit line retains Lemonade's memory verdict with the "could not be checked" caveat. Regression tests decode the old plan shape and check the memory line end to end. Refs amd#6698 Signed-off-by: Niladri Das <[email protected]>
2246577 to
2ceecd5
Compare
…#6698) (amd#7125) ## Summary The local model catalog now judges NPU models by the setup plan's NPU verdict instead of by NPU memory, so a PC with no NPU, one whose NPU is not set up, and one whose setup plan could not be read are told apart rather than collapsed into "no NPU". A downloaded FLM model on an NPU that is known not ready is blocked with the server's reason, while an unreadable plan falls back to the memory verdict and keeps a downloaded model selectable. A confirmed-absent NPU hides the unlisted recommendation instead of showing it as a broken option. An unknown verdict hides that recommendation too when Lemonade reports no NPU memory, because the row could never be selected. With amd#7124 merged, this branch now uses the shared `setupapi.NPU` types and treats a plan without an `npu` field as unknown. ## Why `Capacity.NPU()` reports NPU memory, and the catalog treated a report of none as a PC with no NPU. That figure is zero both for a PC that has no NPU and for one whose NPU Lemonade did not measure, so an unreadable machine produced the same rows, with the same claim of absence, as one known to have none. Two consequences followed: an NPU model could be offered for download on a PC whose NPU cannot run it, and an NPU recommendation was silently dropped when no NPU memory was reported, so the row could not explain itself. The first version of this change also read the plan for cloud providers and let an unreadable plan block a model already on disk; both are corrected here. The setup plan already answers this. This PR carries that answer into the catalog. This is one part of amd#6698. The provider picker and the preflight screen are separate surfaces with separate changes. ## Linked issue Refs amd#6698 This PR does not complete amd#6698. The NPU-less Linux check has not been run (see Outstanding), and the preflight surface landed in amd#7124. ## Changes - `lemonade.NPUVerdict` carries `Present`, `Ready`, `Known` and the server's `Reasons`. `Blocks()` returns a reason only for a known absent or known not-ready verdict; ready and unknown leave the memory rule in charge. - `Catalog` and `BuildEntries` take the verdict as a new parameter, placed before the existing variadic `added`. Existing callers pass it explicitly. - `BuildEntries` checks the verdict before the checks that decide whether a download is needed, because readiness is about the hardware and not the file. Ready keeps the memory rule; present-but-not-ready blocks with the server's own reason and fix; absent keeps the absence line; unknown falls through to memory rather than claiming absence or permission. - `Selectable()` keeps a downloaded model selectable unless a known verdict set `FitUnknown`. That blocks a downloaded FLM model on a known not-ready or known absent NPU, and keeps it selectable when the plan is unknown. - A confirmed-absent NPU hides an unlisted NPU recommendation, because there it is not an option. A not-ready NPU keeps the row so its reason stays visible. An unknown verdict keeps it when NPU memory is reported and leaves it to the memory rule; with no NPU memory, it hides the row as before. - `providers.loadCatalog` reads the plan only for the local provider, through `setupapi.NewAttachedDaemon()`, so a cloud catalog neither reads the plan nor starts a daemon for it. A plan that cannot be read becomes unknown, never absent. - `readNPUVerdictFrom` treats `plan.NPU == nil` as an unknown verdict. A daemon older than v0.25.4 sends no `npu` field, so its plan must not read as a PC without an NPU. - Existing tests that asserted memory-as-presence were updated: the no-NPU recommendation is hidden, the unknown verdict follows memory, and downloaded FLM rows are blocked only by a known verdict. ## Integration with main amd#7124 merged as `43cdaddc`, so this branch merged `main` at `4c5d11bcb` and dropped its duplicate `setupapi.NPU` and `setupapi.NPUProblem` types. The plan's `NPU` is now the shared `*setupapi.NPU`, which is `nil` when the daemon omits the field. The merge keeps main's `OnlyProvenNPU` filter after the verdict-aware catalog build, so the amd#7975 rule still applies to the merged entries. `TestOnlyProvenNPUModelsAreOffered` was updated to pass the verdict parameter. `TestAnOlderPlanWithoutAnNPUFieldLeavesADownloadedFLMModelSelectable` decodes a plan with no `npu` field, asserts the verdict is unknown, and asserts a downloaded FLM model on a PC with enough memory stays selectable. Removing the `plan.NPU == nil` guard makes that test panic, and restoring the guard makes it pass. ## Review follow-up Fixed in `9bae0f1b4`. An unknown NPU verdict now hides an unlisted recommendation when no NPU memory is reported. Unknown verdicts with reported NPU memory still defer to the memory check. Added regression coverage for both missing and unreadable memory. ## Test plan The full local suite passed on the merge head `4c5d11bcb`, and the full CI run passed on `9bae0f1b4` (`TUI Build and Test`, run 43461799707). The review fix on `9bae0f1b4` also passed the focused tests and checks below. - [x] `cd tui && go test ./... -count=1` on head `4c5d11bcb`: every TUI package passed. - [x] `cd tui && go test ./internal/lemonade/... ./internal/ui/providers/... -count=1` on head `9bae0f1b4`: both packages passed. - [x] `cd tui && gofmt -l .` on head `9bae0f1b4`: no output. - [x] `cd tui && go vet ./...` on head `9bae0f1b4`: exit 0 on darwin. - [x] `git diff --check` on head `9bae0f1b4`: clean. - [x] Mutation check on the nil guard: without `plan.NPU == nil` the older-daemon regression panics, and with it restored the test passes. - [x] Mutation check on the new recommendation condition: without it both unknown-verdict cases fail, and with it restored they pass. - [x] `cd tui && go test ./... -count=1 -race -timeout=15m` on head `84952d9a8`, and CI's race-enabled suite on `4c5d11bcb` and `9bae0f1b4`: all TUI packages passed. - [x] golangci-lint v2.12.2 with `GOOS=linux` reported `0 issues` on an earlier head, and CI's Lint job passed on `4c5d11bcb` and `9bae0f1b4`. - [x] `catalog_verdict_test.go` covers ready, known not ready, known absent, and unknown. The unknown cases check a fitting memory report, a tight one, and the downloaded case. - [x] `TestCloudCatalogDoesNotReadTheNPUPlan` counts zero verdict reads for a cloud provider. - [x] `TestAConfirmedAbsentNPUHidesAnUnlistedNPURecommendation` checks the absent case, `TestAnUnlistedNPURecommendationStaysWithItsReason` keeps the not-ready case visible, and `TestAnUnknownVerdictWithNoNPUMemoryHidesTheRecommendation` covers missing and unreadable memory. - [x] `providers/verdict_test.go` checks the plan-to-verdict wiring, that an unreadable plan keeps the memory verdict rather than claiming absence, and that a plan without an `npu` field leaves a downloaded FLM model selectable. ## Evidence - [ ] **Agent exposed in the Agent UI** (Chat, Email, ...) - N/A, this changes the Go TUI's model picker, not the Agent UI. - [ ] **MCP tools / servers** - N/A, no tool surface changed. - [ ] **CLI** - N/A, no subcommand changed. The picker is a TUI view and this was not captured on video. - [ ] **HTTP API / REST** - N/A, the change reads a plan route that already exists; its wire shape is pinned by the existing `tests/unit/test_npu_linux.py::test_plan_reports_npu_problems`. ## Outstanding - **NPU-less Linux end to end verification has not been run.** Every verdict in the tests is a stub. Nothing here shows what the picker displays on a real machine whose NPU is absent, unready, or not measurable. - **The Linux acceptance check, when it runs, should confirm three things:** a PC whose memlock limit is unmet shows the NPU as not ready, with that reason, in the place this PR covers; a PC with no NPU is reported as absent; and a PC whose setup plan cannot be read is reported as unknown, not as absent. Those three are the states this change keeps apart. - **Wording is the server's, not the Agent UI's translation.** The line shows the plan's `title` and `fix` verbatim and does not decode `params`. The Agent UI maps each problem `code` to its own localized sentence, and for `memlock` picks a different one depending on whether the fix is `restart` or `stuck`. The underlying reason is the same; the exact wording is not. Matching the Agent UI's code-aware copy is a decision for review, not a defect in this change. - The verdict is a positional parameter with a safe unknown default. A future caller that omits it silently gets unknown rather than a compile error. That is deliberate for this change and left for a later API cleanup. ## Checklist - [x] I have linked a GitHub issue above (`Closes #N` / `Fixes #N` / `Refs #N`). - [x] I have described **why** this change is being made, not just what changed. - [x] I have run the available local checks and tests. This PR touches only the Go TUI, so the gates are `gofmt`, `go vet`, the pinned golangci-lint and `go test ./...` under `tui/`; `util/lint.py --all` and `pytest tests/unit/` do not cover that module. The pinned golangci-lint check remains for CI. - [ ] I have attached **real-world evidence matched to the surface I changed** (see Evidence above), or marked each surface N/A. All four surfaces are marked N/A; a picker screenshot on a PC with an NPU was not produced. - [ ] I have updated documentation if user-visible behavior changed. No docs describe the catalog fit rules, so no doc change was needed; say if a changelog entry is wanted. --------- Signed-off-by: Niladri Das <[email protected]>
Summary
Preflight now reads the setup plan's
npuverdict when it judges an NPU chat model, so a PC with no NPU and a PC whose NPU is present but not set up no longer read the same. The verdict is read only for FLM models, through an attach-only daemon, and a plan that omits the field or cannot be read keeps Lemonade's memory verdict with a readiness caveat rather than reading as an absent NPU.Why
The preflight chat line could only judge
gemma4-it-e4b-FLMfrom Lemonade's capacity report, which carries no NPU state. Every branch about the NPU was therefore inferred from memory alone, so the line could not name the server's own reason. The daemon's setup plan already answers this:build_plan()returns annpufield withpresent,readyandproblemsfrom the same checks innpu_linux.pythat the Agent UI uses. The TUI's setup client never decoded it.This is one part of #6698. It covers the preflight surface only. The setup picker and the local catalog are separate changes, and none of the three resolves the issue alone.
Linked issue
Refs #6698
This PR does not complete #6698. The NPU-less Linux check has not been run (see Outstanding), and the local catalog remains in #7125.
Changes
setupapi.PlangainsNPU *NPU, withPresent,ReadyandProblems(code,title,fix).paramsis deliberately not decoded: preflight never reads it. A pointer tells an omitted field apart from a reported absence.readNPUVerdictreturns the verdict plus aknownflag. A plan that failed to load or omittednpureturnsfalse, so the zero value never stands in for two different facts. This covers daemons before v0.25.4, which answer without the field; the attach-only client accepts them because their API major matches.localFitasks for the verdict only when the chat model is an FLM model. A GGUF or other local model no longer pays for a plan read, let alone a daemon attach, to read an answer it ignores.readNPUVerdictusessetupapi.NewAttachedDaemon()so drawing the first-run fit line does not start a daemon. A cold start falls back to Lemonade's capacity report.fitLinekeeps four states distinct: plan unreadable with no NPU memory figure ("could not be checked", claiming neither absence nor readiness), confirmed absent ("Lemonade reports none on this PC"), present but not ready (the server's first reason and fix, with a count of the rest, and the model stays listed), and ready (judged on NPU memory, as before).knownflag infitLine, about whether the model's size is known, is renamedknownSizenow that the NPU verdict has its own.preflight/chat.golost their em dashes.Rebase
Rebased onto
mainata7cb7dc9f, producing285ad7362,dc19b5469, and2ceecd59b. This rebase had no conflicts. The earlier rebase onto6d27b91ffhad one conflict in the import block intui/internal/ui/preflight/chat.go; bothsetupapiandui/componentswere kept, with no logic conflict.Test plan
cd tui && go test ./internal/ui/preflight/... ./internal/setupapi/... -count=1on head2ceecd59b: preflight passed in 23.083s, setupapi passed in 0.508s.cd tui && go test ./... -count=1 -race -timeout=15mon head2ceecd59b: all TUI packages passed.cd tui && gofmt -l .on head2ceecd59b: no output.cd tui && go vet ./...on head2ceecd59b: exit 0 on darwin.git diff --checkon head2ceecd59b: clean.golangci-lintwas not run on2ceecd59bbecause it is not installed in this environment. The earlier v2.12.2GOOS=linuxrun passed on224657781; CI's Lint job is the check for this head.fitline_npu_test.gopass, covering ready, present-not-ready, absent, unreadable, and the unreadable-with-memory case.TestFitLineDoesNotClaimAbsenceWhenThePlanIsUnreadablefails when the!knownguard is removed, withgot "gemma4-it-e4b-FLM will not fit: it runs on a Ryzen AI NPU, and Lemonade reports none on this PC."That is the exact misleading line the fix removes.npuverdict_test.gochecks that a plan which answers reportsknown, and a plan that fails to load does not.TestLocalFitReadsTheNPUVerdictOnlyForAnNPUModelcounts verdict reads for a GGUF model (0) and an FLM model (1).TestNewAttachedDaemonNeverStartsOnepins the attach-only constructor used by the probe.TestFitLineKeepsTheMemoryVerdictWhenReadinessIsUnknownchecks the memory fit decision survives with the caveat, and the no-memory case still says readiness could not be checked.TestReadNPUVerdictIsUnknownWhenThePlanOmitsNPUuses a plan with no NPU, checksknownis false, and checks the line keeps "fits" with the caveat.TestDecodeLeavesAMissingNPUVerdictUnknowncovers both an omitted field and explicit null.Evidence
tests/unit/test_npu_linux.py::test_plan_reports_npu_problems.Outstanding
titleandfixverbatim and does not decodeparams. The Agent UI maps each problemcodeto its own localized sentence, and formemlockpicks a different one depending on whether the fix isrestartorstuck. The underlying reason is the same; the exact wording is not. Matching the Agent UI's code-aware copy is a decision for review, not a defect in this change.Checklist
Closes #N/Fixes #N/Refs #N).gofmt,go vetandgo test ./...undertui/;golangci-lintis covered by CI because it is not installed locally;util/lint.py --allandpytest tests/unit/do not cover that module.