Skip to content

Add dedicated LFM2MoE GGUF graph support - #606

Merged
justinchuby merged 3 commits into
mainfrom
justinchuby-implement-deferred-recurrent-gguf
Aug 25, 2026
Merged

Add dedicated LFM2MoE GGUF graph support#606
justinchuby merged 3 commits into
mainfrom
justinchuby-implement-deferred-recurrent-gguf

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • add a dedicated LFM2MoE model graph with dense-prefix SwiGLU and correction-biased sigmoid-routed experts
  • reuse LFM2 mixed short-convolution/KV-cache state ABI with exact pinned layer scheduling and tensor closure
  • add pinned GGUF config extraction, float and explicit-dequantized Q4 import, state rollback/reorder, save/load, weight-alignment, and synthetic parity coverage
  • advance config/tensor-map/graph verdicts while keeping runtime DEFERRED pending independent real-checkpoint evidence

Validation

  • 1,558 GGUF integration/unit tests passed
  • 22 targeted model/CLI tests passed (1 unrelated selection skipped)
  • changed-file lintrunner passed
  • two independent reviews completed; all findings fixed; final review found no issues

The repository-wide non-integration run completed 3,345 passing tests with three unrelated existing failures: granitemoehybrid synthetic parity and two glm_moe_dsa shape-inference checks. No GitHub CI wait requested.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing ab11232f09eb0c

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

Copy link
Copy Markdown

Performance Comparison

Comparing ab11232f09eb0c

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.

@justinchuby
justinchuby force-pushed the justinchuby-finalize-gguf-support-matrix branch from 7326da4 to 2e0df5a Compare August 25, 2026 16:56
Base automatically changed from justinchuby-finalize-gguf-support-matrix to main August 25, 2026 16:57
@justinchuby
justinchuby requested a review from a team August 25, 2026 16:57
justinchuby and others added 3 commits August 25, 2026 09:58
Implement the dense-prefix and correction-biased sigmoid-routed expert graph on top of LFM2's mixed convolution/attention state ABI. Add pinned GGUF metadata and tensor closure, explicit quantized-source dequantization, state threading coverage, synthetic parity, and weight alignment tests while retaining the deferred runtime verdict pending independent real-weight evidence.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Regenerate the authoritative support matrix and move quantization rejection into the architecture registry used by current main. Preserve the routing correction bias in fp32 so fp16 and bf16 exports keep a valid, reference-matching selection graph.

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-implement-deferred-recurrent-gguf branch from ef635bd to f09eb0c Compare August 25, 2026 17:10
Copilot AI lite review requested due to automatic review settings August 25, 2026 17:10
@justinchuby
justinchuby merged commit fada98a into main Aug 25, 2026
13 of 22 checks passed
@justinchuby
justinchuby deleted the justinchuby-implement-deferred-recurrent-gguf branch August 25, 2026 17:10

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 adds first-class support for importing and graph-building the LFM2MoE GGUF architecture in mobius, including a dedicated MoE decoder graph, pinned GGUF config/tensor mapping, and expanded synthetic/weight-alignment test coverage. It fits into mobius’ model-registry + GGUF-import pipeline by introducing an lfm2_moe model type and making lfm2moe a supported (but runtime-deferred) GGUF architecture with explicit float import requirements.

Changes:

  • Add Lfm2MoECausalLMModel (sigmoid top‑k routing with selection-only correction bias, dense-prefix → routed MoE transition) plus Lfm2MoeConfig.
  • Extend GGUF integration to map/configure/validate lfm2moe, including tensor-map extras, postprocessing invariants, mixed-state contract checks, and dequantization-only import behavior.
  • Add targeted tests for expert weight alignment, synthetic HF-config adaptation, GGUF build/save/load/state semantics, and update GGUF support-matrix documentation.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/weight_alignment_test.py Adds targeted alignment tests for LFM2MoE expert weight formats (w1/w2/w3 and fused tensors).
tests/synthetic_parity_test.py Extends HF-config adaptation to cover lfm2_moe (including MoE-specific field translation).
tests/_test_configs.py Registers a tiny lfm2_moe test config for shared test parametrizations.
src/mobius/models/lfm2.py Introduces LFM2MoE routing gate, MoE feed-forward, MoE layer composition, and top-level Lfm2MoECausalLMModel.
src/mobius/models/lfm2_test.py Adds a dtype-preservation test ensuring selection-bias math stays float32 under fp16 builds.
src/mobius/models/init.py Exports Lfm2MoECausalLMModel from the public models package.
src/mobius/integrations/gguf/_tensor_mapping.py Adds LFM2MoE extra tensor stems and routes exp_probs_b.bias to an expert_bias parameter via the @ suffix convention.
src/mobius/integrations/gguf/_config_mapping.py Adds lfm2moe hybrid-layout handling and a pinned postprocessor enforcing loader invariants.
src/mobius/integrations/gguf/_config_mapping_test.py Adds tests validating the LFM2MoE postprocessor’s defaults and fail-closed behavior.
src/mobius/integrations/gguf/_builder.py Extends hybrid tensor-contract validation to enforce dense vs routed FFN tensor families per layer for lfm2moe.
src/mobius/integrations/gguf/_builder_test.py Adds end-to-end GGUF build tests for float import, explicit dequantization, state rollback/reorder, and misdispatch rejection.
src/mobius/integrations/gguf/_arch_registry.py Promotes lfm2moe to supported config/tensor-map/graph with runtime still deferred; rejects quantized-preservation import.
src/mobius/integrations/gguf/_arch_registry_test.py Updates census expectations and adds a focused assertion for the new lfm2moe support verdicts.
src/mobius/_registry.py Registers lfm2_moe model type to Lfm2MoECausalLMModel with Lfm2MoeConfig.
src/mobius/_configs/_base.py Adds Lfm2MoeConfig config class for dense-prefix + expert-bias toggles.
src/mobius/_configs/init.py Exports Lfm2MoeConfig from the configs package.
docs/api/build_from_gguf.md Updates the support matrix/census and documents lfm2moe as graph-supported but runtime-deferred with quantized import rejected.

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

titaiwangms added a commit that referenced this pull request Aug 26, 2026
## Summary

- align Jais2, CodeShell, Xverse, and Kimi-K3 model `config_class`
declarations with registry dispatch
- record Kimi-K3 and LFM2-MoE coverage limitations without fabricating
golden data
- support both tensor and mapping Transformers linear-attention cache
ABIs in Falcon-H1 and GatedDeltaNet parity tests
- mark the selective-MXFP4 Kimi-K3 checkpoint as a strict graph-only L2
xfail
- preserve independent dashboard confidence levels when L2 xfails but L3
passes

## Root causes

- #635 introduced the Jais2, CodeShell, and Xverse registry/model
contract mismatches
- #621 introduced the Kimi-K3 contract and coverage gaps
- #606 introduced LFM2-MoE without an L4/L5 coverage disposition
- #610 assumed the older tensor cache representation in Falcon-H1 parity
coverage
- #327 added a dashboard meta-assertion that incorrectly required every
L2 xfail to have confidence below L2, contradicting the
independent-level truth table

## Validation

- dashboard plus original CI regression gates: 90 passed
- affected graph and weight-alignment gates: 25 passed
- Kimi-K3 L2: 1 passed, 2 strict xfailed

---------

Signed-off-by: titaiwang <titaiwang@microsoft.com>
Copilot-Session: 2fe48e9f-4ebc-43a9-85f3-4e4f99f3ed5d
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