Repository navigation
Add hybrid attention/recurrent GGUF cohort - #587
Conversation
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
Performance Comparison
|
1fe0c7e to
0dc4ddc
Compare
Import pinned llama.cpp semantics for LFM2, Qwen3.5 dense and MoE, and Qwen3-Next. Reconstruct mixer schedules, validate suffix-exact tensor closure, expose mixer-specific state, and fail closed for unsupported cache, MTP, alternate tensor, and quantization layouts. Keep runtime packaging deferred pending independent real-weight parity. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
Expose a dedicated post-final-norm MTP seed while preserving ordinary pre-norm hidden-state captures. Support optional dedicated nextn embedding, norm, and output-head tensors with exact backbone fallback and initializer metadata for tied, untied, and quantized weights. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 5e542579-8cc6-4fcf-9019-0af2824b73bf Signed-off-by: Justin Chu <[email protected]>
Construct dense and MoE Qwen3.5 decoders through the canonical text-model replacement path so float and packed tied heads share the actual embedding parameters. Fail closed on incompatible mixed tied storage and update MTP shared-weight metadata to name only graph-owned initializers. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 5e542579-8cc6-4fcf-9019-0af2824b73bf Signed-off-by: Justin Chu <[email protected]>
Treat top-level and quantization tie declarations as one effective contract across causal model construction, text-model rebinding, weight preprocessing, Qwen3.5 variants, and MTP metadata. This preserves Olive ties when the top-level flag is cleared while keeping mixed storage fail-closed. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 5e542579-8cc6-4fcf-9019-0af2824b73bf Signed-off-by: Justin Chu <[email protected]>
Preserve the post-#586 fail-closed quantization policy during the hybrid cohort replay. Keep explicit float fallback execution coverage, validate the complete MTP schedule, and pin the new quantized-import architectures. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
048954f to
75ac6af
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new GGUF “hybrid attention/recurrent” cohort (lfm2, qwen35, qwen35moe, qwen3next) with fail-closed metadata/tensor-contract validation and a deterministic mixed-state ABI, plus extends Qwen3.5 MTP support to handle optional dedicated embedding/LM-head tables and to seed speculation from an explicit post-final-norm mtp_seed.
Changes:
- Enforce pinned hybrid schedule reconstruction (per-layer mixer layout) and suffix-exact tensor closure checks before graph build; reject task/cache misdispatch for mixed-state models.
- Extend Qwen3.5 MTP export path: optional dedicated
input_ids/logitsports, explicitmtp_seedoutput from the backbone, and correct shared-weight inference for tied/quantized variants. - Improve Qwen3.5 embedding/head tying behavior under quantization (including Olive-tied cases) and add targeted tests for tied-table rebinding and GGUF hybrid ABI threading.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/mobius/tasks/_qwen35_mtp.py | Adds conditional input_ids input / logits output support for MTP sidecars when dedicated tables exist. |
| src/mobius/tasks/_causal_lm.py | Supports an optional 4-tuple model return to emit mtp_seed from post-final-norm hidden state. |
| src/mobius/models/qwen35.py | Switches token embedding construction to embedding_for_config and centralizes effective tie behavior. |
| src/mobius/models/qwen35_test.py | Adds extensive tests for tied embedding/LM-head behavior across float and quantized modes (incl. save/reload). |
| src/mobius/models/qwen35_mtp.py | Extends MTP head module to optionally own embedding/head tables and emit logits vs mtp_hidden. |
| src/mobius/models/base.py | Introduces effective_tie_word_embeddings, embedding_for_config, tie-storage compatibility checks, and optional final hidden emission. |
| src/mobius/integrations/onnx_genai/inference_metadata.py | Updates MTP workflow metadata generation: dynamic ports, shared-weight inference, and mtp_seed role assignment. |
| src/mobius/integrations/onnx_genai/inference_metadata_test.py | Extends tests to validate dynamic MTP ports/shared-weights and new mtp_seed semantics. |
| src/mobius/integrations/gguf/_upstream_data/llamacpp_pin.json | Pins explicit tensor inventories for the new hybrid cohort architectures. |
| src/mobius/integrations/gguf/_tensor_mapping.py | Adds mapping tables/extras for lfm2 and qwen3next hybrid tensor naming. |
| src/mobius/integrations/gguf/_mtp.py | Detects optional dedicated MTP tables and derives MTP config accordingly; adds norm fallback mapping. |
| src/mobius/integrations/gguf/_mtp_test.py | Tests optional MTP table behavior, post-final-norm mtp_seed, and fail-closed rejection cases. |
| src/mobius/integrations/gguf/_config_mapping.py | Reconstructs exact hybrid schedules from pinned metadata and validates DeltaNet dimension derivations. |
| src/mobius/integrations/gguf/_config_mapping_test.py | Adds unit tests for hybrid schedule extraction and stricter fail-closed metadata behavior. |
| src/mobius/integrations/gguf/_builder.py | Adds hybrid tensor-contract validation and enforces hybrid-task-only dispatch; improves fused expert splitting. |
| src/mobius/integrations/gguf/_builder_test.py | Adds end-to-end synthetic hybrid ABI threading tests for lfm2 and qwen35; validates quantized/float behavior. |
| src/mobius/integrations/gguf/_arch_registry.py | Registers lfm2/qwen35/qwen35moe/qwen3next as runtime-deferred GGUF architectures with required metadata gates. |
| src/mobius/integrations/gguf/_arch_registry_test.py | Updates the pinned supported-architectures set to include the new hybrid cohort. |
| src/mobius/_configs/_base.py | Adds output_final_hidden_state and MTP config flags for dedicated embeddings/LM head ownership. |
| src/mobius/main.py | Passes proposer (MTP head) config into metadata writer for accurate workflow declaration. |
| docs/api/build_from_gguf.md | Documents the hybrid mixed-state ABI contract, pinned schedule reconstruction, and MTP seed/tables behavior. |
Suppressed comments (1)
src/mobius/tasks/_qwen35_mtp.py:14
- The docstring’s “Graph inputs/outputs” section is now inaccurate: the graph can expose
input_ids(dedicated embeddings) instead ofinputs_embeds, and it can emitlogits(dedicated LM head) instead ofmtp_hidden. This contract is part of the task’s public documentation and should match the actual ports created inbuild().
GQA KV cache. It consumes ``input_ids`` and emits ``logits`` when the GGUF
provides dedicated embedding/head tables; otherwise those ports are
``inputs_embeds`` and ``mtp_hidden`` and the runtime borrows target weights.
Graph inputs:
- ``inputs_embeds`` : ``[batch, seq_len, hidden]`` (model dtype) — the
target's ``embed_tokens(t_{i+1})`` for the token(s) the head
conditions on.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| The Qwen3.5/3.8 MTP head is a self-speculative drafter saved next to the | ||
| backbone (``mtp/model.onnx``). It borrows the target's shared embedding / | ||
| LM head and is seeded by the backbone's final-layer hidden state. | ||
| backbone (``mtp/model.onnx``). It borrows target embedding / LM-head weights | ||
| only when the GGUF omits dedicated tables, and is seeded by the backbone's | ||
| dedicated post-final-norm ``mtp_seed`` output. |
## 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
lfm2,qwen35,qwen35moe, andqwen3nextStacked on #586 (
justinchuby-add-audio-codec-gguf-cohort). Routed-expert Qwen3.5-MoE/Qwen3-Next MTP blocks are explicitly rejected until the MTP sidecar can represent their experts; dense Qwen3.5 MTP remains supported.Validation
1640 passed— fullsrc/mobius/integrations/ggufsuite6105 passed, 52 skipped— broad non-integration suiteglm_moe_dsafailures remain in ONNX checker/output shape inferencelintrunner f --output oneline --all-filespassed