Repository navigation
[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 intoNov 18, 2026
Conversation
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.   ### 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
marked this pull request as ready for review
November 17, 2026 18:35
[skip ci]
[skip ci]
Member
|
@codex review |
1 similar comment
Member
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
unsloth run --modelandunsloth chatonly knew an NPU model by its Lemonade id (qwen3.6-moe-35b-a3b-FLM) orlemonade:<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 idFastFlowLM/Qwen3.6-35B-A3B-NPU2, went down the GGUF path and failed with an AutoConfig error onunsloth/Qwen3.6-35B-A3B-NPU2.The fix
npu_model_path(unsloth_cli/_npu.py) also routes names ending in-NPU<n>andFastFlowLM/<name>repo ids to the NPU, case-insensitive. Anything else with a slash is still a Hugging Face repo.prepare_npu_modelresolves the name against/api/npu/models, matching each row's id,hf_repoand repo name.hf_repois the field the app's display names come from (npu_backend.catalog, read from FastFlowLM'smodel_list.json), so there's no second name table. It returns thelemonade:<id>thatunsloth runandconnect_studio_serverthen load.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-GGUFstill loads as a GGUF, although FastFlowLM'sqwen3-core:0.6bdownloads 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-GGUFstays GGUF;connect_studio_serverloads the resolved id. 15 of the new cases fail on main. Fullunsloth_cli/tests: 2679 passed, 4 failed intest_doctor_mcp.py, which fail the same on main.Hardware
Both legs installed Unsloth Studio with
install.sh --localinto separate homes on the same runner.Before and after
unsloth run --model Qwen3.6-35B-A3B-NPU2on main:On this branch it resolves to
qwen3.6-moe-35b-a3b-FLM, downloads 20.6 GB, loads on the NPU and serves:(The 64-token cap ran out inside Qwen3.6's reasoning, so
contentis null;/no_thinkdidn't turn it off. The point here is the load and the 200.)unsloth chatwith piped stdin, main then branch:Every case from run 43971387783,
unsloth run --model <name>(Qwen3-0.6B, so it runs quickly):Qwen3-0.6B-NPU2unsloth/Qwen3-0.6B-NPU2 is not a local folder and is not a valid model identifierModel loaded: lemonade:qwen3-0.6b-FLM,/v1/chat/completionsreplieshelloFastFlowLM/Qwen3-0.6B-NPU2Download for 'FastFlowLM/Qwen3-0.6B-NPU2' returned an incomplete snapshotModel loaded: lemonade:qwen3-0.6b-FLM, replieshelloqwen3-0.6b-npu2unsloth/qwen3-0.6b-npu2Model loaded: lemonade:qwen3-0.6b-FLM, replieshellounsloth/Qwen3-0.6B-GGUFModel loaded: unsloth/Qwen3-0.6B-GGUF, replieshelloQwen3-0.6B-NPU3unsloth/Qwen3-0.6B-NPU3Error: 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
/api/npu/modelsresponse, but no Windows NPU box ran it.-NPU<n>, noFastFlowLM/, no-FLM) can't be recognised before Unsloth Studio is up, so a typo likeQwen3-0.6Bstill goes to the GGUF path. FastFlowLM names every build-NPU2today; if that changes, the suffix rule needs it.hf_repo, so they resolve by id only.unsloth inferenceandunsloth startsharenpu_model_path, so they see the new names too; onlyrunandchatwere driven on hardware.