|
19 | 19 | from diffusers import AutoencoderVidTok |
20 | 20 | from diffusers.utils.torch_utils import randn_tensor |
21 | 21 |
|
22 | | -from ...testing_utils import IS_GITHUB_ACTIONS, enable_full_determinism, torch_device |
| 22 | +from ...testing_utils import enable_full_determinism, torch_device |
23 | 23 | from ..testing_utils import BaseModelTesterConfig, MemoryTesterMixin, ModelTesterMixin, TrainingTesterMixin |
24 | 24 | from .testing_utils import NewAutoencoderTesterMixin |
25 | 25 |
|
26 | 26 |
|
27 | 27 | enable_full_determinism() |
28 | 28 |
|
29 | 29 |
|
| 30 | +def _run_nondeterministic(fn): |
| 31 | + # avg_pool3d_backward_cuda has no deterministic CUDA implementation; |
| 32 | + # temporarily relax the requirement for tests that do backward passes. |
| 33 | + torch.use_deterministic_algorithms(False) |
| 34 | + try: |
| 35 | + fn() |
| 36 | + finally: |
| 37 | + torch.use_deterministic_algorithms(True) |
| 38 | + |
| 39 | + |
30 | 40 | class AutoencoderVidTokTesterConfig(BaseModelTesterConfig): |
31 | 41 | @property |
32 | 42 | def model_class(self): |
@@ -82,14 +92,25 @@ def test_gradient_checkpointing_is_applied(self): |
82 | 92 | expected_set = {"VidTokEncoder3D", "VidTokDecoder3D"} |
83 | 93 | super().test_gradient_checkpointing_is_applied(expected_set=expected_set) |
84 | 94 |
|
85 | | - @pytest.mark.skipif(IS_GITHUB_ACTIONS, reason="Skipping test inside GitHub Actions environment") |
86 | | - def test_layerwise_casting_training(self): |
87 | | - super().test_layerwise_casting_training() |
| 95 | + def test_training(self): |
| 96 | + _run_nondeterministic(super().test_training) |
| 97 | + |
| 98 | + def test_training_with_ema(self): |
| 99 | + _run_nondeterministic(super().test_training_with_ema) |
| 100 | + |
| 101 | + def test_mixed_precision_training(self): |
| 102 | + _run_nondeterministic(super().test_mixed_precision_training) |
| 103 | + |
| 104 | + def test_gradient_checkpointing_equivalence(self): |
| 105 | + _run_nondeterministic(super().test_gradient_checkpointing_equivalence) |
88 | 106 |
|
89 | 107 |
|
90 | 108 | class TestAutoencoderVidTokMemory(AutoencoderVidTokTesterConfig, MemoryTesterMixin): |
91 | 109 | """Memory optimization tests for AutoencoderVidTok.""" |
92 | 110 |
|
| 111 | + def test_layerwise_casting_training(self): |
| 112 | + _run_nondeterministic(super().test_layerwise_casting_training) |
| 113 | + |
93 | 114 |
|
94 | 115 | class TestAutoencoderVidTokSlicingTiling(AutoencoderVidTokTesterConfig, NewAutoencoderTesterMixin): |
95 | 116 | """Slicing and tiling tests for AutoencoderVidTok.""" |
|
0 commit comments