Skip to content

[Feature] AMD NPU: name NPU models by their Hugging Face repo instead of the Lemonade ID - #17610

Merged
danielhanchen merged 18 commits into
unslothai:mainfrom
LeoBorcherding:studio/npu-hf-display-names
Nov 14, 2026
Merged

danielhanchen merged 18 commits into
unslothai:mainfrom
LeoBorcherding:studio/npu-hf-display-names

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

NPU models showed up under their Lemonade ID, e.g. qwen3.6-moe-35b-a3b-FLM, a name nobody searches for and that doesn't match anything on Hugging Face. They now show as their Hugging Face repo, Qwen3.6-35B-A3B-NPU2, the same name as on FastFlowLM's HF page.

Display only. Model IDs, API calls, saved run settings and loaded-model state all still use the Lemonade ID. Searching the picker by the old ID still finds the model.

Where the new name shows:

  • Model picker, NPU section, and the selected-model chip
  • Run settings header
  • Hub NPU list
  • Loaded-models list

Depends on #17514. The HF repo comes from the hf_repo field that #17514 adds to the NPU catalog. Without it, every NPU model keeps its Lemonade ID, so this PR merges safely in either order.

If listing the NPU catalog fails, names fall back to the Lemonade ID, and the lookup tries again after 30 s instead of staying stuck for the rest of the session.

Tests: npu-display-name.test.ts (new) covers the name mapping, the fallback and the retry. npu-api and npu-catalog-store tests updated. tsc --noEmit clean.

Not tested here: no Ryzen AI NPU on this machine. The new names on a real NPU get checked in the blog stills rerun on the AMD DevLab Strix Halo runner, once this is in the NPU stack. Screenshots will be added after that.

Screenshots

Before (left) and after (right), Unsloth Studio built from each side on the same spoofed AMD NPU.

Model Hub, format NPU: rows read the Hugging Face model names with the FastFlowLM owner instead of Lemonade ids. Before is #17514 head.

Before and after

FastFlowLM's model_list.json names each model's Hugging Face repo (and,
for some, a pinned revision). The NPU catalog now carries it as hf_repo /
hf_revision, and the Hub's NPU list opens the same split detail pane GGUF
models get: repo link, base model, size, capabilities, max context, the
row's Download/Run/Delete, and the README at that revision.
The picker, chat header, Run settings, Hub NPU list, API monitor and NPU
toasts showed the Lemonade id (qwen3.6-moe-35b-a3b-FLM). They now show the
repo name the server sends as hf_repo (Qwen3.6-35B-A3B-NPU2), falling back
to the id. Display only: ids, model paths, requests and saved configs are
unchanged, and search still matches the old id.
The loaded-models indicator and the floating monitor read the status
id, so they now take the repo name as a label. Listing the catalog to
find it waits for a validated NPU runtime, as the Run settings page does.
…play-names

