Skip to content

Studio NPU: name Smart App Control blocks instead of a 500 or a silent picker - #18549

Closed
danielhanchen wants to merge 1 commit into
mainfrom
npu-code-integrity-errors
Closed

danielhanchen wants to merge 1 commit into
mainfrom
npu-code-integrity-errors

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

On Windows with Smart App Control on, the NPU silently disappeared from the chat model picker. Windows refused to start the unsigned lemond.exe (WinError 4551), the OSError escaped LemonadeServer._start_once, and every GET /api/npu/models returned a 500. The picker only shows the NPU notice while the NPU is not set up, so a set-up NPU with a failing list showed nothing at all.

Once Smart App Control allows lemond.exe, the same machine fails one step later. flm.exe links every model DLL, so a single refused DLL ends it with 0xC0E90002 and no output, and Enable reported flm validate returned no report: with an empty reason.

Changes

  • lemonade_server.py: a code integrity refusal while spawning lemond.exe becomes LemonadeUnavailable with code_integrity_user_message, the same wording llama.cpp already uses. Enable, the model list and load then report it as an NpuError (409, not 500). Retrying is skipped since a policy cannot clear itself. Other spawn errors are re-raised unchanged.
  • npu_backend.py: flm validate names the policy both when the spawn is refused and when it exits 0xC0E90002 / -1058471934 without a report. Other silent exits keep the old wording.
  • composer-model-picker.tsx: the NPU section and its notice also render when the list failed (listError), so the reason is shown. It still hides while searching, as for an NPU that is not set up.

Testing

  • New tests/test_npu_code_integrity.py (16 cases, cross-platform): WinError 4551 / 1260 / 577 and the policy text on spawn, no retry, log file closed, unrelated OSErrors untouched, the 409 from the route, Enable state and error, and flm validate refused at spawn or by DLL exit code. 7 of them fail on main.
  • NPU and code integrity backend suites: 488 passed on Linux (WSL, Python 3.12) and 230 passed on Windows (Python 3.13).
  • Real machine (Ryzen AI MAX+ 395, Smart App Control on), fresh Enable into a temp root:
    • main: flm validate returned no report:
    • this PR: Windows blocked part of the local model runtime: Smart App Control or an Application Control policy blocked the image. The blocked file is under ...\cache\bin\flm\npu. ...
    • With the real blocked lemond.exe (before Smart App Control later allowed it), start() raised the new message from the real WinError 4551.
  • Frontend: a new picker test, node --test, and typecheck all pass. The real app was run on vite with /api/npu/models answering 409. The notice with the reason showed in Chromium and Edge (Windows), and in Chromium, Firefox and WebKit (Linux). On main the notice does not appear (negative control).
  • AST diff against main: only LemonadeServer._start_once, LemonadeNpuBackend._validate, the imports and the new _blocked_message changed. The ruff-unsloth formatting pass is AST-identical.

Not covered: macOS (no NPU path there; the picker change was checked on WebKit). Making FastFlowLM itself run under Smart App Control needs signed flm.exe and DLLs upstream. Its license only allows redistributing the binaries unmodified, so Studio cannot sign them itself.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-20T01:10:36.617459Z
We couldn’t complete this review. Comment @codex review to try again.
49415a0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@LeoBorcherding

LeoBorcherding commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Tested on Strix Halo (Ubuntu 24.04, FastFlowLM 1.0.12, Lemonade 2026.44.1) at 49415a0, with lemond made non-executable so the NPU model list fails (run).

  • Discover now shows a notice, but it says "Could not list NPU models (500)" with no reason, since a failure that isn't Smart App Control still returns a plain 500.
  • On Device still says "No models on this device" with three NPU models downloaded. Could the notice show there too?

Picker with the NPU list failing (left: main, then this PR on Discover and On Device):

picker

How this relates to #18528. Both PRs show the NPU list error in the picker on Discover. They cover different backend failures:

Picking and loading an NPU model still works on this PR at 49415a0: 4/4 entry points (new-chat picker, in-chat switch, fresh download from Discover, Hub Run) loaded the model, same as main (run).

Not tested on a real Windows Smart App Control block.

@danielhanchen

Copy link
Copy Markdown
Member Author

Closing in favour of #18528, which is now merged. It covers the same lemond spawn and list failures, and I ported the two flm validate messages from this PR into it (a refused spawn, and the 0xC0E90002 exit with no report), with a fail-fast status alone still treated as an ordinary crash.

oobabooga added a commit that referenced this pull request Nov 20, 2026
…of an empty reason (#18648)

**Problem:** On Windows, when Smart App Control or an App Control policy
refuses one of FastFlowLM's DLLs, `flm.exe` exits with 0xC0E90002 and
prints nothing. Since #18554, Enable NPU then fails with "Installing
FastFlowLM failed: FastFlowLM does not run:" and no reason.

**Change:** `flm_host.py` reports the exit code when flm prints nothing.
Enable recognizes the code integrity status in that error and shows the
message Studio already uses for these blocks, which names the blocked
folder.

**Status:** Tested on the AMD DevLab Windows runner (Strix Halo), `main`
against this branch, with `flm.exe` replaced by a stub that exits
0xC0E90002 without output.

![Before and
after](https://raw.githubusercontent.com/oobabooga/unsloth/pr-media/pr/npu-silent-refusal/npu-silent-refusal-61cb676a7901.png)

## Details

- `flm_host.py`: `Flm.run` turns a failed run with no output into
`[ERROR] exit code N (0xC0E90002)`.
- `npu_backend.py`: when FastFlowLM's install check fails, the reason
goes through the existing `_blocked_message`. Any other failure keeps
"Installing FastFlowLM failed: ...".
- Loading a model already explained a silent refusal through `_explain`,
so the load path is unchanged. A test now covers it.

## Not covered

The runner has Smart App Control off, so the refusal comes from the
stub, not from a real policy. The exit status and the empty output match
what #18549 recorded on a machine with Smart App Control on.

## Testing

- New tests for the install message, an ordinary install failure, the
load message, and the exit code text. The install-message and exit-code
tests fail on `main`.
- NPU backend suites: 729 passed, 1 skipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants