From bf5b20f1171eee58628f0c539eadeb8de779271d Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Tue, 24 Jun 2025 14:43:34 -0700 Subject: [PATCH 1/3] [CI] Resotre MacOS test sanity DeformConv is only implemented for forward on MPS right now, so skip backward checks Logic for modifying markers in place are stolen from `torch.testing._internal.optests`, namely from https://github.com/pytorch/pytorch/blob/310e8361c565ca1602e719e4c812dc3931ec84d7/torch/testing/_internal/optests/generate_tests.py#L269 --- test/test_ops.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/test_ops.py b/test/test_ops.py index 26d13bbe208..acc4de6a4bc 100644 --- a/test/test_ops.py +++ b/test/test_ops.py @@ -1200,12 +1200,28 @@ def test_forward_scriptability(self): # Non-regression test for https://github.com/pytorch/vision/issues/4078 torch.jit.script(ops.DeformConv2d(in_channels=8, out_channels=8, kernel_size=3)) +# NS: Removeme once bacward is implemented +def xfail_if_mps(x): + mps_xfail_param = pytest.param("mps", marks=(pytest.mark.needs_mps, pytest.mark.xfail)) + new_pytestmark = [] + for mark in x.pytestmark: + if isinstance(mark, pytest.Mark) and mark.name == "parametrize": + if mark.args[0] == 'device': + params = cpu_and_cuda() + (mps_xfail_param,) + new_pytestmark.append(pytest.mark.parametrize('device', params)) + continue + new_pytestmark.append(mark) + x.__dict__["pytestmark"] = new_pytestmark + return x + optests.generate_opcheck_tests( testcase=TestDeformConv, namespaces=["torchvision"], failures_dict_path=os.path.join(os.path.dirname(__file__), "optests_failures_dict.json"), - additional_decorators=[], + # Skip tests due to unimplemented backward + additional_decorators={"test_aot_dispatch_dynamic__test_forward" : [xfail_if_mps], + "test_autograd_registration__test_forward" : [xfail_if_mps]}, test_utils=OPTESTS, ) From a5fd812e493198070d5960df7fe65e8161b47d7a Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Tue, 24 Jun 2025 15:03:52 -0700 Subject: [PATCH 2/3] Fix lint --- test/test_ops.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/test_ops.py b/test/test_ops.py index acc4de6a4bc..c97e821066f 100644 --- a/test/test_ops.py +++ b/test/test_ops.py @@ -1200,15 +1200,16 @@ def test_forward_scriptability(self): # Non-regression test for https://github.com/pytorch/vision/issues/4078 torch.jit.script(ops.DeformConv2d(in_channels=8, out_channels=8, kernel_size=3)) + # NS: Removeme once bacward is implemented def xfail_if_mps(x): mps_xfail_param = pytest.param("mps", marks=(pytest.mark.needs_mps, pytest.mark.xfail)) new_pytestmark = [] for mark in x.pytestmark: if isinstance(mark, pytest.Mark) and mark.name == "parametrize": - if mark.args[0] == 'device': + if mark.args[0] == "device": params = cpu_and_cuda() + (mps_xfail_param,) - new_pytestmark.append(pytest.mark.parametrize('device', params)) + new_pytestmark.append(pytest.mark.parametrize("device", params)) continue new_pytestmark.append(mark) x.__dict__["pytestmark"] = new_pytestmark @@ -1220,8 +1221,10 @@ def xfail_if_mps(x): namespaces=["torchvision"], failures_dict_path=os.path.join(os.path.dirname(__file__), "optests_failures_dict.json"), # Skip tests due to unimplemented backward - additional_decorators={"test_aot_dispatch_dynamic__test_forward" : [xfail_if_mps], - "test_autograd_registration__test_forward" : [xfail_if_mps]}, + additional_decorators={ + "test_aot_dispatch_dynamic__test_forward": [xfail_if_mps], + "test_autograd_registration__test_forward": [xfail_if_mps], + }, test_utils=OPTESTS, ) From 3c7a7add9a22fbdc9a3a5d4b1031cd054a995ecc Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Tue, 24 Jun 2025 17:29:38 -0700 Subject: [PATCH 3/3] Fix typos --- test/test_ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_ops.py b/test/test_ops.py index c97e821066f..9cb0cddedf7 100644 --- a/test/test_ops.py +++ b/test/test_ops.py @@ -1201,7 +1201,7 @@ def test_forward_scriptability(self): torch.jit.script(ops.DeformConv2d(in_channels=8, out_channels=8, kernel_size=3)) -# NS: Removeme once bacward is implemented +# NS: Remove me once backward is implemented for MPS def xfail_if_mps(x): mps_xfail_param = pytest.param("mps", marks=(pytest.mark.needs_mps, pytest.mark.xfail)) new_pytestmark = []