Nightly integration tests (#1664) · camyoung1234/diffusers@086c7f9 · GitHub
Skip to content

Commit 086c7f9

Browse files
anton-lpatrickvonplatenpcuenca
authored
Nightly integration tests (huggingface#1664)
* [WIP] Nightly integration tests * initial SD tests * update SD slow tests * style * repaint * ImageVariations * style * finish imgvar * img2img tests * debug * inpaint 1.5 * inpaint legacy * torch isn't happy about deterministic ops * allclose -> max diff for shorter logs * add SD2 * debug * Update tests/pipelines/stable_diffusion_2/test_stable_diffusion.py Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Update tests/pipelines/stable_diffusion/test_stable_diffusion.py Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * fix refs * Update src/diffusers/utils/testing_utils.py Co-authored-by: Pedro Cuenca <pedro@huggingface.co> * fix refs * remove debug Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
1 parent acd3178 commit 086c7f9

18 files changed

Lines changed: 1317 additions & 925 deletions

‎.github/workflows/nightly_tests.yml‎

Lines changed: 101 additions & 5 deletions

‎.github/workflows/pr_tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run fast tests
1+
name: Fast tests for PRs
22

33
on:
44
pull_request:

‎.github/workflows/push_tests.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run all tests
1+
name: Slow tests on main
22

33
on:
44
push:
@@ -10,7 +10,7 @@ env:
1010
HF_HOME: /mnt/cache
1111
OMP_NUM_THREADS: 8
1212
MKL_NUM_THREADS: 8
13-
PYTEST_TIMEOUT: 1000
13+
PYTEST_TIMEOUT: 600
1414
RUN_SLOW: yes
1515

1616
jobs:

‎src/diffusers/utils/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
load_hf_numpy,
5656
load_image,
5757
load_numpy,
58+
nightly,
5859
parse_flag_from_env,
5960
require_torch_gpu,
6061
slow,

‎src/diffusers/utils/testing_utils.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def parse_flag_from_env(key, default=False):
8383

8484

8585
_run_slow_tests = parse_flag_from_env("RUN_SLOW", default=False)
86+
_run_nightly_tests = parse_flag_from_env("RUN_NIGHTLY", default=False)
8687

8788

8889
def floats_tensor(shape, scale=1.0, rng=None, name=None):
@@ -111,6 +112,16 @@ def slow(test_case):
111112
return unittest.skipUnless(_run_slow_tests, "test is slow")(test_case)
112113

113114

115+
def nightly(test_case):
116+
"""
117+
Decorator marking a test that runs nightly in the diffusers CI.
118+
119+
Slow tests are skipped by default. Set the RUN_NIGHTLY environment variable to a truthy value to run them.
120+
121+
"""
122+
return unittest.skipUnless(_run_nightly_tests, "test is nightly")(test_case)
123+
124+
114125
def require_torch(test_case):
115126
"""
116127
Decorator marking a test that requires PyTorch. These tests are skipped when PyTorch isn't installed.

‎tests/pipelines/repaint/test_repaint.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
import gc
1617
import unittest
1718

1819
import numpy as np
1920
import torch
2021

2122
from diffusers import RePaintPipeline, RePaintScheduler, UNet2DModel
22-
from diffusers.utils.testing_utils import load_image, load_numpy, require_torch_gpu, slow, torch_device
23+
from diffusers.utils.testing_utils import load_image, load_numpy, nightly, require_torch_gpu, torch_device
2324

2425
from ...test_pipelines_common import PipelineTesterMixin
2526

@@ -83,9 +84,14 @@ def test_repaint(self):
8384
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-3
8485

8586

86-
@slow
87+
@nightly
8788
@require_torch_gpu
88-
class RepaintPipelineIntegrationTests(unittest.TestCase):
89+
class RepaintPipelineNightlyTests(unittest.TestCase):
90+
def tearDown(self):
91+
super().tearDown()
92+
gc.collect()
93+
torch.cuda.empty_cache()
94+
8995
def test_celebahq(self):
9096
original_image = load_image(
9197
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/"
@@ -104,6 +110,8 @@ def test_celebahq(self):
104110
scheduler = RePaintScheduler.from_pretrained(model_id)
105111

106112
repaint = RePaintPipeline(unet=unet, scheduler=scheduler).to(torch_device)
113+
repaint.set_progress_bar_config(disable=None)
114+
repaint.enable_attention_slicing()
107115

108116
generator = torch.Generator(device=torch_device).manual_seed(0)
109117
output = repaint(

‎tests/pipelines/stable_diffusion/test_onnx_stable_diffusion.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
OnnxStableDiffusionPipeline,
2828
PNDMScheduler,
2929
)
30-
from diffusers.utils.testing_utils import is_onnx_available, require_onnxruntime, require_torch_gpu, slow
30+
from diffusers.utils.testing_utils import is_onnx_available, nightly, require_onnxruntime, require_torch_gpu
3131

3232
from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin
3333

@@ -128,7 +128,7 @@ def test_pipeline_dpm_multistep(self):
128128
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2
129129

130130

131-
@slow
131+
@nightly
132132
@require_onnxruntime
133133
@require_torch_gpu
134134
class OnnxStableDiffusionPipelineIntegrationTests(unittest.TestCase):

‎tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_img2img.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
PNDMScheduler,
2828
)
2929
from diffusers.utils import floats_tensor
30-
from diffusers.utils.testing_utils import is_onnx_available, load_image, require_onnxruntime, require_torch_gpu, slow
30+
from diffusers.utils.testing_utils import (
31+
is_onnx_available,
32+
load_image,
33+
nightly,
34+
require_onnxruntime,
35+
require_torch_gpu,
36+
)
3137

3238
from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin
3339

@@ -134,7 +140,7 @@ def test_pipeline_dpm_multistep(self):
134140
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-1
135141

136142

137-
@slow
143+
@nightly
138144
@require_onnxruntime
139145
@require_torch_gpu
140146
class OnnxStableDiffusionImg2ImgPipelineIntegrationTests(unittest.TestCase):

‎tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
import numpy as np
1919

2020
from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline
21-
from diffusers.utils.testing_utils import is_onnx_available, load_image, require_onnxruntime, require_torch_gpu, slow
21+
from diffusers.utils.testing_utils import (
22+
is_onnx_available,
23+
load_image,
24+
nightly,
25+
require_onnxruntime,
26+
require_torch_gpu,
27+
)
2228

2329
from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin
2430

@@ -32,7 +38,7 @@ class OnnxStableDiffusionPipelineFastTests(OnnxPipelineTesterMixin, unittest.Tes
3238
pass
3339

3440

35-
@slow
41+
@nightly
3642
@require_onnxruntime
3743
@require_torch_gpu
3844
class OnnxStableDiffusionInpaintPipelineIntegrationTests(unittest.TestCase):

‎tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint_legacy.py‎

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)