Skip to content

Commit 133ab10

Browse files
authored
Fix accumulated model contract CI regressions (#638)
## 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 <[email protected]> Copilot-Session: 2fe48e9f-4ebc-43a9-85f3-4e4f99f3ed5d
1 parent 8e3ab92 commit 133ab10

11 files changed

Lines changed: 113 additions & 17 deletions

‎src/mobius/_registry.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@
8888
HunYuanV1DenseCausalLMModel,
8989
HunYuanVLMoTModel,
9090
InternLM2CausalLMModel,
91+
Jais2CausalLMModel,
9192
KimiK3CausalLMModel,
9293
KimiLinearCausalLMModel,
9394
LayerNormCausalLMModel,
94-
LegacyLayerNormCausalLMModel,
9595
Lfm2CausalLMModel,
9696
Lfm2MoECausalLMModel,
9797
Lfm2VlForConditionalGeneration,
@@ -136,6 +136,7 @@
136136
SmolLM3CausalLMModel,
137137
SortformerDiarizationModel,
138138
WhisperForConditionalGeneration,
139+
XverseCausalLMModel,
139140
)
140141
from mobius.models.bamba import BambaCausalLMModel
141142
from mobius.models.bart import BartForConditionalGeneration
@@ -432,7 +433,7 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
432433
"code_llama": ModelRegistration(CausalLMModel),
433434
"codegen2": ModelRegistration(CausalLMModel),
434435
"command_r": ModelRegistration(CohereCausalLMModel),
435-
"jais2": ModelRegistration(LegacyLayerNormCausalLMModel, config_class=Jais2Config),
436+
"jais2": ModelRegistration(Jais2CausalLMModel, config_class=Jais2Config),
436437
"kclgpt": ModelRegistration(CodeShellCausalLMModel, config_class=CodeShellConfig),
437438
"csm": ModelRegistration(CausalLMModel),
438439
"dots1": ModelRegistration(DeepSeekV3CausalLMModel),
@@ -446,7 +447,7 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
446447
"ministral3": ModelRegistration(CausalLMModel),
447448
"mistral": ModelRegistration(CausalLMModel),
448449
"open-llama": ModelRegistration(CausalLMModel),
449-
"xverse": ModelRegistration(CausalLMModel, config_class=XverseConfig),
450+
"xverse": ModelRegistration(XverseCausalLMModel, config_class=XverseConfig),
450451
"openelm": ModelRegistration(CausalLMModel),
451452
"qwen2": ModelRegistration(CausalLMModel),
452453
"seed_oss": ModelRegistration(CausalLMModel),

‎src/mobius/models/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"MageVLForConditionalGeneration",
8484
"JambaCausalLMModel",
8585
"JinaBertV2GGUFModel",
86+
"Jais2CausalLMModel",
8687
"JetMoeCausalLMModel",
8788
"KimiK3CausalLMModel",
8889
"KimiLinearCausalLMModel",
@@ -189,6 +190,7 @@
189190
"WhisperForConditionalGeneration",
190191
"MLPWorldModel",
191192
"XLMCausalLMModel",
193+
"XverseCausalLMModel",
192194
"Zamba2CausalLMModel",
193195
"mimi_default_config",
194196
"moshi_depformer_config",
@@ -277,7 +279,9 @@
277279
from mobius.models.kimi_linear import KimiLinearCausalLMModel
278280
from mobius.models.legacy_decoder import (
279281
CodeShellCausalLMModel,
282+
Jais2CausalLMModel,
280283
LegacyLayerNormCausalLMModel,
284+
XverseCausalLMModel,
281285
)
282286
from mobius.models.lfm2 import Lfm2CausalLMModel, Lfm2MoECausalLMModel
283287
from mobius.models.lfm2_vl import Lfm2VlForConditionalGeneration

‎src/mobius/models/kimi_k3.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import torch
1212
from onnxscript import OpBuilder, nn
1313

