Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

test: retire #4159 as the MPS known-failure tracker now that the baseline is empty (#5139)

Dmytro Mishkin9f8a26ae5ee5
diff --git a/.github/workflows/pr_test_cpu.yml b/.github/workflows/pr_test_cpu.yml
index b2c2224b0..4b32e6710 100644
--- a/.github/workflows/pr_test_cpu.yml
+++ b/.github/workflows/pr_test_cpu.yml
@@ -183,7 +183,7 @@ jobs:
model-weights-
# Single blocking MPS leg: newest Python, float32, on an Apple-silicon image.
- # The exact known-failure baseline is pinned as strict xfails (see #4159): a new failure,
+ # The exact known-failure baseline is pinned as strict xfails: a new failure,
# changed failure, skipped pin, or fixed pin makes the job red and requires review. The
# torch pin tracks the newest pin of the CPU matrix so the leg resolves the locked
# dependency set; changing it means re-recording the manifest in the same change, because
@@ -196,8 +196,7 @@ jobs:
# 664 tests down across every subpackage -- `linalg.inv`, `linalg.solve`, `inv_ex`,
# `lu_factor_ex` and `F.conv3d` all route through it -- where the same runner on torch
# 2.9.1 had 200 failures. The blocker is the *virtual* GPU and not macOS 26: a physical M1
- # on macOS 26.5 compiled those shaders in the #4202 comparison. The strict manifest is empty
- # since #4185 fixed the two YUV420/YUV422 empty-input failures and #5078 the 12 eigvals ones.
+ # on macOS 26.5 compiled those shaders in the #4202 comparison.
# The macOS 15 image is Metal 3 and takes the older kernel path, which is the path that
# works on the runner fleet. Two consequences: no job here exercises the Metal 4 path that
# users on current macOS run, and when GitHub retires macos-15 this leg stops scheduling
diff --git a/AGENTS.md b/AGENTS.md
index b5c2c0db1..d686ca91c 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -97,7 +97,7 @@ when more than one virtualenv is in play: name the interpreter explicitly rather
recording, fresh-process replay, and manual installation.
- CUDA `float16`/`bfloat16` tests need per-test subprocess isolation; use `pixi run -e cuda test-cuda-half` or pytest's `--isolate-half-precision` option.
- MPS does not support float64 gradcheck. MPS autocast can also change the effective dtype; inspect nearby tests before changing tolerances or skips.
-- The blocking MPS job runs `--device=mps --dtype=float32 --xfail-known-failures`. Its exact strict-xfail baseline is `testing/known_failure_xfails/mps_float32.txt` and is tracked in #4159. A fix removes its manifest line; a rename or reparametrization updates the node ID; a new failure is fixed or explicitly documented before being added. The manifest contract requires a full-suite run, without `-k` or a partial path.
+- The blocking MPS job runs `--device=mps --dtype=float32 --xfail-known-failures`. Its exact strict-xfail baseline is `testing/known_failure_xfails/mps_float32.txt`. A fix removes its manifest line; a rename or reparametrization updates the node ID; a new failure is fixed, or gets its own tracking issue named in a manifest comment before being added. The manifest contract requires a full-suite run, without `-k` or a partial path.
- TF32 matmul is disabled by default; `--tf32` enables it. cuDNN convolutions still use PyTorch's TF32 default. Tests marked `tf32` are xfailed at collection unless `--tf32` is passed, and that marker is non-strict, so a default run reports neither their failure nor their recovery.
- `torch.clamp` is not a portable gradient guard: its derivative **at the bound** passes the incoming gradient
through (`1.0`) on torch 2.5.1 and 2.9.1 and returns `0.0` on 2.14.0. Wherever the bound is also the singular
diff --git a/TESTING.md b/TESTING.md
index e94eec927..4aeefd17b 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -319,15 +319,10 @@ and torch's own "matrix too large to stage in MPS threadgroup memory ... falling
check triggers on *greater than* that limit, so an input sitting exactly on it neither falls
back nor compiles. Shape is irrelevant -- `(128, 64)`, `(64, 128)`, `(8192, 1)` and `(1, 8192)`
all raise, and 8191 and 8193 elements both pass -- which is why the guard counts elements and
-does not inspect batch rank. That ceiling is why `RANSAC`'s
-batched minimal solvers used to raise on MPS
-([#4201](https://github.com/kornia/kornia/issues/4201)). `_torch_svd_cast` and
-`_torch_linalg_svdvals` now route such inputs through the CPU, so the fundamental and
-homography solvers no longer hit it. `find_essential` raised for an unrelated reason --
-`run_5point` called `torch.linalg.eigvals`, which has no MPS kernel -- until #5078 moved
-those roots to the host. The ceiling
-is *not* why those solvers are absent from the baseline below -- see the next section:
-they are skipped, because they abort the process before they can raise.
+does not inspect batch rank. `_torch_svd_cast` and `_torch_linalg_svdvals` route such inputs
+through the CPU, so `RANSAC`'s batched fundamental and homography solvers do not hit the ceiling.
+The RANSAC tests are skipped on MPS for a different reason -- see the next section: they abort the
+process before they can raise.
**How Kornia handles these automatically.** The test infrastructure in `conftest.py` and `testing/base.py` skips known-unsupported test classes at collection time so you don't need per-test guards for the common cases:
@@ -346,11 +341,11 @@ they are skipped, because they abort the process before they can raise.
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.
-**CI coverage.** Pull-request CI runs one blocking MPS leg (`tests-mps` in `.github/workflows/pr_test_cpu.yml`): the newest Python and the newest pinned PyTorch, `float32`, on the GitHub-hosted **`macos-15`** Apple-silicon image. The image is pinned deliberately. `macos-latest` is `macos-26-arm64`, whose GPU is paravirtualized, and on macOS 26 torch 2.14 emits Metal 4 `mpp::tensor_ops::matmul2d` cooperative-tensor shaders that this virtual GPU cannot compile β€” one specialization failed 664 tests across every subpackage, since `linalg.inv`, `linalg.solve`, `inv_ex`, `lu_factor_ex` and `F.conv3d` all route through it. The defect is the *virtual* GPU, not macOS 26: a physical M1 on macOS 26.5 compiled those shaders in the #4202 comparison. macOS 15 is Metal 3 and takes the older kernel path, which is the path that happens to work on the runner fleet. Two consequences worth knowing: no job in this repository now exercises the Metal 4 path that users on current macOS actually run, and when GitHub retires the `macos-15` image this leg stops scheduling and `collector` goes red with no fallback. Re-test `macos-latest` once upstream guards those kernels by device capability; `macos-14` segfaults inside MPS kernels and must never be used. The comparison is recorded in [#4159](https://github.com/kornia/kornia/issues/4159#issuecomment-5532655834). The exact known-failure baseline from [#4159](https://github.com/kornia/kornia/issues/4159) lives in `testing/known_failure_xfails/mps_float32.txt`: #4202 reduced it from 200 entries to 14, #4185 then fixed the YUV420/YUV422 empty-input cases, and #5078 fixed the last 12, the `torch.linalg.eigvals` calls of `find_essential`, which leaves the baseline empty. `--xfail-known-failures` applies the manifest's entries as strict xfails with their exact exception types. A new failure, a different exception, a skipped recorded test, or a fixed test therefore makes CI red.
+**CI coverage.** Pull-request CI runs one blocking MPS leg (`tests-mps` in `.github/workflows/pr_test_cpu.yml`): the newest Python and the newest pinned PyTorch, `float32`, on the GitHub-hosted **`macos-15`** Apple-silicon image. The image is pinned deliberately. `macos-latest` is `macos-26-arm64`, whose GPU is paravirtualized, and on macOS 26 torch 2.14 emits Metal 4 `mpp::tensor_ops::matmul2d` cooperative-tensor shaders that this virtual GPU cannot compile β€” one specialization failed 664 tests across every subpackage, since `linalg.inv`, `linalg.solve`, `inv_ex`, `lu_factor_ex` and `F.conv3d` all route through it. The defect is the *virtual* GPU, not macOS 26: a physical M1 on macOS 26.5 compiled those shaders in the #4202 comparison. macOS 15 is Metal 3 and takes the older kernel path, which is the path that happens to work on the runner fleet. Two consequences worth knowing: no job in this repository now exercises the Metal 4 path that users on current macOS actually run, and when GitHub retires the `macos-15` image this leg stops scheduling and `collector` goes red with no fallback. Re-test `macos-latest` once upstream guards those kernels by device capability; `macos-14` segfaults inside MPS kernels and must never be used. The comparison is recorded in [#4159](https://github.com/kornia/kornia/issues/4159#issuecomment-5532655834). The exact known-failure baseline lives in `testing/known_failure_xfails/mps_float32.txt`. `--xfail-known-failures` applies the manifest's entries as strict xfails with their exact exception types. A new failure, a different exception, a skipped recorded test, or a fixed test therefore makes CI red.
Run the identical contract locally with `pixi run test-mps`. `PYTORCH_ENABLE_MPS_FALLBACK=1` silently routes missing MPS kernels to the CPU and invalidates the baseline, so unset it first. The manifest is a full-suite contract and is not intended for `-k` or partial-directory runs; use `pixi run test-module ... --device=mps --dtype=float32` for focused diagnosis without the manifest. "Full suite" means the suite as an `mps`-only run collects it: tests marked `device_agnostic` are deselected there and covered by the CPU jobs, so they never appear in the manifest.
-When an MPS failure is fixed, remove its line from `mps_float32.txt`. When a test is renamed or reparametrized, update its node ID. Treat an unlisted failure as a regression to fix; add it only when the new limitation is understood and documented in #4159. After a deliberate Python, PyTorch, or runner-image update, regenerate the full manifest from that CI job's final `short test summary info`, recording one exact exception type and node ID per `FAILED` line.
+When an MPS failure is fixed, remove its line from `mps_float32.txt`. When a test is renamed or reparametrized, update its node ID. Treat an unlisted failure as a regression to fix; add it only when the new limitation is understood and has its own tracking issue, named in a comment beside the entry. After a deliberate Python, PyTorch, or runner-image update, regenerate the full manifest from that CI job's final `short test summary info`, recording one exact exception type and node ID per `FAILED` line.
**Writing new tests that work on MPS.** Follow these rules:
diff --git a/testing/known_failure_xfails/mps_float32.txt b/testing/known_failure_xfails/mps_float32.txt
index fdfd5a821..e47218df6 100644
--- a/testing/known_failure_xfails/mps_float32.txt
+++ b/testing/known_failure_xfails/mps_float32.txt
@@ -1,14 +1,8 @@
-# Exact strict baseline verified by
-# https://github.com/kornia/kornia/actions/runs/33920557535/job/101177935411 -- the post-#4185
-# full-suite replay completed with --xfail-known-failures: 8327 passed, 4126 skipped, 95 deselected,
-# 43 xfailed, 9 xpassed in 425.15s. It recorded 12 entries; #5078 fixed them all, so the manifest is empty.
-# macos-15-arm64, Python 3.13.11, PyTorch 2.14.0, MPS float32, no CPU fallback,
-# one pytest process for the full suite (tests marked device_agnostic are deselected on an mps-only run).
-# Remove an entry when it becomes a strict XPASS; fix or explicitly add any new failure. Tracked in #4159.
-# torch 2.14.0 added MPS kernels for the eigen/QR/LU/SVD family and for both grid_sample backward
-# passes, which took the baseline from 200 entries to 14. #4185 then fixed the two YUV420/YUV422
-# empty-input failures, leaving 12 entries, all from aten::_linalg_eigvals, which has no MPS kernel: the
-# 5-point essential solver called it on the input's device. #5078 takes those roots on the host.
+# Strict known-failure baseline for the tests-mps CI leg: macos-15-arm64, Python 3.13, PyTorch 2.14.0,
+# MPS float32, no CPU fallback, one pytest process for the full suite (tests marked device_agnostic are
+# 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.
diff --git a/testing/known_failures.py b/testing/known_failures.py
index 4f1a226f4..263a18e21 100644
--- a/testing/known_failures.py
+++ b/testing/known_failures.py
@@ -22,7 +22,6 @@ from typing import Any, Sequence
import pytest
-ISSUE_URL = "https://github.com/kornia/kornia/issues/4159"
_MANIFEST_DIR = Path(__file__).with_name("known_failure_xfails")
_EXCEPTION_TYPES: dict[str, type[BaseException]] = {
"AssertionError": AssertionError,
@@ -130,7 +129,7 @@ def mark_known_failures(
preview = "\n".join(sorted(missing)[:10])
raise ValueError(f"{len(missing)} failures from {path} were not collected:\n{preview}")
- reason = f"Known {device}/{dtype} failure tracked in {ISSUE_URL}"
+ reason = f"Known {device}/{dtype} failure recorded in {path.name}; see its tracking issue there"
tracker = KnownFailureTracker(failures, path, reason)
for item in items:
if exception_type := failures.get(item.nodeid):
diff --git a/tests/test_known_failures.py b/tests/test_known_failures.py
index 362491ed5..5f5ccd408 100644
--- a/tests/test_known_failures.py
+++ b/tests/test_known_failures.py
@@ -21,7 +21,7 @@ from pathlib import Path
import pytest
-from testing.known_failures import ISSUE_URL, load_known_failures, mark_known_failures
+from testing.known_failures import load_known_failures, mark_known_failures
pytest_plugins = ["pytester"]
@@ -34,7 +34,7 @@ class TestLoadKnownFailures:
def test_loads_nodeids_and_exception_types(self, tmp_path: Path) -> None:
_write_manifest(
tmp_path,
- "# tracked in kornia#4159\n"
+ "# tracked in kornia#1234\n"
"AssertionError\ttests/a.py::test_a[mps-float32]\n"
"RuntimeError\ttests/b.py::TestB::test_b[mps]\n",
)
@@ -92,7 +92,7 @@ class TestMarkKnownFailures:
"reason": tracker.reason,
"strict": True,
}
- assert tracker.reason == f"Known mps/float32 failure tracked in {ISSUE_URL}"
+ assert tracker.reason == "Known mps/float32 failure recorded in mps_float32.txt; see its tracking issue there"
def test_rejects_manifest_entries_that_were_not_collected(self, tmp_path: Path) -> None:
_write_manifest(tmp_path, "AssertionError\ttests/missing.py::test_missing[mps-float32]\n")
@@ -197,4 +197,3 @@ def test_recorded_mps_float32_baseline() -> None:
# not a number.
assert path.name == "mps_float32.txt"
assert all(issubclass(exception, BaseException) for exception in failures.values())
- assert ISSUE_URL == "https://github.com/kornia/kornia/issues/4159"