Skip to content

Promote conventional GGUF MoE architectures - #637

Merged
justinchuby merged 12 commits into
mainfrom
justinchuby-deferred-gguf-moe
Aug 26, 2026
Merged

Promote conventional GGUF MoE architectures#637
justinchuby merged 12 commits into
mainfrom
justinchuby-deferred-gguf-moe

Conversation

@justinchuby

@justinchuby justinchuby commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • promote bailingmoe, original deepseek, and dots1 from deferred to exact GGUF config/tensor-map/graph support while keeping runtime support deferred
  • preserve authoritative routing contracts: Bailing full-softmax top-k; DeepSeek unnormalized softmax top-k; Dots1 metadata-selected softmax/sigmoid, selection-only correction bias, pinned 2^-14 normalization floor, and route scaling
  • validate exact dense-prefix/routed/shared-expert schedules, including all-dense DeepSeek/Dots1 files with absent or zero inactive expert metadata
  • enforce full-head RoPE for all three, full MHA for Dots1, complete supported YaRN metadata, pinned beta/attention defaults, and fail-closed rejection of unsupported scaling
  • close tensor families and shapes, packed fused-QKV splits, bias alternatives, shared experts, output ownership, auxiliary quantization sidecars, and out-of-range tensors
  • preserve llama.cpp Q/K inverse permutation for Bailing/DeepSeek while retaining Dots1's Qwen2 checkpoint row order across F32 and Q4 packed weights/scales/zero-points
  • preserve existing PhiMoE output-head, GLM-MoE-DSA CPU/grouped-routing, LFM2MoE correction-bias, dense/multimodal/specialized/runtime/package, inference-metadata, and Qwen3.5 ORT GenAI contracts

Exact base and head

Evidence

  • focused registry/config/tensor/processor/closure/builder/docs/model suite: 1899 passed, 1 skipped
  • shared MoE/build regression suite: 204 passed, 8 skipped, 1374 deselected
  • broad serial non-integration: 8120 passed, 57 skipped, 12 deselected, 1 subtest passed, explicit PYTEST_EXIT=0
  • promoted packed fused-QKV value/runtime coverage includes F32 and Q4_0 weights, scales, zero-points, biases, graph construction, and ORT execution
  • initialized all-files lint: clean
  • generated GGUF documentation closure: clean
  • final GPT-5.6 Sol medium architecture review: approved, no findings
  • final GPT-5.6 Sol medium regression review: approved, no findings

An intermittent libc++ recursive_mutex teardown diagnostic was previously reproduced after an assertion-clean parallel run. It did not reproduce in the serial GGUF builder probe or final serial broad suites; clean serial process exits are the publication evidence.

Runtime waiver

Runtime remains DEFERRED for all three promotions. No practical immutable small real-weight GGUF artifact was available to establish full CLI/ORT GenAI generation parity without downloading production-scale checkpoints. Graph execution, synthetic numerical routing parity, packed tensor value checks, and ORT execution are covered; runtime metadata does not claim support from architecture-name matching.

Residual deferred MoE

Different whole-model contracts remain separate batches:

  • ernie4_5-moe, hunyuan-moe, minimax-m2, mellum: unmatched per-layer schedules or Q/K norm/RoPE ordering
  • arctic, dbrx, grok, smallthinker: incompatible residual topology, norm order/type, fused/clamped attention, scaling/softcaps, router input, expert activation, or per-layer RoPE
  • afmoe, laguna, granite_swa, conditional granite/minicpm: unmatched gates, SWA/cache contracts, architecture scales, or value transforms
  • grovemoe: grouped dual-bank routing is unsupported
  • gpt-oss: value-changing MXFP4 packed expert conversion is unsupported
  • minimax-m3: second sparse-index cache ABI is unsupported
  • bailingmoe3, deepseek4, Kimi/DeltaNet/Mamba hybrids: heterogeneous recurrent/compressed state ABI
  • DeepSeek NextN/MTP families: executable MTP/cache ABI is owned by the separate deferred MTP batch
  • multimodal MoE backbones remain excluded from this text-only cohort

