Skip to content

Commit c3fa21e

Browse files
justinchubyCopilot
andauthored
Add exact legacy dense GGUF graph subsets (#639)
## Summary Adds fail-closed, architecture-owned GGUF graph paths for the maximal exact subsets of: - **GPT-NeoX:** bias LayerNorm/GELU, partial NeoX RoPE, MHA, parallel residual only; pinned converter QKV row reformat is reversed before graph load. - **JAIS:** bias LayerNorm, sequential SwiGLU, causal ALiBi, `1/head_dim` attention scale, converter-baked MuP values. - **MPT:** causal ALiBi, sequential pre-LayerNorm GELU; supports all-or-none optional bias families and tied/untied output while rejecting learned positions, Q/K norms, nonzero KQV clipping, AWQ activation scales, and partial bias families. - **Refact:** RMSNorm, max-8 causal ALiBi, one KV head, bias-free sequential SwiGLU; rejects expert, RoPE-factor, and loaded-but-unexecuted bias families. - **Dense ERNIE 4.5:** RMSNorm, full adjacent-pair RoPE, split bias-free Q/K/V and SwiGLU; rejects fused, MoE, sectioned-position, and bias variants. - **OpenELM:** per-layer Q/KV head and FFN arrays, per-head Q/K RMSNorm, full NeoX RoPE, mandatory tied output, and per-layer dynamic KV-cache geometry. All six advance config/tensor/graph import while **runtime remains deferred**. Static cache is rejected fail-closed. Packed quantized import is rejected for every dedicated graph: fused-QKV architectures require row splitting, while Refact/ERNIE currently lack quantization-aware graph targets. Explicit dequantization remains available. The implementation is pinned to llama.cpp `8d9af256337d1a501250f9bbf4c0859a654bddd6` and retains the existing BailingMoE, DeepSeek, and Dots1 registry/config/tensor/docs behavior from base `8b5f89ab22ea8cc5333d6a05fa7960cdc81cf768`. ## Evidence - Tiny graph/config/tensor closure and fail-closed loader-union tests for all six architectures. - Realistic value-based GPT-NeoX converter row-order transform and OpenELM per-layer fused-row checks. - Independent PyTorch equation reference versus full ORT logits for multi-token prefill and reused-cache decode across all six architectures. - Focused shared GGUF/cache/parity suite: `1199 passed, 1 skipped`. - Broad non-integration suite: `8139 passed, 57 skipped, 1 subtest passed`. - Existing shared GGUF suite: `41 passed`. - Generated GGUF docs check and initialized all-files lint pass. - Pinned real artifact CLI evidence: `tensorblock/pythia-70m-v0-GGUF@8a29e7567c0feef4b3ecca9ae554141d46ea790c`, `pythia-70m-v0-Q2_K.gguf`, SHA-256 `345e1ab0e14035766cfd1faf0cf9c14a3ee8d87e5bf0e8296567277865b77649`. Default packed import is rejected; `--dequantize --dtype f32` builds and runs finite ORT prefill `[1,3,50304]` plus cached decode `[1,1,50304]`, growing cache to `[1,8,4,64]`. ## Reviews Two independent GPT-5.6 Sol medium reviews covered architecture exactness and shared-surface regressions. Findings fixed before publication: - ERNIE 4.5 changed from mirrored NeoX RoPE to pinned adjacent-pair RoPE, including an independent parity reference. - Refact/ERNIE packed-import claims changed to fail-closed rejection because the dedicated graph lacks quantization-aware targets. - Static-cache exposure changed to explicit rejection because dedicated layers implement dynamic cache only. ## Waivers / residual blockers - No YAML/HuggingFace L2 case is added because `gguf_legacy` is an internal graph selected only after GGUF metadata validation, not a HuggingFace architecture alias; dedicated graph/config/closure coverage is registered as specialized coverage instead. - No sufficiently small, pinned representative GGUF was practical for JAIS, MPT, Refact, ERNIE 4.5, or OpenELM in this pass. Their evidence is synthetic full-logit prefill/decode parity, so runtime packaging remains deferred. - The real GPT-NeoX artifact proves CLI import, graph serialization, ORT load, prefill, and reused-cache decode, but not upstream real-weight logit/generation parity; GPT-NeoX runtime therefore also remains deferred. - Quantized preservation and static cache remain explicit residual blockers for all six; callers must dequantize and use dynamic cache. Base: `8b5f89ab22ea8cc5333d6a05fa7960cdc81cf768` Head: `843c3acd6a25874eaa22587a714465bf3a6fee80` --------- Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]>
1 parent 8b5f89a commit c3fa21e

18 files changed

Lines changed: 1616 additions & 30 deletions

‎docs/api/build_from_gguf.md‎

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

‎src/mobius/_configs/_base.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,12 @@ class ArchitectureConfig(BaseModelConfig):
458458
attn_qk_norm: bool = False
459459
attn_qk_norm_full: bool = False
460460
mlp_bias: bool = False
461+
attention_scale: float | None = None
462+
alibi_max_bias: float | None = None
463+
use_parallel_residual: bool = False
464+
layer_intermediate_sizes: tuple[int, ...] = ()
465+
layer_attention_head_counts: tuple[int, ...] = ()
466+
layer_attention_kv_head_counts: tuple[int, ...] = ()
461467

462468
# Encoder-specific config
463469
type_vocab_size: int = 0

‎src/mobius/_registry.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
NeoBertGGUFModel,
164164
NomicBertGGUFModel,
165165
)
166+
from mobius.models.gguf_legacy_decoders import ExactLegacyGGUFCausalLMModel
166167
from mobius.models.glm_asr import GlmAsrForConditionalGeneration
167168
from mobius.models.gpt2 import GPT2CausalLMModel, ScaledEmbeddingGPT2CausalLMModel
168169
from mobius.models.gpt_neox import GPTNeoXCausalLMModel, GPTNeoXJapaneseCausalLMModel
@@ -533,6 +534,7 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
533534
"glm": ModelRegistration(GlmCausalLMModel),
534535
"glm4": ModelRegistration(Glm4CausalLMModel),
535536
"gpt_neox": ModelRegistration(GPTNeoXCausalLMModel),
537+
"gguf_legacy": ModelRegistration(ExactLegacyGGUFCausalLMModel),
536538
"gpt_neox_japanese": ModelRegistration(GPTNeoXJapaneseCausalLMModel),
537539
"gpt_oss": ModelRegistration(GPTOSSCausalLMModel),
538540
"gptj": ModelRegistration(GPTJCausalLMModel),

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

