Repository navigation
[Feature] Unsloth Studio / Desktop: the API accepts the NPU model name the app shows - #18147
Conversation
/v1/chat/completions, /v1/responses and the other routes that resolve lemonade: ids now take the Hugging Face repo name Unsloth Studio shows for an NPU model (Qwen3-0.6B-NPU2, or FastFlowLM/Qwen3-0.6B-NPU2, any case) and route it as its lemonade:<id>. The loaded model answers without I/O; others resolve through the catalog, which may start the runtime only for a request that could load. /v1/models adds a display_name field to the NPU entry.
… the NPU With the runtime stopped and switching off, a display name used to fall through and be answered by whatever model was loaded, where its lemonade: id gets the not-loaded 404. On a host with a supported NPU and the runtime installed, an NPU name that resolves to nothing now gets that 404, or 'No NPU model is named' when the request could load.
…pported NPU [skip ci]
|
@codex review |
1 similar comment
|
@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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6150bdd13
ℹ️ 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".
| if isinstance(eid, str) and model_id.lower() in ( | ||
| eid.lower(), | ||
| str(entry.get("display_name") or "").lower(), | ||
| ): |
There was a problem hiding this comment.
Resolve full FastFlowLM repo names in model retrieval
With lemonade:qwen3-0.6b-FLM loaded, GET /v1/models/FastFlowLM/Qwen3-0.6B-NPU2 still returns 404: this branch compares only the canonical ID and bare display name, and the subsequent catalog loop also compares only IDs. Chat accepts the full repo name through NpuModel.answers_to(), so a client that retrieves its configured model before generating cannot use this newly supported identifier. Match retrieval requests against the NPU model's full repo name as well, while preserving the existing alias precedence.
Useful? React with 👍 / 👎.
| gguf_requires_vision = ( | ||
| (require_audio_input or require_video) if tool_images_only else require_vision | ||
| ) | ||
| requested_model = await _npu_path_for_display_name(requested_model, fastapi_request) |
There was a problem hiding this comment.
Check endpoint support before allowing NPU runtime startup
With auto-switch enabled and the NPU runtime stopped, an otherwise valid /v1/completions request naming Qwen3-0.6B-NPU2 reaches model_path_for_name() and catalog() before the endpoint's NPU capability is checked. This starts Lemonade; after a runtime pin update, _ensure_running() can even invoke enable() to download and validate the replacement runtime, only for _refuse_unservable_npu_switch() to reject the request because completions cannot serve NPU models. The equivalent canonical lemonade: request is rejected before that catalog I/O. Gate runtime startup on the endpoint's NPU capability so an unsupported request cannot trigger this potentially lengthy setup.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ee084e7: _maybe_auto_switch_model passes serves_npu to the display-name step, and only an endpoint that serves the NPU may start its runtime. Test: test_an_endpoint_that_cannot_serve_the_npu_never_starts_the_runtime.
…a credential that may load starts the runtime [skip ci]
… its runtime [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! 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". |
…-r red since #18147) (#18197) Two Studio tests fail on main since #18147 (`m-r` shard, seen on the staging run of #18188, a computer-use change): ``` tests/test_multi_model_serving.py::test_a_resident_npu_model_keeps_to_the_primarys_seat routes/inference.py:10720: in _loaded_satisfies E AttributeError: 'types.SimpleNamespace' object has no attribute 'answers_to' tests/test_multi_model_serving.py::test_the_loaded_models_list_names_the_npu_model_once E AttributeError: 'types.SimpleNamespace' object has no attribute 'display_name' ``` ## Cause #18147 lets the API accept the NPU model name the app shows: `NpuModel` gained `display_name` and `answers_to()`, and the routing / loaded-models code now calls them. That is correct for the real class. These tests stand in for the resident NPU model with a `SimpleNamespace` carrying only the fields the code used before, so the new calls fail. ## Fix A `_npu_model()` helper builds the real `npu_backend.NpuModel` (frozen dataclass, `model_path` derived from `id`), and the four NPU stubs in the file use it. The surrounding backend stubs (`is_loaded`, `resident`) are unchanged. With the real class, a later method on `NpuModel` reaches these tests automatically instead of breaking them. ## Verification - main: 2 failed, 108 passed. - this branch: `tests/test_multi_model_serving.py` 110 passed.
|
Pushed The public preview also refused an NPU-shaped name with a 404 when that model wasn't loaded, before it reached the code that serves the preview's pinned checkpoint whatever model the caller names. The resolver now passes the name on untouched for a preview request, the same as for any other name. Starting the runtime only on the chat route is Tests added. Codex is clean on this commit on the mirror (LeoBorcherding#947 (comment)). |
The OpenAI-compatible API now takes the NPU model name Unsloth Studio shows (
Qwen3.6-35B-A3B-NPU2), or itsFastFlowLM/repo, wherever it takes a model id. Before, it only took the Lemonade id (lemonade:qwen3.6-moe-35b-a3b-FLM).Since #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
That now loads and answers from
lemonade:qwen3.6-moe-35b-a3b-FLM.FastFlowLM/Qwen3.6-35B-A3B-NPU2, any casing, and the oldlemonade:id work too. The response'smodelfield 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: main3384411vs062f2e7. The first run, 44023985957 onee35baa, gave the same codes in every row but the last.Qwen3-0.6B-NPU2, model loadedfastflowlm/qwen3-0.6b-npu2, model loaded/v1/responses,Qwen3-0.6B-NPU2GET /v1/models/Qwen3-0.6B-NPU2GET /v1/models"display_name": "Qwen3-0.6B-NPU2"lemonade:qwen3-0.6b-FLMand answersQwen3-9B-Nope-NPU2(no such model), NPU model loaded on this PR's legOn 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
ee35baaa made-up-NPU2name got the loaded model's answer with a 200. At062f2e7it'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_nameandanswers_to()match on thehf_repothe app's names come from.model_path_for_name()resolves a name tolemonade:<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. A catalog it can't read raises rather than matching nothing, so a runtime that won't start is never mistaken for an unknown name.routes/inference.py:_maybe_auto_switch_modelresolves the name first; a host without a supported NPU passes it on untouched. Reading the catalog can start the NPU runtime, so only/v1/chat/completions(the one route an NPU model serves) on a request that's allowed to load starts it: auto-switch on, a credential whose load policy lets it load, not a managed account, not a held-back keyless caller. Other routes (/v1/messages,count_tokens,/v1/responses, TTS, music, separation) never start it and only resolve the model already loaded. A managed account only ever reaches the model already loaded./v1/modelslistsdisplay_name, and/v1/models/{id}matches on it or itsFastFlowLM/repo, in any case.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.pyandtest_npu_chat_route.py: name and repo matching in any case, the shared-repo refusal, the managed-account and auto-switch-off paths, the refusal of an unknown name on an NPU host, the 503 for a runtime that won't start, a non-chat route that never starts the runtime but still finds the loaded model, and the preview passing an NPU name on.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 #18048.