@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 26, 2026 00:24
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing c8803af6df92b6

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 26, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing c8803af6df92b6

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 429 429 +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.

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

This PR promotes three previously-deferred GGUF MoE architectures (bailingmoe, original deepseek, dots1) to exact config extraction, tensor mapping/processing, and graph-build validation in Mobius’ GGUF import pipeline, while explicitly keeping runtime support deferred. It extends the GGUF integration to validate strict tensor closures and routing/metadata contracts for these MoE layouts, and updates DeepSeek routing/model code to support the promoted contracts (including optional correction-bias and pinned normalization-floor behavior).

Changes:

  • Add GGUF architecture specs + strict conventional-MoE tensor-closure validation, including fused-QKV alternatives and routing/rope-scaling constraints.
  • Extend DeepSeek routing/model logic (bias selection semantics, normalization floor, QMoE encoding selection) and add/expand tests for these behaviors.
  • Update registry/config aliases and documentation/support census to reflect the promoted GGUF graph-importable architectures.

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/_test_configs.py Adds small config aliases for deepseek and bailing_moe to exercise graph builds in tests.
src/mobius/models/moe.py Refactors Ernie45MoECausalLMModel init to use the base CausalLMModel initializer and _replace_text_model.
src/mobius/models/deepseek.py Updates DeepSeek MoE gate routing contracts (bias semantics, normalization floor, QMoE router_probs selection) and preprocessing rename behavior.
src/mobius/models/deepseek_test.py Adds/extends unit tests for routing defaults, bias optionality, normalization floor behavior, and GGUF rename behavior.
src/mobius/integrations/gguf/_tensor_processors.py Adds fused qkv_proj splitting before applying optional Llama Q/K inverse permutation.
src/mobius/integrations/gguf/_tensor_processors_test.py Adds tests ensuring fused-QKV split behavior matches separate-projection transforms and preserves Dots1 ordering.
src/mobius/integrations/gguf/_tensor_mapping.py Adds DeepSeek shared-MoE “extras” tensor mappings (router + experts + shared experts + correction bias).
src/mobius/integrations/gguf/_conventional_moe_test.py New focused test suite validating exact tensor closure + metadata constraints for promoted conventional MoE architectures.
src/mobius/integrations/gguf/_config_mapping.py Adds conventional shared-MoE key/post-processing, including strict YaRN-only scaling validation and pinned routing defaults.
src/mobius/integrations/gguf/_config_mapping_test.py Adds extensive tests for conventional shared-MoE config extraction/validation and dense-prefix edge cases.
src/mobius/integrations/gguf/_builder.py Enforces conventional-MoE tensor contract in GGUF validation and applies Q/K permute to split fused quantized projections (weight/scales/zero_points).
src/mobius/integrations/gguf/_builder_test.py Extends GGUF build tests to cover promoted MoE architectures, fused biased QKV, and deepseek tied-quantized head behavior.
src/mobius/integrations/gguf/_arch_registry.py Promotes bailingmoe, deepseek, dots1 to supported (graph) with deferred runtime, including recipes and processors.
src/mobius/integrations/gguf/_arch_registry_test.py Updates expected supported-architecture counts and closure sets for the promotions.
src/mobius/_registry.py Registers fallback deepseek and bailing_moe model_type mappings for graph construction.
src/mobius/_configs/_base.py Adds new config fields (routing_weight_normalization_floor, use_expert_bias) and updates Lfm2MoeConfig typing for the new semantics.
docs/api/build_from_gguf.md Updates census/support matrix entries for bailingmoe, deepseek, and dots1 to reflect supported graph import and deferred runtime.

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

