From 60247f9729df83ec3322a44c4fdcbaaf21f84b8a Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Wed, 12 Apr 2023 22:33:03 +0200 Subject: [PATCH 1/7] [Tests] parallelize --- tests/{ => models}/test_layers_utils.py | 0 tests/{ => models}/test_lora_layers.py | 0 tests/{ => models}/test_modeling_common.py | 0 tests/{ => models}/test_modeling_common_flax.py | 0 tests/{ => models}/test_unet_2d_blocks.py | 0 tests/{ => models}/test_unet_blocks_common.py | 0 tests/{repo_utils => others}/test_check_copies.py | 0 tests/{repo_utils => others}/test_check_dummies.py | 0 tests/{ => others}/test_config.py | 0 tests/{ => others}/test_ema.py | 0 tests/{ => others}/test_hub_utils.py | 0 tests/{ => others}/test_image_processor.py | 0 tests/{ => others}/test_outputs.py | 0 tests/{ => others}/test_training.py | 0 tests/{ => others}/test_utils.py | 0 tests/{ => pipelines}/pipeline_params.py | 0 tests/{ => pipelines}/test_pipelines.py | 0 tests/{ => pipelines}/test_pipelines_common.py | 0 tests/{ => pipelines}/test_pipelines_flax.py | 0 tests/{ => pipelines}/test_pipelines_onnx_common.py | 0 20 files changed, 0 insertions(+), 0 deletions(-) rename tests/{ => models}/test_layers_utils.py (100%) rename tests/{ => models}/test_lora_layers.py (100%) rename tests/{ => models}/test_modeling_common.py (100%) rename tests/{ => models}/test_modeling_common_flax.py (100%) rename tests/{ => models}/test_unet_2d_blocks.py (100%) rename tests/{ => models}/test_unet_blocks_common.py (100%) rename tests/{repo_utils => others}/test_check_copies.py (100%) rename tests/{repo_utils => others}/test_check_dummies.py (100%) rename tests/{ => others}/test_config.py (100%) rename tests/{ => others}/test_ema.py (100%) rename tests/{ => others}/test_hub_utils.py (100%) rename tests/{ => others}/test_image_processor.py (100%) rename tests/{ => others}/test_outputs.py (100%) rename tests/{ => others}/test_training.py (100%) rename tests/{ => others}/test_utils.py (100%) rename tests/{ => pipelines}/pipeline_params.py (100%) rename tests/{ => pipelines}/test_pipelines.py (100%) rename tests/{ => pipelines}/test_pipelines_common.py (100%) rename tests/{ => pipelines}/test_pipelines_flax.py (100%) rename tests/{ => pipelines}/test_pipelines_onnx_common.py (100%) diff --git a/tests/test_layers_utils.py b/tests/models/test_layers_utils.py similarity index 100% rename from tests/test_layers_utils.py rename to tests/models/test_layers_utils.py diff --git a/tests/test_lora_layers.py b/tests/models/test_lora_layers.py similarity index 100% rename from tests/test_lora_layers.py rename to tests/models/test_lora_layers.py diff --git a/tests/test_modeling_common.py b/tests/models/test_modeling_common.py similarity index 100% rename from tests/test_modeling_common.py rename to tests/models/test_modeling_common.py diff --git a/tests/test_modeling_common_flax.py b/tests/models/test_modeling_common_flax.py similarity index 100% rename from tests/test_modeling_common_flax.py rename to tests/models/test_modeling_common_flax.py diff --git a/tests/test_unet_2d_blocks.py b/tests/models/test_unet_2d_blocks.py similarity index 100% rename from tests/test_unet_2d_blocks.py rename to tests/models/test_unet_2d_blocks.py diff --git a/tests/test_unet_blocks_common.py b/tests/models/test_unet_blocks_common.py similarity index 100% rename from tests/test_unet_blocks_common.py rename to tests/models/test_unet_blocks_common.py diff --git a/tests/repo_utils/test_check_copies.py b/tests/others/test_check_copies.py similarity index 100% rename from tests/repo_utils/test_check_copies.py rename to tests/others/test_check_copies.py diff --git a/tests/repo_utils/test_check_dummies.py b/tests/others/test_check_dummies.py similarity index 100% rename from tests/repo_utils/test_check_dummies.py rename to tests/others/test_check_dummies.py diff --git a/tests/test_config.py b/tests/others/test_config.py similarity index 100% rename from tests/test_config.py rename to tests/others/test_config.py diff --git a/tests/test_ema.py b/tests/others/test_ema.py similarity index 100% rename from tests/test_ema.py rename to tests/others/test_ema.py diff --git a/tests/test_hub_utils.py b/tests/others/test_hub_utils.py similarity index 100% rename from tests/test_hub_utils.py rename to tests/others/test_hub_utils.py diff --git a/tests/test_image_processor.py b/tests/others/test_image_processor.py similarity index 100% rename from tests/test_image_processor.py rename to tests/others/test_image_processor.py diff --git a/tests/test_outputs.py b/tests/others/test_outputs.py similarity index 100% rename from tests/test_outputs.py rename to tests/others/test_outputs.py diff --git a/tests/test_training.py b/tests/others/test_training.py similarity index 100% rename from tests/test_training.py rename to tests/others/test_training.py diff --git a/tests/test_utils.py b/tests/others/test_utils.py similarity index 100% rename from tests/test_utils.py rename to tests/others/test_utils.py diff --git a/tests/pipeline_params.py b/tests/pipelines/pipeline_params.py similarity index 100% rename from tests/pipeline_params.py rename to tests/pipelines/pipeline_params.py diff --git a/tests/test_pipelines.py b/tests/pipelines/test_pipelines.py similarity index 100% rename from tests/test_pipelines.py rename to tests/pipelines/test_pipelines.py diff --git a/tests/test_pipelines_common.py b/tests/pipelines/test_pipelines_common.py similarity index 100% rename from tests/test_pipelines_common.py rename to tests/pipelines/test_pipelines_common.py diff --git a/tests/test_pipelines_flax.py b/tests/pipelines/test_pipelines_flax.py similarity index 100% rename from tests/test_pipelines_flax.py rename to tests/pipelines/test_pipelines_flax.py diff --git a/tests/test_pipelines_onnx_common.py b/tests/pipelines/test_pipelines_onnx_common.py similarity index 100% rename from tests/test_pipelines_onnx_common.py rename to tests/pipelines/test_pipelines_onnx_common.py From 9000a80072f5b3a59edd088578348adfe5f748d6 Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Wed, 12 Apr 2023 22:47:36 +0200 Subject: [PATCH 2/7] finish folder structuring --- tests/models/test_models_unet_1d.py | 2 +- tests/models/test_models_unet_2d.py | 2 +- tests/models/test_models_unet_2d_condition.py | 2 +- tests/models/test_models_unet_3d_condition.py | 2 +- tests/models/test_models_vae.py | 2 +- tests/models/test_models_vae_flax.py | 2 +- tests/models/test_models_vq.py | 2 +- tests/pipelines/altdiffusion/test_alt_diffusion.py | 4 ++-- tests/pipelines/audioldm/test_audioldm.py | 4 ++-- tests/pipelines/dance_diffusion/test_dance_diffusion.py | 4 ++-- tests/pipelines/ddim/test_ddim.py | 4 ++-- tests/pipelines/dit/test_dit.py | 4 ++-- tests/pipelines/latent_diffusion/test_latent_diffusion.py | 4 ++-- tests/pipelines/paint_by_example/test_paint_by_example.py | 4 ++-- tests/pipelines/repaint/test_repaint.py | 4 ++-- .../spectrogram_diffusion/test_spectrogram_diffusion.py | 4 ++-- tests/pipelines/stable_diffusion/test_cycle_diffusion.py | 4 ++-- .../pipelines/stable_diffusion/test_onnx_stable_diffusion.py | 2 +- .../stable_diffusion/test_onnx_stable_diffusion_img2img.py | 2 +- .../stable_diffusion/test_onnx_stable_diffusion_inpaint.py | 2 +- .../stable_diffusion/test_onnx_stable_diffusion_upscale.py | 2 +- tests/pipelines/stable_diffusion/test_stable_diffusion.py | 4 ++-- .../stable_diffusion/test_stable_diffusion_controlnet.py | 4 ++-- .../stable_diffusion/test_stable_diffusion_image_variation.py | 4 ++-- .../stable_diffusion/test_stable_diffusion_img2img.py | 4 ++-- .../stable_diffusion/test_stable_diffusion_inpaint.py | 4 ++-- .../test_stable_diffusion_instruction_pix2pix.py | 4 ++-- .../stable_diffusion/test_stable_diffusion_model_editing.py | 4 ++-- .../stable_diffusion/test_stable_diffusion_panorama.py | 4 ++-- .../stable_diffusion/test_stable_diffusion_pix2pix_zero.py | 4 ++-- tests/pipelines/stable_diffusion/test_stable_diffusion_sag.py | 4 ++-- tests/pipelines/stable_diffusion_2/test_stable_diffusion.py | 4 ++-- .../test_stable_diffusion_attend_and_excite.py | 4 ++-- .../stable_diffusion_2/test_stable_diffusion_depth.py | 4 ++-- .../stable_diffusion_2/test_stable_diffusion_inpaint.py | 4 ++-- .../test_stable_diffusion_latent_upscale.py | 4 ++-- tests/pipelines/stable_unclip/test_stable_unclip.py | 4 ++-- tests/pipelines/stable_unclip/test_stable_unclip_img2img.py | 4 ++-- tests/pipelines/test_pipelines_common.py | 4 ++-- tests/pipelines/text_to_video/test_text_to_video.py | 4 ++-- tests/pipelines/text_to_video/test_text_to_video_zero.py | 2 +- tests/pipelines/unclip/test_unclip.py | 4 ++-- tests/pipelines/unclip/test_unclip_image_variation.py | 4 ++-- 43 files changed, 74 insertions(+), 74 deletions(-) diff --git a/tests/models/test_models_unet_1d.py b/tests/models/test_models_unet_1d.py index d3a3d5cfc9a0..f954d876fa76 100644 --- a/tests/models/test_models_unet_1d.py +++ b/tests/models/test_models_unet_1d.py @@ -20,7 +20,7 @@ from diffusers import UNet1DModel from diffusers.utils import floats_tensor, slow, torch_device -from ..test_modeling_common import ModelTesterMixin +from .test_modeling_common import ModelTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/models/test_models_unet_2d.py b/tests/models/test_models_unet_2d.py index 8f831fcf7cbf..c20b0ef7d0a4 100644 --- a/tests/models/test_models_unet_2d.py +++ b/tests/models/test_models_unet_2d.py @@ -22,7 +22,7 @@ from diffusers import UNet2DModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device -from ..test_modeling_common import ModelTesterMixin +from .test_modeling_common import ModelTesterMixin logger = logging.get_logger(__name__) diff --git a/tests/models/test_models_unet_2d_condition.py b/tests/models/test_models_unet_2d_condition.py index 17e08e0a426e..15f77fb8c106 100644 --- a/tests/models/test_models_unet_2d_condition.py +++ b/tests/models/test_models_unet_2d_condition.py @@ -34,7 +34,7 @@ ) from diffusers.utils.import_utils import is_xformers_available -from ..test_modeling_common import ModelTesterMixin +from .test_modeling_common import ModelTesterMixin logger = logging.get_logger(__name__) diff --git a/tests/models/test_models_unet_3d_condition.py b/tests/models/test_models_unet_3d_condition.py index c552b503af05..f245045bb3bb 100644 --- a/tests/models/test_models_unet_3d_condition.py +++ b/tests/models/test_models_unet_3d_condition.py @@ -30,7 +30,7 @@ ) from diffusers.utils.import_utils import is_xformers_available -from ..test_modeling_common import ModelTesterMixin +from .test_modeling_common import ModelTesterMixin logger = logging.get_logger(__name__) diff --git a/tests/models/test_models_vae.py b/tests/models/test_models_vae.py index abd4a078e692..fe0041850bb4 100644 --- a/tests/models/test_models_vae.py +++ b/tests/models/test_models_vae.py @@ -22,7 +22,7 @@ from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device -from ..test_modeling_common import ModelTesterMixin +from .test_modeling_common import ModelTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/models/test_models_vae_flax.py b/tests/models/test_models_vae_flax.py index 8fedb85eccfc..e5c56b61a5a4 100644 --- a/tests/models/test_models_vae_flax.py +++ b/tests/models/test_models_vae_flax.py @@ -4,7 +4,7 @@ from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax -from ..test_modeling_common_flax import FlaxModelTesterMixin +from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): diff --git a/tests/models/test_models_vq.py b/tests/models/test_models_vq.py index 66c33e07371e..015d2abfc6fa 100644 --- a/tests/models/test_models_vq.py +++ b/tests/models/test_models_vq.py @@ -20,7 +20,7 @@ from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device -from ..test_modeling_common import ModelTesterMixin +from .test_modeling_common import ModelTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/altdiffusion/test_alt_diffusion.py b/tests/pipelines/altdiffusion/test_alt_diffusion.py index faa56e18f748..4d19621f0c2c 100644 --- a/tests/pipelines/altdiffusion/test_alt_diffusion.py +++ b/tests/pipelines/altdiffusion/test_alt_diffusion.py @@ -28,8 +28,8 @@ from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/audioldm/test_audioldm.py b/tests/pipelines/audioldm/test_audioldm.py index 10de5440eb00..ec72108fafc9 100644 --- a/tests/pipelines/audioldm/test_audioldm.py +++ b/tests/pipelines/audioldm/test_audioldm.py @@ -38,8 +38,8 @@ ) from diffusers.utils import slow, torch_device -from ...pipeline_params import TEXT_TO_AUDIO_BATCH_PARAMS, TEXT_TO_AUDIO_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_AUDIO_BATCH_PARAMS, TEXT_TO_AUDIO_PARAMS +from ..test_pipelines_common import PipelineTesterMixin class AudioLDMPipelineFastTests(PipelineTesterMixin, unittest.TestCase): diff --git a/tests/pipelines/dance_diffusion/test_dance_diffusion.py b/tests/pipelines/dance_diffusion/test_dance_diffusion.py index bbd4aa694b76..5db90a3aa740 100644 --- a/tests/pipelines/dance_diffusion/test_dance_diffusion.py +++ b/tests/pipelines/dance_diffusion/test_dance_diffusion.py @@ -23,8 +23,8 @@ from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu, skip_mps -from ...pipeline_params import UNCONDITIONAL_AUDIO_GENERATION_BATCH_PARAMS, UNCONDITIONAL_AUDIO_GENERATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import UNCONDITIONAL_AUDIO_GENERATION_BATCH_PARAMS, UNCONDITIONAL_AUDIO_GENERATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/ddim/test_ddim.py b/tests/pipelines/ddim/test_ddim.py index 4d2c4e490d63..319bd778e3b2 100644 --- a/tests/pipelines/ddim/test_ddim.py +++ b/tests/pipelines/ddim/test_ddim.py @@ -21,8 +21,8 @@ from diffusers import DDIMPipeline, DDIMScheduler, UNet2DModel from diffusers.utils.testing_utils import require_torch_gpu, slow, torch_device -from ...pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAGE_GENERATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAGE_GENERATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/dit/test_dit.py b/tests/pipelines/dit/test_dit.py index 947fd3cbf43d..d8098178f339 100644 --- a/tests/pipelines/dit/test_dit.py +++ b/tests/pipelines/dit/test_dit.py @@ -23,11 +23,11 @@ from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import ( +from ..pipeline_params import ( CLASS_CONDITIONED_IMAGE_GENERATION_BATCH_PARAMS, CLASS_CONDITIONED_IMAGE_GENERATION_PARAMS, ) -from ...test_pipelines_common import PipelineTesterMixin +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/latent_diffusion/test_latent_diffusion.py b/tests/pipelines/latent_diffusion/test_latent_diffusion.py index 2ff7feda6317..05ff4162e5c6 100644 --- a/tests/pipelines/latent_diffusion/test_latent_diffusion.py +++ b/tests/pipelines/latent_diffusion/test_latent_diffusion.py @@ -23,8 +23,8 @@ from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNet2DConditionModel from diffusers.utils.testing_utils import load_numpy, nightly, require_torch_gpu, slow, torch_device -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/paint_by_example/test_paint_by_example.py b/tests/pipelines/paint_by_example/test_paint_by_example.py index 14b045d6c480..17feba59e8e4 100644 --- a/tests/pipelines/paint_by_example/test_paint_by_example.py +++ b/tests/pipelines/paint_by_example/test_paint_by_example.py @@ -27,8 +27,8 @@ from diffusers.utils import floats_tensor, load_image, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import IMAGE_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, IMAGE_GUIDED_IMAGE_INPAINTING_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import IMAGE_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, IMAGE_GUIDED_IMAGE_INPAINTING_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/repaint/test_repaint.py b/tests/pipelines/repaint/test_repaint.py index 060e6c9161ba..4f98675bc5af 100644 --- a/tests/pipelines/repaint/test_repaint.py +++ b/tests/pipelines/repaint/test_repaint.py @@ -22,8 +22,8 @@ from diffusers import RePaintPipeline, RePaintScheduler, UNet2DModel from diffusers.utils.testing_utils import load_image, load_numpy, nightly, require_torch_gpu, skip_mps, torch_device -from ...pipeline_params import IMAGE_INPAINTING_BATCH_PARAMS, IMAGE_INPAINTING_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import IMAGE_INPAINTING_BATCH_PARAMS, IMAGE_INPAINTING_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/spectrogram_diffusion/test_spectrogram_diffusion.py b/tests/pipelines/spectrogram_diffusion/test_spectrogram_diffusion.py index 594d7c598f75..3b64ea2d2fc1 100644 --- a/tests/pipelines/spectrogram_diffusion/test_spectrogram_diffusion.py +++ b/tests/pipelines/spectrogram_diffusion/test_spectrogram_diffusion.py @@ -24,8 +24,8 @@ from diffusers.utils import require_torch_gpu, skip_mps, slow, torch_device from diffusers.utils.testing_utils import require_note_seq, require_onnxruntime -from ...pipeline_params import TOKENS_TO_AUDIO_GENERATION_BATCH_PARAMS, TOKENS_TO_AUDIO_GENERATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TOKENS_TO_AUDIO_GENERATION_BATCH_PARAMS, TOKENS_TO_AUDIO_GENERATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_cycle_diffusion.py b/tests/pipelines/stable_diffusion/test_cycle_diffusion.py index 5282cfd8dd24..05b72ab6a0fd 100644 --- a/tests/pipelines/stable_diffusion/test_cycle_diffusion.py +++ b/tests/pipelines/stable_diffusion/test_cycle_diffusion.py @@ -25,8 +25,8 @@ from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu, skip_mps -from ...pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion.py b/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion.py index 3a5f9379ae50..6c90f0526662 100644 --- a/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion.py +++ b/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion.py @@ -29,7 +29,7 @@ ) from diffusers.utils.testing_utils import is_onnx_available, nightly, require_onnxruntime, require_torch_gpu -from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin +from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin if is_onnx_available(): diff --git a/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_img2img.py b/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_img2img.py index e1aa2f6dc0a1..9147dc461fc5 100644 --- a/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_img2img.py +++ b/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_img2img.py @@ -35,7 +35,7 @@ require_torch_gpu, ) -from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin +from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin if is_onnx_available(): diff --git a/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint.py b/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint.py index 16287d64d154..6004067887ea 100644 --- a/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint.py +++ b/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint.py @@ -26,7 +26,7 @@ require_torch_gpu, ) -from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin +from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin if is_onnx_available(): diff --git a/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_upscale.py b/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_upscale.py index d1527a42a1e5..a124c3de60ca 100644 --- a/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_upscale.py +++ b/tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_upscale.py @@ -36,7 +36,7 @@ require_torch_gpu, ) -from ...test_pipelines_onnx_common import OnnxPipelineTesterMixin +from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin if is_onnx_available(): diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion.py b/tests/pipelines/stable_diffusion/test_stable_diffusion.py index 79796afdf597..14421a64b9e8 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion.py @@ -40,8 +40,8 @@ from diffusers.utils.testing_utils import CaptureLogger, require_torch_gpu from ...models.test_models_unet_2d_condition import create_lora_layers -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_controlnet.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_controlnet.py index d556e6318f43..d7c5e2b0323a 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_controlnet.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_controlnet.py @@ -33,8 +33,8 @@ from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin class StableDiffusionControlNetPipelineFastTests(PipelineTesterMixin, unittest.TestCase): diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_image_variation.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_image_variation.py index 2a07ab64a36d..3bfa5810428a 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_image_variation.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_image_variation.py @@ -32,8 +32,8 @@ from diffusers.utils import floats_tensor, load_image, load_numpy, nightly, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import IMAGE_VARIATION_BATCH_PARAMS, IMAGE_VARIATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import IMAGE_VARIATION_BATCH_PARAMS, IMAGE_VARIATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_img2img.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_img2img.py index 69b92f685f25..127b1c216549 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_img2img.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_img2img.py @@ -34,8 +34,8 @@ from diffusers.utils import floats_tensor, load_image, load_numpy, nightly, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu, skip_mps -from ...pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py index 3553679e0ef6..290d9b0a9134 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py @@ -34,8 +34,8 @@ from diffusers.utils import floats_tensor, load_image, load_numpy, nightly, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_instruction_pix2pix.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_instruction_pix2pix.py index 78e697fbbac3..8915f524d972 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_instruction_pix2pix.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_instruction_pix2pix.py @@ -34,8 +34,8 @@ from diffusers.utils import floats_tensor, load_image, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_model_editing.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_model_editing.py index 1e11500c72b1..bafad63ec2db 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_model_editing.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_model_editing.py @@ -31,8 +31,8 @@ from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu, skip_mps -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_panorama.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_panorama.py index 752ed6e969c3..3ead4fe55bab 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_panorama.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_panorama.py @@ -32,8 +32,8 @@ from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu, skip_mps -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_pix2pix_zero.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_pix2pix_zero.py index 59c45d603b91..0809a91041ce 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_pix2pix_zero.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_pix2pix_zero.py @@ -33,8 +33,8 @@ from diffusers.utils import load_numpy, slow, torch_device from diffusers.utils.testing_utils import load_image, load_pt, require_torch_gpu, skip_mps -from ...pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_sag.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_sag.py index abaefbcad011..73859bdbf7d8 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_sag.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_sag.py @@ -29,8 +29,8 @@ from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion_2/test_stable_diffusion.py b/tests/pipelines/stable_diffusion_2/test_stable_diffusion.py index 7b607c8fdd36..623dbde99469 100644 --- a/tests/pipelines/stable_diffusion_2/test_stable_diffusion.py +++ b/tests/pipelines/stable_diffusion_2/test_stable_diffusion.py @@ -35,8 +35,8 @@ from diffusers.utils import load_numpy, nightly, slow, torch_device from diffusers.utils.testing_utils import CaptureLogger, require_torch_gpu -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion_2/test_stable_diffusion_attend_and_excite.py b/tests/pipelines/stable_diffusion_2/test_stable_diffusion_attend_and_excite.py index 90bb1461d351..f153ae08cbb6 100644 --- a/tests/pipelines/stable_diffusion_2/test_stable_diffusion_attend_and_excite.py +++ b/tests/pipelines/stable_diffusion_2/test_stable_diffusion_attend_and_excite.py @@ -29,8 +29,8 @@ from diffusers.utils import load_numpy, skip_mps, slow from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin @skip_mps diff --git a/tests/pipelines/stable_diffusion_2/test_stable_diffusion_depth.py b/tests/pipelines/stable_diffusion_2/test_stable_diffusion_depth.py index 6b0205f3faeb..7a5e02a42af4 100644 --- a/tests/pipelines/stable_diffusion_2/test_stable_diffusion_depth.py +++ b/tests/pipelines/stable_diffusion_2/test_stable_diffusion_depth.py @@ -51,8 +51,8 @@ ) from diffusers.utils.testing_utils import require_torch_gpu, skip_mps -from ...pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion_2/test_stable_diffusion_inpaint.py b/tests/pipelines/stable_diffusion_2/test_stable_diffusion_inpaint.py index ee059314904f..2fa8b9045f43 100644 --- a/tests/pipelines/stable_diffusion_2/test_stable_diffusion_inpaint.py +++ b/tests/pipelines/stable_diffusion_2/test_stable_diffusion_inpaint.py @@ -26,8 +26,8 @@ from diffusers.utils import floats_tensor, load_image, load_numpy, torch_device from diffusers.utils.testing_utils import require_torch_gpu, slow -from ...pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_diffusion_2/test_stable_diffusion_latent_upscale.py b/tests/pipelines/stable_diffusion_2/test_stable_diffusion_latent_upscale.py index 38f4b053714b..aff1c1cdbde9 100644 --- a/tests/pipelines/stable_diffusion_2/test_stable_diffusion_latent_upscale.py +++ b/tests/pipelines/stable_diffusion_2/test_stable_diffusion_latent_upscale.py @@ -31,8 +31,8 @@ from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu -from ...pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/stable_unclip/test_stable_unclip.py b/tests/pipelines/stable_unclip/test_stable_unclip.py index 368ab21f24a9..891323d22fe0 100644 --- a/tests/pipelines/stable_unclip/test_stable_unclip.py +++ b/tests/pipelines/stable_unclip/test_stable_unclip.py @@ -15,8 +15,8 @@ from diffusers.pipelines.stable_diffusion.stable_unclip_image_normalizer import StableUnCLIPImageNormalizer from diffusers.utils.testing_utils import load_numpy, require_torch_gpu, slow, torch_device -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference class StableUnCLIPPipelineFastTests(PipelineTesterMixin, unittest.TestCase): diff --git a/tests/pipelines/stable_unclip/test_stable_unclip_img2img.py b/tests/pipelines/stable_unclip/test_stable_unclip_img2img.py index 907853394040..69e3225ced52 100644 --- a/tests/pipelines/stable_unclip/test_stable_unclip_img2img.py +++ b/tests/pipelines/stable_unclip/test_stable_unclip_img2img.py @@ -27,8 +27,8 @@ torch_device, ) -from ...pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS -from ...test_pipelines_common import ( +from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS +from ..test_pipelines_common import ( PipelineTesterMixin, assert_mean_pixel_difference, ) diff --git a/tests/pipelines/test_pipelines_common.py b/tests/pipelines/test_pipelines_common.py index 981bc9061ef9..acbe42f87720 100644 --- a/tests/pipelines/test_pipelines_common.py +++ b/tests/pipelines/test_pipelines_common.py @@ -85,7 +85,7 @@ def params(self) -> frozenset: raise NotImplementedError( "You need to set the attribute `params` in the child test class. " "`params` are checked for if all values are present in `__call__`'s signature." - " You can set `params` using one of the common set of parameters defined in`pipeline_params.py`" + " You can set `params` using one of the common set of parameters defined ..pipeline_params.py`" " e.g., `TEXT_TO_IMAGE_PARAMS` defines the common parameters used in text to " "image pipelines, including prompts and prompt embedding overrides." "If your pipeline's set of arguments has minor changes from one of the common sets of arguments, " @@ -100,7 +100,7 @@ def batch_params(self) -> frozenset: raise NotImplementedError( "You need to set the attribute `batch_params` in the child test class. " "`batch_params` are the parameters required to be batched when passed to the pipeline's " - "`__call__` method. `pipeline_params.py` provides some common sets of parameters such as " + "`__call__` method..pipeline_params.py` provides some common sets of parameters such as " "`TEXT_TO_IMAGE_BATCH_PARAMS`, `IMAGE_VARIATION_BATCH_PARAMS`, etc... If your pipeline's " "set of batch arguments has minor changes from one of the common sets of batch arguments, " "do not make modifications to the existing common sets of batch arguments. I.e. a text to " diff --git a/tests/pipelines/text_to_video/test_text_to_video.py b/tests/pipelines/text_to_video/test_text_to_video.py index 438e685a443c..b59653694616 100644 --- a/tests/pipelines/text_to_video/test_text_to_video.py +++ b/tests/pipelines/text_to_video/test_text_to_video.py @@ -28,8 +28,8 @@ ) from diffusers.utils import load_numpy, skip_mps, slow -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin torch.backends.cuda.matmul.allow_tf32 = False diff --git a/tests/pipelines/text_to_video/test_text_to_video_zero.py b/tests/pipelines/text_to_video/test_text_to_video_zero.py index 45bb93fbd9c6..8fc7254c52d1 100644 --- a/tests/pipelines/text_to_video/test_text_to_video_zero.py +++ b/tests/pipelines/text_to_video/test_text_to_video_zero.py @@ -20,7 +20,7 @@ from diffusers import DDIMScheduler, TextToVideoZeroPipeline from diffusers.utils import load_pt, require_torch_gpu, slow -from ...test_pipelines_common import assert_mean_pixel_difference +from ..test_pipelines_common import assert_mean_pixel_difference @slow diff --git a/tests/pipelines/unclip/test_unclip.py b/tests/pipelines/unclip/test_unclip.py index c36fb02b190f..4df3e4d3828b 100644 --- a/tests/pipelines/unclip/test_unclip.py +++ b/tests/pipelines/unclip/test_unclip.py @@ -25,8 +25,8 @@ from diffusers.utils import load_numpy, nightly, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu, skip_mps -from ...pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS -from ...test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference +from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS +from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference class UnCLIPPipelineFastTests(PipelineTesterMixin, unittest.TestCase): diff --git a/tests/pipelines/unclip/test_unclip_image_variation.py b/tests/pipelines/unclip/test_unclip_image_variation.py index 3cacb0bcad0b..57d15559cc75 100644 --- a/tests/pipelines/unclip/test_unclip_image_variation.py +++ b/tests/pipelines/unclip/test_unclip_image_variation.py @@ -39,8 +39,8 @@ from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import load_image, require_torch_gpu, skip_mps -from ...pipeline_params import IMAGE_VARIATION_BATCH_PARAMS, IMAGE_VARIATION_PARAMS -from ...test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference +from ..pipeline_params import IMAGE_VARIATION_BATCH_PARAMS, IMAGE_VARIATION_PARAMS +from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference class UnCLIPImageVariationPipelineFastTests(PipelineTesterMixin, unittest.TestCase): From a9e611ab25c79b6ec7117f877482f26348ef5496 Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Wed, 12 Apr 2023 23:02:39 +0200 Subject: [PATCH 3/7] Parallelize tests more --- .github/workflows/pr_tests.yml | 33 +++++++++++++++++++++++---------- tests/others/test_utils.py | 2 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr_tests.yml b/.github/workflows/pr_tests.yml index 3d5fd84ad949..d06b576fa631 100644 --- a/.github/workflows/pr_tests.yml +++ b/.github/workflows/pr_tests.yml @@ -21,22 +21,27 @@ jobs: fail-fast: false matrix: config: - - name: Fast PyTorch CPU tests on Ubuntu - framework: pytorch + - name: Fast PyTorch Pipeline CPU tests + framework: pytorch_pipelines runner: docker-cpu image: diffusers/diffusers-pytorch-cpu - report: torch_cpu - - name: Fast Flax CPU tests on Ubuntu + report: torch_cpu_pipelines + - name: Fast PyTorch Models & Schedulers CPU tests + framework: pytorch_models + runner: docker-cpu + image: diffusers/diffusers-pytorch-cpu + report: torch_cpu_models_schedulers + - name: Fast Flax CPU tests framework: flax runner: docker-cpu image: diffusers/diffusers-flax-cpu report: flax_cpu - - name: Fast ONNXRuntime CPU tests on Ubuntu + - name: Fast ONNXRuntime CPU tests framework: onnxruntime runner: docker-cpu image: diffusers/diffusers-onnxruntime-cpu report: onnx_cpu - - name: PyTorch Example CPU tests on Ubuntu + - name: PyTorch Example CPU tests framework: pytorch_examples runner: docker-cpu image: diffusers/diffusers-pytorch-cpu @@ -71,13 +76,21 @@ jobs: run: | python utils/print_env.py - - name: Run fast PyTorch CPU tests - if: ${{ matrix.config.framework == 'pytorch' }} + - name: Run fast PyTorch Pipeline CPU tests + if: ${{ matrix.config.framework == 'pytorch_pipelines' }} run: | python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \ -s -v -k "not Flax and not Onnx" \ --make-reports=tests_${{ matrix.config.report }} \ - tests/ + tests/pipelines + + - name: Run fast PyTorch Model Scheduler CPU tests + if: ${{ matrix.config.framework == 'pytorch_models' }} + run: | + python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \ + -s -v -k "not Flax and not Onnx" \ + --make-reports=tests_${{ matrix.config.report }} \ + tests/models tests/schedulers tests/others - name: Run fast Flax TPU tests if: ${{ matrix.config.framework == 'flax' }} @@ -85,7 +98,7 @@ jobs: python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \ -s -v -k "Flax" \ --make-reports=tests_${{ matrix.config.report }} \ - tests/ + tests - name: Run fast ONNXRuntime CPU tests if: ${{ matrix.config.framework == 'onnxruntime' }} diff --git a/tests/others/test_utils.py b/tests/others/test_utils.py index 4fc4e1a06638..6e7cc095f8df 100755 --- a/tests/others/test_utils.py +++ b/tests/others/test_utils.py @@ -167,4 +167,4 @@ def test_deprecate_stacklevel(self): with self.assertWarns(FutureWarning) as warning: deprecate(("deprecated_arg", self.higher_version, "This message is better!!!"), standard_warn=False) assert str(warning.warning) == "This message is better!!!" - assert "diffusers/tests/test_utils.py" in warning.filename + assert "diffusers/tests/others/test_utils.py" in warning.filename From c5aaccc7dd46266aa8f183c33521ee6bf4301020 Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Thu, 13 Apr 2023 00:00:29 +0200 Subject: [PATCH 4/7] Correct saving of pipelines --- src/diffusers/pipelines/pipeline_utils.py | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/diffusers/pipelines/pipeline_utils.py b/src/diffusers/pipelines/pipeline_utils.py index 2e20c21aaf38..72c4363da3c6 100644 --- a/src/diffusers/pipelines/pipeline_utils.py +++ b/src/diffusers/pipelines/pipeline_utils.py @@ -19,6 +19,7 @@ import inspect import os import re +import sys import warnings from dataclasses import dataclass from pathlib import Path @@ -540,11 +541,9 @@ def save_pretrained( variant (`str`, *optional*): If specified, weights are saved in the format pytorch_model..bin. """ - self.save_config(save_directory) - model_index_dict = dict(self.config) - model_index_dict.pop("_class_name") - model_index_dict.pop("_diffusers_version") + model_index_dict.pop("_class_name", None) + model_index_dict.pop("_diffusers_version", None) model_index_dict.pop("_module", None) expected_modules, optional_kwargs = self._get_signature_keys(self) @@ -557,7 +556,6 @@ def is_saveable_module(name, value): return True model_index_dict = {k: v for k, v in model_index_dict.items() if is_saveable_module(k, v)} - for pipeline_component_name in model_index_dict.keys(): sub_model = getattr(self, pipeline_component_name) model_cls = sub_model.__class__ @@ -571,7 +569,13 @@ def is_saveable_module(name, value): save_method_name = None # search for the model's base class in LOADABLE_CLASSES for library_name, library_classes in LOADABLE_CLASSES.items(): - library = importlib.import_module(library_name) + if library_name in sys.modules: + library = importlib.import_module(library_name) + else: + logger.info( + f"{library_name} is not installed. Cannot save {pipeline_component_name} as {library_classes} from {library_name}" + ) + for base_class, save_load_methods in library_classes.items(): class_candidate = getattr(library, base_class, None) if class_candidate is not None and issubclass(model_cls, class_candidate): @@ -581,6 +585,12 @@ def is_saveable_module(name, value): if save_method_name is not None: break + if save_method_name is None: + logger.warn(f"self.{pipeline_component_name}={sub_model} of type {type(sub_model)} cannot be saved.") + # make sure that unsaveable components are not tried to be loaded afterward + self.register_to_config(**{pipeline_component_name: (None, None)}) + continue + save_method = getattr(sub_model, save_method_name) # Call the save method with the argument safe_serialization only if it's supported @@ -596,6 +606,9 @@ def is_saveable_module(name, value): save_method(os.path.join(save_directory, pipeline_component_name), **save_kwargs) + # finally save the config + self.save_config(save_directory) + def to( self, torch_device: Optional[Union[str, torch.device]] = None, From 44f9ba8ffc3a6a8bdcbafb8822e1fb67157b533c Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Thu, 13 Apr 2023 00:24:33 +0200 Subject: [PATCH 5/7] make sure logging level is correct --- tests/others/test_config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/others/test_config.py b/tests/others/test_config.py index 95b0cdf9a597..8e34df1bfa38 100644 --- a/tests/others/test_config.py +++ b/tests/others/test_config.py @@ -29,6 +29,9 @@ from diffusers.utils.testing_utils import CaptureLogger +logging.set_verbosity_warning() + + class SampleObject(ConfigMixin): config_name = "config.json" From e17cd25156de60fa9e8e6fd24c0e478110dfc1b3 Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Thu, 13 Apr 2023 00:32:55 +0200 Subject: [PATCH 6/7] try again --- tests/others/test_config.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/others/test_config.py b/tests/others/test_config.py index 8e34df1bfa38..a29190c199ca 100644 --- a/tests/others/test_config.py +++ b/tests/others/test_config.py @@ -29,9 +29,6 @@ from diffusers.utils.testing_utils import CaptureLogger -logging.set_verbosity_warning() - - class SampleObject(ConfigMixin): config_name = "config.json" @@ -144,6 +141,8 @@ def test_save_load(self): def test_load_ddim_from_pndm(self): logger = logging.get_logger("diffusers.configuration_utils") + # 30 for warning + logger.setLevel(30) with CaptureLogger(logger) as cap_logger: ddim = DDIMScheduler.from_pretrained( @@ -156,6 +155,8 @@ def test_load_ddim_from_pndm(self): def test_load_euler_from_pndm(self): logger = logging.get_logger("diffusers.configuration_utils") + # 30 for warning + logger.setLevel(30) with CaptureLogger(logger) as cap_logger: euler = EulerDiscreteScheduler.from_pretrained( @@ -168,6 +169,8 @@ def test_load_euler_from_pndm(self): def test_load_euler_ancestral_from_pndm(self): logger = logging.get_logger("diffusers.configuration_utils") + # 30 for warning + logger.setLevel(30) with CaptureLogger(logger) as cap_logger: euler = EulerAncestralDiscreteScheduler.from_pretrained( @@ -180,6 +183,8 @@ def test_load_euler_ancestral_from_pndm(self): def test_load_pndm(self): logger = logging.get_logger("diffusers.configuration_utils") + # 30 for warning + logger.setLevel(30) with CaptureLogger(logger) as cap_logger: pndm = PNDMScheduler.from_pretrained( @@ -192,6 +197,8 @@ def test_load_pndm(self): def test_overwrite_config_on_load(self): logger = logging.get_logger("diffusers.configuration_utils") + # 30 for warning + logger.setLevel(30) with CaptureLogger(logger) as cap_logger: ddpm = DDPMScheduler.from_pretrained( @@ -215,6 +222,8 @@ def test_overwrite_config_on_load(self): def test_load_dpmsolver(self): logger = logging.get_logger("diffusers.configuration_utils") + # 30 for warning + logger.setLevel(30) with CaptureLogger(logger) as cap_logger: dpm = DPMSolverMultistepScheduler.from_pretrained( From ab07faeba7705a2e96b1a40a85b6f0a416d85291 Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Thu, 13 Apr 2023 13:21:27 +0100 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Pedro Cuenca --- tests/pipelines/test_pipelines_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/pipelines/test_pipelines_common.py b/tests/pipelines/test_pipelines_common.py index acbe42f87720..d0712bdec8f6 100644 --- a/tests/pipelines/test_pipelines_common.py +++ b/tests/pipelines/test_pipelines_common.py @@ -85,7 +85,7 @@ def params(self) -> frozenset: raise NotImplementedError( "You need to set the attribute `params` in the child test class. " "`params` are checked for if all values are present in `__call__`'s signature." - " You can set `params` using one of the common set of parameters defined ..pipeline_params.py`" + " You can set `params` using one of the common set of parameters defined in `pipeline_params.py`" " e.g., `TEXT_TO_IMAGE_PARAMS` defines the common parameters used in text to " "image pipelines, including prompts and prompt embedding overrides." "If your pipeline's set of arguments has minor changes from one of the common sets of arguments, " @@ -100,7 +100,7 @@ def batch_params(self) -> frozenset: raise NotImplementedError( "You need to set the attribute `batch_params` in the child test class. " "`batch_params` are the parameters required to be batched when passed to the pipeline's " - "`__call__` method..pipeline_params.py` provides some common sets of parameters such as " + "`__call__` method. `pipeline_params.py` provides some common sets of parameters such as " "`TEXT_TO_IMAGE_BATCH_PARAMS`, `IMAGE_VARIATION_BATCH_PARAMS`, etc... If your pipeline's " "set of batch arguments has minor changes from one of the common sets of batch arguments, " "do not make modifications to the existing common sets of batch arguments. I.e. a text to "