Repository navigation
tools: check a Q4NX directory's chunk layout before it is served (#587) - #617
Merged
Merged
Conversation
A published FastFlowLM `*-NPU2` directory is served as it is, so the only thing the engine can say about it up front is whether every tensor's shape names one of the three chunk kinds (npu/q4nx.h) and whether the declared bytes are the tiles that kind needs. tools/check_q4nx_dir.py reads the container header the way npu/model.cpp does - no numpy, no gguf, no dequantize - names each quantized tensor's kind, and exits 1 on an unknown chunk size, a tensor shorter than its layout needs, or offsets past the end of the file. It reports the Q8 tensors rather than asserting a layout: two code layouts share the 8704-byte chunk and the container does not say which. `--self-test` builds the synthetic containers (one tensor of each kind; an int8 tensor whose last dimension names no kind; a truncated tensor; a directory with two .q4nx files) and the new ctest `q4nx_dir_check` runs it, so the check is proved on a box with no NPU and no model. Checked against the real file, FastFlowLM/Qwen3.8-27B-NPU2 (17,097,334,824 B, sha256 2f0c797f...eaf00fa1): 962 table entries, 506 quantized tensors - 408 Q4_K, 98 Q8, no q4_1 - 17,044,684,800 chunk bytes, 0 errors; vision_weight.q4nx (959,336,080 B) carries no quantized tensor at all. Nothing was dequantized; the Q8 layout stays unverified for this model, so no decoder is pointed at it yet (engine #587 has no 27B delta-net lane).
bong-water-water-bong
enabled auto-merge (squash)
October 27, 2026 08:46
added 3 commits
October 27, 2026 05:51
This was referenced Oct 27, 2026
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.
Part of #587 (preflight only; the issue stays open — the 27B does not yet produce correct text on the NPU).
tools/: validates a Q4NX directory before it is served — chunk count, per-chunk sizes, quant-tile compatibility and the file hashes, so a model that would fail inside the runtime fails here with a reason instead.Evidence
Run against
~/models/npu/Qwen3.8-27B-NPU2:model.q4nx17,097,334,824 B, sha2562f0c797f…eaf00fa1, 962 entries — 408 Q4_K chunks (4736 B) + 98 Q8 chunks (8704 B), no q4_1 tile tensor, 0 errors;vision_weight.q4nx959,336,080 B, 0 quantized tensors, reported unused.Not in this PR
The 27B runtime work (GDN row-padding dequant, weight-cache fix, device-path correctness) is not included: it is unfinished and the model still returns garbage on the device.