mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-27 17:22:53 +03:00
Refactor full determinism (#3485)
* up * fix more * Apply suggestions from code review * fix more * fix more * Check it * Remove 16:8 * fix more * fix more * fix more * up * up * Test only stable diffusion * Test only two files * up * Try out spinning up processes that can be killed * up * Apply suggestions from code review * up * up
This commit is contained in:
committed by
GitHub
parent
49ad61c204
commit
51843fd7d0
@@ -1,7 +1,6 @@
|
||||
import contextlib
|
||||
import copy
|
||||
import os
|
||||
import random
|
||||
from random import random
|
||||
from typing import Any, Dict, Iterable, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
@@ -14,26 +13,6 @@ if is_transformers_available():
|
||||
import transformers
|
||||
|
||||
|
||||
def enable_full_determinism(seed: int):
|
||||
"""
|
||||
Helper function for reproducible behavior during distributed training. See
|
||||
- https://pytorch.org/docs/stable/notes/randomness.html for pytorch
|
||||
"""
|
||||
# set seed first
|
||||
set_seed(seed)
|
||||
|
||||
# Enable PyTorch deterministic mode. This potentially requires either the environment
|
||||
# variable 'CUDA_LAUNCH_BLOCKING' or 'CUBLAS_WORKSPACE_CONFIG' to be set,
|
||||
# depending on the CUDA version, so we set them both here
|
||||
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
|
||||
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8"
|
||||
torch.use_deterministic_algorithms(True)
|
||||
|
||||
# Enable CUDNN deterministic mode
|
||||
torch.backends.cudnn.deterministic = True
|
||||
torch.backends.cudnn.benchmark = False
|
||||
|
||||
|
||||
def set_seed(seed: int):
|
||||
"""
|
||||
Args:
|
||||
|
||||
@@ -514,3 +514,21 @@ class CaptureLogger:
|
||||
|
||||
def __repr__(self):
|
||||
return f"captured: {self.out}\n"
|
||||
|
||||
|
||||
def enable_full_determinism():
|
||||
"""
|
||||
Helper function for reproducible behavior during distributed training. See
|
||||
- https://pytorch.org/docs/stable/notes/randomness.html for pytorch
|
||||
"""
|
||||
# Enable PyTorch deterministic mode. This potentially requires either the environment
|
||||
# variable 'CUDA_LAUNCH_BLOCKING' or 'CUBLAS_WORKSPACE_CONFIG' to be set,
|
||||
# depending on the CUDA version, so we set them both here
|
||||
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
|
||||
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8"
|
||||
torch.use_deterministic_algorithms(True)
|
||||
|
||||
# Enable CUDNN deterministic mode
|
||||
torch.backends.cudnn.deterministic = True
|
||||
torch.backends.cudnn.benchmark = False
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
|
||||
@@ -27,9 +27,6 @@ from diffusers.models.transformer_2d import Transformer2DModel
|
||||
from diffusers.utils import torch_device
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
|
||||
|
||||
class EmbeddingsTests(unittest.TestCase):
|
||||
def test_timestep_embeddings(self):
|
||||
embedding_dim = 256
|
||||
|
||||
@@ -23,9 +23,6 @@ from diffusers.utils import floats_tensor, slow, torch_device
|
||||
from .test_modeling_common import ModelTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
|
||||
|
||||
class UNet1DModelTests(ModelTesterMixin, unittest.TestCase):
|
||||
model_class = UNet1DModel
|
||||
|
||||
|
||||
@@ -21,13 +21,14 @@ import torch
|
||||
|
||||
from diffusers import UNet2DModel
|
||||
from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism
|
||||
|
||||
from .test_modeling_common import ModelTesterMixin
|
||||
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class Unet2DModelTests(ModelTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -33,13 +33,14 @@ from diffusers.utils import (
|
||||
torch_device,
|
||||
)
|
||||
from diffusers.utils.import_utils import is_xformers_available
|
||||
from diffusers.utils.testing_utils import enable_full_determinism
|
||||
|
||||
from .test_modeling_common import ModelTesterMixin
|
||||
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
def create_lora_layers(model, mock_weights: bool = True):
|
||||
|
||||
@@ -29,13 +29,14 @@ from diffusers.utils import (
|
||||
torch_device,
|
||||
)
|
||||
from diffusers.utils.import_utils import is_xformers_available
|
||||
from diffusers.utils.testing_utils import enable_full_determinism
|
||||
|
||||
from .test_modeling_common import ModelTesterMixin
|
||||
|
||||
|
||||
enable_full_determinism()
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
|
||||
|
||||
def create_lora_layers(model, mock_weights: bool = True):
|
||||
|
||||
@@ -22,12 +22,12 @@ from parameterized import parameterized
|
||||
from diffusers import AutoencoderKL
|
||||
from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device
|
||||
from diffusers.utils.import_utils import is_xformers_available
|
||||
from diffusers.utils.testing_utils import enable_full_determinism
|
||||
|
||||
from .test_modeling_common import ModelTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class AutoencoderKLTests(ModelTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -19,12 +19,12 @@ import torch
|
||||
|
||||
from diffusers import VQModel
|
||||
from diffusers.utils import floats_tensor, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism
|
||||
|
||||
from .test_modeling_common import ModelTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class VQModelTests(ModelTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -20,11 +20,10 @@ import torch
|
||||
|
||||
from diffusers import UNet2DConditionModel
|
||||
from diffusers.training_utils import EMAModel
|
||||
from diffusers.utils.testing_utils import skip_mps, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, skip_mps, torch_device
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class EMAModelTests(unittest.TestCase):
|
||||
|
||||
@@ -26,14 +26,13 @@ from diffusers.pipelines.alt_diffusion.modeling_roberta_series import (
|
||||
RobertaSeriesModelWithTransformation,
|
||||
)
|
||||
from diffusers.utils import slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class AltDiffusionPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -33,11 +33,10 @@ from diffusers.pipelines.alt_diffusion.modeling_roberta_series import (
|
||||
RobertaSeriesModelWithTransformation,
|
||||
)
|
||||
from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class AltDiffusionImg2ImgPipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -30,11 +30,10 @@ from diffusers import (
|
||||
UNet2DModel,
|
||||
)
|
||||
from diffusers.utils import slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class PipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -37,13 +37,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import slow, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism
|
||||
|
||||
from ..pipeline_params import TEXT_TO_AUDIO_BATCH_PARAMS, TEXT_TO_AUDIO_PARAMS
|
||||
from ..test_pipelines_common import PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class AudioLDMPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -32,7 +32,7 @@ from diffusers import (
|
||||
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_controlnet import MultiControlNetModel
|
||||
from diffusers.utils import load_image, load_numpy, randn_tensor, slow, torch_device
|
||||
from diffusers.utils.import_utils import is_xformers_available
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import (
|
||||
TEXT_TO_IMAGE_BATCH_PARAMS,
|
||||
@@ -41,8 +41,7 @@ from ..pipeline_params import (
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class ControlNetPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -35,7 +35,7 @@ from diffusers import (
|
||||
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_controlnet import MultiControlNetModel
|
||||
from diffusers.utils import floats_tensor, load_image, load_numpy, randn_tensor, slow, torch_device
|
||||
from diffusers.utils.import_utils import is_xformers_available
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import (
|
||||
TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
|
||||
@@ -44,8 +44,7 @@ from ..pipeline_params import (
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class ControlNetImg2ImgPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -35,7 +35,7 @@ from diffusers import (
|
||||
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_controlnet import MultiControlNetModel
|
||||
from diffusers.utils import floats_tensor, load_image, load_numpy, randn_tensor, slow, torch_device
|
||||
from diffusers.utils.import_utils import is_xformers_available
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import (
|
||||
TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS,
|
||||
@@ -44,8 +44,7 @@ from ..pipeline_params import (
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class ControlNetInpaintPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -21,13 +21,13 @@ import torch
|
||||
|
||||
from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNet1DModel
|
||||
from diffusers.utils import slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu, skip_mps
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps
|
||||
|
||||
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
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class DanceDiffusionPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -19,13 +19,13 @@ import numpy as np
|
||||
import torch
|
||||
|
||||
from diffusers import DDIMPipeline, DDIMScheduler, UNet2DModel
|
||||
from diffusers.utils.testing_utils import require_torch_gpu, slow, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, 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
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class DDIMPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -19,10 +19,10 @@ import numpy as np
|
||||
import torch
|
||||
|
||||
from diffusers import DDPMPipeline, DDPMScheduler, UNet2DModel
|
||||
from diffusers.utils.testing_utils import require_torch_gpu, slow, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class DDPMPipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -21,7 +21,7 @@ import torch
|
||||
|
||||
from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, Transformer2DModel
|
||||
from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import (
|
||||
CLASS_CONDITIONED_IMAGE_GENERATION_BATCH_PARAMS,
|
||||
@@ -30,7 +30,7 @@ from ..pipeline_params import (
|
||||
from ..test_pipelines_common import PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class DiTPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -19,10 +19,10 @@ import numpy as np
|
||||
import torch
|
||||
|
||||
from diffusers import KarrasVePipeline, KarrasVeScheduler, UNet2DModel
|
||||
from diffusers.utils.testing_utils import require_torch, slow, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class KarrasVePipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -21,13 +21,20 @@ import torch
|
||||
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer
|
||||
|
||||
from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNet2DConditionModel
|
||||
from diffusers.utils.testing_utils import load_numpy, nightly, require_torch_gpu, slow, torch_device
|
||||
from diffusers.utils.testing_utils import (
|
||||
enable_full_determinism,
|
||||
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
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class LDMTextToImagePipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -21,10 +21,10 @@ import torch
|
||||
|
||||
from diffusers import DDIMScheduler, LDMSuperResolutionPipeline, UNet2DModel, VQModel
|
||||
from diffusers.utils import PIL_INTERPOLATION, floats_tensor, load_image, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class LDMSuperResolutionPipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -20,10 +20,10 @@ import torch
|
||||
from transformers import CLIPTextConfig, CLIPTextModel
|
||||
|
||||
from diffusers import DDIMScheduler, LDMPipeline, UNet2DModel, VQModel
|
||||
from diffusers.utils.testing_utils import require_torch, slow, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class LDMPipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -25,14 +25,13 @@ from transformers import CLIPImageProcessor, CLIPVisionConfig
|
||||
from diffusers import AutoencoderKL, PaintByExamplePipeline, PNDMScheduler, UNet2DConditionModel
|
||||
from diffusers.pipelines.paint_by_example import PaintByExampleImageEncoder
|
||||
from diffusers.utils import floats_tensor, load_image, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
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
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class PaintByExamplePipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -19,10 +19,10 @@ import numpy as np
|
||||
import torch
|
||||
|
||||
from diffusers import PNDMPipeline, PNDMScheduler, UNet2DModel
|
||||
from diffusers.utils.testing_utils import require_torch, slow, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class PNDMPipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -20,14 +20,21 @@ import numpy as np
|
||||
import torch
|
||||
|
||||
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 diffusers.utils.testing_utils import (
|
||||
enable_full_determinism,
|
||||
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
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class RepaintPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -19,10 +19,10 @@ import numpy as np
|
||||
import torch
|
||||
|
||||
from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNet2DModel
|
||||
from diffusers.utils.testing_utils import require_torch, slow, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class ScoreSdeVeipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -25,10 +25,10 @@ from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer
|
||||
from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNet2DConditionModel
|
||||
from diffusers.pipelines.semantic_stable_diffusion import SemanticStableDiffusionPipeline as StableDiffusionPipeline
|
||||
from diffusers.utils import floats_tensor, nightly, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class SafeDiffusionPipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -22,13 +22,13 @@ import torch
|
||||
from diffusers import DDPMScheduler, MidiProcessor, SpectrogramDiffusionPipeline
|
||||
from diffusers.pipelines.spectrogram_diffusion import SpectrogramContEncoder, SpectrogramNotesEncoder, T5FilmDecoder
|
||||
from diffusers.utils import require_torch_gpu, skip_mps, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_note_seq, require_onnxruntime
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, 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
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
MIDI_FILE = "./tests/fixtures/elise_format0.mid"
|
||||
|
||||
@@ -23,14 +23,13 @@ from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer
|
||||
|
||||
from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNet2DConditionModel
|
||||
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 diffusers.utils.testing_utils import enable_full_determinism, 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 PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class CycleDiffusionPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -15,11 +15,16 @@
|
||||
|
||||
|
||||
import gc
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
import torch
|
||||
from huggingface_hub import hf_hub_download
|
||||
from packaging import version
|
||||
@@ -39,15 +44,25 @@ from diffusers import (
|
||||
)
|
||||
from diffusers.models.attention_processor import AttnProcessor
|
||||
from diffusers.utils import load_numpy, nightly, slow, torch_device
|
||||
from diffusers.utils.testing_utils import CaptureLogger, require_torch_gpu
|
||||
from diffusers.utils.testing_utils import CaptureLogger, enable_full_determinism, 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_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def process_fixture():
|
||||
# This will be run before each test
|
||||
command = [sys.executable, os.path.abspath(__file__)]
|
||||
process = subprocess.Popen(command)
|
||||
enable_full_determinism()
|
||||
yield process
|
||||
# This will be run after each test
|
||||
try:
|
||||
os.kill(process.pid, signal.SIGTERM) # or signal.SIGKILL
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
|
||||
|
||||
class StableDiffusionPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
@@ -551,8 +566,7 @@ class StableDiffusionPipelineFastTests(PipelineLatentTesterMixin, PipelineTester
|
||||
@slow
|
||||
@require_torch_gpu
|
||||
class StableDiffusionPipelineSlowTests(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
def setUp(self):
|
||||
gc.collect()
|
||||
torch.cuda.empty_cache()
|
||||
|
||||
|
||||
@@ -30,14 +30,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import floats_tensor, load_image, load_numpy, nightly, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import IMAGE_VARIATION_BATCH_PARAMS, IMAGE_VARIATION_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusionImageVariationPipelineFastTests(
|
||||
|
||||
@@ -34,7 +34,7 @@ from diffusers import (
|
||||
)
|
||||
from diffusers.image_processor import VaeImageProcessor
|
||||
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 diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps
|
||||
|
||||
from ..pipeline_params import (
|
||||
IMAGE_TO_IMAGE_IMAGE_PARAMS,
|
||||
@@ -44,8 +44,7 @@ from ..pipeline_params import (
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusionImg2ImgPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -33,15 +33,14 @@ from diffusers import (
|
||||
)
|
||||
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_inpaint import prepare_mask_and_masked_image
|
||||
from diffusers.utils import floats_tensor, load_image, load_numpy, nightly, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ...models.test_models_unet_2d_condition import create_lora_layers
|
||||
from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusionInpaintPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -34,11 +34,10 @@ from diffusers import (
|
||||
VQModel,
|
||||
)
|
||||
from diffusers.utils import floats_tensor, load_image, nightly, slow, torch_device
|
||||
from diffusers.utils.testing_utils import load_numpy, preprocess_image, require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, load_numpy, preprocess_image, require_torch_gpu
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusionInpaintLegacyPipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -32,14 +32,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import floats_tensor, load_image, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusionInstructPix2PixPipelineFastTests(
|
||||
|
||||
@@ -21,10 +21,10 @@ import torch
|
||||
|
||||
from diffusers import StableDiffusionKDiffusionPipeline
|
||||
from diffusers.utils import slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
@slow
|
||||
|
||||
@@ -29,14 +29,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu, skip_mps
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps
|
||||
|
||||
from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
@skip_mps
|
||||
|
||||
@@ -30,14 +30,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu, skip_mps
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps
|
||||
|
||||
from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
@skip_mps
|
||||
|
||||
@@ -33,14 +33,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import floats_tensor, load_numpy, slow, torch_device
|
||||
from diffusers.utils.testing_utils import load_image, load_pt, require_torch_gpu, skip_mps
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, 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 PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
@skip_mps
|
||||
|
||||
@@ -27,14 +27,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusionSAGPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -33,14 +33,13 @@ from diffusers import (
|
||||
logging,
|
||||
)
|
||||
from diffusers.utils import load_numpy, nightly, slow, torch_device
|
||||
from diffusers.utils.testing_utils import CaptureLogger, require_torch_gpu
|
||||
from diffusers.utils.testing_utils import CaptureLogger, enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusion2PipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -49,14 +49,13 @@ from diffusers.utils import (
|
||||
slow,
|
||||
torch_device,
|
||||
)
|
||||
from diffusers.utils.testing_utils import require_torch_gpu, skip_mps
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, 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 PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
@skip_mps
|
||||
|
||||
@@ -33,14 +33,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import load_image, slow
|
||||
from diffusers.utils.testing_utils import floats_tensor, require_torch_gpu, torch_device
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, floats_tensor, require_torch_gpu, torch_device
|
||||
|
||||
from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusionDiffEditPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -24,14 +24,13 @@ from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer
|
||||
|
||||
from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNet2DConditionModel
|
||||
from diffusers.utils import floats_tensor, load_image, load_numpy, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu, slow
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow
|
||||
|
||||
from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusion2InpaintPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -29,13 +29,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusionLatentUpscalePipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -24,10 +24,10 @@ from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer
|
||||
|
||||
from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNet2DConditionModel
|
||||
from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusionUpscalePipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -30,11 +30,10 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
from diffusers.utils import load_numpy, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableDiffusion2VPredictionPipelineFastTests(unittest.TestCase):
|
||||
|
||||
@@ -28,9 +28,6 @@ from diffusers.utils import floats_tensor, nightly, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
|
||||
|
||||
class SafeDiffusionPipelineFastTests(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
# clean up the VRAM after each test
|
||||
|
||||
@@ -13,14 +13,13 @@ from diffusers import (
|
||||
UNet2DConditionModel,
|
||||
)
|
||||
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 diffusers.utils.testing_utils import enable_full_determinism, load_numpy, require_torch_gpu, slow, torch_device
|
||||
|
||||
from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
|
||||
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin, assert_mean_pixel_difference
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableUnCLIPPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -18,6 +18,7 @@ from diffusers.pipelines.pipeline_utils import DiffusionPipeline
|
||||
from diffusers.pipelines.stable_diffusion.stable_unclip_image_normalizer import StableUnCLIPImageNormalizer
|
||||
from diffusers.utils.import_utils import is_xformers_available
|
||||
from diffusers.utils.testing_utils import (
|
||||
enable_full_determinism,
|
||||
floats_tensor,
|
||||
load_image,
|
||||
load_numpy,
|
||||
@@ -35,8 +36,7 @@ from ..test_pipelines_common import (
|
||||
)
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class StableUnCLIPImg2ImgPipelineFastTests(PipelineLatentTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -65,6 +65,7 @@ from diffusers.utils import (
|
||||
)
|
||||
from diffusers.utils.testing_utils import (
|
||||
CaptureLogger,
|
||||
enable_full_determinism,
|
||||
get_tests_dir,
|
||||
load_numpy,
|
||||
require_compel,
|
||||
@@ -73,8 +74,7 @@ from diffusers.utils.testing_utils import (
|
||||
)
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class DownloadTests(unittest.TestCase):
|
||||
@@ -700,7 +700,6 @@ class CustomPipelineTests(unittest.TestCase):
|
||||
def test_download_from_git(self):
|
||||
# Because adaptive_avg_pool2d_backward_cuda
|
||||
# does not have a deterministic implementation.
|
||||
torch.use_deterministic_algorithms(False)
|
||||
clip_model_id = "laion/CLIP-ViT-B-32-laion2B-s34B-b79K"
|
||||
|
||||
feature_extractor = CLIPImageProcessor.from_pretrained(clip_model_id)
|
||||
@@ -722,7 +721,6 @@ class CustomPipelineTests(unittest.TestCase):
|
||||
|
||||
image = pipeline("a prompt", num_inference_steps=2, output_type="np").images[0]
|
||||
assert image.shape == (512, 512, 3)
|
||||
torch.use_deterministic_algorithms(True)
|
||||
|
||||
def test_save_pipeline_change_config(self):
|
||||
pipe = DiffusionPipeline.from_pretrained(
|
||||
|
||||
@@ -18,9 +18,6 @@ from diffusers.utils.import_utils import is_accelerate_available, is_accelerate_
|
||||
from diffusers.utils.testing_utils import require_torch, torch_device
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
|
||||
|
||||
def to_np(tensor):
|
||||
if isinstance(tensor, torch.Tensor):
|
||||
tensor = tensor.detach().cpu().numpy()
|
||||
|
||||
@@ -27,13 +27,13 @@ from diffusers import (
|
||||
UNet3DConditionModel,
|
||||
)
|
||||
from diffusers.utils import load_numpy, skip_mps, slow
|
||||
from diffusers.utils.testing_utils import enable_full_determinism
|
||||
|
||||
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
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
@skip_mps
|
||||
|
||||
@@ -23,14 +23,13 @@ from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokeni
|
||||
from diffusers import PriorTransformer, UnCLIPPipeline, UnCLIPScheduler, UNet2DConditionModel, UNet2DModel
|
||||
from diffusers.pipelines.unclip.text_proj import UnCLIPTextProjModel
|
||||
from diffusers.utils import load_numpy, nightly, slow, torch_device
|
||||
from diffusers.utils.testing_utils import require_torch_gpu, skip_mps
|
||||
from diffusers.utils.testing_utils import enable_full_determinism, 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
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class UnCLIPPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@@ -37,14 +37,13 @@ from diffusers import (
|
||||
)
|
||||
from diffusers.pipelines.unclip.text_proj import UnCLIPTextProjModel
|
||||
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 diffusers.utils.testing_utils import enable_full_determinism, 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
|
||||
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = False
|
||||
torch.use_deterministic_algorithms(True)
|
||||
enable_full_determinism()
|
||||
|
||||
|
||||
class UnCLIPImageVariationPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user