Skip to content

Commit 86cd1ca

Browse files
justinchubyCopilot
andauthored
Prove Qwen3.5 MoE GGUF explicit-float runtime route (#672)
## Summary - pin `Flexan/kshitijthakkar-qwen3.5-moe-0.87B-d0.8B-GGUF@a9b8adbec2cc87479c772dac1944f313b4036c26` / `qwen3.5-moe-0.87B-d0.8B.Q2_K.gguf` (626,599,552 bytes, SHA-256 `e8a84df1a50ce65cf80c2b55bba8c6e80f913679fdf9e9439f2c3b52ef3145d5`) - promote only the explicitly dequantized dense-MoE CPU route, with structured source-fidelity, target-storage, compute-mode, runtime, tokenizer, graph, and package evidence - prove full logits, KV/convolution/recurrent state prefill and cached decode, replay/rollback/reorder, deterministic 20-token generation, package/report round-trips, tokenizer identity, and ORT GenAI 0.15.2 compatibility - keep the default mixed-quantized route fail-closed and document the reduced checkpoint's publisher quality limitation and routed-expert tolerance - correct Qwen3.5 M-RoPE channel interleaving independently of flat RoPE rotation ## Evidence - graph SHA-256: `8c1aa1075cee03ffd5ce5bbd283ee88b2466e6c1d645f0a41e542230951d6f09` - runtime package SHA-256: `bd69cf72acffd393a706bb012c23990acfdaf3a43e25ad919ef1148afac42a15` - deterministic tokens: `[198, 198, 198, 321, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198]` ## Validation - promoted real-artifact runtime test: passed - focused GGUF evidence/config/docs/YAML closure: 1,246 passed - broad serial non-integration suite: 8,563 passed, 62 skipped, 12 deselected - lint, generated-doc check, targeted type check, and independent code review: passed --------- Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]>
1 parent eb0e38b commit 86cd1ca

16 files changed

Lines changed: 481 additions & 61 deletions

‎docs/api/build_from_gguf.md‎

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

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,14 @@
856856
"ssm.state_size",
857857
"ssm.time_step_rank",
858858
),
859-
runtime=Support.DEFERRED,
860-
reason=_RECURRENT_RUNTIME_VALIDATION_PENDING,
859+
runtime=Support.SUPPORTED,
860+
runtime_evidence_ids=("qwen3.5-moe-0.87b-q2-k-ort-genai-0.15.2",),
861+
reason=(
862+
"Runtime support is restricted to the pinned Q2_K reduced checkpoint's "
863+
"explicit-float CPU route, exact tokenizer revision, hybrid KV/convolution/"
864+
"recurrent-state evidence, and ORT GenAI 0.15.2. Quantization preservation "
865+
"and sparse MoE throughput are not claimed."
866+
),
861867
),
862868
GGUFArchitectureSpec(
863869
gguf_arch="qwen3next",

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4291,6 +4291,61 @@ def test_preflight_records_mapped_bias_and_scale_parameters(self) -> None:
42914291
stat.source_bytes for stat in report.source_qtype_census
42924292
)
42934293

