Skip to content

Close pinned GGUF MTP and NextN support - #600

Merged
justinchuby merged 3 commits into
mainfrom
justinchuby-complete-gguf-mtp-closure
Aug 25, 2026
Merged

justinchuby merged 3 commits into
mainfrom
justinchuby-complete-gguf-mtp-closure

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • make the pinned llama.cpp 8d9af256337d1a501250f9bbf4c0859a654bddd6 MTP/NextN loader and converter census authoritative across dense, routed, hybrid, draft, and multimodal architecture namespaces
  • export the exact one-head dense Qwen3.5 auxiliary sidecar while failing closed before graph construction for routed/MoE/hybrid, multi-head, partial, unknown, legacy, scale/state, malformed, and out-of-range contracts
  • preserve exact target/sidecar embedding, norm, head, packed-weight, and initializer ownership; persist and reload the MTP sidecar as a first-class ModelPackage attachment
  • require immutable selected-file Hub revisions and exact header architecture validation; document downstream runtime support as DEFERRED

Validation

  • focused MTP suite: 103 passed
  • affected MTP/GGUF/package/CLI/coverage suites: 817 passed, 225 skipped
  • broad non-integration suite: 6,525 passed, 52 skipped
  • full initialized lintrunner format and lint
  • two independent high-confidence full-diff reviews clean after all findings were fixed

Runtime status

DEFERRED: runtime support is not claimed without a pinned real artifact, independent full-logit parity, and deterministic end-to-end speculative/MTP generation.

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 43896fa → bcd2268

Model Sub-model Changes Status

No architecture changes detected. ✅


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 43896fa → bcd2268

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 68 68 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 105 105 +0.0% ⚪
gpt2 model_size_bytes 388 KB 388 KB +0.0% ⚪
gpt2 num_nodes 54 54 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 60 60 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 56 56 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 94 94 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 58 58 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 54 54 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 60 60 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 264 264 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 126 126 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 428 428 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 176 176 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

@justinchuby
justinchuby force-pushed the justinchuby-add-multimodal-gguf-cohort branch from 985c553 to b835949 Compare August 25, 2026 16:27
Base automatically changed from justinchuby-add-multimodal-gguf-cohort to main August 25, 2026 16:28
@justinchuby
justinchuby requested a review from a team August 25, 2026 16:28
justinchuby and others added 3 commits August 25, 2026 09:29
Make the pinned llama.cpp MTP and NextN census authoritative and fail closed across all loader and converter architectures. Export only the exact dense Qwen3.5 sidecar while rejecting routed, hybrid, malformed, multi-head, and unknown contracts before graph construction.\n\nPersist the auxiliary head as a first-class ModelPackage sidecar, harden immutable selected-file Hub validation, and document runtime support as deferred pending real-artifact generation evidence.\n\nCo-authored-by: Copilot App <[email protected]>

Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Preserve fail-closed quantized ownership while allowing the reviewed Q4_1 dedicated MTP head to dequantize explicitly. Keep deterministic test tensor ordering and compatible multi-head diagnostics after the parent squash reconstruction.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-complete-gguf-mtp-closure branch from 7ac405e to bcd2268 Compare August 25, 2026 16:35
Copilot AI lite review requested due to automatic review settings August 25, 2026 16:35
@justinchuby
justinchuby merged commit 85fb322 into main Aug 25, 2026
19 of 22 checks passed
@justinchuby
justinchuby deleted the justinchuby-complete-gguf-mtp-closure branch August 25, 2026 16:35
justinchuby added a commit that referenced this pull request Aug 25, 2026
## Summary

- close the immutable llama.cpp architecture census at
`8d9af256337d1a501250f9bbf4c0859a654bddd6`: every one of 147 real
`general.architecture` IDs now resolves to exactly one capability spec
- classify the final 50 IDs without fabricating aliases or overclaiming
graph/runtime support; reject dead `gptj` and defer all other newly
closed IDs before config extraction because their exact
graph/task/cache/tensor/quantization contracts are not representable
- pin helper-expanded loader tensor unions, suffixless tensors,
required/defaulted scalar and array metadata, RWKV variant state ABI
distinctions, exact 25-qtype closure, and generated 147-row support
documentation
- prevent unknown architectures from silently falling through generic
Hugging Face config/model dispatch and run architecture verdicts before
MTP/qtype policy

## Final closure set

