Skip to content

Add conventional MoE GGUF architecture cohort - #575

Merged
justinchuby merged 5 commits into
mainfrom
justinchuby-gguf-moe-transformer-cohort
Aug 25, 2026
Merged

Add conventional MoE GGUF architecture cohort#575
justinchuby merged 5 commits into
mainfrom
justinchuby-gguf-moe-transformer-cohort

Conversation

@justinchuby

@justinchuby justinchuby commented Aug 24, 2026

Copy link
Copy Markdown
Member

Summary

  • add pinned llama.cpp (8d9af256337d1a501250f9bbf4c0859a654bddd6) GGUF specs for olmoe, phimoe, qwen2moe, qwen3moe, and granitemoe
  • implement exact metadata/config extraction, canonical Qwen aliases, tensor-family closure, routing/norm/scaling semantics, and Granite dense-vs-MoE dispatch
  • preserve 3-D expert ordering through affine and native quantized imports, split fused Phi QKV tensors, and preserve tied quantized Qwen3/Granite embedding heads
  • reverse llama.cpp's GraniteMoE Q/K row permutation in both float and packed quantized imports
  • map pinned expert .scale/.input_scale suffixes and reject affected files before graph construction because Mobius cannot safely represent NVFP4 scale2/activation-scale sidecars
  • extend the same suffix-aware preflight to reachable MTP nextn.eh_proj scale sidecars before either backbone or MTP graph construction
  • add generated support docs, negative closure/shape tests, and float/Q4 synthetic save-load-ORT coverage

Stacks on #572 (justinchuby-gguf-dense-transformer-cohort).

Real artifact import evidence (runtime deferred)

GraniteMoE

Validated with:

  • repository: bartowski/granite-3.0-1b-a400m-instruct-GGUF
  • repository revision: 0e1c3cecaa6e49ac0721be91ef441ec72eae62d4
  • file: granite-3.0-1b-a400m-instruct-Q4_K_M.gguf
  • size: 821,845,024 bytes
  • LFS SHA-256: 074f09e13484e54e73c93830d34e9fa9917a6319fb8bae762a22594b9b4da0dc
  • source config/tokenizer: ibm-granite/granite-3.0-1b-a400m-instruct@ffec3c35bdfd97a06f0b4cd5fcc92cd9b1584445
  • stored qtypes: 73 F32, 144 Q4_K, 25 Q6_K

The pinned integration test verifies exact tensor closure, 24 routers, 2,304 routed expert projections, mixed-qtype routing, 2,401 MatMulNBits nodes including the tied quantized head, zero QMoE nodes, ONNX save/load, full 49,155-token logits, and repeatable three-token cached decoding. This is deterministic Mobius execution evidence, not independent llama.cpp/HuggingFace parity, so GraniteMoE runtime remains deferred.

Runtime-DEFERRED

All five entries—olmoe, phimoe, qwen2moe, qwen3moe, and granitemoe—have exact registry/config/tensor support and synthetic float/Q4 ORT execution, but no qualifying independent real-weight cross-runtime evidence.

The only compatible Phi representative found was tripathyShaswata/Phi-tiny-MoE-instruct-GGUF@873ccb08cd3380ee2c08573d45267fac9a6cc81b, file Phi-tiny-MoE-instruct-Q8_0.gguf, size 3,999,171,104 bytes, SHA-256 297fa09e906e18aaf03850e77d6de8d9ee8e246e00916ac09787ae2cf4bb6019, sourced from microsoft/Phi-tiny-MoE-instruct@2fe50e88d0e2a5a132563815686ea0dcc8e252b5. It was not downloaded because it is not a reasonably sized representative.

Validation

  • 504 passed full focused GGUF/model tests after the Granite/expert-scale fixes
  • 160 passed focused MTP/builder/tensor-mapping tests after the MTP scale preflight fix
  • 1 passed revised pinned Granite real-artifact integration test
  • 5585 passed, 52 skipped broad non-integration suite with glm_moe_dsa excluded
  • full lintrunner f --output oneline --all-files

The two excluded glm_moe_dsa shape-inference/checker failures reproduce unchanged on the stack base and are unrelated to this cohort.

Comment thread tests/gguf_moe_cohort_integration_test.py Fixed
Comment thread tests/gguf_moe_cohort_integration_test.py Fixed
Comment thread tests/gguf_moe_cohort_integration_test.py Fixed
Comment thread tests/gguf_moe_cohort_integration_test.py Fixed
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing c6b23e24d6efb5

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.

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing c6b23e24d6efb5

