Repository navigation
Add Q4_K_M GGUF→ONNX conversion support - #399
Merged
Merged
Conversation
Performance Comparison
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the GGUF→ONNX “keep_quantized” pipeline to support llama.cpp’s mixed Q4_K_M-style quantization by adding Q4_K handling and a float dequantize→requantize path that normalizes mixed source quant types into a single MatMulNBits target layout.
Changes:
- Add Q4_K super-block handling that reference-dequantizes across flattened storage (including super-blocks crossing logical row boundaries) and requantizes into MatMulNBits 4-bit block-32 layout.
- Introduce
repack_dequantized_tensor()to requantize dequantized float weights into MatMulNBits, enabling normalization of mixed GGUF presets. - Improve GGUF dequantization API (
dequantize_raw_tensor) and add targeted tests for mixed-profile detection and Q4_K correctness/error bounds.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/mobius/integrations/gguf/_repacker.py | Implements Q4_K repacking via reference dequantization + requantization; adds repack_dequantized_tensor() helper. |
| src/mobius/integrations/gguf/_repacker_test.py | Adds MatMulNBits dequant helper and new tests for Q4_K requantization bounds and row-crossing behavior. |
| src/mobius/integrations/gguf/_reader.py | Factors out dequantize_raw_tensor() to preserve K-quant flattened layout before reshaping. |
| src/mobius/integrations/gguf/_builder.py | Normalizes mixed quant presets by repacking all QuantizedLinear weights; adds requantization for non-matching types; adjusts quant-target detection. |
| src/mobius/integrations/gguf/_builder_test.py | Adds tests for mixed-profile target selection and dequantize_raw_tensor() parity with get_tensor(). |
justinchuby
force-pushed
the
feat/gguf-q4km-support
branch
from
July 13, 2026 05:17
f859573 to
019f7f2
Compare
Member
Author
|
@copilot rebase, and address comments if relevant |
Co-authored-by: Copilot <[email protected]>
justinchuby
force-pushed
the
feat/gguf-q4km-support
branch
from
July 13, 2026 13:47
019f7f2 to
5b0467f
Compare
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.
build-gguf previously only handled Q4_0; Q4_K_M (llama.cpp's default deployment quant) failed. Adds Q4_K_M support:
dequantize_row_q4_K), then affine-requantizes into packed uint4 MatMulNBits blocks (block_size=32). Mixed Q5_0/Q6_K/Q8_0 projections use the same target.Qwen2.5-0.5B-Instruct-GGUF:q4_k_m→ 168 MatMulNBits → onnx-genai output 'The capital of France is Paris.'lintrunner clean; gguf pytest 154 passed.