From 8b7eb680d78bdbc7c5e862dc95c4815218a2a1f3 Mon Sep 17 00:00:00 2001 From: Sayak Paul Date: Wed, 2 Sep 2026 05:13:33 +0000 Subject: [PATCH 1/2] fix SVD tests --- .../stable_video_diffusion/pipeline_stable_video_diffusion.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py b/src/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py index fd46ddd1b602..5eadca46ff6d 100644 --- a/src/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +++ b/src/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py @@ -243,7 +243,9 @@ def _encode_vae_image( num_videos_per_prompt: int, do_classifier_free_guidance: bool, ): - image = image.to(device=device) + # The image comes out of `video_processor.preprocess()` in float32, so it has to follow the VAE dtype. + # `needs_upcasting` in `__call__` has already moved a float16 VAE to float32 by this point. + image = image.to(device=device, dtype=self.vae.dtype) image_latents = self.vae.encode(image).latent_dist.mode() # duplicate image_latents for each generation per prompt, using mps friendly method From 67911bfde5e997dae212f0e84c3b4b5f1e12f43e Mon Sep 17 00:00:00 2001 From: Sayak Paul Date: Wed, 2 Sep 2026 06:58:04 +0000 Subject: [PATCH 2/2] make comment less confusing --- .../stable_video_diffusion/pipeline_stable_video_diffusion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py b/src/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py index 5eadca46ff6d..007d2b8da0cb 100644 --- a/src/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +++ b/src/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py @@ -243,8 +243,8 @@ def _encode_vae_image( num_videos_per_prompt: int, do_classifier_free_guidance: bool, ): - # The image comes out of `video_processor.preprocess()` in float32, so it has to follow the VAE dtype. - # `needs_upcasting` in `__call__` has already moved a float16 VAE to float32 by this point. + # The image comes out of `video_processor.preprocess()` in float32. When `needs_upcasting=False`, the VAE may not + # be in FP32 (for example, it could be in BF16) so we need to cast in this case. image = image.to(device=device, dtype=self.vae.dtype) image_latents = self.vae.encode(image).latent_dist.mode()