π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
test: run test_ransac.py on MPS again and remove the mps_process_abort skip (#6353)
Muhammad Talhaa625f303d02c
diff --git a/TESTING.md b/TESTING.mdindex 3b1bbfc50..c73018311 100644--- a/TESTING.md+++ b/TESTING.md@@ -399,15 +399,6 @@ process before they can raise.- `test_gradcheck[mps*]` β skipped automatically (`gradcheck` requires float64)- `*[mps*cdtype1*]` β skipped automatically (parametrized `torch.cdouble` tests)- `test_autocast[mps*]` β skipped automatically (MPS autocast changes dtype)-- any module marked `mps_process_abort` on MPS β skipped automatically; today that is- `tests/geometry/test_ransac.py`. RANSAC's batched minimal solvers abort the process (SIGABRT) on- the paravirtualized GPU of the hosted macOS runners, at a site that moves between runs, and- SIGABRT carries no exception type, so these **cannot be pinned** as strict xfails β the process- dies and every test after it is lost ([#4204](https://github.com/kornia/kornia/issues/4204)).- The marker lives on the test module, so a rename cannot silently disarm the skip. Real Apple- hardware does not abort: `--run-mps-process-abort` (env `KORNIA_TEST_RUN_MPS_PROCESS_ABORT`)- runs them anyway for local diagnosis, at the cost of failures the manifest does not pin β on an- M1 with torch 2.14.0 that is 3 failed / 10 passed, so the skip costs 9 real-hardware passes.The `padding_mode="border"` issue in `F.grid_sample` (2D) is worked around in the implementation (`kornia/feature/laf.py`) by clamping the sampling grid to the outermost pixel *centers*, at `Β±(1 - 1/size)`, and using `padding_mode="zeros"`, which is exactly equivalent. Clamping to `[-1, 1]` is not: with `align_corners=False` that is the outer edge of the border pixel, where bilinear sampling blends it with the zero padding.diff --git a/conftest.py b/conftest.pyindex db5322e29..a5c8d5c3d 100644--- a/conftest.py+++ b/conftest.py@@ -341,7 +341,7 @@ def pytest_generate_tests(metafunc) -> None:metafunc.parametrize(names, combinations)-def _apply_device_skips(items, run_mps_process_abort: bool) -> None:+def _apply_device_skips(items) -> None:"""Skip the test classes a device cannot run at all, before they are executed."""# gradcheck requires float64. MPS does not support it at all, and XLA lowers a float64 request# to float32, where gradcheck's default eps=1e-6 makes the numerical Jacobian invalid β so a@@ -351,16 +351,6 @@ def _apply_device_skips(items, run_mps_process_abort: bool) -> None:skip_mps_cdouble = pytest.mark.skip(reason="MPS does not support complex128 (cdouble)")# MPS autocast uses float16 and does not preserve original dtype β skip autocast tests on MPSskip_mps_autocast = pytest.mark.skip(reason="MPS autocast changes dtype to float16, not supported the same way")- # A module marked mps_process_abort takes the Metal shader compiler down on the paravirtualized- # GPU of the hosted macOS runners, and the next MPS allocation aborts the pytest process- # (SIGABRT). The abort site moves between runs, and SIGABRT has no exception type, so these- # cannot be pinned as strict xfails β the process dies and everything after it is lost. Real- # Apple hardware does not abort, so --run-mps-process-abort forces them back on for local- # diagnosis; note that doing so leaves failures the manifest does not pin. Tracked in #4204,- # and the marker lives on the test module so a rename cannot silently disarm this.- skip_mps_abort = pytest.mark.skip(- reason="aborts the pytest process on MPS on virtualized Apple GPUs (#4204); --run-mps-process-abort runs anyway"- )for item in items:name = item.name.lower()@@ -371,8 +361,6 @@ def _apply_device_skips(items, run_mps_process_abort: bool) -> None:item.add_marker(skip_mps_cdouble)if on_mps and "autocast" in name:item.add_marker(skip_mps_autocast)- if on_mps and not run_mps_process_abort and item.get_closest_marker("mps_process_abort"):- item.add_marker(skip_mps_abort)def pytest_collection_modifyitems(config, items):@@ -430,7 +418,7 @@ def pytest_collection_modifyitems(config, items):raise pytest.UsageError(str(error)) from errorconfig.pluginmanager.register(tracker, "known-failure-tracker")- _apply_device_skips(items, config.getoption("--run-mps-process-abort"))+ _apply_device_skips(items)tf32_enabled = config.getoption("--tf32")@@ -558,18 +546,6 @@ def pytest_addoption(parser):"on one device anyway. (env: KORNIA_TEST_RUN_DEVICE_AGNOSTIC)"),)- parser.addoption(- "--run-mps-process-abort",- action="store_true",- default=os.environ.get("KORNIA_TEST_RUN_MPS_PROCESS_ABORT", "false").lower() == "true",- help=(- "Run tests marked mps_process_abort on MPS. They take the Metal shader compiler down "- "on the paravirtualized GPU of the hosted macOS runners and abort the pytest process, "- "so they are skipped by default; real Apple hardware does not abort, and this restores "- "them for local diagnosis. Expect failures the known-failure manifest does not pin. "- "(env: KORNIA_TEST_RUN_MPS_PROCESS_ABORT)"- ),- )for promise in conformance_promise.PROMISES:parser.addoption(promise.option,diff --git a/pyproject.toml b/pyproject.tomlindex a46cd8c3f..948693473 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -174,7 +174,6 @@ filterwarnings = [markers = ["device_agnostic: run CPU-only test logic once in a CPU-containing device matrix","compile_conformance: torch.compile conformance of the promised operators (#5819); deselected unless --compile-conformance selects packages",- "mps_process_abort: aborts the pytest process on MPS on virtualized Apple GPUs (#4204); skipped there unless --run-mps-process-abort","onnx_conformance: ONNX conformance of the promised operators (#5819); deselected unless --onnx-conformance selects packages","slow: mark test as slow to run","tf32: mark a test as sensitive to TF32 (TensorFloat-32) CUDA matmul and cuDNN precision; xfail by default, run with --tf32 to activate",diff --git a/testing/known_failure_xfails/mps_float32.txt b/testing/known_failure_xfails/mps_float32.txtindex e47218df6..42af7d8b8 100644--- a/testing/known_failure_xfails/mps_float32.txt+++ b/testing/known_failure_xfails/mps_float32.txt@@ -3,7 +3,6 @@# deselected on an mps-only run).# Remove an entry when it becomes a strict XPASS; fix any new failure, or add it with a comment naming its own# tracking issue.-# tests/geometry/test_ransac.py is skipped on MPS, not pinned: it aborts the process (#4204).# Keep the entries sorted by node ID: KnownFailureTracker prints its regeneration output sorted,# so an unsorted file turns the next re-record into a whole-file diff.# Format: <exact exception type>\t<pytest node ID>diff --git a/tests/geometry/test_ransac.py b/tests/geometry/test_ransac.pyindex 2b12fe9b8..52c067eef 100644--- a/tests/geometry/test_ransac.py+++ b/tests/geometry/test_ransac.py@@ -42,15 +42,6 @@ from testing.casts import dict_tofrom testing.default_device import default_devicefrom testing.geometry.create import create_dominant_plane_scene-# RANSAC's batched minimal solvers take the Metal shader compiler down on the paravirtualized GPU-# of the hosted macOS runners, and the next MPS allocation aborts the pytest process (SIGABRT).-# The abort site moves between runs β observed inside the 5-point solver and, with that class-# deselected, later in an unrelated `F.pad` β and SIGABRT carries no exception type, so these-# cannot be recorded as strict xfails in testing/known_failure_xfails/mps_float32.txt: the process-# dies and every test after it is lost. conftest skips this module on MPS; real Apple hardware-# does not abort, so `--run-mps-process-abort` runs it anyway. Tracked in #4204.-pytestmark = pytest.mark.mps_process_abort-class TestRANSACHomography(BaseTester):def test_smoke(self, device, dtype):