4294+
def test_qwen35moe_mixed_float_experts_fail_closed_on_default_route(self) -> None:
4295+
"""The quantized Qwen3.5-MoE route must not requantize source-float experts."""
4296+
from gguf import GGMLQuantizationType
4297+
from onnxscript import nn
4298+
4299+
from mobius.components import QuantizedLinear
4300+
from mobius.integrations.gguf._builder import _preflight_quantization_report
4301+
4302+
def make_expert() -> nn.Module:
4303+
expert = nn.Module()
4304+
expert.gate_proj = QuantizedLinear(64, 64)
4305+
expert.up_proj = QuantizedLinear(64, 64)
4306+
expert.down_proj = QuantizedLinear(64, 64)
4307+
return expert
4308+
4309+
mlp = nn.Module()
4310+
mlp.experts = nn.ModuleList([make_expert(), make_expert()])
4311+
layer = nn.Module()
4312+
layer.mlp = mlp
4313+
layer.self_attn = nn.Module()
4314+
layer.self_attn.o_proj = QuantizedLinear(64, 64)
4315+
module = nn.Module()
4316+
module.model = nn.Module()
4317+
module.model.layers = nn.ModuleList([layer])
4318+
tensors = [
4319+
SimpleNamespace(
4320+
name="blk.0.attn_output.weight",
4321+
tensor_type=GGMLQuantizationType.Q4_0,
4322+
shape=(64, 64),
4323+
n_bytes=2_304,
4324+
),
4325+
SimpleNamespace(
4326+
name="blk.0.ffn_gate_exps.weight",
4327+
tensor_type=GGMLQuantizationType.F16,
4328+
shape=(64, 64, 2),
4329+
n_bytes=16_384,
4330+
),
4331+
]
4332+
source = SimpleNamespace(reader_tensors=lambda: iter(tensors), _reader=None)
4333+
4334+
with pytest.raises(
4335+
ValueError,
4336+
match="selected quantized graph would quantize a source-float tensor",
4337+
):
4338+
_preflight_quantization_report(
4339+
source,
4340+
"qwen35moe",
4341+
module,
4342+
SimpleNamespace(),
4343+
preserve_quantization=True,
4344+
target_bits=4,
4345+
target_block_size=32,
4346+
execution_provider="cpu",
4347+
)
4348+
42944349
def test_norms_are_float(self, q4_0_gguf: Path):
42954350
"""Norm weights remain float, not quantized."""
42964351
import onnx_ir as ir

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,7 @@ def gguf_to_config(
10311031
partial_rotary_factor=partial_rotary_factor,
10321032
rope_interleave=rope_interleave,
10331033
mrope_section=mrope_section,
1034+
mrope_interleaved=canonical_arch in {"qwen35", "qwen35moe"},
10341035
num_decoder_layers=hf_fields.get("num_decoder_layers"),
10351036
decoder_start_token_id=hf_fields.get("decoder_start_token_id"),
10361037
relative_attention_num_buckets=hf_fields.get("relative_attention_num_buckets", 32),

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,13 +1473,11 @@ def test_nextn_not_greater_than_block_count(self) -> None:
14731473

14741474

14751475
class TestQwen35RopeInterleave:
1476-
"""M-RoPE section metadata is not a GPT-J adjacent-pair rotation signal.
1476+
"""Qwen3.5 uses interleaved M-RoPE sections with split-half rotation.
14771477
1478-
Qwen3.5/3.8 rotate with split-half (NEOX) semantics. Deriving the flat
1479-
``rope_interleave`` from section presence corrupts RoPE — the exported
1480-
GroupQueryAttention/RotaryEmbedding gets ``rotary_interleaved=1`` and the
1481-
full-attention layers emit garbage tokens. The mapping must keep
1482-
``rope_interleave`` False for section-carrying non-interleaving arches.
1478+
The flat ``rope_interleave`` flag selects GPT-J adjacent-pair rotation and
1479+
must remain false. ``mrope_interleaved`` independently selects Qwen3.5's
1480+
temporal/height/width channel assignment and must be true.
14831481
"""
14841482

14851483
def _fake_model(self, metadata: dict, architecture: str = "qwen35") -> object:
@@ -1526,6 +1524,7 @@ def test_dimension_sections_do_not_force_interleave(self) -> None:
15261524
config = gguf_to_config(self._fake_model(md))
15271525

15281526
assert config.rope_interleave is False
1527+
assert config.mrope_interleaved is True
15291528

15301529
def test_missing_sections_fail_closed(self) -> None:
15311530
from mobius.integrations.gguf._config_mapping import gguf_to_config

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ def _runtime_evidence_table() -> str:
317317
f"ONNX Runtime {evidence.onnxruntime_version} "
318318
f"`{evidence.execution_provider}`; {evidence.runtime} "
319319
f"{evidence.runtime_version}; result={evidence.result}; "
320-
f"{evidence.parity_kind}; {evidence.stateful_semantics} |"
320+
f"{evidence.parity_kind}; {evidence.stateful_semantics}"
321+
f"{'; ' + evidence.limitations if evidence.limitations else ''} |"
321322
)
322323
return "\n".join(rows)
323324

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def test_runtime_support_requires_structured_evidence() -> None:
142142
),
143143
("qwen2", ("qwen2.5-0.5b-instruct-q8-ort-genai-0.15.2",)),
144144
("lfm2", ("lfm2-350m-f16-ort-genai-0.15.2",)),
145+
("qwen35moe", ("qwen3.5-moe-0.87b-q2-k-ort-genai-0.15.2",)),
145146
]
146147

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

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,18 @@ def _artifact_records() -> tuple[list[dict[str, object]], int]:
268268
"downstream_runtime": evidence.runtime,
269269
"downstream_runtime_version": evidence.runtime_version,
270270
"result": evidence.result,
271+
"import_route": evidence.import_route,
272+
"source_fidelity": evidence.source_fidelity,
273+
"storage_quantized": evidence.storage_quantized,
274+
"target_storage_format": evidence.target_storage_format,
275+
"compute_mode": evidence.compute_mode,
271276
"parity_kind": evidence.parity_kind,
272277
"stateful_semantics": evidence.stateful_semantics,
273278
"parity_test": evidence.parity_test,
274279
"deterministic_test": evidence.deterministic_test,
275280
"graph_sha256": evidence.graph_sha256,
276281
"runtime_package_sha256": evidence.runtime_package_sha256,
282+
"limitations": evidence.limitations,
277283
}
278284
)
279285
artifacts = [grouped[key] for key in sorted(grouped)]

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,23 @@ def test_selected_real_artifacts_stay_within_global_budget() -> None:
136136
assert isinstance(policy, dict)
137137
assert isinstance(artifacts, list)
138138
assert isinstance(lossy, list)
139-
assert len(artifacts) == 3
139+
assert len(artifacts) == 4
140140
assert len(lossy) == 1
141141
selected = sum(int(record["size"]) for record in [*artifacts, *lossy])
142-
assert selected == 1_763_532_768
142+
assert selected == 2_390_132_320
143143
assert selected == policy["selected_artifact_bytes"]
144144
assert selected <= policy["max_selected_artifact_bytes"]
145145
assert lossy[0]["lfs_sha256"] == (
146146
"ed5fa30c487b282ec156c29062f1222e5c20875a944ac98289dbd242e947f747"
147147
)
148148
assert "source_fidelity=false" in lossy[0]["disposition"]
149149
assert "runtime support deferred" in lossy[0]["runtime_disposition"]
150+
151+
qwen = next(record for record in artifacts if record["filename"].endswith("Q2_K.gguf"))
152+
[runtime] = qwen["runtime_results"]
153+
assert runtime["source_fidelity"] is False
154+
assert runtime["storage_quantized"] is False
155+
assert runtime["target_storage_format"] == "float"
156+
assert runtime["compute_mode"] == "float operators"
157+
assert '"preserve_quantization":false' in runtime["import_route"]
158+
assert "Explicit-float correctness route only" in runtime["limitations"]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ def test_every_route_has_one_actionable_classification() -> None:
5656
assert {item.category for item in items} == allowed
5757
assert all(item.batch and item.dependencies and item.reason.strip() for item in items)
5858
assert Counter(item.kind for item in items) == {
59-
"architecture": 145,
59+
"architecture": 144,
6060
"projector": 60,
6161
"tokenizer": 57,
6262
"mtp": 22,
6363
"draft": 2,
6464
}
6565
assert Counter(item.category for item in items) == {
6666
"dependency-or-runtime-abi-blocked": 101,
67-
"evidence-only": 95,
67+
"evidence-only": 94,
6868
"immediately-implementable": 67,
6969
"intentionally-rejected": 19,
7070
"artifact-unavailable": 4,

0 commit comments

Comments
 (0)