Skip to content

Commit 57dad1e

Browse files
authored
Skip flaky MacOS tests (#9488)
1 parent 499ca51 commit 57dad1e

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

test/test_ops.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def bilinear_interpolate(data, y, x, snap_border=False):
407407

408408

409409
class TestRoIAlign(RoIOpTester):
410-
mps_backward_atol = 6e-2
410+
mps_backward_atol = 1e-1
411411

412412
def fn(self, x, rois, pool_h, pool_w, spatial_scale=1, sampling_ratio=-1, aligned=False, **kwargs):
413413
return ops.RoIAlign(
@@ -1244,6 +1244,20 @@ def xfail_if_mps(x):
12441244
return x
12451245

12461246

1247+
def skip_if_mps(x):
1248+
mps_skip_param = pytest.param("mps", marks=(pytest.mark.needs_mps, pytest.mark.skip(reason="Flaky on MPS")))
1249+
new_pytestmark = []
1250+
for mark in x.pytestmark:
1251+
if isinstance(mark, pytest.Mark) and mark.name == "parametrize":
1252+
if mark.args[0] == "device":
1253+
params = cpu_and_cuda() + (mps_skip_param,)
1254+
new_pytestmark.append(pytest.mark.parametrize("device", params))
1255+
continue
1256+
new_pytestmark.append(mark)
1257+
x.__dict__["pytestmark"] = new_pytestmark
1258+
return x
1259+
1260+
12471261
optests.generate_opcheck_tests(
12481262
testcase=TestDeformConv,
12491263
namespaces=["torchvision"],
@@ -1252,6 +1266,7 @@ def xfail_if_mps(x):
12521266
additional_decorators={
12531267
"test_aot_dispatch_dynamic__test_forward": [xfail_if_mps],
12541268
"test_autograd_registration__test_forward": [xfail_if_mps],
1269+
"test_faketensor__test_forward": [skip_if_mps],
12551270
},
12561271
test_utils=OPTESTS,
12571272
)

test/test_transforms_v2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3843,6 +3843,10 @@ def test_functional_image_correctness(self, dtype, device):
38433843
@pytest.mark.parametrize("device", cpu_and_cuda())
38443844
@pytest.mark.parametrize("seed", list(range(5)))
38453845
def test_transform_image_correctness(self, param, value, dtype, device, seed):
3846+
if sys.platform == "darwin" and value == "random" and dtype == torch.uint8:
3847+
# Mismatched elements: 10 / 561 (1.8%)
3848+
pytest.skip("Non-deterministic RNG behavior on macOS for random erase with uint8")
3849+
38463850
transform = transforms.RandomErasing(**{param: value}, p=1)
38473851

38483852
image = make_image(dtype=dtype, device=device)

0 commit comments

Comments
 (0)