From 8c249d1401f12d55a59a7bdb2329b29921ae864e Mon Sep 17 00:00:00 2001 From: Meatfucker <74834323+Meatfucker@users.noreply.github.com> Date: Tue, 13 May 2025 12:31:45 -0400 Subject: [PATCH 1/3] Update pipeline_flux_img2img.py to add missing vae_slicing and vae_tiling calls. (#11545) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update pipeline_flux_img2img.py Adds missing vae_slicing and vae_tiling calls to FluxImage2ImagePipeline * Update src/diffusers/pipelines/flux/pipeline_flux_img2img.py Co-authored-by: Álvaro Somoza * Update src/diffusers/pipelines/flux/pipeline_flux_img2img.py Co-authored-by: Álvaro Somoza * Update src/diffusers/pipelines/flux/pipeline_flux_img2img.py Co-authored-by: Álvaro Somoza * Update src/diffusers/pipelines/flux/pipeline_flux_img2img.py Co-authored-by: Álvaro Somoza --------- Co-authored-by: Álvaro Somoza --- .../pipelines/flux/pipeline_flux_img2img.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/diffusers/pipelines/flux/pipeline_flux_img2img.py b/src/diffusers/pipelines/flux/pipeline_flux_img2img.py index 64cd6ac45f..572ad5096b 100644 --- a/src/diffusers/pipelines/flux/pipeline_flux_img2img.py +++ b/src/diffusers/pipelines/flux/pipeline_flux_img2img.py @@ -607,6 +607,39 @@ class FluxImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFile return latents + # Copied from diffusers.pipelines.flux.pipeline_flux.FluxPipeline.enable_vae_slicing + def enable_vae_slicing(self): + r""" + Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to + compute decoding in several steps. This is useful to save some memory and allow larger batch sizes. + """ + self.vae.enable_slicing() + + # Copied from diffusers.pipelines.flux.pipeline_flux.FluxPipeline.disable_vae_slicing + def disable_vae_slicing(self): + r""" + Disable sliced VAE decoding. If `enable_vae_slicing` was previously enabled, this method will go back to + computing decoding in one step. + """ + self.vae.disable_slicing() + + # Copied from diffusers.pipelines.flux.pipeline_flux.FluxPipeline.enable_vae_tiling + def enable_vae_tiling(self): + r""" + Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to + compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow + processing larger images. + """ + self.vae.enable_tiling() + + # Copied from diffusers.pipelines.flux.pipeline_flux.FluxPipeline.disable_vae_tiling + def disable_vae_tiling(self): + r""" + Disable tiled VAE decoding. If `enable_vae_tiling` was previously enabled, this method will go back to + computing decoding in one step. + """ + self.vae.disable_tiling() + def prepare_latents( self, image, From 7e3353196cc5cc582b212691fbc05a6c86ed8a98 Mon Sep 17 00:00:00 2001 From: Anwesha Chowdhury <133762127+AChowdhury1211@users.noreply.github.com> Date: Tue, 13 May 2025 23:35:52 +0530 Subject: [PATCH 2/3] Fix deprecation warnings in test_ltx_image2video.py (#11538) Fixed 2 warnings that were raised during running LTXImageToVideoPipelineFastTests Co-authored-by: achowdhury1211@gmail.com --- tests/pipelines/ltx/test_ltx_image2video.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/pipelines/ltx/test_ltx_image2video.py b/tests/pipelines/ltx/test_ltx_image2video.py index 1c3e018a8a..6c425a2e3f 100644 --- a/tests/pipelines/ltx/test_ltx_image2video.py +++ b/tests/pipelines/ltx/test_ltx_image2video.py @@ -109,7 +109,7 @@ class LTXImageToVideoPipelineFastTests(PipelineTesterMixin, unittest.TestCase): else: generator = torch.Generator(device=device).manual_seed(seed) - image = torch.randn((1, 3, 32, 32), generator=generator, device=device) + image = torch.rand((1, 3, 32, 32), generator=generator, device=device) inputs = { "image": image, @@ -142,7 +142,7 @@ class LTXImageToVideoPipelineFastTests(PipelineTesterMixin, unittest.TestCase): self.assertEqual(generated_video.shape, (9, 3, 32, 32)) expected_video = torch.randn(9, 3, 32, 32) - max_diff = np.abs(generated_video - expected_video).max() + max_diff = torch.amax(torch.abs(generated_video - expected_video)) self.assertLessEqual(max_diff, 1e10) def test_callback_inputs(self): From f4fa3beee7f49b80ce7a58f9c8002f43299175c9 Mon Sep 17 00:00:00 2001 From: Seokhyeon Jeong Date: Wed, 14 May 2025 14:56:12 +0900 Subject: [PATCH 3/3] [tests] Add torch.compile test for UNet2DConditionModel (#11537) Co-authored-by: Sayak Paul --- tests/models/unets/test_models_unet_2d_condition.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/models/unets/test_models_unet_2d_condition.py b/tests/models/unets/test_models_unet_2d_condition.py index 94a5d641a7..24d944bbf9 100644 --- a/tests/models/unets/test_models_unet_2d_condition.py +++ b/tests/models/unets/test_models_unet_2d_condition.py @@ -53,7 +53,12 @@ from diffusers.utils.testing_utils import ( torch_device, ) -from ..test_modeling_common import LoraHotSwappingForModelTesterMixin, ModelTesterMixin, UNetTesterMixin +from ..test_modeling_common import ( + LoraHotSwappingForModelTesterMixin, + ModelTesterMixin, + TorchCompileTesterMixin, + UNetTesterMixin, +) if is_peft_available(): @@ -351,7 +356,7 @@ def create_custom_diffusion_layers(model, mock_weights: bool = True): class UNet2DConditionModelTests( - ModelTesterMixin, LoraHotSwappingForModelTesterMixin, UNetTesterMixin, unittest.TestCase + ModelTesterMixin, TorchCompileTesterMixin, LoraHotSwappingForModelTesterMixin, UNetTesterMixin, unittest.TestCase ): model_class = UNet2DConditionModel main_input_name = "sample"