Repository navigation
[Feature] AMD NPU: pick the Q4NX source GGUF with a model picker instead of free-text fields - #17515
Conversation
The Q4NX convert card took a repo, a file and a base model as free text. It now searches GGUF repos on the Hub (or lists the on-device GGUF models), lists the repo's .gguf files with Q4_0, Q4_1 and Q4_K_M first and the rest marked as re-quantized, fills the original model from the card's base_model, hides Hub repos whose GGUF architecture the pinned converter does not map, and notes when the architecture is unknown until conversion.
The pinned converter only knows Qwen2.5-VL, by basename, so a Qwen2-VL GGUF would fall to the dense qwen2 converter. /api/models/local rows carry no base_model or tags, so the local base-model fallback never fired.
Local GGUFs have no architecture until conversion, so the guard now runs on the row id and file path when the architecture is unknown.
Listing a models--org--repo folder keys each variant by its snapshot path (snapshots/<sha>/m-Q4_1), so every cached file read as re-quantized and the directly packed quants were not picked first.
A local folder picked before switching to the Hub stayed set and its files were listed under the Hub repo's key.
cachedModelInfo never expands gguf, so a typed repo's architecture was always null and an unsupported one was only warned about instead of blocked.
|
Screenshots of this PR's change: Export > Convert a GGUF to Q4NX, Hugging Face source: a GGUF model picker and a file picker instead of free-text fields. Local file source: picks from local GGUFs (or a typed path).
|
…ed query Typing a new search kept the previous repo selected, so Convert stayed enabled and would submit a model the field no longer showed.
… with each row's NPU memory need The convert card's GGUF source is now a list of the chat picker's rows instead of a combobox and a file select: a model row opens its GGUF files, one model at a time, or every On Device model at once when Expand quantizations is on. Each row shows the NPU memory the converted model needs (4-bit weights plus the 1 GB load margin) against the NPU memory window from /api/npu/status, for Hub repos and local files, and the picked file charts it on the picker's memory bar.
…d refuse an unsupported size before the download While the Q4NX card is in use the export page's summary panel shows the conversion (model, GGUF file and quant, original model, save directory, estimated Q4NX size, NPU memory fit, convertibility) and the convert steps, instead of the training export's dashes. A size named in the repo or file that the converter has no model for (Qwen3.8 27B under the qwen35 architecture) is refused in the card with Convert disabled, where it used to show a caveat and start the download. Also: files of a model with no directly packed quant show the estimate too, a failed file listing is asked again on reopen, and the picked Hub repo is listed again after a token change.
…and a convert settings page The GGUF model field becomes the chat picker's trigger and glass popover (search, Hugging Face / On Device tabs, one row per model with its NPU memory need), and source quant, original model and save directory move to a Convert settings sub-page. Q4_K_M counts as a direct pack only for the architectures the q4k converter handles (qwen35, qwen35moe), matching q4nx_converter_pins.json.
…sts per HF token A cleanable row in a GGUF listing has no file behind it, so it is no longer offered as a source. Listings in flight are tracked per token, so a token change no longer leaves a row on Loading files.
A split GGUF is listed as one variant named by its first shard, and the convert endpoint reads one file.
… the same request A 4xx from the convert endpoint is the backend's answer for that file and those settings, so Convert is disabled beside the reason until the file, original model, save directory or token changes. A dropped connection can still be retried as is.
…request A 500 or 501 is a server fault, not a refusal, so it stays retryable like a dropped connection.
…, Unsloth Studio)
…, mint, glass (spoofed NPU, Unsloth Studio)
|
@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: 82fb26af63
ℹ️ 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".
| const { results: hubResults, isLoading: searchingHub } = useHubModelSearch( | ||
| debouncedHubQuery, |
There was a problem hiding this comment.
Wire pagination into the Hub source picker
For Hub queries with more than 48 matches, useHubModelSearch supplies only the initial batch from useHubPaginatedSearch, but this component discards hasMore and fetchMore and never requests another page. Later matches are therefore inaccessible through scrolling. Because hubRows applies architecture filtering after pagination, the picker can also display “No GGUF models found” when the first page is unsupported but convertible repositories exist on subsequent pages. Connect the list to the hook’s pagination API, including continuing when filtering empties the current page.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not a correctness bug: results are Unsloth-first per query, a narrower query or a typed owner/name reaches any repo, and nothing shown is wrong; infinite scroll is a separate enhancement.
… also ships split [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2f793565d
ℹ️ 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".
| !row.folder && q4nxHasSplitFiles(response.variants) | ||
| ? await hubRepoFiles(row.id, accessToken) | ||
| : undefined; |
There was a problem hiding this comment.
Recover whole GGUFs from local folders as well as Hub repos
For an On Device folder containing a whole GGUF alongside its split form, such as a cached Qwen/Qwen2.5-Coder-7B-Instruct-GGUF snapshot, list_local_gguf_variants also uses group_gguf_variant_files and returns only the first-shard row for that quant. Since repoFiles is populated only when !row.folder, q4nxConvertibleFiles drops that row even though the convertible whole file exists locally. If this is the folder's only quant, the picker incorrectly reports “No single-file GGUF found”; selecting the valid source requires manually typing its full path instead. Apply whole-file recovery to local directory listings too.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reachable in practice: a local folder only collapses to shards when it holds both the whole file and every shard of the same quant (a whole-file-only download lists the whole file as usual), and that rare folder's file can still be picked by typing its .gguf path.
…r the search changes
|
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". |
…ts main already has (unslothai#17517) [skip ci]
… LoRA and Q4NX into tabs (unslothai#17717) The Export page stacked its flows as cards (Source, Export method, "Export an image LoRA", "Convert a GGUF to Q4NX (AMD NPU)"), so the image LoRA and Q4NX flows sat below the whole LLM form. This puts each flow behind its own tab under the page header. ## What changed - A tab bar under the "Export" title, using the app's existing `Tabs` component (`components/ui/tabs.tsx`): 1. **LLM**: the existing Source + Export method flow and its summary card. 2. **Diffusion LoRA**: the image LoRA export card. 3. **Convert to Q4NX**: main's Q4NX model-picker card, next to its own Export summary card (model, GGUF file, quant, original model, save directory, estimated size, NPU memory, quick guide). No Export button there: the card converts with its own Convert button. The tab only shows when main's gate passes (a supported AMD NPU with FastFlowLM ready); a stale `q4nx` selection falls back to LLM. - Subtitle is now "Export models and adapters for deployment, or convert GGUFs for AMD NPUs". - Card contents are as main has them. Each flow is a real tab panel (`TabsContent`, `forceMount`), hidden while inactive rather than unmounted, so a running export or conversion keeps its state when you switch tabs. - An `?imageLora=` deep link from a finished training run opens on the Diffusion LoRA tab. Starting the guided tour switches to the LLM tab, since the tour only walks that flow. - New `exportTabs` i18n keys in `en.ts` and every overlay (`npm run i18n:check:strict` passes). ## Merge of main Merged main at `d2d8823325` (the NPU phase PRs had landed and the page conflicted). Main's Q4NX picker card (unslothai#17515) and the NPU-and-FastFlowLM gate (unslothai#17522) are kept as is. Main switched one shared summary card between the LLM flow and the Q4NX card by tracking which card you last clicked; with tabs that tracking has nothing to do, so it's dropped and the Q4NX tab renders its own summary from the card's `onSummary`. The loading and error fallback that rendered both extra cards above the LLM form is gone too, since each card now lives in its own tab regardless of checkpoint state. `tests/export-q4nx-npu-gate.test.ts` now counts the gated Q4NX tab trigger and panel instead of two `<Q4nxConvertCard>` sites. ## Tests All at `5b74aa2973`. Codex: "Didn't find any major issues" at this commit on the mirror, LeoBorcherding#886 ([comment](LeoBorcherding#886 (comment))). - `tsc -b`: clean - `tsc -p tsconfig.test.json --noEmit`: clean - `npm run i18n:check:strict`: all overlays pass - `tests/export-page-tabs.test.ts` (tab fallback without an NPU, one trigger and one panel per tab, each card rendered once, image LoRA deep link opens its tab) - Export page tests (`tests/export-*.test.ts`, `image-lora-export-handoff`, `finetune-export-branches`, `reload-snapshot`, `chat-only-full-install`): 123/123 pass - Full frontend suite (`npm test`): 16456 pass, 0 fail, 1 skipped ## Tested on a Strix Halo NPU | | | |---|---| | Machine | AMD DevLab runner `X2-LA03-S04-D04`: Ryzen AI MAX+ 395, Radeon 8060S, XDNA2 NPU, 124 GiB | | OS / kernel | Ubuntu 24.04, `7.0.0-43-generic` | | NPU driver | `amdxdna` 2.25.260102.56, NPU firmware 1.1.2.65 | | Runtime | FastFlowLM 1.0.12, Lemonade 2026.44.1 (installed by Unsloth Studio) | | Commit | `5b74aa2973`, installed with `install.sh --local` | | Run | [oobabooga/unsloth run 43897124471](https://github.com/oobabooga/unsloth/actions/runs/43897124471) | What ran, headless Chromium at 1440x1000, mint theme, glass on, light mode, no chats: 1. LLM tab with `unsloth/Qwen3-0.6B` picked from the Hugging Face source and GGUF Q4_K_M selected: summary reads Ready, ~343 MB. 2. Diffusion LoRA tab as it shows on a box with no image LoRAs. 3. A real conversion through the Q4NX card: `unsloth/Qwen3-0.6B-GGUF`, file `Qwen3-0.6B-Q4_1.gguf`, original model `Qwen/Qwen3-0.6B`. It finished in under 30 s and wrote `q4nx/Qwen3-0.6B-Q4_1-q4nx` (`model.q4nx`, `tokenizer.json`, `tokenizer_config.json`). 4. The converted `model.q4nx` is byte-identical to FastFlowLM's own published `Qwen3-0.6B-NPU2/model.q4nx` (both sha256 `db8dec4d…53fa667`, 683,820,832 bytes). Unsloth Studio only loads NPU models from FastFlowLM's catalog, so the job copied the converted files into that catalog folder (a no-op, same bytes), loaded `qwen3-0.6b-FLM` on the NPU from Unsloth Studio, and asked one question from the chat page with temperature forced to 0 (the UI's 0.6 rewritten on the request). Reply: "The capital of France is Paris.", 112.6 tok/s. The folder's hash was unchanged after the chat. Not covered here: Q4_0 conversion (still broken on main), Q4_K_M re-quantization, Windows, and the NVIDIA path (the tab is hidden there by main's gate, which the unit test covers). ## Screenshots **LLM**, Hugging Face model picked  **Diffusion LoRA**  **Convert to Q4NX**, nothing picked  **Convert to Q4NX**, Q4_1 picked, convert settings open  **Converting**  **Done**  **The result loaded on the NPU and chatting** (temperature 0)  ## Before / after on a host without an AMD NPU Main at the merge base (`d2d8823325`) vs this PR (`729950ad5f`), two isolated Studio installs, Chromium at 1440x1000. No NPU on this host, so the Q4NX tab and the AMD NPU subtitle clause stay hidden on both sides. LLM flow: the page now opens on the LLM tab, with "LLM" and "Diffusion LoRA" as the only tabs.  Image LoRA flow: stacked under the LLM form before, its own tab after.  --------- Co-authored-by: Daniel Han <[email protected]>
…the NPU model list (unslothai#17636) Q4NX folders converted on the Export page now show in the NPU section of the model picker as "Converted" rows, and load on the AMD NPU. Before, a converted model could only be run by hand outside Unsloth Studio. Loading links the folder's files into FastFlowLM's model folder next to the base model's `config.json`, and adds a `model_list.json` entry (through `FLM_CONFIG_PATH`) that runs on the base model's kernels. Removing a converted model drops only that registration, never the export folder. Converted models are text-only: the Export page converts the language weights, not the vision tower. Builds on the Q4NX export PRs (unslothai#17521, unslothai#17515, unslothai#17522, unslothai#17533, unslothai#17534). ## Tested on a Strix Halo NPU | | | |---|---| | Machine | AMD DevLab runner: Ryzen AI MAX+ 395, Radeon 8060S, XDNA2 NPU, 124 GiB | | OS / kernel | Ubuntu 24.04.5, `7.0.0-43-generic` | | NPU driver | `amdxdna` 2.25.260102.56, NPU firmware 1.1.2.65 | | Runtime | FastFlowLM 1.0.12, Lemonade 2026.44.1 | | Commit that ran | `8f5c293fb5`: this PR's head `d2256204` plus the review fixes from the fork mirror (LeoBorcherding#876, to `380ee036c4`), merged with main `b66e8f498a`, plus two follow-ups (a test stub kept on main's memory tag, and converted rows named by folder in main's new composer model picker) | | Run | [oobabooga/unsloth run 43900756899](https://github.com/oobabooga/unsloth/actions/runs/43900756899) | What ran, in the real UI with headless Chromium (mint theme, glass on, light mode, no chats): 1. Export page Q4NX card: `unsloth/Qwen3-0.6B-GGUF`, file `Qwen3-0.6B-Q4_1.gguf`, original model `Qwen/Qwen3-0.6B`. Converted in 23 s to `q4nx/Qwen3-0.6B-Q4_1-q4nx`. 2. The chat model picker lists it under NPU as `Qwen3-0.6B-Q4_1-q4nx` ("Converted on the Export page"). 3. Loaded on the NPU in 8 s and chatted at temperature 0 (Run settings field). "Name the three primary colors in one short sentence." got "The three primary colors are red, blue, and yellow." at 119.5 tok/s (17 tokens, first token 631 ms, prompt 42.1 tok/s). Not covered: Q4_0 sources (they convert but decode as noise on FastFlowLM, a separate converter issue), Q4_K_M sources, vision models, Windows. The temperature is the Run settings value; the request body wasn't captured. Known issue on main, not changed here: the composer model picker lists FastFlowLM catalog models by internal id in backend order (unslothai#17517). Converted rows from this PR show their folder name. Pushed as `f39b6f687d` (merge with main included; Codex clean at that commit on the mirror, LeoBorcherding#876). It has three review fixes on top of what ran, not rerun on the NPU: - `be91ed7b51`: Auto context sizes a converted model from its staged folder (the run above loaded at 8192 because the plan had no config). - `b0281fe807`: converted rows get the memory-fit fields, so the "May not fit NPU memory" tag and the Hub warning show for them. - `f39b6f687d`: a GGUF export with Q4NX saved four or more levels deep under exports registers its save folder, so the conversion is listed. ## Screenshots **Export page, Q4NX card: GGUF file list**  **Convert settings, Q4_1**  **Converting**  **Done**  **The converted model in the NPU section of the chat picker**  **Loaded, temperature 0**  **Chat on the NPU**  **Reply stats**  --------- Co-authored-by: Daniel Han <[email protected]>


The "Convert a GGUF to Q4NX (AMD NPU)" card on the Export page took the GGUF repo, file and original model as plain text. It now matches the rest of the Export page:
base_model(the Hub's Base chip) and stays editable.The request to
POST /convert/q4nxand the backend are unchanged. Helpers infeatures/export/lib/q4nx-source.tsare covered bytests/export-q4nx-source.test.ts.Tested: typecheck and frontend tests pass on Windows 11. Not yet run in the app.
Screenshots
NPU spoofed: fake Lemonade/FastFlowLM on a Windows 11 PC with no NPU; no speed numbers. After only, built from this PR's head
a21e783(Unsloth Studio web against the spoof backend, Convert never clicked). Light mode, mint theme, glass on. This branch doesn't have #17531, so its backend sends nomemory_window_gb; the captures inject 16.0 GB into/api/npu/status, which is what #17531 reports for the 32 GB of RAM the spoof shows (Windows, half of RAM). Without it the rows show the need with no window.Hugging Face tab: the convert card opens the chat model picker's popover, one row per model with its NPU memory need, "Not convertible" on an unsupported size.

A model expanded to its GGUF files: Q4_0, Q4_1 and Q4_K_M first, the rest tagged re-quantized, each with its NPU memory.

Convert settings page (source quant, original model, save directory) and the export summary describing the conversion.

On Device tab: local GGUFs from the Hugging Face cache.

The chat model picker (left) next to the convert card picker (right): same popover.

Before / after (merge base afc8ffb vs head d2f7935)
Two isolated Studio installs on Linux, no NPU on the host:
/api/npu/statusis answered as supported with a 16 GB window in the browser so the card renders on both sides. Before: the card takes the GGUF repo, file, original model and save directory as free text. After: a "Select GGUF model" picker; searching "Qwen3-0.6B" lists 35 Hub GGUF repos, each with its NPU memory need (about 1.3 of 16.0 GB), and the export summary describes the conversion.