Skip to content

Commit 4543476

Browse files
authored
Promote first low-cost GGUF runtime evidence batch (#681)
## Summary - promote exact-artifact ORT GenAI runtime support for six graph-supported GGUF architectures: GPT-2, GPT-NeoX/Pythia, MPT, OLMo, StarCoder, and StarCoder2 - bind every route to immutable source/config/tokenizer revisions, exact artifact identity, tensor/value closure, full logits, dynamic-cache replay/rollback/reorder, deterministic 20-token generation, tokenizer identity, and graph/package/report roundtrips - keep all six routes explicitly dequantized to float storage and float operators; this PR makes no native or source-faithful quantized-runtime claim - add network-free case fixtures and a machine-readable batch manifest, then regenerate the capability matrix and GGUF documentation - route GPT-2 through the generic decoder ABI, permit exact-evidenced portable/default graphs for CPU packages, and close dense Qwen3 Q/K norm tensor mapping - preserve the global revision policy: `revision=None` remains unpinned and arbitrary explicit revisions continue to forward unchanged; immutable revisions appear only in tests/evidence ## Selected artifacts | Architecture | Artifact bytes | SHA-256 | |---|---:|---| | GPT-2 | 81,196,544 | `4234545f917ec1df10dab4d926796a83422b68e9010d85a4c111b8b541f32892` | | GPT-NeoX/Pythia | 38,508,192 | `8e331c8c8016bed8ff1863b78fafe51e86b2364f32c2d7f3e201687e081cf7f7` | | MPT | 8,734,304 | `5627dcb0ff18f6f7200f83c0aed2056a6a7c86b5f2d865833e1b5f00b00e4daa` | | OLMo | 33,860,576 | `be1c5a22ac0e75cd5874467ffd80bcd2c8500609d3bf7ccdb5b269373e4d6da4` | | StarCoder | 103,899,456 | `aa8c2170bb9172447baba14309916cfc0d901dbffaf10f1448f4f631e10c1f41` | | StarCoder2 | 68,039,904 | `ab0a4b4e79c906520808db065a00a317c8b097e2176638b34088975eada6e0ed` | Artifact payload is **334,238,976 bytes**; tokenizer assets add **12,586,075 bytes**, for **346,825,051 downloaded bytes** total, below the 16 GiB policy ceiling. ## Fail-closed outcomes - Qwen3: `TOKENIZER_CHAT_TEMPLATE_IDENTITY_MISMATCH` - BLOOM: `FULL_LOGIT_PARITY_DIVERGENCE` - StableLM: `TENSOR_SHAPE_CLOSURE_FAILED` - Gemma/Gemma2/Gemma3/Phi3: `TOKENIZER_COMPILED_SEMANTICS_UNAVAILABLE` - Falcon: `INVALID_GGUF_HEADER` - Qwen3.5 MoE and Nemotron-H MoE remain excluded as recently handled by #672/#674; tokenizer-only and ABI-blocked route classes remain out of scope ## Runtime evidence - ONNX Runtime 1.29.0 / ORT GenAI 0.15.2 / CPU - exact tensor census and value closure - independent full-logit parity with per-route bounded tolerances - prefill, cached decode, full replay, rollback, reorder, and deterministic generation - tokenizer vocabulary/special-token identity - graph package and `quantization_report.json` roundtrip identity - all downloaded payloads and temporary ONNX packages removed after collection ## Validation - promoted real-artifact runtime cases: 6 passed - focused GGUF unit suite: 1,441 passed, 1 skipped - schema/dashboard/docs coverage: 1,135 passed, 255 skipped - broad serial non-integration suite: 8,626 passed, 64 skipped, 12 deselected - post-rebase focused suite: 413 passed - Ruff check/format and generated-doc check: passed - changed source type check: clean except six pre-existing `auto_export.py` errors outside changed lines; repository-wide mypy remains a known non-clean baseline - independent high-confidence review: no findings --------- Signed-off-by: Justin Chu <[email protected]> Copilot-Session: e2a8f3cf-109b-47c5-bc61-0a91ffd27ebf Copilot-Session: f5f288c7-b4e5-4371-ad46-9d163511ade9
1 parent 2605d6d commit 4543476

32 files changed

Lines changed: 1856 additions & 108 deletions

‎docs/api/build_from_gguf.md‎

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

‎docs/cli_reference.md‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ and global cache indices, so dense, MoE, tied-weight, quantized, and unknown
170170
architecture names do not need a runtime registry entry.
171171

172172
Architecture-specific types remain only where the runtime selects different
173-
behavior. `lfm2` uses its legacy convolution-cache implementation. `gpt2` selects
174-
`Gpt_Model`, but Mobius's separate rank-4 key/value cache ABI does not match that
175-
runtime's rank-5 combined-cache contract, so config generation currently fails
176-
closed. `phi3`, `phimoe`, and `phi3small` retain their names only when their config selects
173+
behavior. `lfm2` uses its legacy convolution-cache implementation. `gpt2` uses the
174+
generic decoder because Mobius exports separate rank-4 key/value caches rather than
175+
the specialized `Gpt_Model` rank-5 combined-cache contract. `phi3`, `phimoe`, and
176+
`phi3small` retain their names only when their config selects
177177
LongRoPE, because the released generator uses those names to recompute caches when
178178
generation crosses the short-context threshold. Ordinary Phi-3-family graphs use
179179
`decoder`. Multimodal, audio, encoder-decoder, special-position-ID,
@@ -197,10 +197,11 @@ dense cache. The deferred state-manifest work is tracked by
197197
Each export also writes `runtime_compatibility.json`. Generic decoder metadata
198198
records the minimum runtime version and the latest stable release exercised by
199199
Mobius (0.15.2); it never emits the unreleased `decoder.state_groups` field.
200-
Generic config availability does not promote a GGUF runtime verdict: the only
201-
runtime-supported GGUF route remains the exact pinned SmolLM F16/CPU package, while
202-
SmolLM2 remains rejected because its GGUF padding-token metadata conflicts with the
203-
official pinned tokenizer.
200+
Generic config availability does not promote a GGUF runtime verdict. Runtime
201+
admission is restricted to exact artifacts named by the generated GGUF evidence
202+
matrix, which now includes GPT-2 and other independently verified decoder routes in
203+
addition to SmolLM. SmolLM2 remains rejected because its GGUF padding-token metadata
204+
conflicts with the official pinned tokenizer.
204205

205206
#### Example
206207

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

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@
659659
GGUFArchitectureSpec(
660660
gguf_arch="qwen3",
661661
model_type="qwen3",
662-
tensor_map_recipe=("llama",),
662+
tensor_map_recipe=("llama", "moe_qk_norm_extras"),
663+
config_postprocessor="qwen3",
663664
runtime=Support.DEFERRED,
664665
reason=_RUNTIME_VALIDATION_PENDING,
665666
),
@@ -1042,11 +1043,13 @@
10421043
model_type="gpt2",
10431044
tensor_map_recipe=("gpt2",),
10441045
tensor_processor="gpt2",
1045-
runtime=Support.DEFERRED,
1046+
runtime=Support.SUPPORTED,
1047+
runtime_evidence_ids=("gpt2-q2-k-ort-genai-0.15.2",),
10461048
quantized_import=Support.REJECTED,
10471049
reason=(
1048-
_RUNTIME_VALIDATION_PENDING
1049-
+ " Quantization preservation is rejected because canonical GPT-2 GGUF "
1050+
"Runtime support is restricted to the exact evidenced GPT-2 Q2_K artifact, "
1051+
"explicit-float CPU import route, pinned tokenizer, and ORT GenAI 0.15.2. "
1052+
"Quantization preservation is rejected because canonical GPT-2 GGUF "
10501053
"projections must be transposed into graph order, and the current packed "
10511054
"route cannot transpose values together with their scales and zero-points. "
10521055
"Use keep_quantized=False for explicit float import."
@@ -1610,8 +1613,13 @@
16101613
gguf_arch="starcoder2",
16111614
model_type="starcoder2",
16121615
tensor_map_recipe=("llama",),
1613-
runtime=Support.DEFERRED,
1614-
reason=_RUNTIME_VALIDATION_PENDING,
1616+
config_postprocessor="starcoder2",
1617+
runtime=Support.SUPPORTED,
1618+
runtime_evidence_ids=("tiny-starcoder2-q2-k-ort-genai-0.15.2",),
1619+
reason=(
1620+
"Runtime support is restricted to the exact evidenced tiny StarCoder2 Q2_K "
1621+
"artifact, explicit-float CPU import route, pinned tokenizer, and ORT GenAI 0.15.2."
1622+
),
16151623
),
16161624
GGUFArchitectureSpec(
16171625
gguf_arch="stablelm",
@@ -1638,8 +1646,12 @@
16381646
required_metadata=("attention.layer_norm_epsilon",),
16391647
tensor_processor="llama",
16401648
llama_qk_permute=True,
1641-
runtime=Support.DEFERRED,
1642-
reason=_RUNTIME_VALIDATION_PENDING,
1649+
runtime=Support.SUPPORTED,
1650+
runtime_evidence_ids=("tiny-olmo-q2-k-ort-genai-0.15.2",),
1651+
reason=(
1652+
"Runtime support is restricted to the exact evidenced tiny OLMo Q2_K artifact, "
1653+
"explicit-float CPU import route, pinned tokenizer, and ORT GenAI 0.15.2."
1654+
),
16431655
),
16441656
GGUFArchitectureSpec(
16451657
gguf_arch="olmo2",
@@ -2174,11 +2186,13 @@
21742186
tensor_map_recipe=("legacy_layernorm",),
21752187
config_postprocessor="exact_legacy_gguf",
21762188
required_metadata=("attention.layer_norm_epsilon", "attention.max_alibi_bias"),
2177-
runtime=Support.DEFERRED,
2189+
runtime=Support.SUPPORTED,
2190+
runtime_evidence_ids=("tiny-mpt-q2-k-ort-genai-0.15.2",),
21782191
quantized_import=Support.REJECTED,
21792192
reason=(
2180-
_RUNTIME_VALIDATION_PENDING
2181-
+ " The admitted subset rejects learned positions, Q/K norms, KQV clipping, "
2193+
"Runtime support is restricted to the exact evidenced tiny MPT Q2_K artifact, "
2194+
"explicit-float portable graph, pinned tokenizer, and ORT GenAI 0.15.2. "
2195+
"The admitted subset rejects learned positions, Q/K norms, KQV clipping, "
21822196
"AWQ activation scales, and inconsistent optional bias families. Quantization "
21832197
"preservation is rejected because fused QKV must be split."
21842198
),
@@ -2190,11 +2204,13 @@
21902204
tensor_map_recipe=("legacy_layernorm",),
21912205
config_postprocessor="exact_legacy_gguf",
21922206
required_metadata=("attention.layer_norm_epsilon", "use_parallel_residual"),
2193-
runtime=Support.DEFERRED,
2207+
runtime=Support.SUPPORTED,
2208+
runtime_evidence_ids=("pythia-70m-q2-k-ort-genai-0.15.2",),
21942209
quantized_import=Support.REJECTED,
21952210
reason=(
2196-
_RUNTIME_VALIDATION_PENDING
2197-
+ " The admitted subset requires parallel residual MHA. Quantization "
2211+
"Runtime support is restricted to the exact evidenced Pythia-70M Q2_K artifact, "
2212+
"explicit-float portable graph, pinned tokenizer, and ORT GenAI 0.15.2. "
2213+
"The admitted subset requires parallel residual MHA. Quantization "
21982214
"preservation is rejected because fused QKV rows must be split."
21992215
),
22002216
),
@@ -2336,11 +2352,13 @@
23362352
tensor_map_recipe=("starcoder",),
23372353
config_postprocessor="conventional_legacy",
23382354
required_metadata=("attention.layer_norm_epsilon",),
2339-
runtime=Support.DEFERRED,
2355+
runtime=Support.SUPPORTED,
2356+
runtime_evidence_ids=("tiny-starcoder-q2-k-ort-genai-0.15.2",),
23402357
quantized_import=Support.REJECTED,
23412358
reason=(
2342-
_RUNTIME_VALIDATION_PENDING
2343-
+ " Quantization preservation is rejected because StarCoder stores one fused "
2359+
"Runtime support is restricted to the exact evidenced tiny StarCoder Q2_K "
2360+
"artifact, explicit-float CPU import route, pinned tokenizer, and ORT GenAI "
2361+
"0.15.2. Quantization preservation is rejected because StarCoder stores one fused "
23442362
"biased MQA projection that must be split for the graph."
23452363
),
23462364
),

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,27 @@ def _moe_postprocess(
15331533
return dataclasses.replace(config, **updates)
15341534

15351535

1536+
def _qwen3_postprocess(
1537+
config: ArchitectureConfig,
1538+
metadata: dict[str, Any],
1539+
model: Any = None,
1540+
) -> ArchitectureConfig:
1541+
"""Apply Qwen3's per-head Q/K normalization omitted by GGUF metadata."""
1542+
return dataclasses.replace(config, attn_qk_norm=True, attn_qk_norm_full=False)
1543+
1544+
1545+
def _starcoder2_postprocess(
1546+
config: ArchitectureConfig,
1547+
metadata: dict[str, Any],
1548+
model: Any = None,
1549+
) -> ArchitectureConfig:
1550+
"""Restore StarCoder2's architecture-owned uniform sliding window."""
1551+
del metadata, model
1552+
if config.sliding_window is not None:
1553+
return config
1554+
return dataclasses.replace(config, sliding_window=4096)
1555+
1556+
15361557
def _dbrx_postprocess(
15371558
config: ArchitectureConfig,
15381559
metadata: dict[str, Any],
@@ -4716,6 +4737,8 @@ def _qwen4exp_postprocess(
47164737
"phimoe": _phimoe_postprocess,
47174738
"pangu_embedded": _pangu_embedded_postprocess,
47184739
"dense_sliding": _dense_sliding_postprocess,
4740+
"qwen3": _qwen3_postprocess,
4741+
"starcoder2": _starcoder2_postprocess,
47194742
"gemma2": _gemma2_postprocess,
47204743
"baichuan": _baichuan_postprocess,
47214744
"chatglm": _chatglm_postprocess,
@@ -4764,15 +4787,17 @@ def _default_activation(model_type: str) -> str:
47644787
# Most modern models use SiLU/Swish
47654788
if model_type == "arcee":
47664789
return "relu2"
4790+
if model_type in {"gpt2", "starcoder2"}:
4791+
# These architectures use tanh-approximate GELU by default. Their GGUF
4792+
# metadata omits that architecture-owned choice, so exact GELU is not equivalent.
4793+
return "gelu_pytorch_tanh"
47674794
gelu_models = {
47684795
"bert",
47694796
"bloom",
4770-
"gpt2",
47714797
"gpt_bigcode",
47724798
"jais2",
47734799
"kclgpt",
47744800
"modernbert",
4775-
"starcoder2",
47764801
"t5",
47774802
}
47784803
if model_type in gelu_models:

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

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,19 +1382,67 @@ def test_gemma_uses_gelu_pytorch_tanh(self, model_type: str) -> None:
13821382

13831383
assert _default_activation(model_type) == "gelu_pytorch_tanh"
13841384

1385-
@pytest.mark.parametrize("model_type", ["gpt2", "bloom", "starcoder2", "t5"])
1385+
@pytest.mark.parametrize("model_type", ["bloom", "t5"])
13861386
def test_gelu_models(self, model_type: str) -> None:
13871387
from mobius.integrations.gguf._config_mapping import _default_activation
13881388

13891389
assert _default_activation(model_type) == "gelu"
13901390

1391+
@pytest.mark.parametrize("model_type", ["gpt2", "starcoder2"])
1392+
def test_architecture_default_uses_tanh_approximate_gelu(self, model_type: str) -> None:
1393+
from mobius.integrations.gguf._config_mapping import _default_activation
1394+
1395+
assert _default_activation(model_type) == "gelu_pytorch_tanh"
1396+
13911397
@pytest.mark.parametrize("model_type", ["llama", "qwen2", "mistral"])
13921398
def test_silu_default(self, model_type: str) -> None:
13931399
from mobius.integrations.gguf._config_mapping import _default_activation
13941400

13951401
assert _default_activation(model_type) == "silu"
13961402

13971403

1404+
def test_qwen3_qk_norm_weights_have_graph_consumers() -> None:
1405+
from mobius.integrations.gguf._config_mapping import gguf_to_config
1406+
1407+
tensor_names = [
1408+
"token_embd.weight",
1409+
"output.weight",
1410+
*[
1411+
f"blk.{layer}.{name}.weight"
1412+
for layer in range(2)
1413+
for name in ("attn_q_norm", "attn_k_norm")
1414+
],
1415+
]
1416+
config = gguf_to_config(_FakeDenseGGUF("qwen3", _dense_metadata("qwen3"), tensor_names))
1417+
1418+
assert config.attn_qk_norm is True
1419+
assert config.attn_qk_norm_full is False
1420+
module = registry.get(config.model_type)(config)
1421+
for layer in module.model.layers:
1422+
assert layer.self_attn.q_norm is not None
1423+
assert layer.self_attn.k_norm is not None
1424+
1425+
1426+
@pytest.mark.parametrize(
1427+
("metadata_window", "expected_window"),
1428+
[(None, 4096), (2048, 2048)],
1429+
)
1430+
def test_starcoder2_restores_architecture_sliding_window(
1431+
metadata_window: int | None,
1432+
expected_window: int,
1433+
) -> None:
1434+
from mobius.integrations.gguf._config_mapping import gguf_to_config
1435+
1436+
metadata = _dense_metadata("starcoder2")
1437+
if metadata_window is not None:
1438+
metadata["starcoder2.attention.sliding_window"] = metadata_window
1439+
config = gguf_to_config(_FakeDenseGGUF("starcoder2", metadata, []))
1440+
1441+
assert config.sliding_window == expected_window
1442+
module = registry.get(config.model_type)(config)
1443+
assert module.model._sliding_window == expected_window
1444+
1445+
13981446
class TestQwen35MtpBlockExclusion:
13991447
"""Qwen3.5/3.8 GGUF ``block_count`` includes trailing MTP (nextn) blocks.
14001448

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ def test_conventional_decoder_support_and_runtime_verdicts_are_explicit() -> Non
199199
for architecture in _ARCHITECTURES:
200200
spec = get_arch_spec(architecture)
201201
assert spec.is_importable
202-
assert spec.runtime is Support.DEFERRED
202+
expected_runtime = (
203+
Support.SUPPORTED if architecture == "starcoder" else Support.DEFERRED
204+
)
205+
assert spec.runtime is expected_runtime
203206
expected = (
204207
Support.SUPPORTED if architecture in supported_quantized else Support.REJECTED
205208
)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,12 @@ def render_document() -> str:
647647
648648
## Runtime evidence
649649
650+
The first low-cost architecture batch promotes GPT-2, GPT-NeoX/Pythia, MPT, OLMo,
651+
StarCoder, and StarCoder2 using 334,238,976 bytes of GGUF payload and 346,825,051
652+
download bytes including tokenizer assets. Every route is explicit-float only. The
653+
network-free selection, budget, exclusions, and fail-closed candidate reasons are recorded in
654+
`testdata/evidence/gguf_low_cost_runtime_batch.json`.
655+
650656
{_runtime_evidence_table()}
651657
652658
Runtime support above is independent from tokenizer materialization support below.

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_document_is_exact_generator_output() -> None:
3939

4040
def test_document_is_concise_and_reason_coded() -> None:
4141
document = Path("docs/api/build_from_gguf.md").read_text(encoding="utf-8")
42-
assert len(document.splitlines()) < 545
42+
assert len(document.splitlines()) < 560
4343
assert "RUNTIME_EVIDENCE_PENDING" in document
4444
assert "qwen3.5-0.8b-q4-tokenizer" in document
4545
assert "qwen2.5-0.5b-instruct-q8-tokenizer" in document
@@ -143,6 +143,12 @@ def test_runtime_support_requires_structured_evidence() -> None:
143143
("qwen2", ("qwen2.5-0.5b-instruct-q8-ort-genai-0.15.2",)),
144144
("lfm2", ("lfm2-350m-f16-ort-genai-0.15.2",)),
145145
("qwen35moe", ("qwen3.5-moe-0.87b-q2-k-ort-genai-0.15.2",)),
146+
("gpt2", ("gpt2-q2-k-ort-genai-0.15.2",)),
147+
("starcoder2", ("tiny-starcoder2-q2-k-ort-genai-0.15.2",)),
148+
("olmo", ("tiny-olmo-q2-k-ort-genai-0.15.2",)),
149+
("mpt", ("tiny-mpt-q2-k-ort-genai-0.15.2",)),
150+
("gptneox", ("pythia-70m-q2-k-ort-genai-0.15.2",)),
151+
("starcoder", ("tiny-starcoder-q2-k-ort-genai-0.15.2",)),
146152
]
147153

148154
pins = {pin.artifact_id for pin in MMPROJ_ARTIFACT_PINS}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ def test_exact_legacy_config_tensor_and_graph_closure(architecture: str) -> None
154154
"openelm": "openelm",
155155
}[architecture]
156156
)
157-
assert spec.runtime is Support.DEFERRED
157+
expected_runtime = (
158+
Support.SUPPORTED if architecture in {"gptneox", "mpt"} else Support.DEFERRED
159+
)
160+
assert spec.runtime is expected_runtime
158161
if architecture == "ernie4_5":
159162
assert config.rope_interleave
160163

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ def test_selected_real_artifacts_stay_within_global_budget() -> None:
167167
assert isinstance(policy, dict)
168168
assert isinstance(artifacts, list)
169169
assert isinstance(lossy, list)
170-
assert len(artifacts) == 4
170+
assert len(artifacts) == 10
171171
assert len(lossy) == 1
172172
selected = sum(int(record["size"]) for record in [*artifacts, *lossy])
173-
assert selected == 2_390_132_320
173+
assert selected == 2_724_371_296
174174
assert selected == policy["selected_artifact_bytes"]
175175
assert selected <= policy["max_selected_artifact_bytes"]
176176
assert lossy[0]["lfs_sha256"] == (

0 commit comments

Comments
 (0)