From eaf0f6a5b32502d6894209aa132a80452d1195bb Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Thu, 18 Jun 2026 22:50:38 +0000 Subject: [PATCH] fix: apply CodeRabbit auto-fixes Fixed 2 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit --- fastvideo/configs/pipelines/kandinsky5.py | 6 ++++++ fastvideo/pipelines/stages/kandinsky5.py | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fastvideo/configs/pipelines/kandinsky5.py b/fastvideo/configs/pipelines/kandinsky5.py index d67924765..1b3b1e308 100644 --- a/fastvideo/configs/pipelines/kandinsky5.py +++ b/fastvideo/configs/pipelines/kandinsky5.py @@ -76,6 +76,12 @@ class Kandinsky5T2VConfig(PipelineConfig): vae_tiling: bool = True def __post_init__(self) -> None: + if len(self.text_encoder_configs) != 2: + raise ValueError( + f"Kandinsky5 pipeline requires exactly 2 text encoders (qwen and clip), " + f"but got {len(self.text_encoder_configs)} encoder(s)." + ) + self.vae_config.load_encoder = False self.vae_config.load_decoder = True diff --git a/fastvideo/pipelines/stages/kandinsky5.py b/fastvideo/pipelines/stages/kandinsky5.py index 360b96f7a..787e09bfc 100644 --- a/fastvideo/pipelines/stages/kandinsky5.py +++ b/fastvideo/pipelines/stages/kandinsky5.py @@ -2,6 +2,8 @@ from __future__ import annotations +import contextlib + import torch from diffusers.utils.torch_utils import randn_tensor from tqdm.auto import tqdm @@ -184,7 +186,9 @@ class Kandinsky5DenoisingStage(PipelineStage): continue t_expand = timestep.unsqueeze(0).repeat(latents.shape[0]).to(device=device, dtype=target_dtype) - with torch.autocast(device_type="cuda", dtype=target_dtype, enabled=autocast_enabled): + autocast_ctx = (torch.autocast(device_type="cuda", dtype=target_dtype, enabled=autocast_enabled) + if device.type == "cuda" else contextlib.nullcontext()) + with autocast_ctx: pred_velocity = self.transformer( hidden_states=latents.to(dtype=target_dtype), encoder_hidden_states=prompt_embeds,