`afmoe`, `bailingmoe`, `bailingmoe2`, `bitnet`, `codeshell`,
`cohere2moe`, `command-r`, `deepseek`, `deepseek2`, `deepseek32`,
`dots1`, `dots3note`, `ernie4_5`, `ernie4_5-moe`, `exaone-moe`,
`exaone4`, `gemma-embedding`, `gemma4-assistant`, `glm-dsa`, `glm4`,
`glm4moe`, `gptj`, `gptneox`, `granite`, `granite_swa`, `graniteswitch`,
`hunyuan-moe`, `hy_v3`, `jais`, `jais2`, `laguna`, `llama-embed`,
`maincoder`, `mellum`, `mimo2`, `minicpm`, `minimax-m2`, `minimax-m3`,
`mistral4`, `nanbeige`, `orion`, `pangu-embedded`, `plamo`, `plamo3`,
`plm`, `qwen`, `refact`, `starcoder`, `step35`, `xverse`.

## Validation

- focused registry/census/qtype: 1,663 passed
- full GGUF suite: 2,564 passed
- broad non-integration suite excluding inherited `glm_moe_dsa` baseline
failures: 6,994 passed, 52 skipped
- initialized lintrunner format and full lint: clean
- two independent GPT-5.6 Sol full-diff reviews: clean after findings
were fixed and affected gates rerun

The two `glm_moe_dsa` ONNX shape/checker failures reproduce unchanged on
the exact stacked base SHA `7ac405e6394bc595d359945263bf724516720450`;
this PR does not touch that model.

Stacked on #600.

---------

Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens GGUF Multi-Token Prediction (MTP / “NextN”) handling by enforcing an authoritative, pinned llama.cpp contract: it validates metadata/tensor layouts up-front (fail-closed), exports the supported dense Qwen3.5 MTP sidecar, and records the upstream capability census. It also changes Hub download preflight to require immutable revisions and adds persistence for the exported MTP sidecar.

Changes:

  • Add a pinned MTP/NextN capability census + strict pre-graph contract validation, and export exactly one supported dense Qwen3.5 MTP sidecar.
  • Require immutable HuggingFace Hub revision resolution and validate GGUF header architecture before downloading.
  • Persist/reload the MTP sidecar alongside saved packages; expand documentation and tests for the new contract and behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/model_coverage_test.py Updates coverage text to reflect the new Qwen3.5 MTP IO/ownership contract and test coverage.
tests/build_graph_test.py Adjusts build-graph exclusions/comments to reference new GGUF MTP capability tests.
src/mobius/integrations/gguf/_upstream_data/llamacpp_pin.json Records pinned llama.cpp MTP/NextN metadata/tensor contract + architecture census and runtime status.
src/mobius/integrations/gguf/_mtp.py Implements pinned capability policy + strict validation and sidecar export behavior.
src/mobius/integrations/gguf/_mtp_test.py Adds contract/census tests and additional shape/metadata failure-mode coverage.
src/mobius/integrations/gguf/_builder.py Enforces MTP contract validation during GGUF pre-validation; tightens HF preflight to immutable revisions; adds targeted dequantization exception.
src/mobius/integrations/gguf/_builder_test.py Updates tests to reflect immutable-revision preflight behavior and new preflight API.
src/mobius/_model_package.py Adds mtp_head attachment persistence and special loading behavior for mtp/.
src/mobius/_model_package_test.py Adds roundtrip tests for saving/loading packages with an attached mtp_head.
src/mobius/main.py Relies on ModelPackage.save() to persist the MTP sidecar under mtp/.
docs/api/build_from_gguf.md Documents the pinned MTP/NextN contract, failure modes, supported cohort, and deferred runtime status.
Suppressed comments (1)

src/mobius/_model_package.py:628

  • Restoring mtp_head from "mtp/model.onnx" makes the collision with a primary "mtp" component even worse: a previously valid multi-component package with an "mtp" model will now be interpreted as an auxiliary attachment and become inaccessible via pkg["mtp"]. This is a backwards-incompatible behavioral change for ModelPackage.load().
        mtp_dir = os.path.join(directory, "mtp")
        if os.path.isfile(os.path.join(mtp_dir, "model.onnx")):
            package.mtp_head = cls.load(mtp_dir)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +281 to +291
if self.mtp_head is not None:
self.mtp_head.save(
os.path.join(directory, "mtp"),
external_data=external_data,
max_shard_size_bytes=max_shard_size_bytes,
max_workers=max_workers,
progress_bar=progress_bar,
check_weights=check_weights,
include_policy_components=include_policy_components,
include_adapter_artifacts=include_adapter_artifacts,
)
Comment on lines +610 to +614
# Preserve the established multi-component precedence while excluding
# the nested MTP auxiliary package from the primary component scan.
for entry in sorted(os.listdir(directory)):
if entry == "mtp":
continue
Comment on lines +352 to +356
raise ValueError(
f"{architecture} GGUF declares {count} MTP heads and has {count} MTP blocks, "
"but only exactly one appended MTP block can be represented; refusing to "
"silently truncate the remaining heads"
)
justinchuby added a commit that referenced this pull request Aug 25, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants