Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e6198d0
[WIP] Nightly integration tests
anton-l Dec 12, 2022
18b216d
initial SD tests
anton-l Dec 12, 2022
d8c9a6f
update SD slow tests
anton-l Dec 12, 2022
8bb254c
style
anton-l Dec 12, 2022
c4d215b
repaint
anton-l Dec 12, 2022
da5af01
ImageVariations
anton-l Dec 14, 2022
d80a93a
style
anton-l Dec 15, 2022
344818f
Merge remote-tracking branch 'origin/main' into nightly-tests
anton-l Dec 15, 2022
06bb7ab
merge main
anton-l Dec 15, 2022
0b976f8
finish imgvar
anton-l Dec 15, 2022
edf2d1f
img2img tests
anton-l Dec 15, 2022
55f10e4
debug
anton-l Dec 15, 2022
0fb4bf2
inpaint 1.5
anton-l Dec 15, 2022
817f1c9
inpaint legacy
anton-l Dec 15, 2022
b960b02
Merge remote-tracking branch 'origin/main' into nightly-tests
anton-l Dec 15, 2022
0214037
torch isn't happy about deterministic ops
anton-l Dec 16, 2022
1286a40
allclose -> max diff for shorter logs
anton-l Dec 16, 2022
ba7c1bf
add SD2
anton-l Dec 16, 2022
0f64d88
debug
anton-l Dec 16, 2022
89b2d5f
Update tests/pipelines/stable_diffusion_2/test_stable_diffusion.py
anton-l Dec 16, 2022
3df885e
Update tests/pipelines/stable_diffusion/test_stable_diffusion.py
anton-l Dec 16, 2022
6322cde
Merge remote-tracking branch 'origin/main' into nightly-tests
anton-l Dec 16, 2022
bed3dac
fix refs
anton-l Dec 16, 2022
b10ea27
Merge remote-tracking branch 'origin/nightly-tests' into nightly-tests
anton-l Dec 16, 2022
63105db
Update src/diffusers/utils/testing_utils.py
anton-l Dec 16, 2022
2859dec
Merge remote-tracking branch 'origin/main' into nightly-tests
anton-l Dec 16, 2022
130c5c5
fix refs
anton-l Dec 16, 2022
cdbf882
Merge remote-tracking branch 'origin/nightly-tests' into nightly-tests
anton-l Dec 16, 2022
f7b1fd5
remove debug
anton-l Dec 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 101 additions & 5 deletions .github/workflows/nightly_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nightly integration tests
name: Nightly tests on main

on:
schedule:
Expand All @@ -9,12 +9,108 @@ env:
HF_HOME: /mnt/cache
OMP_NUM_THREADS: 8
MKL_NUM_THREADS: 8
PYTEST_TIMEOUT: 1000
PYTEST_TIMEOUT: 600
RUN_SLOW: yes
RUN_NIGHTLY: yes

jobs:
run_slow_tests_apple_m1:
name: Slow PyTorch MPS tests on MacOS
run_nightly_tests:
strategy:
fail-fast: false
matrix:
config:
- name: Nightly PyTorch CUDA tests on Ubuntu
framework: pytorch
runner: docker-gpu
image: diffusers/diffusers-pytorch-cuda
report: torch_cuda
- name: Nightly Flax TPU tests on Ubuntu
framework: flax
runner: docker-tpu
image: diffusers/diffusers-flax-tpu
report: flax_tpu
- name: Nightly ONNXRuntime CUDA tests on Ubuntu
framework: onnxruntime
runner: docker-gpu
image: diffusers/diffusers-onnxruntime-cuda
report: onnx_cuda

name: ${{ matrix.config.name }}

runs-on: ${{ matrix.config.runner }}

container:
image: ${{ matrix.config.image }}
options: --shm-size "16gb" --ipc host -v /mnt/hf_cache:/mnt/cache/ ${{ matrix.config.runner == 'docker-tpu' && '--privileged' || '--gpus 0'}}

defaults:
run:
shell: bash

steps:
- name: Checkout diffusers
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: NVIDIA-SMI
if: ${{ matrix.config.runner == 'docker-gpu' }}
run: |
nvidia-smi

- name: Install dependencies
run: |
python -m pip install -e .[quality,test]
python -m pip install git+https://github.com/huggingface/accelerate
python -m pip install -U git+https://github.com/huggingface/transformers

- name: Environment
run: |
python utils/print_env.py

- name: Run nightly PyTorch CUDA tests
if: ${{ matrix.config.framework == 'pytorch' }}
env:
HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
run: |
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
-s -v -k "not Flax and not Onnx" \
--make-reports=tests_${{ matrix.config.report }} \
tests/

- name: Run nightly Flax TPU tests
if: ${{ matrix.config.framework == 'flax' }}
env:
HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
run: |
python -m pytest -n 0 \
-s -v -k "Flax" \
--make-reports=tests_${{ matrix.config.report }} \
tests/

- name: Run nightly ONNXRuntime CUDA tests
if: ${{ matrix.config.framework == 'onnxruntime' }}
env:
HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
run: |
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
-s -v -k "Onnx" \
--make-reports=tests_${{ matrix.config.report }} \
tests/

- name: Failure short reports
if: ${{ failure() }}
run: cat reports/tests_${{ matrix.config.report }}_failures_short.txt

