Skip to content

Commit 8f902ac

Browse files
justinchubyCopilot
andauthored
Add exact fail-closed Qwen4Exp GGUF support (#656)
## Stack - Depends on #655 (`justinchuby-finish-qwen4exp-core`). - Includes the sharded GGUF importer commit from #652 (`eacf244864284cc96bd70f1187b145446783aab4`) so the three-file artifact is evaluated as one complete model. ## Summary - register `general.architecture=qwen4exp` as `qwen4_exp_text` with the exact Qwen3.8 Flash-Next config, DeltaNet/QSA schedule, hyper-connections, PLE, routed/shared MoE, and output HC mixer metadata - pin `unsloth/Qwen3.8-Flash-Next-GGUF@d3bc75ee6ccef3efc1e228ec00a6cc2cdb1e2249`, all three shard sizes/LFS SHA-256 identities, and the metadata-only shard-0 closure `0 + 595 + 629 = 1224` - map every GGUF tensor family, including GGUF split indexer Q/K rows reconstructed exactly into Hugging Face's fused `index_qk_proj` - validate every tensor name, logical shape, and dynamic qtype using the complete bounded-header manifest digest `25a1e6a2073caf19d3a3835dd23702a19fa09cc651506e11a13de7b48076359d` - preserve existing official fused HF indexer checkpoints while accepting only the exact GGUF split representation on the GGUF path - fail closed before Hub payload download when header policy cannot be established, source/revision/shard identity differs, or either payload mode is requested ## Fail-closed payload policy The only published `UD-IQ1_S` route is intentionally not emitted as an executable ONNX payload: - `per_layer_token_embd.weight` is an enormous IQ4_NL embedding with no compatible native gather ABI - rank-3 routed expert banks dynamically mix IQ1_S/IQ2_XXS gate/up with IQ4_NL down tensors; released runtime evidence does not establish a matching mixed-format sparse native-block MoE ABI - these tensors are not ordinary affine rank-2 `MatMulNBits` - float32 dequantization would materialize roughly 191 GiB for the PLE table alone, exceeding the bounded 8 GiB single-tensor policy The exact header/config/mapping support is therefore a truthful preflight foundation for future ABI work, not a quantized-runtime claim. ## Validation - targeted Qwen4Exp/GGUF/registry review suite: `1187 passed, 2 skipped` - complete GGUF + Qwen4Exp + graph serial suite: `4865 passed, 54 skipped` - broad serial non-integration suite: `8409 passed, 64 skipped, 12 deselected, 1 subtest passed` - `lintrunner f --output oneline --all-files && lintrunner -a`: clean - GPT-5.6 Sol medium review run twice; fused-HF compatibility, complete qtype evidence, config pinning, and Hub fallback findings were resolved ## Waivers - No full payload download, real-weight runtime execution, L4, or L5 claim is made for the GGUF route. The exact pinned artifact is deliberately rejected before its 72+ GB payload is downloaded because neither supported native preservation nor bounded dequantization is truthful under the current Mobius/ORT ABI. - Runtime support remains deferred. This PR must not be interpreted as ORT or ORT GenAI execution evidence for the quantized artifact. --------- Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]>
1 parent 27c24d3 commit 8f902ac

28 files changed

Lines changed: 3164 additions & 172 deletions

‎docs/api/build_from_gguf.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Support is capability-specific: graph import does not imply runtime packaging.
99

1010
| Census | Total | Closure |
1111
|---|---:|---|
12-
| Architectures | 147 | graph verdicts: {'deferred': 55, 'rejected': 2, 'supported': 90}; importable: 89; quantized import: {'rejected': 31, 'supported': 116}; runtime: {'deferred': 142, 'rejected': 2, 'supported': 3} |
12+
| Architectures | 148 | graph verdicts: {'deferred': 56, 'rejected': 2, 'supported': 90}; importable: 89; quantized import: {'rejected': 32, 'supported': 116}; runtime: {'deferred': 143, 'rejected': 2, 'supported': 3} |
1313
| Active stored qtypes | 25 | 24 have an import route; 1 are explicitly deferred with no route |
1414
| Serialized projector strings | 60 | {'graph-importable': 5, 'runtime-supported': 0} |
1515
| Tokenizer pre identifiers | 87 | 56 semantic groups; route dispositions: {'deferred-compiled-semantics': 45, 'deferred-pinned-artifact-evidence': 12, 'validated-pinned-source': 30} |
@@ -33,12 +33,10 @@ payload conversion, emits one aggregate warning for lossy requantization, and
3333
saves the typed result as `quantization_report.json`. Use
3434
`keep_quantized=False` for explicit float import.
3535

36-
Storage and compute are separate: packed MatMulNBits initializers may use a
37-
native custom op or a portable inline fallback with nibble unpack,
38-
`DequantizeLinear`, and float `MatMul`. The fallback does not replace packed
39-
initializers with dense float storage or promise a particular ORT kernel. Pass
40-
`mmproj=` only for an evidenced multimodal sidecar. The CLI equivalent is
41-
`mobius build model.gguf -o output`.
36+
Packed MatMulNBits storage may use a native op or portable nibble unpack,
37+
`DequantizeLinear`, and float `MatMul`; neither implies dense storage or a specific kernel.
38+
Use `mmproj=` only for evidenced sidecars; CLI: `mobius build model.gguf -o output`.
39+
Split shards validate siblings and ownership; Hub references reject partial downloads.
4240

4341
## API
4442

@@ -87,6 +85,7 @@ remain machine-readable in `_route_census.py`; this table groups only shared nex
8785
| `artifact-unavailable` | `tokenizer-artifact-replacement` | `tokenizer:gpt-4o`, `tokenizer:jina-v1-en` | replacement complete artifact; matching official tokenizer source |
8886
| `artifact-unavailable` | `tokenizer-artifact-replacement` | `tokenizer:llama4` | replacement complete artifact; matching official tokenizer source; PR #652 |
8987
| `dependency-or-runtime-abi-blocked` | `architecture-abi-dependencies` | `architecture:falcon-h1`, `architecture:granitehybrid`, `architecture:jamba`, `architecture:kimi-k3`, `architecture:kimi-linear`, `architecture:minimax-01`, `architecture:nemotron_h_moe`, `architecture:plamo2` | ORT GenAI heterogeneous-state schema (issue #605); stateful runtime package parity |
88+
| `dependency-or-runtime-abi-blocked` | `architecture-abi-dependencies` | `architecture:qwen4exp` | dedicated graph topology; cache/state contract; synthetic parity |
9089
| `dependency-or-runtime-abi-blocked` | `architecture-abi-dependencies` | `architecture:afmoe`, `architecture:arwkv7`, `architecture:bailingmoe3`, `architecture:chameleon`, `architecture:cogvlm`, `architecture:cohere2moe`, `architecture:deepseek2`, `architecture:deepseek2-ocr`, `architecture:deepseek32`, `architecture:deepseek4`, `architecture:gemma3n`, `architecture:gemma4-assistant`, `architecture:gpt-oss`, `architecture:granite_swa`, `architecture:graniteswitch`, `architecture:hunyuan_vl`, `architecture:hy_v3`, `architecture:laguna`, `architecture:llama4`, `architecture:mellum`, `architecture:mimo2`, `architecture:minimax-m3`, `architecture:mistral3`, `architecture:nanbeige`, `architecture:paddleocr`, `architecture:plamo3`, `architecture:pockettts`, `architecture:qwen3tts`, `architecture:qwen3vl`, `architecture:qwen3vlmoe`, `architecture:rwkv6`, `architecture:rwkv6qwen2`, `architecture:rwkv7`, `architecture:step35`, `architecture:wavtokenizer-dec` | exact metadata extraction; tensor closure; dedicated graph and parity |
9190
| `dependency-or-runtime-abi-blocked` | `mtp-specialized-abi` | `mtp:bailingmoe3`, `mtp:cohere2moe`, `mtp:deepseek2`, `mtp:deepseek32`, `mtp:deepseek4`, `mtp:glm-dsa`, `mtp:hy_v3`, `mtp:mimo2`, `mtp:nemotron_h_moe`, `mtp:qwen35moe`, `mtp:qwen3next`, `mtp:step35` | specialized sidecar graph; routed/cache state ABI |
9291
| `dependency-or-runtime-abi-blocked` | `tokenizer-compiled-semantics` | `tokenizer:afmoe`, `tokenizer:bloom`, `tokenizer:chameleon`, `tokenizer:codeshell`, `tokenizer:command-r`, `tokenizer:dbrx`, `tokenizer:deepseek-coder`, `tokenizer:deepseek-llm`, `tokenizer:deepseek-v3`, `tokenizer:default`, `tokenizer:exaone`, `tokenizer:exaone-moe`, `tokenizer:falcon`, `tokenizer:gpt3-finnish`, `tokenizer:granite-docling`, `tokenizer:granite-embed-multi-97m`, `tokenizer:grok-2`, `tokenizer:hunyuan`, `tokenizer:hunyuan-dense`, `tokenizer:jais`, `tokenizer:jais-2`, `tokenizer:joyai-llm`, `tokenizer:kimi-k2`, `tokenizer:laguna`, `tokenizer:megrez`, `tokenizer:mellum2`, `tokenizer:minerva-7b`, `tokenizer:minicpm5`, `tokenizer:minimax-m2`, `tokenizer:mpt`, `tokenizer:olmo`, `tokenizer:poro-chat`, `tokenizer:refact`, `tokenizer:sarvam-moe`, `tokenizer:seed-coder`, `tokenizer:smaug-bpe`, `tokenizer:solar-open`, `tokenizer:stablelm2`, `tokenizer:starcoder`, `tokenizer:superbpe`, `tokenizer:tekken`, `tokenizer:trillion`, `tokenizer:viking`, `tokenizer:whitespace`, `tokenizer:youtu` | compiled pinned llama.cpp oracle; dispatch-equivalence fixture |
@@ -275,6 +274,7 @@ Reason codes are concise user-facing categories; detailed architecture audits re
275274
| `qwen3tts` | — | none (fails before config extraction) | not claimed | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | CONFIG_DEFERRED — The primary GGUF is only a transformed Qwen3-TTS talker backbone, not the existing Mobius Qwen3TTS conditional-generation or codec model. |
276275
| `qwen3vl` | — | none (fails before config extraction) | exact-direct-loader-conditional-union | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | CONFIG_DEFERRED — Qwen3-VL text GGUF requires multimodal position IDs and an exact qwen3vl_merger clip companion, including deep-stack vision features and architecture-specific token placement. |
277276
| `qwen3vlmoe` | — | none (fails before config extraction) | exact-direct-loader-conditional-union | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | CONFIG_DEFERRED — Qwen3-VL-MoE combines the Qwen3-VL multimodal position/token contract and merger sidecar with routed experts in the text backbone. |
277+
| `qwen4exp` | — | header/config/tensor preflight only; model=`qwen4_exp_text`; tensor=`qwen4exp` | exact pinned 3-shard artifact header closure | config=supported; tensor_map=supported; graph=deferred; runtime=deferred; quantized_import=rejected | GRAPH_DEFERRED — Exact header/config/tensor preflight is implemented, but no executable graph import route is claimed. |
278278
| `refact` | — | model=`refact`; module=`gguf_legacy`; tensor=`legacy_layernorm` | audited-direct-loader-conditional-union | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=rejected | RUNTIME_EVIDENCE_PENDING / FLOAT_IMPORT_ONLY — Import is narrowed to split, bias-free dense tensors with one KV head; loaded-but-unexecuted expert, RoPE-factor, and bias families are rejected. |
279279
| `rnd1` | — | model=`llada`; module=`rnd1`; tensor=`llama`+`diffusion_fused_qkv`+`moe_qk_norm_extras`+`moe_extras` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=supported | RUNTIME_EVIDENCE_PENDING — Config extraction, suffix-exact tensor closure, masked-diffusion task dispatch, and synthetic full-sequence execution are covered, but no pinned real GGUF has passed independent Hugging Face/llama.cpp masked-step logit parity and deterministic multi-step generation parity. |
280280
| `rwkv6` | — | none (fails before config extraction) | audited-direct-loader-conditional-union | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | CONFIG_DEFERRED — RWKV6 carries two F32 states per layer (two token-shift vectors and a per-head WKV matrix) and applies token-dependent exp(-exp(decay)), a time_first read-before-update term, per-head group norm, and cumulative rescale transforms. |

‎docs/design/qwen4-exp-text-core.md‎

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Mobius implements the text decoder identified by Hugging Face
77
The implementation is pinned to:
88

99
- `Qwen/Qwen3.8-Flash-Next@f5d08274bafd880402bd16f5e3e6c514136ec06c`
10+
- `unsloth/Qwen3.8-Flash-Next-FP8@41cc25fe32cc20053a59c89716196897580cddf6`
11+
- `unsloth/Qwen3.8-Flash-Next-GGUF@d3bc75ee6ccef3efc1e228ec00a6cc2cdb1e2249`
1012
- `huggingface/transformers@598d8ba8baaec7fec5a22da0e2844c7bf4ea20e1`
1113

1214
Exported models record that pin as `mobius.semantic_reference_revision` and
@@ -55,8 +57,36 @@ Configurations with dedicated MTP embeddings fail closed because omitting
5557
those embeddings could change the decoder contract. A future standalone
5658
NextN sidecar requires an authoritative execution equation and cache ABI.
5759

58-
FP8/NVFP4 checkpoint lowering, GGUF import, and the multimodal wrapper are
59-
outside this text-core implementation. The nested `qwen4_exp_text`
60-
configuration and architecture registration are present so a later
61-
multimodal wrapper can reuse the existing Qwen3/Qwen3.5 vision and embedding
62-
components without aliasing this decoder.
60+
FP8/NVFP4 checkpoint lowering and the multimodal wrapper remain outside this
61+
text-core implementation. The nested `qwen4_exp_text` configuration and
62+
architecture registration are present so a later multimodal wrapper can reuse
63+
the existing Qwen3/Qwen3.5 vision and embedding components without aliasing
64+
this decoder.
65+
66+
## GGUF header support and payload guard
67+
68+
The pinned GGUF is a text-only `general.architecture=qwen4exp` split set:
69+
70+
| Shard | Tensors | Bytes | LFS SHA-256 |
71+
|---|---:|---:|---|
72+
| `UD-IQ1_S/Qwen3.8-Flash-Next-UD-IQ1_S-00001-of-00003.gguf` | 0 | 10,946,624 | `88a1420825a9304063e882ada29d438263617f51ac8923d438d927496693bafd` |
73+
| `UD-IQ1_S/Qwen3.8-Flash-Next-UD-IQ1_S-00002-of-00003.gguf` | 595 | 49,990,818,368 | `3a62e35bbf9add4733bd1438ebd3a67649d5edd6cb0e72bb78e33c913992b2b6` |
74+
| `UD-IQ1_S/Qwen3.8-Flash-Next-UD-IQ1_S-00003-of-00003.gguf` | 629 | 22,544,696,352 | `0e25ceaeb89b8a80aa973c6c0c7448943682f7408c2855b2ebd016b7643a861a` |
75+
76+
Shard 0 owns all model/tokenizer metadata and no tensors. The importer
77+
inherits that metadata across the complete set and requires the exact
78+
`0 + 595 + 629 = 1224` closure. Header validation covers every
79+
hyper-connection, PLE, QSA/indexer, DeltaNet, routed/shared expert, and final
80+
output mixer tensor. GGUF's split indexer query/key matrices are concatenated
81+
row-wise into Hugging Face's fused `index_qk_proj`; they are not Q/K-permuted.
82+
83+
Payload conversion deliberately fails before Hub download. The combined PLE
84+
table is an enormous IQ4_NL embedding for which the graph has no compatible
85+
native gather ABI. Routed experts are rank-3 banks with IQ1_S gate/up and
86+
IQ4_NL down tensors, while the released runtime has neither a mixed-format
87+
sparse native-block MoE ABI nor real-weight execution evidence. Treating these
88+
as ordinary affine `MatMulNBits` would be incorrect. Explicit float
89+
dequantization is also rejected because the PLE table alone expands beyond the
90+
bounded single-tensor materialization policy. The exact header/config/mapping
91+
support is therefore a fail-closed foundation for future runtime ABI work, not
92+
a quantized execution claim.

‎src/mobius/integrations/gguf/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
# Text-only model
1414
pkg = build_from_gguf("path/to/model.gguf")
15+
# Any local shard discovers and validates its exact sibling set.
16+
pkg = build_from_gguf("path/to/model-00002-of-00003.gguf")
17+
# Hub shard references resolve and pin the complete immutable set.
18+
pkg = build_from_gguf("owner/repo@commit:model-00002-of-00003.gguf")
1519
# Quantized target storage is used by default with a fidelity report;
1620
# pass keep_quantized=False for explicitly reported float storage.
1721

‎src/mobius/integrations/gguf/_arch_registry.py‎

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,56 @@
877877
runtime=Support.DEFERRED,
878878
reason=_RECURRENT_RUNTIME_VALIDATION_PENDING,
879879
),
880+
GGUFArchitectureSpec(
881+
gguf_arch="qwen4exp",
882+
model_type="qwen4_exp_text",
883+
tensor_map_recipe=("qwen4exp",),
884+
config_key_map="qwen4exp",
885+
config_postprocessor="qwen4exp",
886+
graph=Support.DEFERRED,
887+
preflight_only=True,
888+
offset_norm=True,
889+
v_head_reorder=True,
890+
required_metadata=(
891+
"attention.head_count_kv",
892+
"attention.key_length",
893+
"attention.layer_norm_rms_epsilon",
894+
"attention.compress_ratios",
895+
"attention.indexer.head_count",
896+
"attention.indexer.key_length",
897+
"attention.indexer.top_k",
898+
"expert_count",
899+
"expert_used_count",
900+
"expert_feed_forward_length",
901+
"expert_shared_feed_forward_length",
902+
"hyper_connection.count",
903+
"hyper_connection.low_rank",
904+
"ple.layers",
905+
"ple.ngram_size",
906+
"ple.heads_per_ngram",
907+
"ple.conv_kernel",
908+
"ple.eos_token_id",
909+
"ple.layer_multipliers",
910+
"ple.head_offsets",
911+
"ple.head_vocab_sizes",
912+
"embedding_length_per_layer_input",
913+
"rope.dimension_sections",
914+
"ssm.conv_kernel",
915+
"ssm.group_count",
916+
"ssm.inner_size",
917+
"ssm.state_size",
918+
"ssm.time_step_rank",
919+
),
920+
quantized_import=Support.REJECTED,
921+
runtime=Support.DEFERRED,
922+
reason=(
923+
"Exact header/config/tensor preflight is implemented, but no executable "
924+
"graph import route is claimed. The published UD-IQ1_S "
925+
"payload is rejected: its IQ4_NL PLE table has no native gather ABI, "
926+
"mixed IQ1_S/IQ4_NL rank-3 experts have no released mixed sparse-MoE "
927+
"ABI/runtime evidence, and float dequantization exceeds bounded memory."
928+
),
929+
),
880930
# ---------------------------------------------------------------- Gemma
881931
GGUFArchitectureSpec(
882932
gguf_arch="gemma",
@@ -2400,9 +2450,10 @@ def _unknown_architecture_message(architecture: str) -> str:
24002450
prefix = f"Unsupported GGUF architecture: {architecture!r}."
24012451
if upstream is None:
24022452
return (
2403-
f"{prefix} It is not among the {len(upstream_architectures())} "
2404-
"architectures llama.cpp defines at the pinned commit, so the file is "
2405-
"either newer than this build of mobius or not a llama.cpp GGUF. "
2453+
f"{prefix} It is not among the {len(upstream_architectures())} pinned "
2454+
"GGUF architecture formats (147 from the llama.cpp census plus explicit "
2455+
"post-census artifact pins), so the file is either newer than this build "
2456+
"of mobius or not a recognized pinned GGUF. "
24062457
f"Supported: {', '.join(supported_architectures())}."
24072458
)
24082459
if not upstream.cpp_loader:

‎src/mobius/integrations/gguf/_arch_registry_test.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ def test_a_mappable_architecture_is_also_configurable_and_buildable(self, spec)
247247
f"{spec.gguf_arch}: tensor mapping is supported but config extraction "
248248
f"is {spec.config.value}"
249249
)
250+
if spec.preflight_only:
251+
assert spec.graph is not Support.SUPPORTED
252+
return
250253
assert spec.graph is Support.SUPPORTED, (
251254
f"{spec.gguf_arch}: tensor mapping is supported but graph construction "
252255
f"is {spec.graph.value}"
@@ -417,9 +420,9 @@ def test_canonical_names_are_real_upstream_architectures(self, spec) -> None:
417420
went unmapped or were unreachable.
418421
"""
419422
assert spec.gguf_arch in upstream_architectures(), (
420-
f"{spec.gguf_arch!r} is not one of the 147 architectures llama.cpp "
421-
"defines at the pinned commit. If it is a defensive spelling, declare "
422-
"it in `aliases` instead of as the canonical name."
423+
f"{spec.gguf_arch!r} is not one of the 148 pinned GGUF formats. "
424+
"If it is a defensive spelling, declare it in `aliases` instead of "
425+
"as the canonical name."
423426
)
424427

425428
def test_aliases_do_not_collide(self) -> None:
@@ -434,7 +437,7 @@ def test_aliases_do_not_collide(self) -> None:
434437
def test_registry_exactly_closes_the_pinned_census(self) -> None:
435438
specs = iter_arch_specs()
436439
_validate_census_closure(specs, frozenset(upstream_architectures()))
437-
assert len(specs) == 147
440+
assert len(specs) == 148
438441
assert {spec.gguf_arch for spec in specs} == set(upstream_architectures())
439442

440443
@pytest.mark.parametrize(
@@ -1609,7 +1612,10 @@ def test_an_unimported_upstream_architecture_names_its_cohort(self) -> None:
16091612
get_arch_spec("rwkv6")
16101613

16111614
def test_an_unknown_architecture_is_distinguished_from_an_upstream_one(self) -> None:
1612-
with pytest.raises(UnsupportedGGUFArchitectureError, match="not among the 147"):
1615+
with pytest.raises(
1616+
UnsupportedGGUFArchitectureError,
1617+
match="not among the 148 pinned",
1618+
):
16131619
get_arch_spec("definitely-not-real")
16141620

16151621
def test_legacy_exception_types_still_catch_everything(self) -> None:

0 commit comments

Comments
 (0)