Skip to content

[Feature] AMD NPU: unsloth run and unsloth chat accept the Hugging Face name Unsloth Studio shows for NPU models - #18048

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

danielhanchen merged 4 commits into
unslothai:mainfrom
LeoBorcherding:studio/cli-npu-display-names

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

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 #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 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 (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

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

(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

branch: unsloth chat with the display name, lowercase, and a wrong name

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.

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 ([Feature] AMD NPU: load Q4NX models converted in Unsloth Studio from the NPU model list #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.

unsloth run and unsloth chat now accept the Hugging Face name the app shows
for an NPU model (Qwen3.6-35B-A3B-NPU2) and its FastFlowLM/ repo id, case
insensitive, by matching the hf_repo of each row in /api/npu/models. A near
miss suggests the closest names; a real Hugging Face GGUF repo still loads
as a GGUF.
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]>
@LeoBorcherding LeoBorcherding changed the title [Feature] Unsloth Studio / Desktop: unsloth run and unsloth chat accept the NPU model name the app shows [Feature] AMD NPU: unsloth run and unsloth chat accept the Hugging Face name Unsloth Studio shows for NPU models Nov 17, 2026
@LeoBorcherding
LeoBorcherding marked this pull request as ready for review November 17, 2026 18:35
@danielhanchen danielhanchen self-assigned this Nov 18, 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 18, 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-18T07:05:21.437688Z 3b2499b 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 3b2499be19

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

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