Comment on lines +161 to +180
# Some pinned loaders accept a fused QKV tensor as an alternative to the
# split projections. Split it before applying the same inverse Q/K RoPE
# permutation used by the separate layout.
fused_qkv = [(name, tensor) for name, tensor in state_dict.items() if ".qkv_proj." in name]
if fused_qkv:
head_dim = int(config.head_dim)
q_width = int(num_heads) * head_dim
kv_width = int(num_kv_heads) * head_dim
for name, tensor in fused_qkv:
if tensor.shape[0] != q_width + 2 * kv_width:
raise ValueError(
f"Invalid fused QKV width for {name}: expected "
f"{q_width + 2 * kv_width}, got {tensor.shape[0]}"
)
query, key, value = tensor.split([q_width, kv_width, kv_width], dim=0)
prefix, suffix = name.rsplit(".qkv_proj.", 1)
state_dict[f"{prefix}.q_proj.{suffix}"] = query
state_dict[f"{prefix}.k_proj.{suffix}"] = key
state_dict[f"{prefix}.v_proj.{suffix}"] = value
del state_dict[name]
fused_weight = torch.from_numpy(
np.array(source.get_tensor("blk.0.attn_qkv.weight"))
)
fused_scales = fused_zero_points = None
justinchuby and others added 12 commits August 25, 2026 18:45
Add exact config, tensor, routing, shared-expert, fused-QKV, and quantized import contracts for BailingMoE, original DeepSeek-MoE, and Dots1. Keep runtime support deferred pending immutable real-artifact parity evidence and fail closed on contradictory schedules or mixed optional tensors.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Preserve existing HF DeepSeek correction-bias defaults, reuse tied quantized head storage, attach fused-QKV handling only to the promoted architectures, and reject correction tensors outside Dots1. Expand fused packed-QKV and tied-head coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Keep the existing LFM2MoE correction-bias default while allowing base DeepSeek configurations to infer their historical routing behavior, and regenerate the support matrix after the live-main rebase.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Apply llama Q/K row permutation after splitting packed fused projections, including affine scales and zero points. Feed raw logits to CUDA QMoE for the exact ungrouped DeepSeek softmax contract and fail closed for unsupported routing variants.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Account for the multimodal GGUF promotion already present on the exact final base and regenerate the support matrix without dropping its Qwen2-VL entries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Use raw logits for the exact promoted DeepSeek CUDA route while retaining the existing activated-score encoding required by grouped GLM-MoE-DSA CPU graphs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Reject missing, unexpected, malformed, out-of-range, mixed-schedule, and incomplete attention or expert tensor families before config extraction. Cover fused and split QKV layouts, shared experts, Dots1 sidecars, and tied DeepSeek output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Require Dots1 full-MHA and full-head RoPE geometry while allowing the pinned DeepSeek and Dots1 loaders' all-dense boundary schedule. Add positive and negative boundary coverage and use authoritative Dots1 cache geometry in synthetic builds.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Apply the repository's initialized formatter to the final Dots1 geometry guard and closure regression tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Reject non-finite or non-positive RMS epsilon and effective routing scales while preserving llama.cpp's zero scale sentinel. Accept authoritative single-expert routed and all-dense schedules with explicit boundary coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Allow exact all-dense DeepSeek and Dots1 schedules while keeping routed metadata fail-closed. Enforce authoritative attention and RoPE contracts, including pinned YaRN defaults, and preserve Dots1's Qwen2 Q/K tensor ordering across F32 and Q4 packed routes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Preserve the pinned llama.cpp denominator clamp for normalized Dots1 expert weights while leaving native DeepSeek routing unchanged. Add a low-score ONNX Runtime parity regression for the boundary.

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-deferred-gguf-moe branch from a66de72 to 6df92b6 Compare August 26, 2026 01:55
@justinchuby
justinchuby merged commit 8b5f89a into main Aug 26, 2026
15 of 24 checks passed
@justinchuby
justinchuby deleted the justinchuby-deferred-gguf-moe branch August 26, 2026 01:55
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