Skip to content

Commit f09eb0c

Browse files
justinchubyCopilot
andcommitted
Integrate LFM2MoE with current GGUF policies
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 <[email protected]> Signed-off-by: Justin Chu <[email protected]>
1 parent a329b74 commit f09eb0c

5 files changed

Lines changed: 52 additions & 5 deletions

File tree

‎docs/api/build_from_gguf.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ from mobius import build_from_gguf
1515

1616
| Census | Total | Closure |
1717
|---|---:|---|
18-
| Architectures | 147 | graph verdicts: {'deferred': 91, 'rejected': 3, 'supported': 53}; importable: 51; quantized import: {'rejected': 11, 'supported': 136}; runtime: {'deferred': 144, 'rejected': 3} |
18+
| Architectures | 147 | graph verdicts: {'deferred': 90, 'rejected': 3, 'supported': 54}; importable: 52; quantized import: {'rejected': 12, 'supported': 135}; runtime: {'deferred': 144, 'rejected': 3} |
1919
| Active stored qtypes | 25 | 24 have an import route; 1 are explicitly deferred with no route |
2020
| Serialized projector strings | 60 | {'graph-importable': 2, 'runtime-supported': 0} |
2121
| Tokenizer pre identifiers | 87 | 56 semantic groups; all default to deferred and become exact-copy only with a validated embedded `tokenizer.huggingface.json` |
@@ -418,7 +418,7 @@ before graph construction or durable output.
418418
| `kimi-linear` | — | none (fails before config extraction) | not claimed | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | Kimi-Linear alternates KDA recurrent and NoPE MLA layers, carrying three rolling convolution histories and a per-head matrix state in addition to attention cache. Its two-stage decay/output gates and sigmoid correction-bias MoE routing are not represented by any Mobius graph or state task; aliasing it to Kimi-K3, Mamba, or ordinary attention would change the model. |
419419
| `laguna` | — | none (fails before config extraction) | audited-direct-loader-conditional-union | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | Laguna combines per-head-or-element softplus attention gates, dual-RoPE interleaved sliding-window attention, a dense prefix, and sigmoid correction-biased routed/shared experts. Mobius has no exact graph or iSWA cache contract. |
420420
| `lfm2` | — | model=`lfm2`; tensor=`lfm2` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=supported | Config extraction, exact pinned tensor-name closure, GGUF value transforms, and synthetic recurrent-state execution are covered, but no representative real-weight GGUF has yet passed independent full-logit parity and deterministic multi-token stateful ORT generation. Runtime packaging remains deferred until that evidence exists. |
421-
| `lfm2moe` | — | none (fails before config extraction) | not claimed | config=deferred; tensor_map=deferred; graph=deferred; runtime=deferred; quantized_import=supported | LFM2MoE has an arbitrary per-layer attention/short-convolution schedule plus a dense-to-sigmoid-routed-MoE transition. Recurrent layers use F32 rolling convolution state with copy-on-write sequence reorder and bounded rollback snapshots, while attention layers use KV cache. The dense LFM2 graph and ordinary KV/static-cache tasks do not own that mixed state or the expert correction-bias semantics. |
421+
| `lfm2moe` | — | model=`lfm2_moe`; tensor=`lfm2`+`lfm2_moe_extras` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=rejected | Config extraction, exact pinned tensor-name closure, GGUF value transforms, and synthetic recurrent-state execution are covered, but no representative real-weight GGUF has yet passed independent full-logit parity and deterministic multi-token stateful ORT generation. Runtime packaging remains deferred until that evidence exists. The mobius graph uses floating Linear modules for this architecture, so no MatMulNBits or BlockQuantizedMatMul target can consume preserved GGUF projection weights. Use keep_quantized=False for explicit float import. |
422422
| `llada` | — | model=`llada`; tensor=`llama` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=supported | Config extraction, suffix-exact tensor closure, masked-diffusion task dispatch, and synthetic full-sequence execution are covered, but no pinned real GGUF has passed independent Hugging Face/llama.cpp masked-step logit parity and deterministic multi-step generation parity. Runtime packaging remains deferred until both exist. |
423423
| `llada-moe` | — | model=`llada`; module=`llada_moe`; tensor=`llama`+`diffusion_fused_qkv`+`moe_qk_norm_extras`+`moe_extras` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=supported | Config extraction, suffix-exact tensor closure, masked-diffusion task dispatch, and synthetic full-sequence execution are covered, but no pinned real GGUF has passed independent Hugging Face/llama.cpp masked-step logit parity and deterministic multi-step generation parity. Runtime packaging remains deferred until both exist. |
424424
| `llama` | `mistral` | model=`llama`; tensor=`llama` | not claimed | config=supported; tensor_map=supported; graph=supported; runtime=deferred; quantized_import=supported | 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. Runtime packaging remains deferred until that evidence exists. |