Model Sub-model Changes Status
bert (feature-extraction) model 0
falcon model 0
gemma2 model 0
gemma4 (gemma4) decoder 0
gemma4 (gemma4) embedding 0
gemma4 (gemma4) vision_encoder 0
gemma4_text model 0
gpt2 model 0
llama model 0
llama (static-cache) model 0
mamba (ssm-text-generation) model 0
phi3 model 0
phi3 (static-cache) model 0
qwen model 0
qwen (static-cache) model 0
qwen2 model 0
qwen2 (static-cache) model 0
qwen2_moe model 0
qwen2_moe (static-cache) model 0
qwen3 model 0
qwen3 (static-cache) model 0
qwen3_5_moe (hybrid-text-generation) model 0
qwen3_5_text (hybrid-text-generation) model 0
qwen3_5_vl (hybrid-qwen-vl) decoder 0
qwen3_5_vl (hybrid-qwen-vl) embedding 0
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0
qwen3_moe model 0
qwen3_moe (static-cache) model 0
qwen3_next (hybrid-text-generation) model 0
t5 (seq2seq) decoder 0
t5 (seq2seq) encoder 0
whisper (speech-to-text) decoder 0
whisper (speech-to-text) encoder 0

No architecture changes detected.


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

@justinchuby
justinchuby force-pushed the justinchuby-gguf-dense-transformer-cohort branch from fbdc807 to 29d33a9 Compare August 25, 2026 14:54
Base automatically changed from justinchuby-gguf-dense-transformer-cohort to main August 25, 2026 14:55
@justinchuby
justinchuby requested a review from a team August 25, 2026 14:55
justinchuby and others added 5 commits August 25, 2026 08:00
Implement pinned llama.cpp metadata, tensor closure, routing, and quantized expert import for OLMoE, PhiMoE, Qwen2MoE, Qwen3MoE, and GraniteMoE. Preserve tied quantized heads, split fused Phi QKV tensors, add synthetic and pinned Granite runtime validation, and keep unsupported runtime claims deferred.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Reverse llama.cpp's GraniteMoE Q/K row permutation in float and packed quantized imports. Make pinned expert scale/input_scale suffixes visible and reject unsupported scale2 sidecars before graph construction instead of dropping them. Downgrade GraniteMoE runtime to deferred until independent cross-runtime parity is available.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Route nextn projection scale/input_scale suffixes through the MTP mapper and reject them in the shared GGUF preflight before either backbone or MTP graph construction. Cover dense and MoE Qwen3.5 variants, float and quantized files, and preserve ordinary MTP weight/bias mapping.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Register coverage metadata for the GGUF-only PhiMoE routing variant and make main's synthetic native-block MoE fixture use block-aligned logical dimensions so strict expert-shape validation remains meaningful after the replay.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Recognize the complete affine expert-major repack route added by the conventional MoE cohort, keep native and decoder rejection semantics intact, and make GGUF MoE output heads quantization-aware. Refresh generated policy documentation and coverage pins for the supported cohort.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby
justinchuby force-pushed the justinchuby-gguf-moe-transformer-cohort branch from 72b4f42 to 4d6efb5 Compare August 25, 2026 15:07
Copilot AI lite review requested due to automatic review settings August 25, 2026 15:07
@justinchuby
justinchuby merged commit 89fe423 into main Aug 25, 2026
17 of 22 checks passed
@justinchuby
justinchuby deleted the justinchuby-gguf-moe-transformer-cohort branch August 25, 2026 15:08

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 a new “conventional MoE” GGUF architecture cohort (olmoe, phimoe, qwen2moe, qwen3moe, granitemoe) to Mobius’ GGUF importer, including pinned upstream tensor-family/spec data, config/metadata extraction, quantized import semantics, and expanded test coverage (synthetic + a pinned real GraniteMoE artifact).

Changes:

  • Extend GGUF architecture registry/specs to support the new MoE cohort, including module-type overrides (PhiMoE GGUF variant), pinned tensor-family closure, and alias handling.
  • Implement/adjust MoE-specific config postprocessing, tensor-name mapping (including expert suffix sidecars), quantized import routes (expert-major affine repack), and preflight rejection for unsupported auxiliary scale sidecars.
  • Add/extend tests: synthetic GGUF save/load/ORT execution for MoE architectures, pinned GraniteMoE real-artifact integration coverage, and closure/shape/negative validation tests.

Reviewed changes

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

