Skip to content

Commit 8917769

Browse files
attend and excite tests disable determinism on the class level (#3478)
1 parent 49b7ccf commit 8917769

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/pipelines/stable_diffusion_2/test_stable_diffusion_attend_and_excite.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535

3636
torch.backends.cuda.matmul.allow_tf32 = False
37-
torch.use_deterministic_algorithms(False)
3837

3938

4039
@skip_mps
@@ -47,6 +46,19 @@ class StableDiffusionAttendAndExcitePipelineFastTests(
4746
batch_params = TEXT_TO_IMAGE_BATCH_PARAMS.union({"token_indices"})
4847
image_params = TEXT_TO_IMAGE_IMAGE_PARAMS
4948

49+
# Attend and excite requires being able to run a backward pass at
50+
# inference time. There's no deterministic backward operator for pad
51+
52+
@classmethod
53+
def setUpClass(cls):
54+
super().setUpClass()
55+
torch.use_deterministic_algorithms(False)
56+
57+
@classmethod
58+
def tearDownClass(cls):
59+
super().tearDownClass()
60+
torch.use_deterministic_algorithms(True)
61+
5062
def get_dummy_components(self):
5163
torch.manual_seed(0)
5264
unet = UNet2DConditionModel(
@@ -171,6 +183,19 @@ def test_save_load_optional_components(self):
171183
@require_torch_gpu
172184
@slow
173185
class StableDiffusionAttendAndExcitePipelineIntegrationTests(unittest.TestCase):
186+
# Attend and excite requires being able to run a backward pass at
187+
# inference time. There's no deterministic backward operator for pad
188+
189+
@classmethod
190+
def setUpClass(cls):
191+
super().setUpClass()
192+
torch.use_deterministic_algorithms(False)
193+
194+
@classmethod
195+
def tearDownClass(cls):
196+
super().tearDownClass()
197+
torch.use_deterministic_algorithms(True)
198+
174199
def tearDown(self):
175200
super().tearDown()
176201
gc.collect()

0 commit comments

Comments
 (0)