From 393dd0d5a7b014614818317e5a3cdcd4fc27d98d Mon Sep 17 00:00:00 2001 From: cmoyates Date: Sun, 1 Mar 2026 04:49:09 -0330 Subject: [PATCH] chore: add remaining test stubs and script placeholders Co-Authored-By: Claude Opus 4.6 --- scripts/bench_mlx.py | 9 +++++++++ scripts/compare_reference.py | 9 +++++++++ tests/__init__.py | 0 tests/test_conversion.py | 23 +++++++++++++++++++++++ tests/test_decoder_parity.py | 19 +++++++++++++++++++ tests/test_import.py | 12 ++++++++++++ tests/test_refiner_parity.py | 19 +++++++++++++++++++ 7 files changed, 91 insertions(+) create mode 100644 scripts/bench_mlx.py create mode 100644 scripts/compare_reference.py create mode 100644 tests/__init__.py create mode 100644 tests/test_conversion.py create mode 100644 tests/test_decoder_parity.py create mode 100644 tests/test_import.py create mode 100644 tests/test_refiner_parity.py diff --git a/scripts/bench_mlx.py b/scripts/bench_mlx.py new file mode 100644 index 0000000..6738ad2 --- /dev/null +++ b/scripts/bench_mlx.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 +"""Benchmark MLX inference on Apple Silicon. + +Reports latency, throughput, and memory usage. + +Usage: + uv run python scripts/bench_mlx.py +""" +# TODO: Phase 5 — implement after full pipeline works diff --git a/scripts/compare_reference.py b/scripts/compare_reference.py new file mode 100644 index 0000000..e55f313 --- /dev/null +++ b/scripts/compare_reference.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 +"""Compare MLX outputs against PyTorch reference fixtures. + +Reports max abs error and mean abs error per tensor. + +Usage: + uv run python scripts/compare_reference.py +""" +# TODO: Phase 2+ — implement after reference fixtures exist diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_conversion.py b/tests/test_conversion.py new file mode 100644 index 0000000..b5e7d1f --- /dev/null +++ b/tests/test_conversion.py @@ -0,0 +1,23 @@ +"""Tests: weight conversion PyTorch → MLX (Phase 3). + +Validates key mapping, shape transforms, and round-trip integrity. +""" + +import pytest + +pytestmark = pytest.mark.skip(reason="Phase 3: converter not yet implemented") + + +def test_key_mapping_complete() -> None: + """Every PyTorch key maps to an MLX key with no orphans.""" + ... + + +def test_conv_weight_transpose() -> None: + """Conv weights correctly transposed from NCHW → NHWC.""" + ... + + +def test_first_conv_4ch_preserved() -> None: + """Patched 4-channel first conv preserved during conversion.""" + ... diff --git a/tests/test_decoder_parity.py b/tests/test_decoder_parity.py new file mode 100644 index 0000000..2a6fc75 --- /dev/null +++ b/tests/test_decoder_parity.py @@ -0,0 +1,19 @@ +"""Parity tests: MLX decoder heads vs PyTorch reference (Phase 2). + +Uses saved backbone features → runs MLX decoder → compares +against saved PyTorch coarse predictions. +""" + +import pytest + +pytestmark = pytest.mark.skip(reason="Phase 2: MLX decoder not yet implemented") + + +def test_alpha_decoder_parity() -> None: + """MLX alpha decoder matches PyTorch within tolerance.""" + ... + + +def test_fg_decoder_parity() -> None: + """MLX foreground decoder matches PyTorch within tolerance.""" + ... diff --git a/tests/test_import.py b/tests/test_import.py new file mode 100644 index 0000000..298f266 --- /dev/null +++ b/tests/test_import.py @@ -0,0 +1,12 @@ +"""Smoke test: verify package imports succeed.""" + + +def test_package_imports() -> None: + import corridorkey_mlx + import corridorkey_mlx.convert + import corridorkey_mlx.inference + import corridorkey_mlx.io + import corridorkey_mlx.model + import corridorkey_mlx.utils + + assert corridorkey_mlx.__version__ == "0.1.0" diff --git a/tests/test_refiner_parity.py b/tests/test_refiner_parity.py new file mode 100644 index 0000000..bca7bd2 --- /dev/null +++ b/tests/test_refiner_parity.py @@ -0,0 +1,19 @@ +"""Parity tests: MLX refiner vs PyTorch reference (Phase 2). + +Uses saved coarse predictions + RGB → runs MLX refiner → +compares against saved PyTorch final outputs. +""" + +import pytest + +pytestmark = pytest.mark.skip(reason="Phase 2: MLX refiner not yet implemented") + + +def test_refiner_delta_parity() -> None: + """MLX refiner delta logits match PyTorch within tolerance.""" + ... + + +def test_refiner_final_output_parity() -> None: + """MLX final alpha and fg match PyTorch within tolerance.""" + ...