Skip to content

Add exact Grok, GroveMoE, and Hunyuan-MoE GGUF graphs - #685

Merged
justinchuby merged 4 commits into
mainfrom
justinchuby-add-remaining-moe-gguf-graphs
Aug 28, 2026
Merged

justinchuby merged 4 commits into
mainfrom
justinchuby-add-remaining-moe-gguf-graphs

Conversation

@justinchuby

Copy link
Copy Markdown
Member

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.

@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 28, 2026 05:48
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 841e629 → 65df276

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 28, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 841e629 → 65df276

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 324 KB 324 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 265 265 +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 127 127 +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 450 450 +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.

Comment thread src/mobius/models/moe.py Fixed
justinchuby and others added 2 commits August 27, 2026 22:55
Implement exact float-import graphs for Grok, GroveMoE, and Hunyuan-MoE, including pinned metadata defaults, suffix-closed tensor mappings, packed expert expansion, architecture-specific routing and normalization, and fail-closed quantized/runtime capability verdicts.

Add executable synthetic parity, end-to-end GGUF builds, architecture fingerprint isolation, immutable artifact evidence, model coverage, and regenerated registry census documentation.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Use an approximate assertion for the pinned floating-point softcap default so the final lint gate remains clean.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[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

Adds float-importable GGUF graph support for three previously-deferred MoE architectures (grok, grovemoe, hunyuan-moe) by introducing dedicated model implementations, GGUF config/tensor mapping, and strict validation + synthetic parity tests, and wiring everything into the GGUF architecture registry and docs.

Changes:

  • Implement Grok/GroveMoE/Hunyuan-MoE GGUF-specific model graphs (incl. Grok scaling/softcaps/sandwich norms, GroveMoE dual-bank routing, Hunyuan post-RoPE Q/K norm).
  • Add GGUF tensor mapping recipes + new “remaining MoE” tensor-contract validator and comprehensive synthetic GGUF build/parity tests.
  • Register new model/config types across the core registry, GGUF arch registry, route census, and public GGUF docs.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/synthetic_parity_test.py Skips HF synthetic parity for new GGUF-only model types.
tests/_test_configs.py Adds tiny test configs for grok_gguf, grovemoe_gguf, hunyuan_moe_gguf.
src/mobius/models/moe.py Adds Grok/GroveMoE/Hunyuan-MoE GGUF graph implementations and attention variant.
src/mobius/models/init.py Exports the new GGUF causal LM model classes.
src/mobius/integrations/gguf/_tensor_mapping.py Adds stem mappings + suffix allowlists for the three new GGUF architectures.
src/mobius/integrations/gguf/_route_census_test.py Updates pinned route-category counts.
src/mobius/integrations/gguf/_remaining_moe.py New: validates exact tensor/metadata closure for Grok/GroveMoE/Hunyuan-MoE.
src/mobius/integrations/gguf/_remaining_moe_test.py New: contract + synthetic end-to-end GGUF build/execution/parity tests.
src/mobius/integrations/gguf/_config_mapping.py Adds config postprocessors for Grok/GroveMoE/Hunyuan-MoE and YaRN beta_fast rule.
src/mobius/integrations/gguf/_builder.py Hooks remaining-MoE validation; adjusts config fingerprint field filtering; supports chunk expert unpacking.
src/mobius/integrations/gguf/_builder_test.py Removes grok/grovemoe from a list expecting pre-graph failures.
src/mobius/integrations/gguf/_arch_registry.py Promotes grok/grovemoe/hunyuan-moe to graph-importable (runtime still deferred; quantized import rejected).
src/mobius/integrations/gguf/_arch_registry_test.py Updates supported-count pins and registry invariants for new architectures.
src/mobius/_registry.py Adds fallback registrations for the new GGUF model types.
src/mobius/_configs/_base.py Adds GrokGGUFConfig and GroveMoEGGUFConfig.
src/mobius/_configs/init.py Re-exports the new GGUF config classes.
docs/api/build_from_gguf.md Updates the support matrix / census numbers and route listings.

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

Document why the three GGUF-only registry keys use dedicated metadata, graph, and synthetic parity coverage instead of native Hugging Face L2 model IDs.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-add-remaining-moe-gguf-graphs branch from 12d95ec to 460fa59 Compare August 28, 2026 06:26
Restore the architecture-owned RMSNorm epsilon when Grok metadata also carries LayerNorm epsilon, and accept the pinned loader’s valid ungated dense up/down pair while preserving uniform topology checks.

Preserve optional base-model outputs in the Grok wrapper and leave mapped auxiliary sidecars to the existing fail-closed quantization preflight, with discriminating execution and regression coverage.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby merged commit 86e70a8 into main Aug 28, 2026
24 of 26 checks passed
@justinchuby
justinchuby deleted the justinchuby-add-remaining-moe-gguf-graphs branch August 28, 2026 07:38
justinchuby added a commit that referenced this pull request Aug 28, 2026
## Summary
- add exact explicit-float MiniMax-M2 import with non-square Q/O
geometry, full-vector Q/K RMSNorm, partial NeoX RoPE, F32
correction-biased sigmoid routing, and dynamic/static KV coverage
- add Mistral4 as its pinned DeepSeek-V2 MLA/MoE architecture, including
a dedicated latent K-only cache and metadata-owned YaRN scaling; correct
the vendored llama.cpp census that previously mislabeled it as Mistral3
- complete GLM-DSA tensor routing and split K/V-B transforms while
preserving the dedicated DSA cache contract and fail-closed MTP boundary
- promote all three graph routes in the registry/census and regenerate
the GGUF support documentation

This includes and supersedes the draft GLM-only work in #682.

## Post-review fixes
- canonicalize `glm_dsa` aliases for validation/task/package dispatch
while retaining the raw alias prefix for metadata reads; the
alias-spelled GGUF proves the exact mixed full/shared indexer schedule,
dedicated default task, complete indexer initializer materialization,
and executable dense-MLA logits
- consume Mistral4's serialized `rope.scaling.yarn_log_multiplier`
through `yarn_apply_mscale`; an independent metadata oracle pins
`0.0707`, factor `4`, qk dim `4` to `0.6028141`, and mutation to `0.1`
discriminates the result
- fail closed during Mistral4 config extraction unless the multiplier is
a non-boolean finite number in the inclusive semantic range `[0.0,
0.1]`; the wire endpoint is `float(np.float32(0.1))`, used for both
validation and normalization
- reject NaN, `+inf`, `-inf`, negative values, and the immediate float32
successor above `0.1`; real `GGUFWriter`/`GGUFModel` round trips accept
both endpoints and prove finite attention scale and rotary caches before
graph execution
- call the immediate Mistral4 superclass initializer and force
`GlmMoeDsaTask()` when callers omit `task`
- reply to and resolve both GitHub review threads

## Evidence and capability boundaries

Pinned semantic source:
`ggml-org/llama.cpp@8d9af256337d1a501250f9bbf4c0859a654bddd6`.

All three real candidates exceed the 16 GiB bounded-artifact policy, so
the PR records immutable metadata-only LFS evidence and uses reduced
synthetic GGUFs for executable graph/cache parity:

| Architecture | Smallest pinned candidate | Complete bytes |
|---|---|---:|
| `minimax-m2` |
`mradermacher/MiniMax-M2-i1-GGUF@2d4f9b1a86d32ce4dfc47db312c8d6fcae8d7b37`
/ `MiniMax-M2.i1-IQ1_S.gguf` | 46,514,882,176 |
| `mistral4` |
`unsloth/Mistral-Small-4-119B-2603-GGUF@bd93c721735aa32c035c0f19e738cb3371fd56ff`
/ `Mistral-Small-4-119B-2603-UD-IQ1_M.gguf` | 32,306,941,632 |
| `glm-dsa` |
`unsloth/GLM-5.2-GGUF@abc55e72527792c6e77069c99b4cb7de16fa9f23` / six
`UD-IQ1_S` shards | 216,715,360,960 |

No GGUF payload was downloaded. Hub probes read file metadata only.
Runtime support remains `DEFERRED`, and quantization-preserving import
is `REJECTED`; callers must use `keep_quantized=False`. GLM routed
DSA/MLA MTP, Mistral4 NextN/legacy MLA/Q-LoRA-free/nonzero-temperature
layouts, and unowned GLM RoPE scaling all fail closed. There are no
production model-ID or revision gates.

**Coverage waivers:** real-weight L2/L4/L5 and runtime generation
evidence cannot fit the artifact budget. Synthetic tests instead execute
full-logit prefill/cached decode, MiniMax static cache, Mistral
latent-vs-expanded MLA parity, GLM indexer scheduling, alias-spelled
weight closure, and weight application.

## Rebase reconciliation

Rebased onto #685 at `86e70a846b572a5266170420373781d2cac23450`. The
combined tree preserves the Grok/GroveMoE/Hunyuan-MoE and
MiniMax-M2/Mistral4/GLM-DSA cohorts in registry dispatch,
tensor-contract validation, architecture fingerprint isolation, model
coverage, parity exclusions, census, and generated docs. Combined pins
are 105 supported architectures and `107` dependency-blocked / `100`
evidence-only / `47` immediately implementable remaining routes.

## Validation
- focused combined GGUF/model coverage suite: `2417 passed, 273 skipped`
- immutable Hub metadata probes: `3 passed`
- broad serial non-integration suite: `8981 passed, 64 skipped, 12
deselected, 1 subtest passed`
- `lintrunner f --output oneline --all-files` and `lintrunner -a
--output oneline`
- `python scripts/generate_gguf_support_docs.py --check`
- `git diff --check origin/main...HEAD`
- changed-line mypy: `0` errors (`29` pre-existing production-file
errors outside changed lines)
- independent max-effort review found no significant issues and verified
both cohorts, the float32 YaRN endpoint, pre-graph failure timing,
fingerprint isolation, tensor mapping, cache semantics, census/docs, and
fail-closed ordering

Base: `86e70a846b572a5266170420373781d2cac23450`
Head: `208f2cb3c7c5215ea9bcf8547a54109acf768bee`

---------

Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0ee8718a-33b9-4015-9e20-3745bad54686
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