Show a summary per file
File Description
tests/model_coverage_test.py Exempts phimoe_gguf from HF checkpoint coverage expectations.
tests/gguf_moe_cohort_integration_test.py Adds pinned real GraniteMoE GGUF integration test (download, hash/size, closure, ORT determinism).
tests/_test_configs.py Adds a tiny phimoe_gguf test config variant (LongRoPE fields).
src/mobius/models/moe.py Adds GGUF-specific PhiMoE model variant; GGUF-specific quantization preprocessing; routing scaling support; embedding factory use; fused-QKV splitting in Phi3MoE.
src/mobius/models/granite.py Uses embedding_for_config, preserves ties via _replace_text_model, and routes GraniteMoE preprocessing through shared MoE quantization path.
src/mobius/models/_models_test.py Adds unit test asserting PhiMoE GGUF norm class matches checkpoint format.
src/mobius/models/init.py Exports PhiMoEGGUFCausalLMModel.
src/mobius/integrations/gguf/_upstream.py Extends upstream architecture payload model with expert_tensor_suffixes.
src/mobius/integrations/gguf/_upstream_data/llamacpp_pin.json Pins tensor families + expert suffix sets for MoE GGUF architectures.
src/mobius/integrations/gguf/_tensor_processors_test.py Extends Q/K permutation expectations to GraniteMoE.
src/mobius/integrations/gguf/_tensor_mapping.py Adds MoE Q/K norm mapping extras; recognizes rope factor tensor skips; includes .scale/.input_scale in suffix splitting.
src/mobius/integrations/gguf/_tensor_mapping_test.py Adds mapping tests for MoE expert/shared tensors, sidecar suffixes, and aliases.
src/mobius/integrations/gguf/_spec.py Adds module_type to support GGUF-only internal graph variants.
src/mobius/integrations/gguf/_quant_registry.py Allows expert-major affine repack route (no longer hard-rejected).
src/mobius/integrations/gguf/_quant_registry_test.py Updates tests to reflect expert-major affine repack and improved rejection reason when decoder is absent.
src/mobius/integrations/gguf/_mtp.py Makes MTP mapping suffix-aware for .scale/.input_scale.
src/mobius/integrations/gguf/_mtp_test.py Adds tests rejecting MTP auxiliary scale sidecars before graph build; expands MTP writer helper.
src/mobius/integrations/gguf/_config_mapping.py Adds conventional MoE postprocessors; supports routed scaling / norm / group metadata; GraniteMoE dense-vs-MoE dispatch; PhiMoE LongRoPE tensor-backed factors.
src/mobius/integrations/gguf/_config_mapping_test.py Adds config extraction tests for MoE architectures, GraniteMoE scaling/dense dispatch, and PhiMoE LongRoPE.
src/mobius/integrations/gguf/_builder.py Adds preflight rejection for unsupported auxiliary quant sidecars; routes module selection via module_type; adds fused-QKV split targeting; validates MoE tensor shapes; supports affine repack expert-major quantized imports.
src/mobius/integrations/gguf/_builder_test.py Adds synthetic MoE GGUF writer + build/save/load/ORT tests; validates Granite Q/K reverse permutation by value; tests fused Phi QKV splitting and tied quantized embedding/head behavior; adds auxiliary scale rejection tests.
src/mobius/integrations/gguf/_block_quantized_moe_builder_test.py Adjusts E2E dims to align with native IQ block constraints.
src/mobius/integrations/gguf/_arch_registry.py Registers new MoE GGUF architectures (required metadata, postprocessors, tensor recipes, module override for PhiMoE).
src/mobius/integrations/gguf/_arch_registry_test.py Updates supported-architecture count and pins closure tests for the new MoE cohort (including expert suffix closure).
src/mobius/components/_rms_norm.py Adds RMSNormBias for RMSNorm-with-bias checkpoint formats.
src/mobius/components/_moe.py Adds routed_scaling_factor handling to gate implementations (forward + QMoE metadata path).
src/mobius/components/init.py Exports RMSNormBias.
src/mobius/_registry.py Registers phimoe_gguf internal module key and default model id mapping.
docs/api/build_from_gguf.md Updates GGUF support matrix and quantization matrix documentation for MoE cohort and expert-major routing behavior.

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

Comment thread src/mobius/models/moe.py
Comment on lines +330 to +333
self.config = config
self.model = MoETextModel(config, norm_class=RMSNormBias)
linear_class = _quantized_linear_class(config) or Linear
self.lm_head = linear_class(config.hidden_size, config.vocab_size, bias=True)
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.

3 participants