Skip to content

Commit 191c80d

Browse files
justinchubyCopilot
andcommitted
Run schema-independent packed tests and report opset29 coverage
Limit schema skips to checker, optimizer validation, grouped construction and reference execution. Keep per-codec binding and package integrity coverage in released-ONNX jobs. Collect and upload dedicated opset29 coverage and JUnit reports, retaining CI artifacts. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
1 parent be449a6 commit 191c80d

3 files changed

Lines changed: 90 additions & 23 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Install released dependencies
4848
run: |
4949
# Test-only dependencies allow source collection before marker selection.
50-
pip install -e . pytest httpx "gguf>=0.10.0" "jsonschema>=4.0" \
50+
pip install -e . pytest pytest-cov httpx "gguf>=0.10.0" "jsonschema>=4.0" \
5151
onnx==1.19.0 onnxruntime==1.31.1 onnxruntime-easy==0.1.2 \
5252
onnxscript==0.7.2 onnx_ir==1.1.0
5353
- name: Test with released ONNX 1.19 schemas
@@ -61,7 +61,32 @@ jobs:
6161
python -c "import onnx; assert onnx.defs.has('GroupedMatMul', 29); assert onnx.defs.has('DequantizePacked', 29)"
6262
- name: Test with pinned opset-29 schemas
6363
run: |
64-
python -m pytest src/mobius tests/ep_optimization_test.py -m opset29 -q -rs
64+
python -m pytest src/mobius tests/ep_optimization_test.py -m opset29 -q -rs \
65+
--cov=src --cov-report=xml:coverage-opset29.xml --cov-branch \
66+
--junitxml=junit-opset29.xml
67+
- name: Upload opset-29 coverage to Codecov
68+
if: always()
69+
uses: codecov/codecov-action@v7
70+
with:
71+
token: ${{ secrets.CODECOV_TOKEN }}
72+
files: coverage-opset29.xml
73+
flags: unittests
74+
- name: Save opset-29 coverage and test reports
75+
if: always()
76+
uses: actions/upload-artifact@v7
77+
with:
78+
name: opset29-coverage
79+
path: |
80+
coverage-opset29.xml
81+
junit-opset29.xml
82+
- name: Upload opset-29 test results to Codecov
83+
if: ${{ !cancelled() }}
84+
uses: codecov/codecov-action@v7
85+
with:
86+
token: ${{ secrets.CODECOV_TOKEN }}
87+
files: junit-opset29.xml
88+
flags: unittests
89+
report_type: test_results
6590

6691
detect-affected:
6792
name: Detect affected models

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def get_schema(name, *args, **kwargs):
3838

3939
@pytest.mark.opset29
4040
@pytest.mark.skipif(
41-
not onnx.defs.has("DequantizePacked", 29),
41+
not (
42+
onnx.defs.has("DequantizePacked", 29)
43+
and onnx.defs.get_schema("DequantizePacked", 29).since_version == 29
44+
),
4245
reason="DequantizePacked-29 schema is required for layout conformance checking.",
4346
)
4447
def test_packed_layouts_match_standard_schema() -> None:

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

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@
1717
from mobius._flags import override_flags
1818
from mobius.integrations.gguf._builder_test_utils import _write_quantized_gguf
1919

20-
pytestmark = [
21-
pytest.mark.opset29,
22-
pytest.mark.skipif(
23-
not all(onnx.defs.has(name, 29) for name in ("DequantizePacked", "GroupedMatMul")),
24-
reason="Official ONNX opset-29 packed/grouped schemas require current ONNX main.",
25-
),
26-
]
20+
pytestmark = pytest.mark.opset29
21+
22+
23+
def _has_schema29(name: str) -> bool:
24+
return onnx.defs.has(name, 29) and onnx.defs.get_schema(name, 29).since_version == 29
25+
26+
27+
requires_packed_schema = pytest.mark.skipif(
28+
not _has_schema29("DequantizePacked"),
29+
reason="DequantizePacked-29 is required for checking and reference execution.",
30+
)
31+
requires_grouped_schema = pytest.mark.skipif(
32+
not _has_schema29("GroupedMatMul"),
33+
reason="GroupedMatMul-29 is required for checking and reference execution.",
34+
)
2735

2836

