diff --git a/tests/pipelines/cogvideo/test_cogvideox.py b/tests/pipelines/cogvideo/test_cogvideox.py index e81cd2ffc9a9..efcb03482886 100644 --- a/tests/pipelines/cogvideo/test_cogvideox.py +++ b/tests/pipelines/cogvideo/test_cogvideox.py @@ -14,7 +14,6 @@ import gc -import numpy as np import pytest import torch from transformers import AutoConfig, AutoTokenizer, T5EncoderModel @@ -22,6 +21,7 @@ from diffusers import AutoencoderKLCogVideoX, CogVideoXPipeline, CogVideoXTransformer3DModel, DDIMScheduler from ...testing_utils import ( + assert_tensors_close, backend_empty_cache, numpy_cosine_similarity_distance, require_torch_accelerator, @@ -142,7 +142,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_inference_batch_single_identical(self): super().test_inference_batch_single_identical(batch_size=3, expected_max_diff=1e-3) @@ -194,14 +194,26 @@ def test_fused_qkv_projections(self): frames = pipe(**inputs).frames image_slice_disabled = frames[0, -2:, -1, -3:, -3:] - assert np.allclose(original_image_slice, image_slice_fused, atol=1e-3, rtol=1e-3), ( - "Fusion of QKV projections shouldn't affect the outputs." + assert_tensors_close( + original_image_slice, + image_slice_fused, + atol=1e-3, + rtol=1e-3, + msg="Fusion of QKV projections shouldn't affect the outputs.", ) - assert np.allclose(image_slice_fused, image_slice_disabled, atol=1e-3, rtol=1e-3), ( - "Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled." + assert_tensors_close( + image_slice_fused, + image_slice_disabled, + atol=1e-3, + rtol=1e-3, + msg="Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled.", ) - assert np.allclose(original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2), ( - "Original outputs should match when fused QKV projections are disabled." + assert_tensors_close( + original_image_slice, + image_slice_disabled, + atol=1e-2, + rtol=1e-2, + msg="Original outputs should match when fused QKV projections are disabled.", ) diff --git a/tests/pipelines/cogvideo/test_cogvideox_fun_control.py b/tests/pipelines/cogvideo/test_cogvideox_fun_control.py index f79c1e71225b..0cae00f6f7a0 100644 --- a/tests/pipelines/cogvideo/test_cogvideox_fun_control.py +++ b/tests/pipelines/cogvideo/test_cogvideox_fun_control.py @@ -13,13 +13,13 @@ # limitations under the License. -import numpy as np import torch from PIL import Image from transformers import AutoConfig, AutoTokenizer, T5EncoderModel from diffusers import AutoencoderKLCogVideoX, CogVideoXFunControlPipeline, CogVideoXTransformer3DModel, DDIMScheduler +from ...testing_utils import assert_tensors_close from ..testing_utils import ( BasePipelineTesterConfig, MemoryTesterMixin, @@ -136,7 +136,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_inference_batch_single_identical(self): super().test_inference_batch_single_identical(batch_size=3, expected_max_diff=1e-3) @@ -189,14 +189,26 @@ def test_fused_qkv_projections(self): frames = pipe(**inputs).frames image_slice_disabled = frames[0, -2:, -1, -3:, -3:] - assert np.allclose(original_image_slice, image_slice_fused, atol=1e-3, rtol=1e-3), ( - "Fusion of QKV projections shouldn't affect the outputs." + assert_tensors_close( + original_image_slice, + image_slice_fused, + atol=1e-3, + rtol=1e-3, + msg="Fusion of QKV projections shouldn't affect the outputs.", ) - assert np.allclose(image_slice_fused, image_slice_disabled, atol=1e-3, rtol=1e-3), ( - "Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled." + assert_tensors_close( + image_slice_fused, + image_slice_disabled, + atol=1e-3, + rtol=1e-3, + msg="Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled.", ) - assert np.allclose(original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2), ( - "Original outputs should match when fused QKV projections are disabled." + assert_tensors_close( + original_image_slice, + image_slice_disabled, + atol=1e-2, + rtol=1e-2, + msg="Original outputs should match when fused QKV projections are disabled.", ) diff --git a/tests/pipelines/cogvideo/test_cogvideox_image2video.py b/tests/pipelines/cogvideo/test_cogvideox_image2video.py index f00fd30e7928..2ef82d90cba6 100644 --- a/tests/pipelines/cogvideo/test_cogvideox_image2video.py +++ b/tests/pipelines/cogvideo/test_cogvideox_image2video.py @@ -14,7 +14,6 @@ import gc -import numpy as np import pytest import torch from PIL import Image @@ -24,6 +23,7 @@ from diffusers.utils import load_image from ...testing_utils import ( + assert_tensors_close, backend_empty_cache, numpy_cosine_similarity_distance, require_torch_accelerator, @@ -162,7 +162,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_inference_batch_single_identical(self): super().test_inference_batch_single_identical(batch_size=3, expected_max_diff=1e-3) @@ -227,14 +227,26 @@ def test_fused_qkv_projections(self): frames = pipe(**inputs).frames image_slice_disabled = frames[0, -2:, -1, -3:, -3:] - assert np.allclose(original_image_slice, image_slice_fused, atol=1e-3, rtol=1e-3), ( - "Fusion of QKV projections shouldn't affect the outputs." + assert_tensors_close( + original_image_slice, + image_slice_fused, + atol=1e-3, + rtol=1e-3, + msg="Fusion of QKV projections shouldn't affect the outputs.", ) - assert np.allclose(image_slice_fused, image_slice_disabled, atol=1e-3, rtol=1e-3), ( - "Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled." + assert_tensors_close( + image_slice_fused, + image_slice_disabled, + atol=1e-3, + rtol=1e-3, + msg="Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled.", ) - assert np.allclose(original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2), ( - "Original outputs should match when fused QKV projections are disabled." + assert_tensors_close( + original_image_slice, + image_slice_disabled, + atol=1e-2, + rtol=1e-2, + msg="Original outputs should match when fused QKV projections are disabled.", ) diff --git a/tests/pipelines/cogvideo/test_cogvideox_video2video.py b/tests/pipelines/cogvideo/test_cogvideox_video2video.py index 4ca5ac27d087..c418d8babc02 100644 --- a/tests/pipelines/cogvideo/test_cogvideox_video2video.py +++ b/tests/pipelines/cogvideo/test_cogvideox_video2video.py @@ -13,13 +13,13 @@ # limitations under the License. -import numpy as np import torch from PIL import Image from transformers import AutoConfig, AutoTokenizer, T5EncoderModel from diffusers import AutoencoderKLCogVideoX, CogVideoXTransformer3DModel, CogVideoXVideoToVideoPipeline, DDIMScheduler +from ...testing_utils import assert_tensors_close from ..testing_utils import ( BasePipelineTesterConfig, MemoryTesterMixin, @@ -137,7 +137,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_inference_batch_single_identical(self): super().test_inference_batch_single_identical(batch_size=3, expected_max_diff=1e-3) @@ -194,14 +194,26 @@ def test_fused_qkv_projections(self): frames = pipe(**inputs).frames image_slice_disabled = frames[0, -2:, -1, -3:, -3:] - assert np.allclose(original_image_slice, image_slice_fused, atol=1e-3, rtol=1e-3), ( - "Fusion of QKV projections shouldn't affect the outputs." + assert_tensors_close( + original_image_slice, + image_slice_fused, + atol=1e-3, + rtol=1e-3, + msg="Fusion of QKV projections shouldn't affect the outputs.", ) - assert np.allclose(image_slice_fused, image_slice_disabled, atol=1e-3, rtol=1e-3), ( - "Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled." + assert_tensors_close( + image_slice_fused, + image_slice_disabled, + atol=1e-3, + rtol=1e-3, + msg="Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled.", ) - assert np.allclose(original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2), ( - "Original outputs should match when fused QKV projections are disabled." + assert_tensors_close( + original_image_slice, + image_slice_disabled, + atol=1e-2, + rtol=1e-2, + msg="Original outputs should match when fused QKV projections are disabled.", ) diff --git a/tests/pipelines/qwenimage/test_qwenimage.py b/tests/pipelines/qwenimage/test_qwenimage.py index 95ad085fd67c..bcc9ec771708 100644 --- a/tests/pipelines/qwenimage/test_qwenimage.py +++ b/tests/pipelines/qwenimage/test_qwenimage.py @@ -22,7 +22,7 @@ QwenImageTransformer2DModel, ) -from ...testing_utils import torch_device +from ...testing_utils import assert_tensors_close, torch_device from ..testing_utils import ( BasePipelineTesterConfig, MemoryTesterMixin, @@ -137,7 +137,7 @@ def test_inference(self): generated_slice = generated_image.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=5e-3) + assert_tensors_close(generated_slice, expected_slice, atol=5e-3) def test_vae_tiling(self, expected_diff_max: float = 0.2): pipe = self.pipeline_class(**self.get_dummy_components()).to(torch_device) diff --git a/tests/pipelines/qwenimage/test_qwenimage_controlnet.py b/tests/pipelines/qwenimage/test_qwenimage_controlnet.py index 70e361ce29a1..949bd5833a7a 100644 --- a/tests/pipelines/qwenimage/test_qwenimage_controlnet.py +++ b/tests/pipelines/qwenimage/test_qwenimage_controlnet.py @@ -25,7 +25,7 @@ ) from diffusers.utils.torch_utils import randn_tensor -from ...testing_utils import torch_device +from ...testing_utils import assert_tensors_close, torch_device from ..testing_utils import ( BasePipelineTesterConfig, MemoryTesterMixin, @@ -173,7 +173,7 @@ def test_qwen_controlnet(self): generated_slice = generated_image.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=5e-3) + assert_tensors_close(generated_slice, expected_slice, atol=5e-3) def test_qwen_controlnet_multicondition(self): # Run on CPU: the expected slice below is CPU-specific. @@ -196,7 +196,7 @@ def test_qwen_controlnet_multicondition(self): generated_slice = generated_image.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=5e-3) + assert_tensors_close(generated_slice, expected_slice, atol=5e-3) def test_vae_tiling(self, expected_diff_max: float = 0.2): pipe = self.pipeline_class(**self.get_dummy_components()).to(torch_device) diff --git a/tests/pipelines/qwenimage/test_qwenimage_edit.py b/tests/pipelines/qwenimage/test_qwenimage_edit.py index c38a4f92af72..3e6c92033169 100644 --- a/tests/pipelines/qwenimage/test_qwenimage_edit.py +++ b/tests/pipelines/qwenimage/test_qwenimage_edit.py @@ -24,7 +24,7 @@ QwenImageTransformer2DModel, ) -from ...testing_utils import torch_device +from ...testing_utils import assert_tensors_close, torch_device from ..testing_utils import ( BasePipelineTesterConfig, MemoryTesterMixin, @@ -142,7 +142,7 @@ def test_inference(self): generated_slice = generated_image.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=5e-3) + assert_tensors_close(generated_slice, expected_slice, atol=5e-3) def test_inference_batch_single_identical(self): super().test_inference_batch_single_identical(batch_size=3, expected_max_diff=1e-1) diff --git a/tests/pipelines/qwenimage/test_qwenimage_edit_plus.py b/tests/pipelines/qwenimage/test_qwenimage_edit_plus.py index 35d75aa75f8f..8680792d6767 100644 --- a/tests/pipelines/qwenimage/test_qwenimage_edit_plus.py +++ b/tests/pipelines/qwenimage/test_qwenimage_edit_plus.py @@ -24,7 +24,7 @@ QwenImageTransformer2DModel, ) -from ...testing_utils import torch_device +from ...testing_utils import assert_tensors_close, torch_device from ..testing_utils import BasePipelineTesterConfig, MemoryTesterMixin, PipelineTesterMixin @@ -139,7 +139,7 @@ def test_inference(self): generated_slice = generated_image.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_vae_tiling(self, expected_diff_max: float = 0.2): pipe = self.pipeline_class(**self.get_dummy_components()).to(torch_device) diff --git a/tests/pipelines/qwenimage/test_qwenimage_img2img.py b/tests/pipelines/qwenimage/test_qwenimage_img2img.py index 0b73cf9d2b42..16a2847e730e 100644 --- a/tests/pipelines/qwenimage/test_qwenimage_img2img.py +++ b/tests/pipelines/qwenimage/test_qwenimage_img2img.py @@ -24,7 +24,7 @@ QwenImageTransformer2DModel, ) -from ...testing_utils import floats_tensor, torch_device +from ...testing_utils import assert_tensors_close, floats_tensor, torch_device from ..testing_utils import ( BasePipelineTesterConfig, MemoryTesterMixin, @@ -141,7 +141,7 @@ def test_inference(self): generated_slice = generated_image.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=5e-3) + assert_tensors_close(generated_slice, expected_slice, atol=5e-3) def test_vae_tiling(self, expected_diff_max: float = 0.2): pipe = self.pipeline_class(**self.get_dummy_components()).to(torch_device) diff --git a/tests/pipelines/wan/test_wan.py b/tests/pipelines/wan/test_wan.py index 8ac9a42c3dfb..e1339cf115e1 100644 --- a/tests/pipelines/wan/test_wan.py +++ b/tests/pipelines/wan/test_wan.py @@ -107,7 +107,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_save_load_optional_components(self, tmp_path, expected_max_difference=1e-4): # `_optional_components` lists both `transformer` and `transformer_2`, but only `transformer_2` is optional diff --git a/tests/pipelines/wan/test_wan_22.py b/tests/pipelines/wan/test_wan_22.py index 164801e0fe91..8c0d873bf489 100644 --- a/tests/pipelines/wan/test_wan_22.py +++ b/tests/pipelines/wan/test_wan_22.py @@ -123,7 +123,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_save_load_optional_components(self, tmp_path, expected_max_difference=1e-4): # For wan 2.2 14B, `transformer` is not used when `boundary_ratio` is 1.0, so only then is it optional. @@ -246,15 +246,12 @@ def test_inference(self): assert generated_video.shape == (9, 3, 32, 32) # fmt: off - expected_slice = torch.tensor([[[0.4814, 0.4298, 0.5094, 0.4289, 0.5061, 0.4301, 0.5043, 0.4284, 0.5375, - 0.5965, 0.5527, 0.6014, 0.5228, 0.6076, 0.6644, 0.5651]]]) + expected_slice = torch.tensor([0.4814, 0.4298, 0.5094, 0.4289, 0.5061, 0.4301, 0.5043, 0.4284, 0.5375, 0.5965, 0.5527, 0.6014, 0.5228, 0.6076, 0.6644, 0.5651]) # fmt: on generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3), ( - f"generated_slice: {generated_slice}, expected_slice: {expected_slice}" - ) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_components_function(self): init_components = self.get_dummy_components() diff --git a/tests/pipelines/wan/test_wan_22_image_to_video.py b/tests/pipelines/wan/test_wan_22_image_to_video.py index 68687889d849..b8967594271b 100644 --- a/tests/pipelines/wan/test_wan_22_image_to_video.py +++ b/tests/pipelines/wan/test_wan_22_image_to_video.py @@ -131,7 +131,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_save_load_optional_components(self, tmp_path, expected_max_difference=1e-4): # `_optional_components` lists `transformer`, `transformer_2`, `image_encoder` and `image_processor`. For the @@ -264,12 +264,12 @@ def test_inference(self): assert generated_video.shape == (9, 3, 32, 32) # fmt: off - expected_slice = torch.tensor([[0.4833, 0.4305, 0.5100, 0.4299, 0.5056, 0.4298, 0.5052, 0.4332, 0.5550, 0.6092, 0.5536, 0.5928, 0.5199, 0.5864, 0.6705, 0.5493]]) + expected_slice = torch.tensor([0.4833, 0.4305, 0.5100, 0.4299, 0.5056, 0.4298, 0.5052, 0.4332, 0.5550, 0.6092, 0.5536, 0.5928, 0.5199, 0.5864, 0.6705, 0.5493]) # fmt: on generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_components_function(self): init_components = self.get_dummy_components() diff --git a/tests/pipelines/wan/test_wan_animate.py b/tests/pipelines/wan/test_wan_animate.py index 93dcf7649325..c76606c81a87 100644 --- a/tests/pipelines/wan/test_wan_animate.py +++ b/tests/pipelines/wan/test_wan_animate.py @@ -31,6 +31,7 @@ WanAnimateTransformer3DModel, ) +from ...testing_utils import assert_tensors_close from ..testing_utils import BasePipelineTesterConfig, MemoryTesterMixin, PipelineTesterMixin @@ -159,7 +160,7 @@ def test_inference(self): generated_slice = video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_inference_replacement(self): # Replacement mode with background and mask videos. Run on CPU. diff --git a/tests/pipelines/wan/test_wan_image_to_video.py b/tests/pipelines/wan/test_wan_image_to_video.py index 6feb1a454e7f..0b881f2742bc 100644 --- a/tests/pipelines/wan/test_wan_image_to_video.py +++ b/tests/pipelines/wan/test_wan_image_to_video.py @@ -137,7 +137,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_save_load_optional_components(self, tmp_path, expected_max_difference=1e-4): # `_optional_components` lists `transformer`, `transformer_2`, `image_encoder` and `image_processor`, but only @@ -281,7 +281,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_save_load_optional_components(self, tmp_path, expected_max_difference=1e-4): # `_optional_components` lists `transformer`, `transformer_2`, `image_encoder` and `image_processor`, but only diff --git a/tests/pipelines/wan/test_wan_vace.py b/tests/pipelines/wan/test_wan_vace.py index e4e5f24be844..c4d62aaec389 100644 --- a/tests/pipelines/wan/test_wan_vace.py +++ b/tests/pipelines/wan/test_wan_vace.py @@ -133,7 +133,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_inference_with_single_reference_image(self): # Run on CPU: the expected slice below is CPU-specific. @@ -151,7 +151,7 @@ def test_inference_with_single_reference_image(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_inference_with_multiple_reference_image(self): # Run on CPU: the expected slice below is CPU-specific. @@ -169,7 +169,7 @@ def test_inference_with_multiple_reference_image(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) def test_inference_with_only_transformer(self): components = self.get_dummy_components() diff --git a/tests/pipelines/wan/test_wan_video_to_video.py b/tests/pipelines/wan/test_wan_video_to_video.py index 3b10ae1bba50..92a8d46d6bfc 100644 --- a/tests/pipelines/wan/test_wan_video_to_video.py +++ b/tests/pipelines/wan/test_wan_video_to_video.py @@ -20,6 +20,7 @@ from diffusers import AutoencoderKLWan, UniPCMultistepScheduler, WanTransformer3DModel, WanVideoToVideoPipeline +from ...testing_utils import assert_tensors_close from ..testing_utils import BasePipelineTesterConfig, MemoryTesterMixin, PipelineTesterMixin @@ -107,7 +108,7 @@ def test_inference(self): generated_slice = generated_video.flatten() generated_slice = torch.cat([generated_slice[:8], generated_slice[-8:]]) - assert torch.allclose(generated_slice, expected_slice, atol=1e-3) + assert_tensors_close(generated_slice, expected_slice, atol=1e-3) @pytest.mark.skip( reason="WanVideoToVideoPipeline has to run in mixed precision. Casting the entire pipeline will result in errors"