Skip to content

Commit 3b2c9cd

Browse files
justinchubyCopilot
andauthored
Add conventional dense GGUF architectures (#635)
## Summary Promotes eight conventional GGUF decoder architectures whose pinned llama.cpp ABI closes over existing Mobius components: - `bloom` → `bloom` - `codeshell` → `kclgpt` - `command-r` → `command_r` - `jais2` → `jais2` - `orion` → `orion` - `qwen` → `qwen` - `starcoder` → `gpt_bigcode` - `xverse` → `xverse` The change adds strict metadata/tensor/shape closure, architecture-specific config normalization and weight transforms, value-based QKV/permutation tests, truthful Hugging Face build paths, generated census updates, and generic decoder metadata compatible with pinned `onnxruntime-genai==0.15.2`. ## Support and evidence - **L1:** config extraction, exact pinned tensor mapping/closure, graph construction, graph-initializer ownership, and weight alignment for every promoted architecture. - **L3:** synthetic parity where a constructible Transformers reference exists; dedicated value-based tests cover CodeShell fused QKV, Bloom interleaving, and Xverse Q/K inverse permutation. - **Quantized import:** supported only for split-projection `command-r` and `jais2`; rejected for fused/permuted projection routes that cannot safely transform packed blocks. - **Runtime:** deferred for all eight pending representative real-weight GGUF ORT parity and deterministic generation evidence. - **Metadata:** generic decoder config remains pinned to OGA 0.15.2; the network-free runtime probe passes. ## Waivers - Real-weight L4/L5 goldens are waived for `jais2` (smallest public checkpoint 8B), `kclgpt`/CodeShell (7B), `orion` (14B), and `xverse` (7B): no bounded small public artifacts exist for CPU CI. The waiver text claims only the evidence actually run. - No real GGUF CLI/runtime support is claimed; runtime verdicts remain deferred. - The full model coverage suite has two unrelated baseline failures on `main`: `kimi_k3` and `lfm2_moe` lack YAML cases. The four new per-model waiver and integrity checks pass. ## Residual conventional dense/encoder architectures Deferred for materially different contracts rather than aliased unsafely: - Encoders `eurobert`, `jina-bert-v2`, `jina-bert-v3`, `neo-bert`, `nomic-bert`: pre/post-norm, RoPE/ALiBi, gated/parallel FFN, or conditional topology differences. - `bitnet`, `gemma-embedding`: special quantization/sub-norm or bidirectional embedding/pooling ABI. - `gptneox`, `mpt`, `openelm`: loader unions or per-layer arrays not represented by the current graph. - `maincoder`, `minicpm3`, `plm`, `nanbeige`, `pangu-embedded`, `plamo3`, `apertus`: special attention order, MLA/cache, logical layer reuse, LongRoPE tensors, alternating SWA, or serialized per-dimension RoPE factors. - `jais`, `plamo`: MuP/ALiBi scaling or parallel RMS/shuffle transforms need dedicated graph/value work. MoE, multimodal, and recurrent/special-state families remain owned by separate workstreams. ## Validation - Focused GGUF/build/config/tensor/weight suite: 3,522 passed, 47 skipped, 39 xfailed. - Broad non-integration suite after final fixes: 7,927 passed, 57 skipped. - Final parity regression subset: 92 passed, 1 skipped. - New coverage waiver integrity: 10 passed, 4 skipped. - OGA 0.15.2 network-free probe: 2 passed. - Generated GGUF docs check: clean. - Initialized lintrunner format/lint: clean. - GPT-5.6 Sol medium architecture and regression reviews: final pass clean after addressing all findings. Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]>
1 parent 8513774 commit 3b2c9cd

23 files changed

Lines changed: 1467 additions & 25 deletions

‎docs/api/build_from_gguf.md‎

Lines changed: 9 additions & 9 deletions
Large diffs are not rendered by default.

‎src/mobius/_configs/__init__.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
BambaConfig,
2828
BaseModelConfig,
2929
CausalLMConfig,
30+
CodeShellConfig,
3031
DepthAnythingConfig,
3132
DFlashConfig,
3233
Eagle3Config,
@@ -39,6 +40,7 @@
3940
Gemma4Config,
4041
GlmAsrConfig,
4142
GraniteMoeHybridConfig,
43+
Jais2Config,
4244
JambaConfig,
4345
JetMoeConfig,
4446
KimiK3Config,
@@ -66,6 +68,7 @@
6668
SpeechToTextConfig,
6769
VisionLanguageConfig,
6870
WhisperConfig,
71+
XverseConfig,
6972
YolosConfig,
7073
Zamba2Config,
7174
_as_attribute_config,
@@ -106,6 +109,7 @@
106109
"BambaConfig",
107110
"BaseModelConfig",
108111
"CausalLMConfig",
112+
"CodeShellConfig",
109113
"CodePredictorConfig",
110114
"CodecDecoderConfig",
111115
"CodecEncoderConfig",
@@ -121,6 +125,7 @@
121125
"Gemma4Config",
122126
"GlmAsrConfig",
123127
"GraniteMoeHybridConfig",
128+
"Jais2Config",
124129
"JambaConfig",
125130
"JetMoeConfig",
126131
"KimiK3Config",
@@ -153,6 +158,7 @@
153158
"VisionConfig",
154159
"VisionLanguageConfig",
155160
"WhisperConfig",
161+
"XverseConfig",
156162
"WorldModelConfig",
157163
"YolosConfig",
158164
"Zamba2Config",

‎src/mobius/_configs/_base.py‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,91 @@ class CausalLMConfig(ArchitectureConfig):
14551455
"""
14561456

14571457

1458+
@dataclasses.dataclass
1459+
class Jais2Config(CausalLMConfig):
1460+
"""Normalize the published Jais2 projection and LayerNorm configuration."""
1461+
1462+
@classmethod
1463+
def from_transformers(cls, config, parent_config=None) -> Jais2Config:
1464+
base = ArchitectureConfig.from_transformers(config, parent_config)
1465+
attention_bias = bool(getattr(config, "attention_bias", True))
1466+
fields = _shallow_fields(base)
1467+
fields.update(
1468+
attn_qkv_bias=attention_bias,
1469+
attn_o_bias=attention_bias,
1470+
mlp_bias=bool(getattr(config, "mlp_bias", True)),
1471+
)
1472+
return cls(**fields)
1473+
1474+
1475+
@dataclasses.dataclass
1476+
class CodeShellConfig(CausalLMConfig):
1477+
"""Canonicalize the published CodeShell HuggingFace configuration."""
1478+
1479+
@classmethod
1480+
def from_transformers(cls, config, parent_config=None) -> CodeShellConfig:
1481+
if getattr(config, "position_embedding_type", "rope") != "rope":
1482+
raise ValueError("CodeShell export only supports position_embedding_type='rope'")
1483+
1484+
base = ArchitectureConfig.from_transformers(config, parent_config)
1485+
hidden_size = int(getattr(config, "hidden_size", None) or config.n_embd)
1486+
num_heads = int(getattr(config, "num_attention_heads", None) or config.n_head)
1487+
num_kv_heads = (
1488+
int(getattr(config, "num_query_groups", num_heads))
1489+
if getattr(config, "group_query_attention", False)
1490+
else num_heads
1491+
)
1492+
rope = base.rope or RoPEConfig(rope_type="default", rope_theta=10_000.0)
1493+
fields = _shallow_fields(base)
1494+
fields.update(
1495+
hidden_size=hidden_size,
1496+
head_dim=hidden_size // num_heads,
1497+
num_attention_heads=num_heads,
1498+
num_key_value_heads=num_kv_heads,
1499+
num_hidden_layers=int(
1500+
getattr(config, "num_hidden_layers", None) or config.n_layer
1501+
),
1502+
intermediate_size=int(
1503+
getattr(config, "intermediate_size", None)
1504+
or getattr(config, "n_inner", None)
1505+
or 4 * hidden_size
1506+
),
1507+
max_position_embeddings=int(
1508+
getattr(config, "max_position_embeddings", None) or config.n_positions
1509+
),
1510+
hidden_act=getattr(config, "activation_function", "gelu_pytorch_tanh"),
1511+
attn_qkv_bias=True,
1512+
attn_o_bias=True,
1513+
mlp_bias=True,
1514+
tie_word_embeddings=True,
1515+
rope=rope,
1516+
rope_type=rope.rope_type,
1517+
rope_theta=rope.rope_theta,
1518+
rope_scaling=rope.rope_scaling,
1519+
partial_rotary_factor=rope.partial_rotary_factor,
1520+
)
1521+
return cls(**fields)
1522+
1523+
1524+
@dataclasses.dataclass
1525+
class XverseConfig(CausalLMConfig):
1526+
"""Supply Xverse's source-defined standard RoPE default."""
1527+
1528+
@classmethod
1529+
def from_transformers(cls, config, parent_config=None) -> XverseConfig:
1530+
base = ArchitectureConfig.from_transformers(config, parent_config)
1531+
rope = base.rope or RoPEConfig(rope_type="default", rope_theta=10_000.0)
1532+
fields = _shallow_fields(base)
1533+
fields.update(
1534+
rope=rope,
1535+
rope_type=rope.rope_type,
1536+
rope_theta=rope.rope_theta,
1537+
rope_scaling=rope.rope_scaling,
1538+
partial_rotary_factor=rope.partial_rotary_factor,
1539+
)
1540+
return cls(**fields)
1541+
1542+
14581543
@dataclasses.dataclass
14591544
class MiniMaxConfig(CausalLMConfig):
14601545
"""Exact configuration for MiniMax-Text-01 and MiniMax-M1 backbones."""

‎src/mobius/_configs/_base_test.py‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,81 @@ def __init__(self, model_type: str = "_unrelated_", **kwargs):
196196
self.__dict__.update(kwargs)
197197

198198

199+
def test_codeshell_config_normalizes_published_hf_fields_and_biases():
200+
from mobius._configs import CodeShellConfig
201+
202+
cfg = _FakeHFConfig(
203+
model_type="kclgpt",
204+
vocab_size=70144,
205+
n_positions=8192,
206+
n_embd=4096,
207+
n_layer=42,
208+
n_head=32,
209+
n_inner=16384,
210+
activation_function="gelu_pytorch_tanh",
211+
layer_norm_epsilon=1e-5,
212+
group_query_attention=True,
213+
num_query_groups=8,
214+
position_embedding_type="rope",
215+
rope_scaling=None,
216+
)
217+
out = CodeShellConfig.from_transformers(cfg)
218+
assert (out.hidden_size, out.num_hidden_layers) == (4096, 42)
219+
assert (out.num_attention_heads, out.num_key_value_heads) == (32, 8)
220+
assert out.intermediate_size == 16384
221+
assert out.max_position_embeddings == 8192
222+
assert out.attn_qkv_bias and out.attn_o_bias and out.mlp_bias
223+
assert out.tie_word_embeddings
224+
assert out.rope is not None
225+
assert out.rope_theta == pytest.approx(10_000.0)
226+
227+
228+
def test_xverse_config_supplies_source_rope_default():
229+
from mobius._configs import XverseConfig
230+
231+
cfg = _FakeHFConfig(
232+
model_type="xverse",
233+
vocab_size=32,
234+
hidden_size=8,
235+
intermediate_size=16,
236+
num_attention_heads=2,
237+
num_hidden_layers=1,
238+
max_position_embeddings=32,
239+
rms_norm_eps=1e-6,
240+
)
241+
out = XverseConfig.from_transformers(cfg)
242+
assert out.rope is not None
243+
assert out.rope_theta == pytest.approx(10_000.0)
244+
245+
246+
def test_jais2_config_preserves_published_bias_and_norm_fields():
247+
from mobius._configs import Jais2Config
248+
249+
cfg = _FakeHFConfig(
250+
model_type="jais2",
251+
vocab_size=150272,
252+
hidden_size=3328,
253+
intermediate_size=26624,
254+
num_hidden_layers=32,
255+
num_attention_heads=26,
256+
num_key_value_heads=26,
257+
head_dim=128,
258+
hidden_act="relu2",
259+
max_position_embeddings=8192,
260+
rope_parameters={"rope_theta": 10_000.0, "rope_type": "default"},
261+
attention_bias=True,
262+
mlp_bias=True,
263+
layer_norm_eps=1e-5,
264+
tie_word_embeddings=False,
265+
)
266+
out = Jais2Config.from_transformers(cfg)
267+
268+
assert out.attn_qkv_bias and out.attn_o_bias
269+
assert out.mlp_bias
270+
assert out.rms_norm_eps == pytest.approx(1e-5)
271+
assert not out.tie_word_embeddings
272+
273+
199274
def test_scalar_intermediate_size_passes_through():
200275
cfg = _FakeHFConfig(
201276
hidden_size=2048,

‎src/mobius/_registry.py‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424

2525
from mobius._configs import (
2626
BaseModelConfig,
27+
CodeShellConfig,
2728
Eagle3Config,
2829
FalconH1Config,
2930
Gemma3nMultiModalConfig,
3031
Gemma4AssistantConfig,
3132
Gemma4Config,
33+
Jais2Config,
3234
KimiK3Config,
3335
KimiLinearConfig,
3436
Lfm2Config,
@@ -43,12 +45,14 @@
4345
Plamo2Config,
4446
SenseNovaU1Config,
4547
WhisperConfig,
48+
XverseConfig,
4649
)
4750
from mobius.models import (
4851
ApertusCausalLMModel,
4952
ArceeCausalLMModel,
5053
CausalLMModel,
5154
ChatGLMCausalLMModel,
55+
CodeShellCausalLMModel,
5256
Cosmos3EdgeTextModel,
5357
Cosmos3EdgeVLModel,
5458
Cosmos3OmniReasonerModel,
@@ -87,6 +91,7 @@
8791
KimiK3CausalLMModel,
8892
KimiLinearCausalLMModel,
8993
LayerNormCausalLMModel,
94+
LegacyLayerNormCausalLMModel,
9095
Lfm2CausalLMModel,
9196
Lfm2MoECausalLMModel,
9297
Lfm2VlForConditionalGeneration,
@@ -152,7 +157,7 @@
152157
from mobius.models.fun_asr import FunASRForConditionalGeneration
153158
from mobius.models.gemma3n import Gemma3nCausalLMModel, Gemma3nMultiModalModel
154159
from mobius.models.glm_asr import GlmAsrForConditionalGeneration
155-
from mobius.models.gpt2 import GPT2CausalLMModel
160+
from mobius.models.gpt2 import GPT2CausalLMModel, ScaledEmbeddingGPT2CausalLMModel
156161
from mobius.models.gpt_neox import GPTNeoXCausalLMModel, GPTNeoXJapaneseCausalLMModel
157162
from mobius.models.gptj_codegen import CodeGenCausalLMModel, GPTJCausalLMModel
158163
from mobius.models.granitemoehybrid import GraniteMoeHybridCausalLMModel
@@ -420,7 +425,9 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
420425
"baichuan": ModelRegistration(CausalLMModel),
421426
"code_llama": ModelRegistration(CausalLMModel),
422427
"codegen2": ModelRegistration(CausalLMModel),
423-
"command_r": ModelRegistration(CausalLMModel),
428+
"command_r": ModelRegistration(CohereCausalLMModel),
429+
"jais2": ModelRegistration(LegacyLayerNormCausalLMModel, config_class=Jais2Config),
430+
"kclgpt": ModelRegistration(CodeShellCausalLMModel, config_class=CodeShellConfig),
424431
"csm": ModelRegistration(CausalLMModel),
425432
"dots1": ModelRegistration(DeepSeekV3CausalLMModel),
426433
"evolla": ModelRegistration(CausalLMModel),
@@ -433,6 +440,7 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
433440
"ministral3": ModelRegistration(CausalLMModel),
434441
"mistral": ModelRegistration(CausalLMModel),
435442
"open-llama": ModelRegistration(CausalLMModel),
443+
"xverse": ModelRegistration(CausalLMModel, config_class=XverseConfig),
436444
"openelm": ModelRegistration(CausalLMModel),
437445
"qwen2": ModelRegistration(CausalLMModel),
438446
"seed_oss": ModelRegistration(CausalLMModel),
@@ -445,6 +453,7 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
445453
"apertus": ModelRegistration(ApertusCausalLMModel),
446454
"arcee": ModelRegistration(ArceeCausalLMModel),
447455
"bloom": ModelRegistration(BloomCausalLMModel),
456+
"orion": ModelRegistration(LayerNormCausalLMModel),
448457
"chatglm": ModelRegistration(ChatGLMCausalLMModel),
449458
"codegen": ModelRegistration(CodeGenCausalLMModel),
450459
"cohere": ModelRegistration(CohereCausalLMModel),
@@ -821,7 +830,7 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
821830
"xmod": ModelRegistration(BertModel, task="feature-extraction"),
822831
"yoso": ModelRegistration(BertModel, task="feature-extraction"),
823832
# --- Absolute positional embeddings (non-RoPE) ---
824-
"biogpt": ModelRegistration(GPT2CausalLMModel),
833+
"biogpt": ModelRegistration(ScaledEmbeddingGPT2CausalLMModel),
825834
"ctrl": ModelRegistration(CTRLCausalLMModel),
826835
"gpt-sw3": ModelRegistration(GPT2CausalLMModel),
827836
"gpt2": ModelRegistration(GPT2CausalLMModel),
@@ -830,7 +839,7 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
830839
"imagegpt": ModelRegistration(GPT2CausalLMModel),
831840
"openai-gpt": ModelRegistration(GPT2CausalLMModel),
832841
"opt": ModelRegistration(OPTCausalLMModel),
833-
"xglm": ModelRegistration(GPT2CausalLMModel),
842+
"xglm": ModelRegistration(ScaledEmbeddingGPT2CausalLMModel),
834843
"xlm": ModelRegistration(XLMCausalLMModel),
835844
# --- Encoder-decoder ---
836845
"bart": ModelRegistration(BartForConditionalGeneration, task="seq2seq"),
@@ -1013,11 +1022,14 @@ def _create_default_registry() -> ModelRegistry:
10131022
"zamba2": "Zyphra/Zamba2-1.2B",
10141023
"codegen2": "Salesforce/codegen2-1B",
10151024
"command_r": "CohereForAI/c4ai-command-r-v01",
1025+
"jais2": "inceptionai/Jais-2-8B-Chat",
1026+
"kclgpt": "WisdomShell/CodeShell-7B",
10161027
"csm": "sesame/csm-1b",
10171028
"evolla": "westlake-repl/Evolla-10B-hf",
10181029
"nemotron_h": "nvidia/NVIDIA-Nemotron-3-Nano-4B-BF16",
10191030
"nemotron_parse": "nvidia/NVIDIA-Nemotron-Parse-2.0",
10201031
"open-llama": "openlm-research/open_llama_3b",
1032+
"orion": "OrionStarAI/Orion-14B-Base",
10211033
"persimmon": "adept/persimmon-8b-base",
10221034
"shieldgemma2": "google/shieldgemma-2b",
10231035
"solar_open": "upstage/solar-pro-preview-instruct",
@@ -1068,6 +1080,7 @@ def _create_default_registry() -> ModelRegistry:
10681080
"imagegpt": "openai/imagegpt-small",
10691081
"openai-gpt": "openai-community/openai-gpt",
10701082
"xglm": "facebook/xglm-564M",
1083+
"xverse": "xverse/XVERSE-7B",
10711084
"xlm": "FacebookAI/xlm-mlm-en-2048",
10721085

10731086
# --- Mixture of Experts ---

0 commit comments

Comments
 (0)