14-
from mobius._configs import ArchitectureConfig
14+
from mobius._configs import ArchitectureConfig, KimiK3Config
1515
from mobius.components import Linear, RMSNorm, create_attention_bias
1616
from mobius.models.base import (
1717
CausalLMModel,
@@ -570,6 +570,7 @@ class KimiK3CausalLMModel(CausalLMModel):
570570

571571
default_task = "kimi-k3-text-generation"
572572
category = "Mixture of Experts"
573+
config_class = KimiK3Config
573574

574575
def __init__(self, config: ArchitectureConfig):
575576
if config.tie_word_embeddings:

‎src/mobius/models/kimi_k3_test.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ def test_config_rejects_empty_convolution_history() -> None:
121121
KimiK3Config.from_transformers(parent)
122122

123123

124+
def test_model_declares_config_class() -> None:
125+
assert KimiK3CausalLMModel.config_class is KimiK3Config
126+
127+
124128
def test_model_has_attention_residual_latent_moe_and_untied_head() -> None:
125129
model = KimiK3CausalLMModel(_config())
126130

‎src/mobius/models/legacy_decoder.py‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77

88
import torch
99

10-
from mobius._configs import ArchitectureConfig
10+
from mobius._configs import (
11+
ArchitectureConfig,
12+
CodeShellConfig,
13+
Jais2Config,
14+
XverseConfig,
15+
)
1116
from mobius._weight_utils import split_fused_qkv
1217
from mobius.components import FCMLP
1318
from mobius.models.base import (
19+
CausalLMModel,
1420
LayerNormCausalLMModel,
1521
linear_class_for_config,
1622
)
@@ -50,9 +56,17 @@ def preprocess_weights(
5056
return super().preprocess_weights(state_dict)
5157

5258

59+
class Jais2CausalLMModel(LegacyLayerNormCausalLMModel):
60+
"""Jais2 decoder with its published bias and normalization configuration."""
61+
62+
config_class = Jais2Config
63+
64+
5365
class CodeShellCausalLMModel(LegacyLayerNormCausalLMModel):
5466
"""CodeShell decoder accepting both published HF and canonical GGUF names."""
5567

68+
config_class = CodeShellConfig
69+
5670
def preprocess_weights(
5771
self, state_dict: dict[str, torch.Tensor]
5872
) -> dict[str, torch.Tensor]:
@@ -81,3 +95,9 @@ def preprocess_weights(
8195
# Tied CodeShell graphs have one initializer owned by embed_tokens.
8296
normalized.pop("lm_head.weight", None)
8397
return normalized
98+
99+
100+
class XverseCausalLMModel(CausalLMModel):
101+
"""Xverse decoder with source-compatible RoPE configuration defaults."""
102+
103+
config_class = XverseConfig

‎src/mobius/models/legacy_decoder_test.py‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import torch
99

1010
from mobius._configs import CodeShellConfig, Jais2Config, XverseConfig
11-
from mobius.models.base import CausalLMModel
1211
from mobius.models.legacy_decoder import (
1312
CodeShellCausalLMModel,
14-
LegacyLayerNormCausalLMModel,
13+
Jais2CausalLMModel,
14+
XverseCausalLMModel,
1515
)
1616
from mobius.tasks import CausalLMTask
1717

@@ -34,6 +34,12 @@ def _codeshell_hf_config() -> SimpleNamespace:
3434
)
3535

3636

37+
def test_specialized_model_config_classes_match_their_architectures() -> None:
38+
assert Jais2CausalLMModel.config_class is Jais2Config
39+
assert CodeShellCausalLMModel.config_class is CodeShellConfig
40+
assert XverseCausalLMModel.config_class is XverseConfig
41+
42+
3743
def test_codeshell_real_hf_names_close_graph_and_preserve_qkv_values() -> None:
3844
config = CodeShellConfig.from_transformers(_codeshell_hf_config())
3945
module = CodeShellCausalLMModel(config)
@@ -105,7 +111,7 @@ def test_xverse_hf_config_builds_rotary_embeddings() -> None:
105111
rms_norm_eps=1e-6,
106112
)
107113
config = XverseConfig.from_transformers(hf_config)
108-
module = CausalLMModel(config)
114+
module = XverseCausalLMModel(config)
109115
graph = CausalLMTask().build(module, config)["model"]
110116

111117
assert module.model.rotary_emb is not None
@@ -131,7 +137,7 @@ def test_jais2_hf_config_emits_and_closes_all_bias_weights() -> None:
131137
tie_word_embeddings=False,
132138
)
133139
config = Jais2Config.from_transformers(hf_config)
134-
module = LegacyLayerNormCausalLMModel(config)
140+
module = Jais2CausalLMModel(config)
135141
graph = CausalLMTask().build(module, config)["model"]
136142
graph_weights = {
137143
name: value

‎tests/arch_validation_test.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
"florence2": "Florence2 DaViT vision encoder is multi-stage (not standard ViT)",
6363
"got_ocr2": "VisionConfig missing without trust_remote_code",
6464
"janus": "VisionConfig.hidden_size missing without trust_remote_code",
65+
"kimi_k3": "Selective MXFP4 compressed-tensors experts are unsupported by the "
66+
"generic quantized-linear loader",
6567
"molmo": "VisionConfig missing without trust_remote_code",
6668
"ovis2": "VisionConfig missing without trust_remote_code",
6769
}

‎tests/falcon_h1_test.py‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from __future__ import annotations
55

6+
from collections.abc import Mapping
7+
68
import numpy as np
79
import onnx_ir as ir
810
import pytest
@@ -28,6 +30,28 @@ def _tiny_overrides() -> dict:
2830
)
2931

3032

