Skip to content

Commit 86e70a8

Browse files
justinchubyCopilot
andauthored
Add exact Grok, GroveMoE, and Hunyuan-MoE GGUF graphs (#685)
## Summary - add dedicated float-import GGUF graphs for `grok`, `grovemoe`, and `hunyuan-moe` - close pinned metadata defaults, conditional tensor families, fused/split QKV layouts, suffix-exact mappings, and packed expert expansion - preserve architecture-specific semantics: Grok scaling/softcaps/sandwich norms/GEGLU, GroveMoE two-bank routing, and Hunyuan post-RoPE Q/K norm plus parallel shared expert - keep quantized/native import rejected and runtime packaging deferred until independent real-weight and OGA evidence exists - update model registry, route census, model coverage, and generated GGUF documentation ## Upstream and artifact evidence Implementation is pinned to `ggml-org/llama.cpp@8d9af256337d1a501250f9bbf4c0859a654bddd6`. Bounded HTTP range reads validated 8 MiB from each immutable artifact (24 MiB total; payloads removed afterward): | Architecture | Artifact | Revision | Header result | |---|---|---|---| | `grok` | `unsloth/grok-2-GGUF/Q2_K/grok-2-Q2_K-00001-of-00003.gguf` | `7b560aeb31bbd8ff7a026f3cfd981c0364024cbf` | `grok`, 477 tensors, split 0/3, 963 logical tensors | | `grovemoe` | `mradermacher/GroveMoE-Inst-GGUF/GroveMoE-Inst.Q2_K.gguf` | `4dec2e9eaf01d5150d5b45a7d7c95c6220aaad7f` | `grovemoe`, 723 tensors | | `hunyuan-moe` | `gabriellarson/Hunyuan-A13B-Instruct-GGUF/Hunyuan-A13B-Instruct-IQ1_S.gguf` | `1ab8a37a314dfa05d4dc11cd899a5dded62c0578` | `hunyuan-moe`, 482 tensors | The older Arki05 Grok-1 IQ1_S header was also audited and deliberately rejected as a current route because it uses the legacy per-expert `ffn_{gate,up,down}.N.weight` layout rather than the pinned loader's packed `*_exps` tensors. GroveMoE intentionally follows the pinned llama.cpp graph where the chunk bank consumes the primary MoE output and gathers weights at floor-mapped chunk IDs, even though those details differ from the Hugging Face reference. ## Validation - broad serial non-integration suite: 8,916 passed, 64 skipped, 12 deselected - focused executable synthetic parity and end-to-end GGUF builds for all three architectures - build-graph and weight-alignment coverage for all three internal model types - lintrunner formatter and full lint clean - GGUF support docs, model docs, and feature-flag generators clean - diff check clean - changed-line mypy: 0 errors across 10 changed production files - two independent high-effort reviews: no significant findings ## Capability boundaries / waivers - **Quantized/native storage:** not claimed. `keep_quantized=True` fails closed because these dedicated graphs currently expose floating `Linear`/expert modules only. - **Runtime/OGA:** deferred. No full representative artifact plus independent ORT GenAI prefill, cached-decode, and generation evidence was established. - **Real-weight golden generation:** deferred with runtime evidence. Grok has no public logical GGUF at or below 16 GiB; the only sub-16-GiB Hunyuan artifact is highly lossy IQ1_S. These limitations do not weaken the synthetic executable parity and exact graph-import acceptance gate added here. --------- Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]>
1 parent 841e629 commit 86e70a8

18 files changed

Lines changed: 2215 additions & 28 deletions

‎docs/api/build_from_gguf.md‎

Lines changed: 6 additions & 6 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 | 148 | graph verdicts: {'deferred': 46, 'rejected': 2, 'supported': 100}; importable: 99; quantized import: {'rejected': 41, 'supported': 107}; runtime: {'deferred': 136, 'rejected': 2, 'supported': 10} |
12+
| Architectures | 148 | graph verdicts: {'deferred': 43, 'rejected': 2, 'supported': 103}; importable: 102; quantized import: {'rejected': 44, 'supported': 104}; runtime: {'deferred': 136, 'rejected': 2, 'supported': 10} |
1313
| Active stored qtypes | 25 | 24 have an import route; 1 are explicitly deferred with no route |
1414
| Serialized projector strings | 60 | {'graph-importable': 9, 'runtime-supported': 0} |
1515
| Tokenizer pre identifiers | 87 | 56 semantic groups; route dispositions: {'deferred-compiled-semantics': 45, 'deferred-pinned-artifact-evidence': 4, 'deferred-pinned-artifact-mismatch': 7, 'validated-pinned-source': 31} |
@@ -111,11 +111,11 @@ remain machine-readable in `_route_census.py`; this table groups only shared nex
111111
| `dependency-or-runtime-abi-blocked` | `projector-runtime-abi` | `projector:resampler` | dynamic processor-to-graph media shape ABI |
112112
| `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 |
113113
| `dependency-or-runtime-abi-blocked` | `tokenizer-compiled-semantics` | `tokenizer:bailingmoe`, `tokenizer:bailingmoe2`, `tokenizer:chatglm-bpe`, `tokenizer:cohere2moe`, `tokenizer:glm4`, `tokenizer:llada-moe`, `tokenizer:tiny_aya` | upstream tokenizer semantic parity; independently proven replacement reconstruction |
114-
| `evidence-only` | `architecture-runtime-evidence` | `architecture:apertus`, `architecture:arcee`, `architecture:arctic`, `architecture:baichuan`, `architecture:bailingmoe`, `architecture:bert`, `architecture:bitnet`, `architecture:bloom`, `architecture:chatglm`, `architecture:codeshell`, `architecture:cohere2`, `architecture:command-r`, `architecture:dbrx`, `architecture:deci`, `architecture:deepseek`, `architecture:dflash`, `architecture:dots1`, `architecture:dream`, `architecture:eagle3`, `architecture:ernie4_5`, `architecture:ernie4_5-moe`, `architecture:eurobert`, `architecture:exaone`, `architecture:falcon`, `architecture:gemma`, `architecture:gemma-embedding`, `architecture:gemma2`, `architecture:gemma3`, `architecture:gemma4`, `architecture:granite`, `architecture:granitemoe`, `architecture:hunyuan-dense`, `architecture:hy_v3`, `architecture:internlm2`, `architecture:jais`, `architecture:jais2`, `architecture:jina-bert-v2`, `architecture:jina-bert-v3`, `architecture:lfm2moe`, `architecture:llada`, `architecture:llada-moe`, `architecture:llama-embed`, `architecture:maincoder`, `architecture:mamba`, `architecture:mamba2`, `architecture:minicpm`, `architecture:minicpm3`, `architecture:modern-bert`, `architecture:muse-glimmer`, `architecture:nemotron`, `architecture:nemotron_h`, `architecture:neo-bert`, `architecture:nomic-bert`, `architecture:nomic-bert-moe`, `architecture:olmo2`, `architecture:olmoe`, `architecture:openelm`, `architecture:orion`, `architecture:pangu-embedded`, `architecture:phi2`, `architecture:phi3`, `architecture:phimoe`, `architecture:plamo`, `architecture:plm`, `architecture:qwen`, `architecture:qwen2moe`, `architecture:qwen2vl`, `architecture:qwen3`, `architecture:qwen35`, `architecture:qwen3moe`, `architecture:qwen3next`, `architecture:refact`, `architecture:rnd1`, `architecture:seed_oss`, `architecture:smallthinker`, `architecture:smollm3`, `architecture:stablelm`, `architecture:t5`, `architecture:t5encoder`, `architecture:talkie`, `architecture:xverse` | immutable representative GGUF; full-logit prefill and cached-decode parity; deterministic generation/state evidence |
114+
| `evidence-only` | `architecture-runtime-evidence` | `architecture:apertus`, `architecture:arcee`, `architecture:arctic`, `architecture:baichuan`, `architecture:bailingmoe`, `architecture:bert`, `architecture:bitnet`, `architecture:bloom`, `architecture:chatglm`, `architecture:codeshell`, `architecture:cohere2`, `architecture:command-r`, `architecture:dbrx`, `architecture:deci`, `architecture:deepseek`, `architecture:dflash`, `architecture:dots1`, `architecture:dream`, `architecture:eagle3`, `architecture:ernie4_5`, `architecture:ernie4_5-moe`, `architecture:eurobert`, `architecture:exaone`, `architecture:falcon`, `architecture:gemma`, `architecture:gemma-embedding`, `architecture:gemma2`, `architecture:gemma3`, `architecture:gemma4`, `architecture:granite`, `architecture:granitemoe`, `architecture:grok`, `architecture:grovemoe`, `architecture:hunyuan-dense`, `architecture:hunyuan-moe`, `architecture:hy_v3`, `architecture:internlm2`, `architecture:jais`, `architecture:jais2`, `architecture:jina-bert-v2`, `architecture:jina-bert-v3`, `architecture:lfm2moe`, `architecture:llada`, `architecture:llada-moe`, `architecture:llama-embed`, `architecture:maincoder`, `architecture:mamba`, `architecture:mamba2`, `architecture:minicpm`, `architecture:minicpm3`, `architecture:modern-bert`, `architecture:muse-glimmer`, `architecture:nemotron`, `architecture:nemotron_h`, `architecture:neo-bert`, `architecture:nomic-bert`, `architecture:nomic-bert-moe`, `architecture:olmo2`, `architecture:olmoe`, `architecture:openelm`, `architecture:orion`, `architecture:pangu-embedded`, `architecture:phi2`, `architecture:phi3`, `architecture:phimoe`, `architecture:plamo`, `architecture:plm`, `architecture:qwen`, `architecture:qwen2moe`, `architecture:qwen2vl`, `architecture:qwen3`, `architecture:qwen35`, `architecture:qwen3moe`, `architecture:qwen3next`, `architecture:refact`, `architecture:rnd1`, `architecture:seed_oss`, `architecture:smallthinker`, `architecture:smollm3`, `architecture:stablelm`, `architecture:t5`, `architecture:t5encoder`, `architecture:talkie`, `architecture:xverse` | immutable representative GGUF; full-logit prefill and cached-decode parity; deterministic generation/state evidence |
115115
| `evidence-only` | `draft-runtime-evidence` | `draft:dflash`, `draft:eagle3` | target acceptance loop; draft cache orchestration; deterministic speedup parity |
116116
| `evidence-only` | `mtp-runtime-evidence` | `mtp:hy_v3`, `mtp:qwen35` | target acceptance loop; cache-threaded draft/target parity |
117117
| `evidence-only` | `projector-runtime-evidence` | `projector:adapter`, `projector:gemma3`, `projector:gemma4v`, `projector:ldp`, `projector:ldpv2`, `projector:mlp`, `projector:muse-glimmer`, `projector:qwen2.5vl_merger`, `projector:qwen2vl_merger` | paired text target; processor boundary; deterministic multimodal package execution |
118-
| `immediately-implementable` | `architecture-implementation` | `architecture:grok`, `architecture:grovemoe`, `architecture:hunyuan-moe`, `architecture:minimax-m2`, `architecture:mistral4` | exact metadata extraction; tensor closure; dedicated graph and parity |
118+
| `immediately-implementable` | `architecture-implementation` | `architecture:minimax-m2`, `architecture:mistral4` | exact metadata extraction; tensor closure; dedicated graph and parity |
119119
| `immediately-implementable` | `architecture-implementation` | `architecture:glm-dsa` | suffix-exact tensor mapping; packed-value transform proof; graph closure |
120120
| `immediately-implementable` | `projector-implementation` | `projector:cogvlm`, `projector:deepseekocr`, `projector:deepseekocr2`, `projector:dots3note_a`, `projector:dots3note_v`, `projector:dots_ocr`, `projector:exaone4_5`, `projector:gemma3na`, `projector:gemma3nv`, `projector:gemma4a`, `projector:gemma4ua`, `projector:gemma4uv`, `projector:glm4v`, `projector:glma`, `projector:granite4_vision`, `projector:granite_speech`, `projector:hunyuanvl`, `projector:idefics3`, `projector:internvl`, `projector:janus_pro`, `projector:kimik25`, `projector:kimivl`, `projector:lfm2`, `projector:lfm2a`, `projector:lightonocr`, `projector:llama4`, `projector:meralion`, `projector:mimo_audio`, `projector:mimovl`, `projector:minicpmv4_6`, `projector:minimax_m3`, `projector:musicflamingo`, `projector:nemotron_v2_vl`, `projector:paddleocr`, `projector:parakeet`, `projector:pixtral`, `projector:pockettts_spkenc`, `projector:qwen2.5o`, `projector:qwen2a`, `projector:qwen3a`, `projector:qwen3tts_spkenc`, `projector:qwen3vl_merger`, `projector:step3vl`, `projector:ultravox`, `projector:voxtral`, `projector:yasa2`, `projector:youtuvl` | metadata schema; tensor closure; component graph parity |
121121
| `intentionally-rejected` | `policy-rejections` | `architecture:bailingmoe2`, `architecture:clip`, `architecture:dots3note`, `architecture:exaone-moe`, `architecture:exaone4`, `architecture:glm4`, `architecture:glm4moe`, `architecture:gptj` | policy change plus independent correctness proof |
@@ -226,10 +226,10 @@ Reason codes are concise user-facing categories; detailed architecture audits re
226226
| `granitehybrid` | — | model=`granitemoehybrid`; tensor=`granitehybrid` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=rejected | RUNTIME_EVIDENCE_PENDING / FLOAT_IMPORT_ONLY — Exact mixed attention/Mamba2 scheduling, architecture-wide dense or routed MoE feed-forward selection, optional shared experts, Granite scaling, value-preserving float expert fusion, and strict pinned tensor closure are supported. |
227227
| `granitemoe` | — | model=`granitemoe`; tensor=`llama`+`moe_extras` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=supported | RUNTIME_EVIDENCE_PENDING — Config extraction, exact tensor-name closure, and a full synthetic GGUF graph build are covered, but no representative real-weight GGUF has yet passed ORT parity or generation validation. |
228228
| `graniteswitch` | — | none (fails before config extraction) | audited-direct-loader-conditional-union | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | CONFIG_DEFERRED — GraniteSwitch repurposes an appended synthetic layer as a token-history-driven adapter router and carries fourteen switched-LoRA tensors per block in addition to decoder KV state. |
229-
| `grok` | — | none (fails before config extraction) | not claimed | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | CONFIG_DEFERRED — The pinned Grok graph applies embedding, attention-output, and logit scales; attention, and optional final-logit softcaps; post-attention and post-FFN norms; and a dense-plus-routed expert residual scaled by sqrt(2)/2. |
230-
| `grovemoe` | — | none (fails before config extraction) | not claimed | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | CONFIG_DEFERRED — The pinned GroveMoE graph shares router logits across two distinct expert banks but performs separate selections for normal and grouped chunk experts, then scales the adjugate contribution independently. |
229+
| `grok` | — | model=`grok_gguf`; module=`grok_gguf`; tensor=`grok` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=rejected | RUNTIME_EVIDENCE_PENDING / FLOAT_IMPORT_ONLY — The mobius graph uses floating Linear modules for this architecture, so no MatMulNBits or BlockQuantizedMatMul target can consume preserved GGUF projection weights. |
230+
| `grovemoe` | — | model=`grovemoe_gguf`; module=`grovemoe_gguf`; tensor=`grovemoe` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=rejected | RUNTIME_EVIDENCE_PENDING / FLOAT_IMPORT_ONLY — The mobius graph uses floating Linear modules for this architecture, so no MatMulNBits or BlockQuantizedMatMul target can consume preserved GGUF projection weights. |
231231
| `hunyuan-dense` | `hunyuan_v1_dense` | model=`hunyuan_v1_dense`; tensor=`llama`+`hunyuan_extras` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=supported | RUNTIME_EVIDENCE_PENDING — Config extraction, exact tensor-name closure, and a full synthetic GGUF graph build are covered, but no representative real-weight GGUF has yet passed ORT parity or generation validation. |
232-
| `hunyuan-moe` | — | none (fails before config extraction) | audited-direct-loader-conditional-union | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | CONFIG_DEFERRED — Hunyuan-MoE applies Q/K normalization after RoPE and runs normalized routed experts with an always-parallel shared branch in every layer. |
232+
| `hunyuan-moe` | — | model=`hunyuan_moe_gguf`; module=`hunyuan_moe_gguf`; tensor=`hunyuan_moe` | audited-direct-loader-conditional-union | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=rejected | RUNTIME_EVIDENCE_PENDING / FLOAT_IMPORT_ONLY — The mobius graph uses floating Linear modules for this architecture, so no MatMulNBits or BlockQuantizedMatMul target can consume preserved GGUF projection weights. |
233233
| `hunyuan_vl` | — | none (fails before config extraction) | exact-direct-loader-conditional-union | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | CONFIG_DEFERRED — The pinned Hunyuan-VL decoder uses its own M-RoPE and Q/K-normalized text contract and pairs with a hunyuanvl clip sidecar. |
234234
| `hy_v3` | — | model=`hy_v3`; tensor=`llama`+`hy_v3_extras` | audited-direct-loader-conditional-union | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=rejected | RUNTIME_EVIDENCE_PENDING / FLOAT_IMPORT_ONLY — Exact full-attention trunk and independently cached NextN sidecar graphs are covered, including per-head Q/K RMSNorm, a contiguous dense prefix, selection-biased sigmoid routed SwiGLU experts, and an ungated shared expert. |
235235
| `internlm2` | — | model=`internlm2`; tensor=`llama` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=rejected | RUNTIME_EVIDENCE_PENDING / FLOAT_IMPORT_ONLY — The mobius graph uses floating Linear modules for this architecture, so no MatMulNBits or BlockQuantizedMatMul target can consume preserved GGUF projection weights. |

‎src/mobius/_configs/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
Gemma4Config,
4141
GlmAsrConfig,
4242
GraniteMoeHybridConfig,
43+
GrokGGUFConfig,
44+
GroveMoEGGUFConfig,
4345
HyV3Config,
4446
HyV3MtpConfig,
4547
Jais2Config,
@@ -127,6 +129,8 @@
127129
"Gemma4AudioConfig",
128130
"Gemma4Config",
129131
"GlmAsrConfig",
132+
"GrokGGUFConfig",
133+
"GroveMoEGGUFConfig",
130134
"GraniteMoeHybridConfig",
131135
"HyV3Config",
132136
"HyV3MtpConfig",

‎src/mobius/_configs/_base.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,31 @@ class CausalLMConfig(ArchitectureConfig):
15481548
"""
15491549

15501550

1551+
@dataclasses.dataclass
1552+
class GrokGGUFConfig(CausalLMConfig):
1553+
"""GGUF-only Grok graph settings loaded by the pinned llama.cpp implementation."""
1554+
1555+
embedding_scale: float = 78.38367176906169
1556+
attention_output_scale: float = 0.08838834764831845
1557+
logit_output_scale: float = 0.5773502691896257
1558+
attn_logit_softcapping: float = 30.0
1559+
router_logit_softcapping: float = 30.0
1560+
final_logit_softcapping: float = 0.0
1561+
attention_temperature_length: int = 0
1562+
has_dense_ffn: bool = False
1563+
has_gated_dense_ffn: bool = False
1564+
has_gated_experts: bool = True
1565+
1566+
1567+
@dataclasses.dataclass
1568+
class GroveMoEGGUFConfig(CausalLMConfig):
1569+
"""GGUF-only GroveMoE chunk-expert routing settings."""
1570+
1571+
chunk_expert_intermediate_size: int = DEFAULT_INT
1572+
experts_per_group: int = DEFAULT_INT
1573+
expert_group_scale: float = 0.05
1574+
1575+
15511576
@dataclasses.dataclass
15521577
class Qwen4ExpConfig(CausalLMConfig):
15531578
"""Exact configuration for experimental Qwen4/Qwen3.8 Flash-Next."""

‎src/mobius/_registry.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
GPTOSSCausalLMModel,
9191
GraniteCausalLMModel,
9292
GraniteMoECausalLMModel,
93+
GrokGGUFCausalLMModel,
94+
GroveMoEGGUFCausalLMModel,
95+
HunyuanMoEGGUFCausalLMModel,
9396
HunYuanMoEV1CausalLMModel,
9497
HunYuanV1DenseCausalLMModel,
9598
HunYuanVLMoTModel,
@@ -681,6 +684,9 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
681684
"granitemoe": ModelRegistration(GraniteMoECausalLMModel),
682685
"granitemoehybrid": ModelRegistration(GraniteMoeHybridCausalLMModel),
683686
"granitemoeshared": ModelRegistration(GraniteMoECausalLMModel),
687+
"grok_gguf": ModelRegistration(GrokGGUFCausalLMModel),
688+
"grovemoe_gguf": ModelRegistration(GroveMoEGGUFCausalLMModel),
689+
"hunyuan_moe_gguf": ModelRegistration(HunyuanMoEGGUFCausalLMModel),
684690
"hunyuan_v1_moe": ModelRegistration(HunYuanMoEV1CausalLMModel),
685691
"jetmoe": ModelRegistration(JetMoeCausalLMModel),
686692
"kimi_linear": ModelRegistration(

0 commit comments

Comments
 (0)