- name: Test suite reports artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.config.report }}_test_reports
path: reports

run_nightly_tests_apple_m1:
name: Nightly PyTorch MPS tests on MacOS
runs-on: [ self-hosted, apple-m1 ]

steps:
Expand Down Expand Up @@ -46,7 +142,7 @@ jobs:
run: |
${CONDA_RUN} python utils/print_env.py

- name: Run slow PyTorch tests on M1 (MPS)
- name: Run nightly PyTorch tests on M1 (MPS)
shell: arch -arch arm64 bash {0}
env:
HF_HOME: /System/Volumes/Data/mnt/cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run fast tests
name: Fast tests for PRs

on:
pull_request:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run all tests
name: Slow tests on main

on:
push:
Expand All @@ -10,7 +10,7 @@ env:
HF_HOME: /mnt/cache
OMP_NUM_THREADS: 8
MKL_NUM_THREADS: 8
PYTEST_TIMEOUT: 1000
PYTEST_TIMEOUT: 600
RUN_SLOW: yes

jobs:
Expand Down
1 change: 1 addition & 0 deletions src/diffusers/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
load_hf_numpy,
load_image,
load_numpy,
nightly,
parse_flag_from_env,
require_torch_gpu,
slow,
Expand Down
11 changes: 11 additions & 0 deletions src/diffusers/utils/testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def parse_flag_from_env(key, default=False):


_run_slow_tests = parse_flag_from_env("RUN_SLOW", default=False)
_run_nightly_tests = parse_flag_from_env("RUN_NIGHTLY", default=False)


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


def nightly(test_case):
"""
Decorator marking a test that runs nightly in the diffusers CI.

Slow tests are skipped by default. Set the RUN_NIGHTLY environment variable to a truthy value to run them.

"""
return unittest.skipUnless(_run_nightly_tests, "test is nightly")(test_case)


def require_torch(test_case):
"""
Decorator marking a test that requires PyTorch. These tests are skipped when PyTorch isn't installed.
Expand Down
14 changes: 11 additions & 3 deletions tests/pipelines/repaint/test_repaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import gc
import unittest

import numpy as np
import torch

from diffusers import RePaintPipeline, RePaintScheduler, UNet2DModel
from diffusers.utils.testing_utils import load_image, load_numpy, require_torch_gpu, slow, torch_device
from diffusers.utils.testing_utils import load_image, load_numpy, nightly, require_torch_gpu, torch_device

from ...test_pipelines_common import PipelineTesterMixin

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


@slow
@nightly
@require_torch_gpu
class RepaintPipelineIntegrationTests(unittest.TestCase):
class RepaintPipelineNightlyTests(unittest.TestCase):
def tearDown(self):
super().tearDown()
gc.collect()
torch.cuda.empty_cache()

def test_celebahq(self):
original_image = load_image(
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/"
Expand All @@ -104,6 +110,8 @@ def test_celebahq(self):
scheduler = RePaintScheduler.from_pretrained(model_id)

repaint = RePaintPipeline(unet=unet, scheduler=scheduler).to(torch_device)
repaint.set_progress_bar_config(disable=None)
repaint.enable_attention_slicing()

generator = torch.Generator(device=torch_device).manual_seed(0)
output = repaint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OnnxStableDiffusionPipeline,
PNDMScheduler,
)
from diffusers.utils.testing_utils import is_onnx_available, require_onnxruntime, require_torch_gpu, slow
from diffusers.utils.testing_utils import is_onnx_available, nightly, require_onnxruntime, require_torch_gpu

from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin

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


@slow
@nightly
@require_onnxruntime
@require_torch_gpu
class OnnxStableDiffusionPipelineIntegrationTests(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@
PNDMScheduler,
)
from diffusers.utils import floats_tensor
from diffusers.utils.testing_utils import is_onnx_available, load_image, require_onnxruntime, require_torch_gpu, slow
from diffusers.utils.testing_utils import (
is_onnx_available,
load_image,
nightly,
require_onnxruntime,
require_torch_gpu,
)

from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin

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


@slow
@nightly
@require_onnxruntime
@require_torch_gpu
class OnnxStableDiffusionImg2ImgPipelineIntegrationTests(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
import numpy as np

from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline
from diffusers.utils.testing_utils import is_onnx_available, load_image, require_onnxruntime, require_torch_gpu, slow
from diffusers.utils.testing_utils import (
is_onnx_available,
load_image,
nightly,
require_onnxruntime,
require_torch_gpu,
)

from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin

Expand All @@ -32,7 +38,7 @@ class OnnxStableDiffusionPipelineFastTests(OnnxPipelineTesterMixin, unittest.Tes
pass


@slow
@nightly
@require_onnxruntime
@require_torch_gpu
class OnnxStableDiffusionInpaintPipelineIntegrationTests(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
is_onnx_available,
load_image,
load_numpy,
nightly,
require_onnxruntime,
require_torch_gpu,
slow,
)


if is_onnx_available():
import onnxruntime as ort


@slow
@nightly
@require_onnxruntime
@require_torch_gpu
class StableDiffusionOnnxInpaintLegacyPipelineIntegrationTests(unittest.TestCase):
Expand Down
Loading