Repository navigation
Validate every stored GGUF quantization type - #574
Conversation
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
Performance Comparison
|
184176f to
3b52342
Compare
Define an exhaustive importer policy for the pinned llama.cpp storage qtype census, including explicit routes, exactness, tensor-role constraints, and deferred runtime verdicts. Enforce those decisions through text, embedding, expert, multimodal, and MTP import paths, and reject unsupported preservation requests actionably instead of silently falling back to float. Add closure, numerical, synthetic package, and generated documentation coverage, plus pinned mixed-qtype artifact evidence. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
Record quantized-import capability per GGUF architecture and derive preservation rejection from that policy so the generated matrix no longer overclaims InternLM2 support. Pin the accepted architecture set and retain an internal graph-policy drift guard. Reject multiple MTP heads during config extraction before any package can be built, while preserving the tested single-head quantized path. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 334b7f18-da8f-4559-b708-0342e3457fae Signed-off-by: Justin Chu <[email protected]>
Use the reader_tensors interface introduced on main when constructing the quantized embedding test fixture. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
Preserve the dense architecture cohort's quantized-import support, regenerate its matrix rows, and keep replayed tests compatible with the shard-aware reader. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
4514c9c to
62375c9
Compare
There was a problem hiding this comment.
Pull request overview
This PR tightens and validates the GGUF quantization import policy by making every active stored GGML qtype map to an explicit, tested importer route (native bytes, affine repack, decoder-backed requant, float dequant, or rejection), and by extending the architecture registry with an explicit “quantized import reachability” capability to prevent keep_quantized=True on graphs that can’t consume packed weights.
Changes:
- Introduces explicit quantization import route metadata (
QuantImportRoute,RepackExactness,TensorRole) and extends GGUF architecture specs with aquantized_importcapability. - Updates the GGUF builder to enforce qtype policy closure (reject unknown/out-of-policy qtypes), gate
keep_quantized=Trueby architecture capability, and apply role-aware routing (projection/embedding/expert/non-matmul) including MTP sidecar handling. - Adds mutation-resistant tests and generated documentation matrices for both architecture support and stored-qtype routing.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/mobius/models/qwen35_mtp.py | Aligns MTP head fc linear module construction with Qwen3.5 quantized-linear factory support. |
| src/mobius/integrations/gguf/_spec.py | Adds explicit route/exactness/role enums and extends architecture & qtype specs with quantized-import and runtime verdict metadata. |
| src/mobius/integrations/gguf/_spec_test.py | Updates/extends spec validation tests to cover new route/exactness invariants. |
| src/mobius/integrations/gguf/_quant_registry.py | Pins an explicit stored-qtype route census and exposes quant_import_decision() plus a generated quant support matrix. |
| src/mobius/integrations/gguf/_quant_registry_test.py | Adds closure/route pinning tests, decoder sanity checks, and doc-matrix drift tests for stored qtypes. |
| src/mobius/integrations/gguf/_mtp.py | Enforces single MTP head export and enables quantized-native linear replacement before graph build when preserving quantization. |
| src/mobius/integrations/gguf/_mtp_test.py | Expands MTP GGUF fixtures to cover quantized weights and multi-head rejection behavior. |
| src/mobius/integrations/gguf/_mmproj.py | Plumbs TensorRole into multimodal repack calls to ensure role-appropriate routing. |
| src/mobius/integrations/gguf/_config_mapping.py | Rejects multi-head MTP (nextn_predict_layers>1) early with an actionable error. |
| src/mobius/integrations/gguf/_builder.py | Adds architecture quantized-import gating, qtype closure enforcement, role-aware repack/requant decisions, and removes “swallow MTP failures” behavior. |
| src/mobius/integrations/gguf/_builder_test.py | Adds fixtures and tests for decoder-backed qtypes, embedding routing conversions, and actionable rejection of unsupported/unknown qtypes. |
| src/mobius/integrations/gguf/_arch_registry.py | Adds an explicit “no quantized projection modules” reason and marks specific architectures as quantized_import=REJECTED. |
| src/mobius/integrations/gguf/_arch_registry_test.py | Pins the quantized-import-supported architecture set and updates doc-table generation to include quantized reachability. |
| docs/api/build_from_gguf.md | Updates the public docs with a generated stored-qtype matrix and a 5-capability architecture support table. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| target_bits: int, | ||
| target_block_size: int, | ||
| target_symmetric: bool, | ||
| tensor_name: str, | ||
| tensor_role=None, |
| core_verdicts = { | ||
| name: verdict | ||
| for name, verdict in spec.verdicts.items() | ||
| if name != "quantized_import" | ||
| } |
## Summary - clean up still-valid typing, documentation, test robustness, error-message, maintainability, and performance findings left by the GGUF PR stack - preserve the behavioral fixes merged in #625-#632 - hash reused multi-GB GGUF sources once, at the final pre-publication integrity gate, while retaining cheap identity checks around staging Exact base: `2db9d33debdc254d879a51b14434c9a81c230f4f` Exact head: `4541ed2bc9d2ab4227484510b4a85b2d9113eb25` ## Reconstructed original 17-item low-priority tranche The persisted audit retained only the totals, so this list was reconstructed from the live threads and current source. All but the already-fixed #596 comment are addressed in this PR. | PR | Comment | Disposition | |---|---:|---| | #550 | 3837144656 | Implemented: correct tuple return annotation | | #552 | 3837389183 | Implemented: multichannel waveform shape docs | | #559 | 3837716261 | Implemented: name-based cache assertions | | #573 | 3854308350 | Implemented: one final GGUF hash, with integrity regression coverage | | #574 | 3854345521 | Implemented: `TensorRole \| None` typing | | #574 | 3854345597 | Implemented: removed obsolete verdict filtering | | #577 | 3854472859 | Implemented: documented SSM sequence length | | #578 | 3843112613 | Implemented: documented F64 passthrough | | #579 | 3854518332 | Implemented: generalized fused-projection error | | #580 | 3854576300 | Implemented: removed brittle node counts | | #583 | 3854681386 | Implemented: documented conditional draft outputs | | #587 | 3854816872 | Implemented: corrected MTP output contract docs | | #596 | 3846110059 | Already fixed on base: unambiguous GQA bias comment | | #600 | 3855174281 | Implemented: metadata-count-only MTP error | | #607 | 3855776048 | Implemented: stable route-field assertions | | #607 | 3855776086 | Implemented: public tensor iterator | | #609 | 3856486136 | Implemented: fail-closed LM-head comment | ## Current unresolved-thread disposition This covers all 48 Copilot threads returned by the reproducible #600-#630 query. The one human #623 thread is excluded. | PR | Comment | Current-main disposition and evidence | |---|---:|---| | #600 | 3855174177 | Already fixed by #629: package cycle and reserved-sidecar validation | | #600 | 3855174238 | Already fixed by #629: explicit MTP sidecar naming/loading | | #600 | 3855174281 | Implemented here: error no longer invents an observed block count | | #602 | 3848155961 | Outside exact stack; already fixed: top-level `expert_dtype` is classified before early return | | #602 | 3848155983 | Outside exact stack; still-valid behavioral block-quant validation, unchanged | | #602 | 3848156000 | Outside exact stack; still-valid truncated-read behavioral finding, unchanged | | #602 | 3848156022 | Outside exact stack; still-valid descriptor byte/dtype validation, unchanged | | #602 | 3848156040 | Outside exact stack; still-valid expert-bank payload validation, unchanged | | #603 | 3855249765 | Already fixed by #630: runtime preflight preserves shard sets | | #603 | 3855249840 | Already fixed by #630: success output follows durable runtime publication | | #604 | 3855343082 | Implemented here: graph-only MTP persistence distinguished from runtime rejection | | #604 | 3855343131 | Already fixed by #630: runtime success messages are atomic | | #607 | 3855776001 | Implemented here: missing generation golden skips before provenance read | | #607 | 3855776048 | Implemented here: only stable route fields are asserted | | #607 | 3855776086 | Implemented here: tensor count uses `tensor_items_raw()` | | #608 | 3856079371 | Still-valid behavioral cache-symlink containment finding; unchanged | | #608 | 3856079415 | Still-valid behavioral lowercase-digest validation finding; unchanged | | #609 | 3856486136 | Implemented here: comment matches value-preserving policy | | #610 | 3855541683 | Already fixed by #628: Falcon bias precedence is explicit | | #610 | 3855541761 | Already fixed by #628: CTRL tiny config exercises projection biases | | #611 | 3856595840 | Implemented here: runtime test resolves the distribution providing the module | | #612 | 3855677383 | Already fixed by #625: supported-version endianness detection | | #612 | 3855677427 | Implemented here: shared `INT64_MAX` sentinel | | #612 | 3855677460 | Implemented here: shared PLaMo2 width inference | | #612 | 3855677486 | Implemented here: accepted PLaMo2 activation spellings are explicit | | #613 | 3855845678 | Implemented here: canonical issue URL | | #613 | 3855845757 | Implemented here: Mamba-1 function-registration docs | | #613 | 3855845806 | Implemented here: test expects the canonical issue URL | | #614 | 3855988545 | Implemented here: removed stale Nemotron-H divergence comments | | #614 | 3855988597 | Already fixed by #628: zero-head geometry raises actionable `ValueError` | | #615 | 3856082290 | Already fixed by #626: dense GraniteHybrid bias closure | | #618 | 3856729330 | Implemented here: required routes filter ORT GenAI evidence | | #618 | 3856729409 | Implemented here: env-selected runtime version is authoritative | | #618 | 3856729490 | Stale/N/A: PR-description-only matrix claim; repository workflow claims one pinned version | | #618 | 3856729563 | Implemented here: schema tail restored to normal indentation | | #619 | 3856342484 | Already fixed on base: Kimi Linear uses `/issues/605` | | #619 | 3856342532 | Already fixed by #628: config rejects convolution kernels below 2 | | #619 | 3856342580 | Already fixed by #628: GGUF contract rejects convolution kernels below 2 | | #620 | 3855717041 | Already fixed by #627: tied LM-head-only checkpoints are retained | | #621 | 3856722324 | Already fixed by #628: Kimi-K3 required metadata is complete | | #623 | 3855931210 | N/A to current main: comment belongs to open, unmerged #623 | | #623 | 3855939302 | N/A to current main: comment belongs to open, unmerged #623 | | #623 | 3855939358 | N/A to current main: comment belongs to open, unmerged #623 | | #623 | 3855939394 | N/A to current main: comment belongs to open, unmerged #623 | | #624 | 3856777152 | Implemented here: runtime compatibility reuses the emitted model type | | #625 | 3857049733 | Implemented here: unsupported header reports both endian candidates | | #629 | 3857313182 | Newer post-audit behavioral sidecar-symlink cleanup finding; unchanged | | #629 | 3857313251 | Newer post-audit cross-platform path-safety finding; unchanged | ## Validation - affected GGUF/package/ORT GenAI/model/schema tests: 1,040 passed - broad non-integration suite: 7,851 passed, 56 skipped, 1 subtest passed - generated GGUF docs checks: 7 passed - initialized `lintrunner`; full lint/format passed - GPT-5.6 Sol medium review: one integrity finding fixed; re-review found no significant issues Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]>
Summary
8d9af256337d1a501250f9bbf4c0859a654bddd6Policy highlights
Native byte preservation is limited to compatible projection/output
BlockQuantizedMatMulweights for IQ4_NL, IQ4_XS, IQ3_S, IQ3_XXS, IQ2_XXS, IQ2_XS, IQ2_S, IQ1_S, IQ1_M, and MXFP4. Embeddings use the separateGatherBlockQuantizedABI and are normalized accordingly. Non-native expert-major tensors reject in quantized mode unless their complete contiguous layout is supported. UnsupportedQ2_0and unknown qtypes fail actionably. Runtime verdicts remainDEFERREDbecause graph construction is not runtime execution evidence.Real mixed-qtype evidence
lmstudio-community/Qwen2.5-0.5B-Instruct-GGUF3b32d0bf1ac136098d417677c7d757360f1ceb6bQwen2.5-0.5B-Instruct-Q4_K_M.gguf397807936bytesfa4d41b65761ed565cac6b5f62e35135d050408b033114a128ab308c02b2e83aMatMulNBits, oneGatherBlockQuantized, zeroBlockQuantizedMatMulValidation
1119 passed— allsrc/mobius/integrations/gguf/tests5517 passed, 52 skipped— broad non-integration suite excludingglm_moe_dsalintrunnerformatter and full lint passThe unfiltered broad suite has two pre-existing
glm_moe_dsafailures, independently reproduced on the base branch: missing inferredlogitsshape and missing ONNX checkervalue_info.type. This PR does not modify that model.