Lines changed: 105 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,19 +1809,103 @@
18091809
),
18101810
GGUFArchitectureSpec(
18111811
gguf_arch="openelm",
1812-
config=Support.DEFERRED,
1813-
tensor_map=Support.DEFERRED,
1814-
graph=Support.DEFERRED,
1812+
model_type="openelm",
1813+
module_type="gguf_legacy",
1814+
tensor_map_recipe=("legacy_layernorm", "exact_legacy_gguf_extras"),
1815+
config_postprocessor="exact_legacy_gguf",
1816+
required_metadata=(
1817+
"attention.layer_norm_rms_epsilon",
1818+
"attention.head_count",
1819+
"attention.head_count_kv",
1820+
"feed_forward_length",
1821+
),
18151822
runtime=Support.DEFERRED,
1816-
reason=_OPENELM_GRAPH_REASON,
1823+
quantized_import=Support.REJECTED,
1824+
reason=(
1825+
_RUNTIME_VALIDATION_PENDING
1826+
+ " Quantization preservation is rejected because every OpenELM layer stores "
1827+
"fused QKV rows that must be split into per-layer Q/K/V graph projections."
1828+
),
18171829
),
18181830
GGUFArchitectureSpec(
18191831
gguf_arch="mpt",
1820-
config=Support.DEFERRED,
1821-
tensor_map=Support.DEFERRED,
1822-
graph=Support.DEFERRED,
1832+
model_type="mpt",
1833+
module_type="gguf_legacy",
1834+
tensor_map_recipe=("legacy_layernorm",),
1835+
config_postprocessor="exact_legacy_gguf",
1836+
required_metadata=("attention.layer_norm_epsilon", "attention.max_alibi_bias"),
1837+
runtime=Support.DEFERRED,
1838+
quantized_import=Support.REJECTED,
1839+
reason=(
1840+
_RUNTIME_VALIDATION_PENDING
1841+
+ " The admitted subset rejects learned positions, Q/K norms, KQV clipping, "
1842+
"AWQ activation scales, and inconsistent optional bias families. Quantization "
1843+
"preservation is rejected because fused QKV must be split."
1844+
),
1845+
),
1846+
GGUFArchitectureSpec(
1847+
gguf_arch="gptneox",
1848+
model_type="gpt_neox",
1849+
module_type="gguf_legacy",
1850+
tensor_map_recipe=("legacy_layernorm",),
1851+
config_postprocessor="exact_legacy_gguf",
1852+
required_metadata=("attention.layer_norm_epsilon", "use_parallel_residual"),
18231853
runtime=Support.DEFERRED,
1824-
reason=_MPT_GRAPH_REASON,
1854+
quantized_import=Support.REJECTED,
1855+
reason=(
1856+
_RUNTIME_VALIDATION_PENDING
1857+
+ " The admitted subset requires parallel residual MHA. Quantization "
1858+
"preservation is rejected because fused QKV rows must be split."
1859+
),
1860+
),
1861+
GGUFArchitectureSpec(
1862+
gguf_arch="jais",
1863+
model_type="jais",
1864+
module_type="gguf_legacy",
1865+
tensor_map_recipe=("legacy_layernorm",),
1866+
config_postprocessor="exact_legacy_gguf",
1867+
required_metadata=("attention.layer_norm_epsilon", "attention.max_alibi_bias"),
1868+
runtime=Support.DEFERRED,
1869+
quantized_import=Support.REJECTED,
1870+
reason=(
1871+
_RUNTIME_VALIDATION_PENDING
1872+
+ " Converter-baked MuP scales are retained exactly, while fused biased QKV "
1873+
"must be split and therefore cannot preserve packed quantization."
1874+
),
1875+
),
1876+
GGUFArchitectureSpec(
1877+
gguf_arch="refact",
1878+
model_type="refact",
1879+
module_type="gguf_legacy",
1880+
tensor_map_recipe=("legacy_layernorm",),
1881+
config_postprocessor="exact_legacy_gguf",
1882+
required_metadata=("attention.layer_norm_rms_epsilon",),
1883+
runtime=Support.DEFERRED,
1884+
quantized_import=Support.REJECTED,
1885+
reason=(
1886+
_RUNTIME_VALIDATION_PENDING
1887+
+ " Import is narrowed to split, bias-free dense tensors with one KV head; "
1888+
"loaded-but-unexecuted expert, RoPE-factor, and bias families are rejected. "
1889+
"Quantization preservation is rejected because this dedicated graph does not "
1890+
"yet provide quantization-aware projection targets; use keep_quantized=False."
1891+
),
1892+
),
1893+
GGUFArchitectureSpec(
1894+
gguf_arch="ernie4_5",
1895+
model_type="ernie4_5",
1896+
module_type="gguf_legacy",
1897+
tensor_map_recipe=("legacy_layernorm",),
1898+
config_postprocessor="exact_legacy_gguf",
1899+
required_metadata=("attention.layer_norm_rms_epsilon",),
1900+
runtime=Support.DEFERRED,
1901+
quantized_import=Support.REJECTED,
1902+
reason=(
1903+
_RUNTIME_VALIDATION_PENDING
1904+
+ " Import is narrowed to the dense split-Q/K/V, split-SwiGLU, full-RoPE "
1905+
"variant and rejects all expert, fused, sectioned-position, and bias alternatives. "
1906+
"Quantization preservation is rejected because this dedicated graph does not "
1907+
"yet provide quantization-aware projection targets; use keep_quantized=False."
1908+
),
18251909
),
18261910
# ------------------------------------------------ known but not importable
18271911
GGUFArchitectureSpec(
@@ -2022,7 +2106,19 @@
20222106
)
20232107
for architecture, reason in _FINAL_CENSUS_DEFERRED_REASONS.items()
20242108
if architecture
2025-
not in {"codeshell", "command-r", "jais2", "orion", "qwen", "starcoder", "xverse"}
2109+
not in {
2110+
"codeshell",
2111+
"command-r",
2112+
"ernie4_5",
2113+
"gptneox",
2114+
"jais",
2115+
"jais2",
2116+
"orion",
2117+
"qwen",
2118+
"refact",
2119+
"starcoder",
2120+
"xverse",
2121+
}
20262122
),
20272123
GGUFArchitectureSpec(
20282124
gguf_arch="arwkv7",

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,23 @@
5757
#: Number of importable architectures. Pinned so that adding support is a
5858
#: deliberate act that also updates the documented support matrix, and so that
5959
#: accidentally losing an architecture is a failure rather than a silence.
60-
_EXPECTED_SUPPORTED_COUNT = 74
60+
_EXPECTED_SUPPORTED_COUNT = 80
6161
_PROMOTED_CONVENTIONAL_DECODERS = frozenset(
62-
{"codeshell", "command-r", "jais2", "orion", "qwen", "starcoder", "xverse"}
62+
{
63+
"codeshell",
64+
"command-r",
65+
"ernie4_5",
66+
"gptneox",
67+
"jais",
68+
"jais2",
69+
"mpt",
70+
"openelm",
71+
"orion",
72+
"qwen",
73+
"refact",
74+
"starcoder",
75+
"xverse",
76+
}
6377
)
6478
_FINAL_CENSUS_CLOSURE = frozenset(
6579
{
@@ -279,6 +293,7 @@ def test_every_float_importable_architecture_has_a_quantized_verdict(self) -> No
279293
assert set(actual) == set(supported_architectures())
280294
rejected = {
281295
"chatglm",
296+
"ernie4_5",
282297
"eurobert",
283298
"granitehybrid",
284299
"internlm2",
@@ -293,8 +308,13 @@ def test_every_float_importable_architecture_has_a_quantized_verdict(self) -> No
293308
"phi2",
294309
"bloom",
295310
"codeshell",
311+
"gptneox",
312+
"jais",
313+
"mpt",
314+
"openelm",
296315
"orion",
297316
"qwen",
317+
"refact",
298318
"starcoder",
299319
"xverse",
300320
}

0 commit comments

Comments
 (0)