Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

test(augmentation): use a float16-representable small beta in the CutMix generator test (#5528)

εŒΊζ’“ηa2d12aeb7b30
diff --git a/testing/half_precision_xfails/cpu_float16.txt b/testing/half_precision_xfails/cpu_float16.txt
index a278493fd..70feac699 100644
--- a/testing/half_precision_xfails/cpu_float16.txt
+++ b/testing/half_precision_xfails/cpu_float16.txt
@@ -65,114 +65,6 @@ call builtins.AssertionError tests/augmentation/test_random_generator.py::TestCo
call builtins.AssertionError tests/augmentation/test_random_generator.py::TestColorJiggleGen::test_same_on_batch[cpu-float16]
call builtins.AssertionError tests/augmentation/test_random_generator.py::TestRandomCropSizeGen::test_random_gen[cpu-float16]
call builtins.AssertionError tests/augmentation/test_random_generator.py::TestRandomCropSizeGen::test_same_on_batch[cpu-float16]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-1-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-1-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-1-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-1-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-1-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-1-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-1-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-1-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-1-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-3-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-3-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-3-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-3-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-3-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-3-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-3-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-3-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-None-beta1-3-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-1-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-1-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-1-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-1-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-1-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-1-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-1-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-1-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-1-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-3-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-3-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-3-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-3-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-3-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-3-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-3-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-3-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size1-beta1-3-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-1-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-1-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-1-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-1-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-1-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-1-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-1-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-1-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-1-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-3-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-3-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-3-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-3-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-3-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-3-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-3-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-3-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-False-cut_size2-beta1-3-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-1-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-1-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-1-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-1-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-1-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-1-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-1-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-1-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-1-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-3-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-3-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-3-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-3-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-3-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-3-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-3-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-3-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-None-beta1-3-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-1-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-1-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-1-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-1-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-1-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-1-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-1-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-1-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-1-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-3-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-3-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-3-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-3-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-3-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-3-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-3-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-3-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size1-beta1-3-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-1-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-1-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-1-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-1-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-1-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-1-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-1-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-1-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-1-200-200-1.0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-3-200-200-0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-3-200-200-0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-3-200-200-0-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-3-200-200-0.5-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-3-200-200-0.5-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-3-200-200-0.5-8]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-3-200-200-1.0-0]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-3-200-200-1.0-1]
-call builtins.ValueError tests/augmentation/test_random_generator.py::TestRandomCutMixGen::test_valid_param_combinations[cpu-float16-True-cut_size2-beta1-3-200-200-1.0-8]
call builtins.AssertionError tests/augmentation/test_random_generator.py::TestRandomPerspectiveGen::test_sampling_method[cpu-float16]
call builtins.AssertionError tests/augmentation/test_random_generator_3d.py::TestRandomAffineGen3D::test_random_gen[cpu-float16]
call builtins.AssertionError tests/augmentation/test_random_generator_3d.py::TestRandomAffineGen3D::test_same_on_batch[cpu-float16]
diff --git a/tests/augmentation/test_random_generator.py b/tests/augmentation/test_random_generator.py
index da5a354f6..a04929fd8 100644
--- a/tests/augmentation/test_random_generator.py
+++ b/tests/augmentation/test_random_generator.py
@@ -1715,7 +1715,10 @@ class TestRandomCutMixGen(RandomGeneratorBaseTests):
@pytest.mark.parametrize("p", [0, 0.5, 1.0])
@pytest.mark.parametrize("width,height", [(200, 200)])
@pytest.mark.parametrize("num_mix", [1, 3])
- @pytest.mark.parametrize("beta", [None, torch.tensor(1e-15), torch.tensor(1.0)])
+ # The small beta is 1e-2: Beta(1e-2, 1e-2) puts most draws of lambda next to 0 or 1, so the generator reaches
+ # the full-size and the empty cut in every dtype. A tinier value does not: 1e-15 rounds to 0 in float16, which
+ # Beta rejects, and torch samples exactly 0.5 from Beta(1e-15, 1e-15) in float32 and float64.
+ @pytest.mark.parametrize("beta", [None, torch.tensor(1e-2), torch.tensor(1.0)])
@pytest.mark.parametrize("cut_size", [None, torch.tensor([0.0, 1.0]), torch.tensor([0.3, 0.6])])
@pytest.mark.parametrize("same_on_batch", [True, False])
def test_valid_param_combinations(