# Conflicts:
#	studio/frontend/src/features/hub/catalog/npu-catalog-list.tsx
#	studio/frontend/src/features/hub/hub-page.tsx
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T14:36:38.947015Z 1531ed0 Manual request
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28575a1bf4

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +672 to +675
if (!urlNpu || selectedNpu || npuStatus === null || npuListing) return;
void navigate({
to: "/hub",
search: (prev) => ({ ...prev, npu: undefined }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore NPU mode before invalidating a URL-selected card

Reloading an opened NPU card, or returning to it with browser Back after opening Run, initializes discoverFormat to recommended and downloadedFormat to all; neither is restored from hubSearch.npu. Consequently, showNpuCatalog is false and selectedNpu is null, so this effect deletes a valid selection even when the runtime is ready and the model exists. Restore the active NPU format from the URL before validating the selection so card URLs and navigation history can reopen their detail pane.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restoring the NPU format from the URL is #17525's scope (switches the format from ?npu before checking the selection); this PR only changes display names.

listed = true;
void refreshNpuModels().then((ok) => {
// Retry a failed listing on a later render, at most every 30 s.
if (!ok) setTimeout(() => (listed = false), 30_000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Drive catalog retries through reactive state

If the initial catalog lookup fails, this timeout only mutates the module-local listed flag, which does not schedule a render. Moreover, if no render occurred during the backoff, even a later render still produces the same [wantsListing, status?.ready] dependencies as the failed attempt, so the effect does not retry. A transient failure can therefore leave the selected-model chip and run-settings header showing Lemonade IDs for the rest of the visit. Use reactive retry state or explicitly schedule the next lookup rather than only resetting this flag.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this: after a failed lookup the chip falls back to the Lemonade id, which is still a correct name, and the next catalog listing fills the names in.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 28575a1bf4

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Conflicts:
#	studio/frontend/src/features/model-picker/components/model-config-page.tsx
@danielhanchen

Copy link
Copy Markdown
Member

pre-commit.ci failed on 0cd335a at its mergeable check, not a lint hook: the branch conflicted with main in studio/frontend/src/features/model-picker/components/model-config-page.tsx after #17517 added data-config-title to the run settings title. Merged main in 9847d5b, keeping both the attribute and this PR's NPU display name; typecheck is clean and the NPU, Hub and model config tests pass (468).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 9847d5b705

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Conflicts:
#	studio/frontend/src/features/model-picker/components/model-config-page.tsx
#	studio/frontend/src/features/npu/api.ts
#	studio/frontend/tests/npu-api.test.ts
…e NPU api's own helpers in the search test

[skip ci]
# Conflicts:
#	studio/frontend/src/features/hub/catalog/npu-catalog-list.tsx
#	studio/frontend/src/features/model-picker/components/model-config-page.tsx
#	studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx
#	studio/frontend/src/features/npu/api.ts
#	studio/frontend/src/features/npu/index.ts

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 1531ed024d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 6fa8c0a into unslothai:main Nov 14, 2026
Stanley00 pushed a commit to stanley-fork/unsloth that referenced this pull request Nov 17, 2026
…the Hub (unslothai#18059)

The composer model picker's NPU section listed FastFlowLM's internal ids
(`d3-edge-FLM`, `gemma4-it-e4b-FLM`, ...) in the backend's alphabetical
order. The Hub's NPU list already shows Hugging Face names
(`Qwen3.6-35B-A3B-NPU2`) in the curated order from unslothai#17513. unslothai#17610
renamed the old picker and the Hub, but the composer picker from unslothai#17517
builds its own NPU rows, so it kept the raw ids.

The picker now builds its NPU rows with the Hub's own helpers,
`npuRowsFor` and `npuDisplayName`, so both lists match. Rows still load
by the `lemonade:<id>-FLM` path, and sizes show as before. On Device's
default Recent sort kept re-sorting never-loaded NPU rows by name, so
device rows carry an optional `rank` and the sort breaks date ties by
date, then rank, then name. Name and Size sorts are unchanged.

**Tests.** `tests/composer-npu-rows.test.ts` covers names, order, the
`-FLM` load path, and the Recent sort with mixed inventories. Typecheck
and the full frontend suite pass (16471 pass, 0 fail).

**Screenshots.** Composer picker, Discover tab, NPU section, light mint
theme, with `/api/npu` answers mocked in the browser (the change is
frontend only). The "Couldn't reach Hugging Face" banner is the mock
having no Hub feed.

| Before (main) | After |
|---|---|
| <img
src="https://raw.githubusercontent.com/LeoBorcherding/unsloth/c6615d8e2fa7d0af28cb584321d143827631ec7c/before.png"
width="380"> | <img
src="https://raw.githubusercontent.com/LeoBorcherding/unsloth/c6615d8e2fa7d0af28cb584321d143827631ec7c/after.png"
width="380"> |

---------

Co-authored-by: Daniel Han <[email protected]>
danielhanchen added a commit to LeoBorcherding/unsloth that referenced this pull request Nov 17, 2026
…e the app shows (unslothai#18147)

The OpenAI-compatible API now takes the NPU model name Unsloth Studio
shows (`Qwen3.6-35B-A3B-NPU2`), or its `FastFlowLM/` repo, wherever it
takes a model id. Before, it only took the Lemonade id
(`lemonade:qwen3.6-moe-35b-a3b-FLM`).

Since unslothai#17610 the app labels NPU models with
FastFlowLM's Hugging Face repo names. Someone who copies that name into
an app like Open WebUI, or into a `curl`, gets a 404 as soon as it
matters: when the model isn't loaded yet, or when they look it up.

### Example

```bash
curl $BASE/v1/chat/completions -H "Authorization: Bearer $KEY" -d '{
  "model": "Qwen3.6-35B-A3B-NPU2",
  "messages": [{"role": "user", "content": "What is the capital of France?"}]
}'
```

That now loads and answers from `lemonade:qwen3.6-moe-35b-a3b-FLM`.
`FastFlowLM/Qwen3.6-35B-A3B-NPU2`, any casing, and the old `lemonade:`
id work too. The response's `model` field stays the Lemonade id.

### Before and after

AMD DevLab Strix Halo runner (Ryzen AI MAX+ 395, Ubuntu 24.04, kernel
7.0.0-43, amdxdna 2.25, FastFlowLM 1.0.12, Lemonade 2026.44.1),
`qwen3-0.6b-FLM`, both legs in one job. [Run
44089863791](https://github.com/oobabooga/unsloth/actions/runs/44089863791):
main `3384411` vs `062f2e7`. The first run,
[44023985957](https://github.com/oobabooga/unsloth/actions/runs/44023985957)
on `ee35baa`, gave the same codes in every row but the last.

| request | main | this PR |
|---|---|---|
| chat, `Qwen3-0.6B-NPU2`, model loaded | 200 | 200 |
| chat, `fastflowlm/qwen3-0.6b-npu2`, model loaded | 200 | 200 |
| `/v1/responses`, `Qwen3-0.6B-NPU2` | 200 | 200 |
| `GET /v1/models/Qwen3-0.6B-NPU2` | **404** "does not exist" | 200, the
loaded NPU model |
| `GET /v1/models` | id only | adds `"display_name": "Qwen3-0.6B-NPU2"`
|
| chat, display name, nothing loaded, auto-switch off | 400 "No model
loaded" | 404 naming the NPU model and the setting that loads it |
| chat, display name, **auto-switch on** | **404** "not downloaded on
this server" | **200**, loads `lemonade:qwen3-0.6b-FLM` and answers |
| chat, `Qwen3-9B-Nope-NPU2` (no such model), NPU model loaded on this
PR's leg | 404 "not downloaded on this server" | 404 "No NPU model is
named 'Qwen3-9B-Nope-NPU2'" |

On main a display name only "works" while that model is already loaded,
because chat answers from whatever is loaded. Loading by name and
looking up by name both fail.

The last row is why there's a second commit. At `ee35baa` a made-up
`-NPU2` name got the loaded model's answer with a 200. At `062f2e7` it's
a 404 "No NPU model is named 'Qwen3-9B-Nope-NPU2'", with the NPU model
loaded, so a typo never quietly gets another model's reply. A host that
can't run the NPU still passes such a name on unchanged.

![main
3384411](https://raw.githubusercontent.com/LeoBorcherding/unsloth/149f49bb06c80e98cd78152204318da2f38a7fc0/npu-api-18147/01-main-3384411.png)

![this PR
062f2e7](https://raw.githubusercontent.com/LeoBorcherding/unsloth/149f49bb06c80e98cd78152204318da2f38a7fc0/npu-api-18147/02-pr-062f2e7.png)

### How it works

- `npu_backend.py`: `NpuModel.display_name` and `answers_to()` match on
the `hf_repo` the app's names come from. `model_path_for_name()`
resolves a name to `lemonade:<id>`, checking the loaded model first,
then the catalog. A name two catalog rows share (FastFlowLM's flash
builds reuse the base repo) gets a 400 listing both.
- `routes/inference.py`: `_maybe_auto_switch_model` resolves the name
first. Reading the catalog can start the NPU runtime, so only a request
that's allowed to load starts it: auto-switch on, not a managed account,
not a held-back keyless caller. A managed account only ever reaches the
model already loaded.
- `/v1/models` lists `display_name`, and `/v1/models/{id}` matches on
it.
- Anything that isn't shaped like an NPU name (`FastFlowLM/<name>` or
`*-NPU<n>`) passes through unchanged, so GGUF and other ids aren't
touched.

### Tests

New cases in `studio/backend/tests/test_npu_backend.py` and
`test_npu_chat_route.py`: name and repo matching in any case, the
shared-repo refusal, the managed-account and auto-switch-off paths, and
the refusal of an unknown name on an NPU host.

Not covered: one model (`qwen3-0.6b-FLM`) on one Linux Strix Halo. No
Windows NPU run.

The CLI side of the same change is unslothai#18048.

---------

Co-authored-by: Daniel Han <[email protected]>
danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Nov 18, 2026
…ce name Unsloth Studio shows for NPU models (unslothai#18048)

`unsloth run --model` and `unsloth chat` only knew an NPU model by its
Lemonade id (`qwen3.6-moe-35b-a3b-FLM`) or `lemonade:<id>`. Since unslothai#17610
the app names NPU models by their Hugging Face repo
(`Qwen3.6-35B-A3B-NPU2`), so typing the name you see in Unsloth Studio,
or its repo id `FastFlowLM/Qwen3.6-35B-A3B-NPU2`, went down the GGUF
path and failed with an AutoConfig error on
`unsloth/Qwen3.6-35B-A3B-NPU2`.

### The fix
- `npu_model_path` (`unsloth_cli/_npu.py`) also routes names ending in
`-NPU<n>` and `FastFlowLM/<name>` repo ids to the NPU, case-insensitive.
Anything else with a slash is still a Hugging Face repo.
- `prepare_npu_model` resolves the name against `/api/npu/models`,
matching each row's id, `hf_repo` and repo name. `hf_repo` is the field
the app's display names come from (`npu_backend.catalog`, read from
FastFlowLM's `model_list.json`), so there's no second name table. It
returns the `lemonade:<id>` that `unsloth run` and
`connect_studio_server` then load.
- A near miss gets the closest names (`No NPU model named
Qwen3-0.6B-NPU3. Did you mean: Qwen3-0.6B-NPU2, Qwen3.5-0.8B-NPU2,
Qwen3-1.7B-NPU2?`). A name two catalog rows share (FastFlowLM's flash
builds reuse the base build's repo, e.g. `Qwen3.5-2B-NPU2`) asks for the
id instead of guessing.
- `unsloth/Qwen3-0.6B-GGUF` still loads as a GGUF, although FastFlowLM's
`qwen3-core:0.6b` downloads from that same repo.

### Tests
`unsloth_cli/tests/test_npu_cli.py`: display name, repo id and lowercase
forms resolve to the id; a resolved name downloads by its id; near
misses suggest; a shared repo asks for an id; `unsloth/Qwen3-0.6B-GGUF`
stays GGUF; `connect_studio_server` loads the resolved id. 15 of the new
cases fail on main. Full `unsloth_cli/tests`: 2679 passed, 4 failed in
`test_doctor_mcp.py`, which fail the same on main.

### Hardware
| machine | kernel | amdxdna / NPU fw | FLM / Lemonade | commit |
|---|---|---|---|---|
| AMD DevLab Strix Halo (Ryzen AI MAX+ 395, Radeon 8060S, NPU Strix
Halo), Ubuntu 24.04.5, run
[43971387783](https://github.com/oobabooga/unsloth/actions/runs/43971387783)
| 7.0.0-43-generic | 2.25.260102.56 / 1.1.2.65 | 1.0.12 / 2026.44.1 |
main e73b085 vs branch 1dc36f4, same job |
| same pool, run
[43974562934](https://github.com/oobabooga/unsloth/actions/runs/43974562934)
(Qwen3.6 35B) | 7.0.0-43-generic | 2.25.260102.56 / 1.1.2.65 | 1.0.12 /
2026.44.1 | main e73b085 vs branch 1dc36f4, same job |

Both legs installed Unsloth Studio with `install.sh --local` into
separate homes on the same runner.

### Before and after

`unsloth run --model Qwen3.6-35B-A3B-NPU2` on main:

![main: unsloth run --model
Qwen3.6-35B-A3B-NPU2](https://raw.githubusercontent.com/LeoBorcherding/unsloth/94ee41b2e097144715d3c64b9654be07150149d8/npu-cli-names/43974562934/01-main-run-qwen3.6-35b-a3b-npu2.png)

On this branch it resolves to `qwen3.6-moe-35b-a3b-FLM`, downloads 20.6
GB, loads on the NPU and serves:

![branch: unsloth run --model
Qwen3.6-35B-A3B-NPU2](https://raw.githubusercontent.com/LeoBorcherding/unsloth/94ee41b2e097144715d3c64b9654be07150149d8/npu-cli-names/43974562934/02-branch-run-qwen3.6-35b-a3b-npu2.png)

(The 64-token cap ran out inside Qwen3.6's reasoning, so `content` is
null; `/no_think` didn't turn it off. The point here is the load and the
200.)

`unsloth chat` with piped stdin, main then branch:

![main: unsloth chat
Qwen3-0.6B-NPU2](https://raw.githubusercontent.com/LeoBorcherding/unsloth/94ee41b2e097144715d3c64b9654be07150149d8/npu-cli-names/43974562934/04-main-chat-display-name.png)

![branch: unsloth chat with the display name, lowercase, and a wrong
name](https://raw.githubusercontent.com/LeoBorcherding/unsloth/94ee41b2e097144715d3c64b9654be07150149d8/npu-cli-names/43974562934/03-branch-chat-display-name.png)

Every case from run 43971387783, `unsloth run --model <name>`
(Qwen3-0.6B, so it runs quickly):

| name | main e73b085 | branch 1dc36f4 |
|---|---|---|
| `Qwen3-0.6B-NPU2` | AutoConfig error: `unsloth/Qwen3-0.6B-NPU2 is not
a local folder and is not a valid model identifier` | `Model loaded:
lemonade:qwen3-0.6b-FLM`, `/v1/chat/completions` replies `hello` |
| `FastFlowLM/Qwen3-0.6B-NPU2` | `Download for
'FastFlowLM/Qwen3-0.6B-NPU2' returned an incomplete snapshot` | `Model
loaded: lemonade:qwen3-0.6b-FLM`, replies `hello` |
| `qwen3-0.6b-npu2` | AutoConfig error on `unsloth/qwen3-0.6b-npu2` |
`Model loaded: lemonade:qwen3-0.6b-FLM`, replies `hello` |
| `unsloth/Qwen3-0.6B-GGUF` | `Model loaded: unsloth/Qwen3-0.6B-GGUF`,
replies `hello` | same, still GGUF |
| `Qwen3-0.6B-NPU3` | AutoConfig error on `unsloth/Qwen3-0.6B-NPU3` |
`Error: No NPU model named Qwen3-0.6B-NPU3. Did you mean:
Qwen3-0.6B-NPU2, Qwen3.5-0.8B-NPU2, Qwen3-1.7B-NPU2?` |

`unsloth chat <name>` against a running Unsloth Studio gave the same
split for the four non-GGUF names. Raw logs:
[npu-cli-names/43971387783](https://github.com/LeoBorcherding/unsloth/tree/94ee41b2e097144715d3c64b9654be07150149d8/npu-cli-names/43971387783).

### Not covered
- Windows (Ryzen AI laptops): the name resolution is plain string
matching against the same `/api/npu/models` response, but no Windows NPU
box ran it.
- A name that isn't NPU-shaped (no `-NPU<n>`, no `FastFlowLM/`, no
`-FLM`) can't be recognised before Unsloth Studio is up, so a typo like
`Qwen3-0.6B` still goes to the GGUF path. FastFlowLM names every build
`-NPU2` today; if that changes, the suffix rule needs it.
- Q4NX models converted on the Export page (unslothai#17636) have no `hf_repo`,
so they resolve by id only.
- `unsloth inference` and `unsloth start` share `npu_model_path`, so
they see the new names too; only `run` and `chat` were driven on
hardware.

---------

Co-authored-by: Daniel Han <[email protected]>
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 18, 2026
… AMD NPU models with download and memory-fit state (unslothai#18049)

`unsloth chat` and `unsloth inference` take an NPU model by its `-FLM`
id, but nothing in the CLI told you which ids exist. `unsloth
list-npu-models` prints the catalog the app shows: the Hugging Face name
(same name as the model picker since unslothai#17610), the `-FLM` id, the size,
whether it's downloaded (or how far a resumable download got), and
whether it fits the memory the NPU can map on this PC.

```
Memory the NPU can map on this PC: 122.9 GB

NAME                 ID                SIZE     DOWNLOADED  FITS IN MEMORY
Qwen3-0.6B-NPU2      qwen3-0.6b-FLM    0.7 GB   yes         yes
D3-Edge-NPU2         d3-edge-FLM       0.6 GB   no          yes
Gemma3-1B-NPU2       gemma3-1b-FLM     1.2 GB   no          yes
...
Chat with one: unsloth chat <ID>
```

Where the data comes from:
- Unsloth Studio running: its `/api/npu/status` and `/api/npu/models`,
so the names, sizes and the `memory_needed_gb` / `fits_memory` fields
are the backend's own. It only reads; it never enables the runtime or
starts a download.
- Unsloth Studio not running: the same status the backend computes, read
in-process without starting the NPU runtime, so a missing NPU, an NPU
turned off with `UNSLOTH_STUDIO_ENABLE_NPU`, or FastFlowLM not installed
is still named. When the runtime is ready it says to start Unsloth
Studio, because the `-FLM` catalog comes from Lemonade, which only
Unsloth Studio runs.

Every case it can't list is one line and exit 1, like
`list-checkpoints`' errors. It sits next to `list-checkpoints` as a
top-level command; no `--json`, since no list command has one.

## Before / after on a real NPU

Same AMD DevLab runner, same job, Unsloth Studio installed from main and
from this branch
([run](https://github.com/oobabooga/unsloth/actions/runs/43971387209)).

Before (main): `No such command 'list-npu-models'`.


![before](https://raw.githubusercontent.com/LeoBorcherding/unsloth/3795cef89fc7f2811214db48cd897189bed35d63/npu-cli-list/43971387209/before-main.png)

After: no runtime yet, with and without Unsloth Studio running (exit 1,
one line); then `unsloth inference qwen3-0.6b-FLM` enables the runtime
and downloads the model; then the full listing with that model
downloaded and the rest not (exit 0); then, with Unsloth Studio stopped,
the one-line "isn't running" message.


![after](https://raw.githubusercontent.com/LeoBorcherding/unsloth/3795cef89fc7f2811214db48cd897189bed35d63/npu-cli-list/43971387209/after-branch.png)

| machine | kernel | amdxdna / NPU firmware | FastFlowLM / Lemonade |
commit |
|---|---|---|---|---|
| AMD DevLab X2-LA03-S03-D01, Ryzen AI MAX+ 395 (NPU Strix Halo), Ubuntu
24.04, 124 GiB | 7.0.0-43-generic | 2.25.260102.56 / 1.1.2.65 | 1.0.12 /
2026.44.1 (as Unsloth Studio installs them) | da9006c (main e73b085 for
before) |

## Tests

`unsloth_cli/tests/test_npu_cli.py`: the listing with downloaded, partly
downloaded and not downloaded rows and fits / doesn't fit / unknown; no
NPU, NPU turned off, an XDNA 1 NPU, FastFlowLM not installed, runtime
installed but not enabled; no Unsloth Studio with a missing NPU, a
missing runtime and a ready one; a dropped connection; and the real
backend `status()` answering without starting the runtime.
`test_cli_lazy_commands.py` gets the new command in its fixed order.

Full CLI suite: 2669 passed, 4 failed; the same 4 (`test_doctor_mcp.py`)
fail on main.

Backend suite: no file under `studio/` changes; on a Mac the full run
hangs in the same test on main and on this branch.

## Not covered

- No "doesn't fit" or "partly downloaded" row on hardware: the runner
has 124 GiB, so every catalog model fits, and nothing was interrupted.
Both are unit-tested only.
- Windows (where the NPU gets about half of RAM) not run.
- A remote `UNSLOTH_STUDIO_URL` is refused, same as `unsloth chat`: the
CLI only sends its self-issued token to a local Unsloth Studio.
- With Unsloth Studio running, listing asks it for the catalog, which
starts its Lemonade server if the runtime is enabled but idle, the same
as opening the Hub.

---------

Co-authored-by: Daniel Han <[email protected]>
danielhanchen added a commit to NilayYadav/unsloth that referenced this pull request Nov 18, 2026
…wLM and converter (Qwen3 14B offered, LFM3 hidden) (unslothai#18050)

NPU model support now comes from what is installed instead of hand-kept
lists:

- `GET /api/npu/compat` (`core/inference/npu_compat.py`) reads
FastFlowLM's `model_list.json`, each catalog model's `config.json`
(downloaded copy, else its Hugging Face repo, cached per listing) for
layers / hidden size / experts, and the pinned Q4NX converters'
`ModelArchNames` and `_QWEN35_GEOMETRY`, parsed with `ast` and never
imported. It never starts the runtime.
- One tag per model: "Runs on NPU", "Convert, then runs", "Converts,
won't run", "Not supported", shown in the composer picker, the Hub NPU
list and the Q4NX convert card.
- Removed the hand-kept `Q4NX_ARCHITECTURES` / `Q4NX_SIZES` (frontend)
and `_NPU_SHAPES` (backend export guard).
- `NPU_POPULAR`, six checkpoints, replaces unslothai#17513's recommended list as
the one order every NPU list uses.
- The composer picker names NPU rows with unslothai#17610's `npuDisplayName` and
orders Discover's NPU rows with `npuRowsFor`.

Base `mirror-base/npu-compat` is upstream main at a2b1f68.



## Screenshots

Composer model picker, On Device tab. Both Studios were built from
source (left: the merge base, right: this PR). The `/api/npu/*` answers
come from a real Strix Halo XDNA2 capture and the FastFlowLM 1.0.12
compat table. Each NPU row now shows its support tag ("Runs on NPU").

![Before and
after](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/18050/pr18050_pair_00_q-7365bc23e91c.png)

Without a supported NPU, `GET /api/npu/compat` returns an all-unknown
table and installs and fetches nothing (checked on a CPU host and on a
Colab T4).

---------

Co-authored-by: Daniel Han <[email protected]>
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