33+
def _linear_attention_state(
34+
states: torch.Tensor | Mapping[int, torch.Tensor | None], state_name: str
35+
) -> torch.Tensor:
36+
if isinstance(states, torch.Tensor):
37+
return states
38+
elif isinstance(states, Mapping):
39+
assert set(states) == {0}, (
40+
f"Falcon-H1 expected one {state_name} tensor at state index 0, "
41+
f"got indices {sorted(states)}"
42+
)
43+
state = states[0]
44+
assert state is not None, (
45+
f"Falcon-H1 expected {state_name} at state index 0 to be a tensor, got None"
46+
)
47+
return state
48+
else:
49+
raise AssertionError( # noqa: TRY004 - unexpected test data is an assertion failure
50+
f"Falcon-H1 received unexpected {state_name} container type: "
51+
f"{type(states).__name__}"
52+
)
53+
54+
3155
def test_falcon_h1_rejects_invalid_attention_and_ssm_geometry() -> None:
3256
base = _tiny_overrides()
3357
with pytest.raises(ValueError, match="hidden_size must equal"):
@@ -188,6 +212,10 @@ def test_falcon_h1_prefill_decode_logits_and_four_states_match_transformers() ->
188212
atol=1e-3,
189213
)
190214
for layer, hf_state in enumerate(hf_prefill.past_key_values.layers):
215+
hf_conv_state = _linear_attention_state(hf_state.conv_states, "convolution state")
216+
hf_recurrent_state = _linear_attention_state(
217+
hf_state.recurrent_states, "recurrent state"
218+
)
191219
np.testing.assert_allclose(
192220
ort_prefill[f"present.{layer}.key"],
193221
hf_state.keys.numpy(),
@@ -202,13 +230,13 @@ def test_falcon_h1_prefill_decode_logits_and_four_states_match_transformers() ->
202230
)
203231
np.testing.assert_allclose(
204232
ort_prefill[f"present.{layer}.conv_state"],
205-
hf_state.conv_states[:, :, -(config.mamba_d_conv - 1) :].numpy(),
233+
hf_conv_state[:, :, -(config.mamba_d_conv - 1) :].numpy(),
206234
rtol=1e-4,
207235
atol=1e-4,
208236
)
209237
np.testing.assert_allclose(
210238
ort_prefill[f"present.{layer}.ssm_state"],
211-
hf_state.recurrent_states.transpose(2, 3).numpy(),
239+
hf_recurrent_state.transpose(2, 3).numpy(),
212240
rtol=1e-3,
213241
atol=1e-3,
214242
)

‎tests/generate_dashboard_test.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -967,9 +967,8 @@ def test_meta_no_skipped_or_xfailed_model_is_counted_as_passing(gd):
967967
assert info.l2_passes is False, (
968968
f"{mt!r} is in an L2 xfail dict yet l2_passes is True; status={info.l2_status!r}"
969969
)
970-
assert info.confidence_level < 2, (
971-
f"{mt!r} L2 xfail must not be counted toward confidence_level; "
972-
f"got {info.confidence_level}"
970+
assert info.confidence_level != 2, (
971+
f"{mt!r} L2 xfail must not determine confidence_level; got {info.confidence_level}"
973972
)
974973

975974

‎tests/model_coverage_test.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ def _all_registered_with_test_id() -> dict[str, str]:
161161
"kimi_linear": "Kimi Linear is a 48B remote-code hybrid with a heterogeneous "
162162
"KDA/MLA state ABI; L1-L2 and synthetic GGUF execution are covered, while "
163163
"real-weight L4/L5 parity remains pending.",
164+
"kimi_k3": "Registered tiny checkpoint uses selective MXFP4 compressed-tensors "
165+
"unsupported by the generic loader; dedicated model/GGUF tests exist, and "
166+
"real-weight L4/L5 awaits an unquantized or supported checkpoint.",
164167
"t5encoder": "Encoder-only T5 task — covered by src/mobius/models/t5_test.py "
165168
"and GGUF integration tests; generic encoder tests require token_type_ids",
166169
# --- Internal / duplicate aliases ---
@@ -254,6 +257,9 @@ def _all_registered_with_test_id() -> dict[str, str]:
254257
"kclgpt": "CodeShell's public checkpoint is 7B; L1 graph, config, "
255258
"weight-alignment, and synthetic weight-path coverage are present, but no "
256259
"small public artifact exists for bounded L4/L5 golden generation.",
260+
"lfm2_moe": "LFM2-MoE is an 8B hybrid recurrent/MoE model with no small public "
261+
"checkpoint; dedicated unit and synthetic parity tests cover its graph and "
262+
"weight paths.",
257263
"llama4_text": "Very large MoE (109B) — no small public checkpoint",
258264
"orion": "Orion's public checkpoint is 14B; L1 graph/config/tensor closure is "
259265
"covered, but no small public artifact exists for bounded L4/L5 validation.",

0 commit comments

Comments
 (0)