Repository navigation
[Bug] AMD NPU: Q4NX export packs Q4_0, Q4_1 or Q8_0 blocks as is into models that read another layout, so Qwen3.5 from a Q4_0 GGUF answers with repeated slashes - #18064
Merged
danielhanchen merged 5 commits intoNov 17, 2026
Conversation
…rong layout for the AMD NPU Both pinned FLM converters pack a Q4_0, Q4_1 or Q8_0 tensor (q4k: also Q4_K) in its own layout, whatever the model's config targets for that slot. FastFlowLM reads each slot as the config says: Q4_0 signed nibbles for Qwen2 / LFM2, Q4_1 unsigned plus a min for Qwen3, Llama and the rest of the q4nx converter's models, Q4_K super-blocks for Qwen3.5. So a Q4_0 GGUF of Qwen3.5 or Qwen3, or a Q4_1 of Qwen2.5, converts without an error and answers with repeated slashes. The converter run now patches GGUFTensor.unpack to compare the type the converter will pack (its own get_used_quantization_type) with the target, and exits 3 on the first mismatch. That is raised as SourceMismatch, and the export tries the next selected source quant, the ones the architecture's converter packs as is first (Q4_K_M for Qwen3.5). The Export page's Q4NX card marks a Q4_0 or Q4_1 the model can't read as "won't convert" and sorts it last.
…he q4k converter does [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. Already looking forward to the next diff. 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 was referenced Nov 19, 2026
danielhanchen
added a commit
to Imagineer99/unsloth
that referenced
this pull request
Nov 23, 2026
…n the repo and calls a local Qwen3.5 Q4_0 "packs directly" (unslothai#18522) The Q4NX source picker on the Export page lists every GGUF file a repo ships. For `unsloth/Qwen3.5-4B-GGUF` that is 22 files, and only one, Q4_K_M, packs as is; the other 21 are dequantized and rounded to 4-bit again, or refused, so the list buries the one file you want. Separately, an **On Device** GGUF never has its architecture read before conversion, so a local Qwen3.5 Q4_0 is labeled "packs directly". That is the file unslothai#18064 refuses, because it answers with repeated slashes. **What changes** - Each model lists the files that pack as is. The rest sit behind "N more files, re-quantized or not readable by this model". A file you already picked stays visible. - `q4nxArchitecture` falls back to the model name when the architecture is unknown, for the families whose layout isn't the Q4_1 default: Qwen3.5/3.6 (Q4_K), Qwen2.5 (Q4_0, not VL) and LFM2 (Q4_0). A local Qwen3.5 Q4_0 now reads "won't convert", Q4_K_M "packs directly". **Tests:** `export-q4nx-source.test.ts` covers the name fallback and the short list. Frontend suite and typecheck pass. **Before / after** on AMD DevLab gfx1151 (Radeon 8060S, XDNA2 NPU), Ubuntu 24.04, kernel 7.0.0-43, FastFlowLM 1.0.12 / Lemonade 2026.44.1, measured at `6eb70fd` vs main `33c6179` ([run 44425657543](https://github.com/oobabooga/unsloth/actions/runs/44425657543)). Export > Convert to Q4NX, `unsloth/Qwen3.5-4B-GGUF` with Q4_K_M picked. | before (main) | after (this branch) | |---|---| |  |  | Not run: the On Device path on a real local Qwen3.5 Q4_0 file; that half is covered by the unit test, not a screenshot. ## Maintainer changes - Synced with main. - The name fallback reads only the last path segment, so a parent folder never names the family (an On Device `/models/Qwen3.5-comparisons/Qwen2.5-3B-Instruct-Q4_0.gguf` stays Qwen2.5 and packs directly). - The Qwen3.5 Omni override reads the same last segment, so `/models/omni/Qwen3.5-4B-Q4_K_M.gguf` is not treated as Omni. ## Before / after at the current head Export > Convert to Q4NX, `unsloth/Qwen3.5-4B-GGUF`, two isolated Studio installs built from the merge base and from this branch (`f71fdf825`). The NPU status is answered as ready in the browser so the tab renders; the file listing and packing tags are each build's own. | before (main): 22 files listed | after: Q4_K_M, then "21 more files, re-quantized or not readable by this model" | |---|---| |  |  | Opening the fold lists the same 22 files as before. --------- Co-authored-by: oobabooga <[email protected]> Co-authored-by: Daniel Han <[email protected]>
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.
A Q4_0 GGUF of Qwen3.5-4B converts to Q4NX in Unsloth Studio without an error, loads on the AMD NPU, and answers "hello" with nothing but
/. This makes the converter refuse that source with a message, and the export falls through to the next selected quant that fits.Cause
Both pinned ROCm/FLM_Q4NX_Converter commits pack a Q4_0, Q4_1 or Q8_0 tensor (the
q4kone also Q4_K) in its own layout, whatever the model's config targets for that slot.GGUFTensor.get_used_quantization_typereturns the source type for those, andunpackpasses the blocks through. FastFlowLM reads each slot as the config says:q4kpinea1df7e)unpackre-encodes to a Q4_K triple, but the slot is then packed withtensor_type=Q4_0(the source type), so the bytes are neitherNothing errors at any step. The stock
unsloth/Qwen3.5-4B-GGUFQ4_0 has 172 Q4_0 and 4 Q4_1 tensors, so almost every weight is wrong.Fix
core/export/q4nx.py: the converter subprocess patchesGGUFTensor.unpackto compare the type the converter will pack (its ownget_used_quantization_type) with the target. On the first quantized mismatch among Q4_0 / Q4_1 / Q4_K / Q8_0 it prints the tensor, both types and what to use instead, and exits 3, which is raised asSourceMismatch. Floats, MXFP4 (gpt-oss experts) and anything the converter re-quantizes itself are untouched. The rule was checked against the realGGUFTensorat both pins (dd0993c,ea1df7e, archive hashes matchq4nx_converter_pins.json):dd0993crefuses Q4_0/Q4_1/Q8_0 into a different 4- or 8-bit target, andea1df7eadditionally Q4_K into a Q4_0/Q4_1 slot (the 0.8Bssm_outcase [Bug] AMD NPU: Qwen3.5 Q4NX exports fail to load in FastFlowLM #17759 fixed by config override) but not Q4_0 into a Q8_0 slot, which it re-quantizes.core/export/export.py: the GGUF export with "Q4NX" ticked tries each selected source quant in turn, the ones the architecture's converter packs as is first, and moves on when one is refused.DIRECT_QUANTS["q4k"]is now Q4_K_M only.qwen2,lfm2read Q4_0;qwen35,qwen35moeQ4_K; the rest Q4_1). When the architecture isn't known yet, nothing changes and the converter decides.Real NPU, main vs this branch
AMD DevLab Strix Halo runner on oobabooga's fork: Ryzen AI MAX+ 395 (Radeon 8060S), NPU Strix Halo (XDNA2, amdxdna 2.25.260102.56, firmware 1.1.2.65), Ubuntu 24.04.5, kernel 7.0.0-43, FastFlowLM 1.0.12, Lemonade 2026.44.1. Run 44003434291, one job, both legs on the same host, driven through the Export page and the chat with Playwright (temperature 0).
Both legs carry #17636 (open), which is what lists a converted model in the NPU picker. before = upstream main
9034f08c29+ #17636f39b6f687d(56b0ddfde7); after = that + this PR's9b42b59706(b6c8be8e95). The head has since moved to2c6ed1d3bb, which only changes the summary's "Convertible" text on the card.unsloth/Qwen3.5-4B-GGUFQ4_0/until stopped at 15 minblk.0.attn_gate.weight is Q4_0, which the Q4NX converter packs as is into a model that reads Q4_K there, so FastFlowLM would read noise. Convert a Q4_K_M GGUF instead.unsloth/Qwen3.5-4B-GGUFQ4_K_MHello! How can I help you today?at 13.4 tok/sunsloth/LFM2-1.2B-GGUFQ4_0 (a model that reads Q4_0)Screenshots
before, Q4_0 converted with no error:

before, streaming:

after, Q4_0 refused on the card:

after, Q4_K_M answers:

after, LFM2-1.2B Q4_0 converts:

Not covered: Windows, a Q4_1 source into Qwen2.5 or LFM2, a Q4_0 source into a
q4nx-converter model such as Qwen3 on the NPU (the unit tests and the per-pin check cover the rule, no NPU run did), and a coherent LFM2 Q4_0 answer.Tests
studio/backend/tests/test_export_npu_q4nx.py: the real_RUN_CONVERTERscript against a stub converter whoseget_used_quantization_typemirrors each pin (22 source/target cases acrossq4nxandq4k), the export falling through a refused source and reporting the last refusal,SourceMismatchfrom exit 3, and Q4_K_M first for Qwen3.5. 77 passed.test_export_q4nx_accounts.py+test_export_gguf_discovery.py: 57 passed.tests/studio/install/test_install_q4nx_converter.py: 12 passed.studio/frontend/tests/export-q4nx-source.test.ts: per-architecture packing, sort order, summary rows. Full frontend suite 16469 passed;npm run typecheckclean.Related
////symptom on Strix Halo, but through llama.cpp with a GGUF, not Q4NX, so it is not this cause.q4kpin and overrode the 0.8B/2Bssm_outslot.