2937
@pytest.mark.parametrize(
@@ -84,6 +92,11 @@ def packed_sources(tmp_path_factory: pytest.TempPathFactory) -> dict[str, Path]:
8492
return paths
8593

8694

95+
@pytest.mark.parametrize(
96+
"validate_schema",
97+
[False, pytest.param(True, marks=requires_packed_schema)],
98+
ids=["binding-roundtrip", "reference"],
99+
)
87100
@pytest.mark.parametrize(
88101
"qtype",
89102
[
@@ -113,7 +126,7 @@ def packed_sources(tmp_path_factory: pytest.TempPathFactory) -> dict[str, Path]:
113126
"Q1_0",
114127
],
115128
)
116-
def test_all_stored_reader_formats(tmp_path: Path, qtype: str) -> None:
129+
def test_all_stored_reader_formats(tmp_path: Path, qtype: str, validate_schema: bool) -> None:
117130
from types import SimpleNamespace
118131

119132
import gguf
@@ -184,6 +197,15 @@ def test_all_stored_reader_formats(tmp_path: Path, qtype: str) -> None:
184197
package.save(str(tmp_path))
185198
restored = ModelPackage.load(str(tmp_path))
186199
assert [value.name for value in restored["model"].graph.outputs] == ["out"]
200+
payload = next(
201+
v.const_value
202+
for v in restored["model"].graph.initializers.values()
203+
if isinstance(v.const_value, ir.ExternalTensor)
204+
)
205+
assert payload.numpy().tobytes() == raw.tobytes()
206+
assert any(n.op_type == "Scan" for n in model.graph.all_nodes())
207+
if not validate_schema:
208+
return
187209
onnx.checker.check_model(str(tmp_path / "model.onnx"), full_check=True)
188210
evaluator = ReferenceEvaluator(str(tmp_path / "model.onnx"))
189211
indices = np.array([[1, 0, 1], [-1, -2, 0]], dtype=np.int64)
@@ -201,13 +223,6 @@ def test_all_stored_reader_formats(tmp_path: Path, qtype: str) -> None:
201223
expected = gguf.dequantize(raw, kind)
202224
assert np.isfinite(expected).all() and np.count_nonzero(expected)
203225
np.testing.assert_allclose(actual, expected[indices], rtol=1e-6, atol=1e-7)
204-
payload = next(
205-
v.const_value
206-
for v in model.graph.initializers.values()
207-
if isinstance(v.const_value, ir.ExternalTensor)
208-
)
209-
assert payload.numpy().tobytes() == raw.tobytes()
210-
assert any(n.op_type == "Scan" for n in model.graph.all_nodes())
211226

212227

213228
@pytest.mark.parametrize("architecture", ["qwen2", "llama"])
@@ -221,7 +236,6 @@ def test_packed_build_roundtrip(packed_sources: dict[str, Path], architecture: s
221236
assert package.gguf_quantization_report.source_fidelity
222237
assert any(n.op_type == "DequantizePacked" for n in package["model"].graph)
223238
package.save(str(tmp_path))
224-
onnx.checker.check_model(str(tmp_path / "model.onnx"), full_check=True)
225239
restored = ModelPackage.load(str(tmp_path))
226240
restored.save(str(tmp_path))
227241
assert not (tmp_path / "model.onnx.data").exists()
@@ -251,7 +265,6 @@ def test_split_shards_and_bf16_preserve_external_ranges(
251265
and v.const_value.dtype == ir.DataType.BFLOAT16
252266
for v in package["model"].graph.initializers.values()
253267
)
254-
onnx.checker.check_model(str(tmp_path / "model.onnx"), full_check=True)
255268
ModelPackage.load(str(tmp_path)).save(str(tmp_path))
256269

257270

@@ -317,6 +330,7 @@ def test_packed_save_rejects_missing_generated_initializer(
317330
package.save(str(source.parent))
318331

319332

333+
@requires_packed_schema
320334
def test_optimization_cannot_fold_original_external_weights(
321335
packed_sources: dict[str, Path],
322336
) -> None:
@@ -332,7 +346,10 @@ def test_optimization_cannot_fold_original_external_weights(
332346
assert not (tmp_path / "model.onnx.data").exists()
333347

334348

335-
@pytest.mark.parametrize("architecture", ["qwen2moe", "qwen3moe"])
349+
@pytest.mark.parametrize(
350+
"architecture",
351+
["qwen2moe", pytest.param("qwen3moe", marks=requires_grouped_schema)],
352+
)
336353
def test_packed_expert_layout_and_standard_moe(
337354
packed_sources: dict[str, Path], architecture: str
338355
) -> None:
@@ -347,10 +364,32 @@ def test_packed_expert_layout_and_standard_moe(
347364
v.name.endswith("ffn_up_exps.weight") and isinstance(v.const_value, ir.ExternalTensor)
348365
for v in package["model"].graph.initializers.values()
349366
)
350-
onnx.checker.check_model(str(tmp_path / "model.onnx"), full_check=True)
351367

352368

353-
@pytest.mark.parametrize("architecture", ["parity", "qwen2moe", "qwen3moe"])
369+
@requires_packed_schema
370+
@pytest.mark.parametrize(
371+
"architecture",
372+
[
373+
"qwen2",
374+
"llama",
375+
"split",
376+
"qwen2moe",
377+
pytest.param("qwen3moe", marks=requires_grouped_schema),
378+
],
379+
)
380+
def test_packed_model_schema(packed_sources: dict[str, Path], architecture: str) -> None:
381+
source = packed_sources[architecture]
382+
with override_flags(experimental_opset29=True):
383+
package = build_from_gguf(source, execution_provider="onnx-standard")
384+
package.save(str(source.parent))
385+
onnx.checker.check_model(str(source.parent / "model.onnx"), full_check=True)
386+
387+
388+
@requires_packed_schema
389+
@pytest.mark.parametrize(
390+
"architecture",
391+
["parity", "qwen2moe", pytest.param("qwen3moe", marks=requires_grouped_schema)],
392+
)
354393
def test_packed_next_token_matches_float_source(
355394
packed_sources: dict[str, Path], architecture: str
356395
) -> None:

0 commit comments

Comments
 (0)