‎src/mobius/integrations/gguf/_arch_registry.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,8 @@
11441144
"expert_gating_func",
11451145
),
11461146
runtime=Support.DEFERRED,
1147-
reason=_RECURRENT_RUNTIME_VALIDATION_PENDING,
1147+
quantized_import=Support.REJECTED,
1148+
reason=_RECURRENT_RUNTIME_VALIDATION_PENDING + " " + _NO_QUANTIZED_PROJECTION_REASON,
11481149
),
11491150
GGUFArchitectureSpec(
11501151
gguf_arch="minimax-01",

‎src/mobius/integrations/gguf/_arch_registry_test.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ def test_every_float_importable_architecture_has_a_quantized_verdict(self) -> No
268268
"granitehybrid",
269269
"internlm2",
270270
"jamba",
271+
"lfm2moe",
271272
"mamba",
272273
"mamba2",
273274
"nemotron_h",
@@ -970,8 +971,10 @@ def test_lfm2moe_graph_and_import_advance_but_runtime_stays_deferred(self) -> No
970971
assert spec.tensor_map is Support.SUPPORTED
971972
assert spec.graph is Support.SUPPORTED
972973
assert spec.runtime is Support.DEFERRED
974+
assert spec.quantized_import is Support.REJECTED
973975
assert spec.reason is not None
974976
assert "representative real-weight GGUF" in spec.reason
977+
assert "keep_quantized=False" in spec.reason
975978

976979
def test_hugging_face_deepseek_v4_registration_remains_valid(self) -> None:
977980
assert "deepseek_v4" in _REGISTRATIONS

‎src/mobius/models/lfm2.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ def __init__(self, config: Lfm2MoeConfig):
216216
if config.use_expert_bias
217217
else None
218218
)
219+
if self.expert_bias is not None:
220+
self.expert_bias._keep_float32 = True
219221

220222
def forward(self, op: OpBuilder, hidden_states: ir.Value) -> ir.Value:
221223
return super().forward(op, hidden_states, self.expert_bias)

‎src/mobius/models/lfm2_test.py‎

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import onnx_ir as ir
1010

1111
from mobius import build_from_module
12-
from mobius._configs import Lfm2Config
12+
from mobius._configs import Lfm2Config, Lfm2MoeConfig
13+
from mobius._optimizations import SymbolicShapeInferencePass
1314
from mobius._registry import registry
14-
from mobius.models.lfm2 import Lfm2CausalLMModel
15+
from mobius.models.lfm2 import Lfm2CausalLMModel, Lfm2MoECausalLMModel
1516

1617

1718
def _hf_config(**overrides):
@@ -108,3 +109,43 @@ def test_cuda_graph_uses_lfm2_fusions():
108109
assert all(
109110
node.attributes.get_int("stash_type") == ir.DataType.FLOAT for node in remaining_norms
110111
)
112+
113+
114+
def test_lfm2moe_fp16_keeps_selection_bias_and_scores_in_float32():
115+
config = Lfm2MoeConfig(
116+
hidden_size=64,
117+
intermediate_size=128,
118+
moe_intermediate_size=32,
119+
num_attention_heads=4,
120+
num_key_value_heads=2,
121+
num_hidden_layers=2,
122+
num_local_experts=4,
123+
num_experts_per_tok=2,
124+
num_dense_layers=1,
125+
vocab_size=256,
126+
max_position_embeddings=128,
127+
head_dim=16,
128+
layer_types=["conv", "full_attention"],
129+
short_conv_kernel=3,
130+
rope_type="default",
131+
rope_theta=10_000.0,
132+
dtype=ir.DataType.FLOAT16,
133+
)
134+
model = build_from_module(
135+
Lfm2MoECausalLMModel(config),
136+
config,
137+
task="hybrid-text-generation",
138+
)["model"]
139+
SymbolicShapeInferencePass()(model)
140+
141+
bias_name = "model.layers.1.feed_forward.expert_bias"
142+
assert model.graph.initializers[bias_name].dtype == ir.DataType.FLOAT
143+
selection_add = next(
144+
node
145+
for node in model.graph
146+
if node.op_type == "Add"
147+
and any(value is not None and value.name == bias_name for value in node.inputs)
148+
)
149+
assert all(
150+
value is None or value.dtype == ir.DataType.FLOAT for value in selection_add.inputs
151+
)

0 commit comments

Comments
 (0)