Sync native GGUF support with current upstream types - #3058
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Reviewed head 1. [P1] Q2_0 packing and decoding disagree with the upstream byte layoutLocations: encoder, lines 213–214, decoder, lines 674–675. The new encoder combines weights Concrete reproduction: a scale-1 block containing This silently permutes weights when loading upstream Q2_0 checkpoints and makes native Q2_0 output incompatible with upstream readers. The added hand-packed Q2_0 test encodes the same incorrect strided layout, so it currently enshrines the bug. Please pack with a 2. [P2] New dequantizers do not preserve the tensor's leading dimensionsLocations: new decoders, lines 670–735, especially each All five new decoders assume a 2D matrix, but Reproduced directly against the PR functions:
Please restore Validation: reviewed all nine changed files and relevant loader/runtime call sites; executed the actual NumPy codec functions extracted from the PR via AST, without importing the GPU-heavy package. The Q2_0 and rank failures above reproduced. On 64 sampled blocks per format, TQ1_0/TQ2_0/MXFP4 quantization and dequantization, plus NVFP4 dequantization, matched the cited upstream Python block codecs exactly for 2D inputs. Full package tests and GPU inference were not run in this environment. |
|
Addressed P1 in |
|
Addressed P2 in |
|
Reviewed current head The earlier P1 Q2_0 byte-layout and P2 dequantized-shape findings are fixed. The independent One remaining low-priority correctness issue: [P3] Preserve float32 rounding immediately below the half-way thresholdLocation:
Reproduced with a block beginning
This is a narrow boundary case, but it breaks exact upstream quantization parity and can make native fallback output differ from the optional upstream codec. Please use upstream's fractional-part formulation ( Validation: reviewed all nine changed files and relevant codec/runtime/backend call sites. Executed the actual NumPy functions extracted from the current source via AST. Compared 256 random blocks per format for TQ1_0/TQ2_0/MXFP4 encoding and decoding, and NVFP4 decoding, against the PR's pinned upstream implementation; those comparisons passed. Confirmed the threshold discrepancy against upstream Python codecs and system C No additional high- or medium-priority findings in this pass. |
|
Fixed in |
Summary
Synchronize GPTQModel's native GGUF tensor IDs, storage layouts, codecs, and runtime routing with llama.cpp
3ad1ba733/ gguf-py0.19.0, while retaining Prism/BonsaiQ1_0_g128as an alias for the official 128-elementQ1_0layout.What Changed
NVFP4=40,Q1_0=41, andQ2_0=42; add reader/checkpoint coverage for the updated layouts.Q2_0,TQ1_0,TQ2_0, andMXFP4, plusNVFP4dequantization; make officialQ1_0use the existing compatible 128-element sign-only codec.roundfsemantics at float32 half-way boundaries for Q2_0, TQ1_0, and TQ2_0 fallback quantization.q2_0configuration support and route current Q1/Q2 checkpoints only to native backends that implement their layouts.Tests
Randomized TQ1_0, TQ2_0, MXFP4, and NVFP4 codec results match the cited upstream gguf-py implementation. Q2_0 encoding and decoding also match the cited llama.cpp consecutive-weight byte layout and its independent
0x64fixture. The float32 threshold regression also matches system Croundfimmediately below, at, and above both+0.5and-0.5.The full
test_weight_only.pysuite reaches a pre-existing environment failure because TorchInductor cannot compile withoutPython.h; the same first test fails on an untouchedmainworktree.Review Requirements
AI-assisted code is welcome.
Every changed file must still be properly reviewed by a human before the PR is opened as ready for review.
We will not accept PRs that are effectively unreviewed AI output. Non-human-reviewed changes often introduce obscure structure, mismatched APIs, project-inconsistent code patterns, or unnecessary monkeypatching instead of a correct fix or clean feature expansion.
Notes
Raw tensor type
40now follows the officialNVFP4assignment. The former private 32-elementQ1_0interpretation cannot coexist under that ID; Prism/Bonsai artifacts using type41remain compatible through theQ1_0_g128alias.Link to Devin session: https://app.devin.ai/sessions/983b34b989f842989aceb3bccefdf8c2
Open in Devin Desktop: https://app.devin.ai/desktop/session/983b34b989f842989aceb3bccefdf8c2?variant=devin
Requested by: @Qubitium