Skip to content

Commit 0fe108d

Browse files
sayakpauldg845github-actions[bot]
authored andcommitted
[tests] fix vidtok tests (#13894)
* fix vidtok tests * style * Update tests/models/autoencoders/test_models_autoencoder_vidtok.py Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com> * Apply style fixes --------- Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 3345756 commit 0fe108d

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

tests/models/autoencoders/test_models_autoencoder_vidtok.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,24 @@
1919
from diffusers import AutoencoderVidTok
2020
from diffusers.utils.torch_utils import randn_tensor
2121

22-
from ...testing_utils import IS_GITHUB_ACTIONS, enable_full_determinism, torch_device
22+
from ...testing_utils import enable_full_determinism, torch_device
2323
from ..testing_utils import BaseModelTesterConfig, MemoryTesterMixin, ModelTesterMixin, TrainingTesterMixin
2424
from .testing_utils import NewAutoencoderTesterMixin
2525

2626

2727
enable_full_determinism()
2828

2929

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+
3040
class AutoencoderVidTokTesterConfig(BaseModelTesterConfig):
3141
@property
3242
def model_class(self):
@@ -82,14 +92,25 @@ def test_gradient_checkpointing_is_applied(self):
8292
expected_set = {"VidTokEncoder3D", "VidTokDecoder3D"}
8393
super().test_gradient_checkpointing_is_applied(expected_set=expected_set)
8494

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)
88106

89107

90108
class TestAutoencoderVidTokMemory(AutoencoderVidTokTesterConfig, MemoryTesterMixin):
91109
"""Memory optimization tests for AutoencoderVidTok."""
92110

111+
def test_layerwise_casting_training(self):
112+
_run_nondeterministic(super().test_layerwise_casting_training)
113+
93114

94115
class TestAutoencoderVidTokSlicingTiling(AutoencoderVidTokTesterConfig, NewAutoencoderTesterMixin):
95116
"""Slicing and tiling tests for AutoencoderVidTok."""

0 commit comments

Comments
 (0)