From 3441f7f44293e024a78ccda14aaa8a92fa07b942 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Mon, 27 Oct 2025 21:12:01 +0530 Subject: [PATCH 1/2] don't run sana layerwise casting tests in CI. --- tests/lora/test_lora_layers_sana.py | 8 ++++++++ .../autoencoders/test_models_autoencoder_dc.py | 13 ++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/lora/test_lora_layers_sana.py b/tests/lora/test_lora_layers_sana.py index 3cdb28de75fb..e4d56ddc9b64 100644 --- a/tests/lora/test_lora_layers_sana.py +++ b/tests/lora/test_lora_layers_sana.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import os import sys import unittest @@ -28,6 +29,9 @@ from .utils import PeftLoraLoaderMixinTests # noqa: E402 +IS_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" and os.getenv("DIFFUSERS_IS_CI") == "yes" + + @require_peft_backend class SanaLoRATests(unittest.TestCase, PeftLoraLoaderMixinTests): pipeline_class = SanaPipeline @@ -136,3 +140,7 @@ def test_simple_inference_with_text_lora_fused(self): @unittest.skip("Text encoder LoRA is not supported in SANA.") def test_simple_inference_with_text_lora_save_load(self): pass + + @unittest.skipIf(IS_GITHUB_ACTIONS, reason="Skipping test inside GitHub Actions environment") + def test_layerwise_casting_inference_denoiser(self): + return super().test_layerwise_casting_inference_denoiser() diff --git a/tests/models/autoencoders/test_models_autoencoder_dc.py b/tests/models/autoencoders/test_models_autoencoder_dc.py index a6912f3ebab7..244e0285ea6c 100644 --- a/tests/models/autoencoders/test_models_autoencoder_dc.py +++ b/tests/models/autoencoders/test_models_autoencoder_dc.py @@ -13,21 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os import unittest from diffusers import AutoencoderDC -from ...testing_utils import ( - enable_full_determinism, - floats_tensor, - torch_device, -) +from ...testing_utils import enable_full_determinism, floats_tensor, torch_device from ..test_modeling_common import ModelTesterMixin from .testing_utils import AutoencoderTesterMixin enable_full_determinism() +IS_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" and os.getenv("DIFFUSERS_IS_CI") == "yes" + class AutoencoderDCTests(ModelTesterMixin, AutoencoderTesterMixin, unittest.TestCase): model_class = AutoencoderDC @@ -82,3 +81,7 @@ def prepare_init_args_and_inputs_for_common(self): init_dict = self.get_autoencoder_dc_config() inputs_dict = self.dummy_input return init_dict, inputs_dict + + @unittest.skipIf(IS_GITHUB_ACTIONS, reason="Skipping test inside GitHub Actions environment") + def test_layerwise_casting_inference(self): + super().test_layerwise_casting_inference() From 51b5461287101422464d02d8f827aedc666f2bb3 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Tue, 28 Oct 2025 12:43:36 +0530 Subject: [PATCH 2/2] up --- tests/lora/test_lora_layers_sana.py | 6 +----- tests/models/autoencoders/test_models_autoencoder_dc.py | 5 +---- tests/pipelines/sana/test_sana.py | 5 +++++ tests/pipelines/sana/test_sana_controlnet.py | 9 +++++---- tests/pipelines/sana/test_sana_sprint.py | 9 +++++---- tests/pipelines/sana/test_sana_sprint_img2img.py | 9 +++++---- tests/testing_utils.py | 2 ++ 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/tests/lora/test_lora_layers_sana.py b/tests/lora/test_lora_layers_sana.py index e4d56ddc9b64..a860b7b44f2c 100644 --- a/tests/lora/test_lora_layers_sana.py +++ b/tests/lora/test_lora_layers_sana.py @@ -12,7 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import os import sys import unittest @@ -21,7 +20,7 @@ from diffusers import AutoencoderDC, FlowMatchEulerDiscreteScheduler, SanaPipeline, SanaTransformer2DModel -from ..testing_utils import floats_tensor, require_peft_backend +from ..testing_utils import IS_GITHUB_ACTIONS, floats_tensor, require_peft_backend sys.path.append(".") @@ -29,9 +28,6 @@ from .utils import PeftLoraLoaderMixinTests # noqa: E402 -IS_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" and os.getenv("DIFFUSERS_IS_CI") == "yes" - - @require_peft_backend class SanaLoRATests(unittest.TestCase, PeftLoraLoaderMixinTests): pipeline_class = SanaPipeline diff --git a/tests/models/autoencoders/test_models_autoencoder_dc.py b/tests/models/autoencoders/test_models_autoencoder_dc.py index 244e0285ea6c..d34001e7b903 100644 --- a/tests/models/autoencoders/test_models_autoencoder_dc.py +++ b/tests/models/autoencoders/test_models_autoencoder_dc.py @@ -13,20 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import unittest from diffusers import AutoencoderDC -from ...testing_utils import enable_full_determinism, floats_tensor, torch_device +from ...testing_utils import IS_GITHUB_ACTIONS, enable_full_determinism, floats_tensor, torch_device from ..test_modeling_common import ModelTesterMixin from .testing_utils import AutoencoderTesterMixin enable_full_determinism() -IS_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" and os.getenv("DIFFUSERS_IS_CI") == "yes" - class AutoencoderDCTests(ModelTesterMixin, AutoencoderTesterMixin, unittest.TestCase): model_class = AutoencoderDC diff --git a/tests/pipelines/sana/test_sana.py b/tests/pipelines/sana/test_sana.py index 34ea3079b143..f23303c966e5 100644 --- a/tests/pipelines/sana/test_sana.py +++ b/tests/pipelines/sana/test_sana.py @@ -23,6 +23,7 @@ from diffusers import AutoencoderDC, FlowMatchEulerDiscreteScheduler, SanaPipeline, SanaTransformer2DModel from ...testing_utils import ( + IS_GITHUB_ACTIONS, backend_empty_cache, enable_full_determinism, require_torch_accelerator, @@ -304,6 +305,10 @@ def test_float16_inference(self): # Requires higher tolerance as model seems very sensitive to dtype super().test_float16_inference(expected_max_diff=0.08) + @unittest.skipIf(IS_GITHUB_ACTIONS, reason="Skipping test inside GitHub Actions environment") + def test_layerwise_casting_inference(self): + super().test_layerwise_casting_inference() + @slow @require_torch_accelerator diff --git a/tests/pipelines/sana/test_sana_controlnet.py b/tests/pipelines/sana/test_sana_controlnet.py index 043e276fcb84..df14d935edf5 100644 --- a/tests/pipelines/sana/test_sana_controlnet.py +++ b/tests/pipelines/sana/test_sana_controlnet.py @@ -28,10 +28,7 @@ ) from diffusers.utils.torch_utils import randn_tensor -from ...testing_utils import ( - enable_full_determinism, - torch_device, -) +from ...testing_utils import IS_GITHUB_ACTIONS, enable_full_determinism, 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 PipelineTesterMixin, to_np @@ -326,3 +323,7 @@ def test_inference_batch_single_identical(self): def test_float16_inference(self): # Requires higher tolerance as model seems very sensitive to dtype super().test_float16_inference(expected_max_diff=0.08) + + @unittest.skipIf(IS_GITHUB_ACTIONS, reason="Skipping test inside GitHub Actions environment") + def test_layerwise_casting_inference(self): + super().test_layerwise_casting_inference() diff --git a/tests/pipelines/sana/test_sana_sprint.py b/tests/pipelines/sana/test_sana_sprint.py index fee2304dce1b..0d45205ea8c7 100644 --- a/tests/pipelines/sana/test_sana_sprint.py +++ b/tests/pipelines/sana/test_sana_sprint.py @@ -21,10 +21,7 @@ from diffusers import AutoencoderDC, SanaSprintPipeline, SanaTransformer2DModel, SCMScheduler -from ...testing_utils import ( - enable_full_determinism, - torch_device, -) +from ...testing_utils import IS_GITHUB_ACTIONS, enable_full_determinism, 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 PipelineTesterMixin, to_np @@ -300,3 +297,7 @@ def test_inference_batch_single_identical(self): def test_float16_inference(self): # Requires higher tolerance as model seems very sensitive to dtype super().test_float16_inference(expected_max_diff=0.08) + + @unittest.skipIf(IS_GITHUB_ACTIONS, reason="Skipping test inside GitHub Actions environment") + def test_layerwise_casting_inference(self): + super().test_layerwise_casting_inference() diff --git a/tests/pipelines/sana/test_sana_sprint_img2img.py b/tests/pipelines/sana/test_sana_sprint_img2img.py index c218abb8e951..5de5c7f44606 100644 --- a/tests/pipelines/sana/test_sana_sprint_img2img.py +++ b/tests/pipelines/sana/test_sana_sprint_img2img.py @@ -22,10 +22,7 @@ from diffusers import AutoencoderDC, SanaSprintImg2ImgPipeline, SanaTransformer2DModel, SCMScheduler from diffusers.utils.torch_utils import randn_tensor -from ...testing_utils import ( - enable_full_determinism, - torch_device, -) +from ...testing_utils import IS_GITHUB_ACTIONS, enable_full_determinism, torch_device from ..pipeline_params import ( IMAGE_TO_IMAGE_IMAGE_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, @@ -312,3 +309,7 @@ def test_inference_batch_single_identical(self): def test_float16_inference(self): # Requires higher tolerance as model seems very sensitive to dtype super().test_float16_inference(expected_max_diff=0.08) + + @unittest.skipIf(IS_GITHUB_ACTIONS, reason="Skipping test inside GitHub Actions environment") + def test_layerwise_casting_inference(self): + super().test_layerwise_casting_inference() diff --git a/tests/testing_utils.py b/tests/testing_utils.py index 7f849219c16f..951ba4128033 100644 --- a/tests/testing_utils.py +++ b/tests/testing_utils.py @@ -63,6 +63,8 @@ IS_CUDA_SYSTEM = False IS_XPU_SYSTEM = False +IS_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" and os.getenv("DIFFUSERS_IS_CI") == "yes" + global_rng = random.Random() logger = get_logger(__name__)