From 6ac4c0e1a91e44f3e56d86ed0cdbd85a8699d16c Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Mon, 6 Jul 2026 01:03:09 +0100 Subject: [PATCH] fix(krea2): resolve default guidance per variant instead of static 1.0 cfg=-1 means use the pipeline's own default. Krea2Pipeline serves both Base and Turbo under one class, so a static signature default cannot fit both: Base needs real guidance while the distilled Turbo runs guidance-free. Resolve the unset default from is_distilled (Base 4.5, Turbo 1.0). Explicit cfg is passed through unchanged. --- pipelines/krea2/pipeline_krea2.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pipelines/krea2/pipeline_krea2.py b/pipelines/krea2/pipeline_krea2.py index a7aa2ca59..2b36c34dd 100644 --- a/pipelines/krea2/pipeline_krea2.py +++ b/pipelines/krea2/pipeline_krea2.py @@ -154,7 +154,7 @@ class Krea2Pipeline(DiffusionPipeline, FromSingleFileMixin): height: int = 1024, width: int = 1024, num_inference_steps: int = 28, - guidance_scale: float = 1.0, + guidance_scale: float | None = None, num_images_per_prompt: int = 1, generator: torch.Generator | list[torch.Generator] | None = None, latents: torch.Tensor | None = None, @@ -173,11 +173,15 @@ class Krea2Pipeline(DiffusionPipeline, FromSingleFileMixin): prompts = [prompt] if isinstance(prompt, str) else list(prompt) device = self._execution_device dtype = self.transformer.dtype - self._guidance_scale = guidance_scale self._interrupt = False is_distilled = bool(getattr(self.transformer.config, "is_distilled", False)) - do_cfg = guidance_scale is not None and guidance_scale > 1 and not is_distilled + # guidance_scale=None is the "use default" path (cfg=-1): Base needs real guidance + # (Krea recommends 4.5), the distilled Turbo runs guidance-free + if guidance_scale is None: + guidance_scale = 1.0 if is_distilled else 4.5 + self._guidance_scale = guidance_scale + do_cfg = guidance_scale > 1 and not is_distilled text, text_mask = self.encode_prompt(prompts, device) text = text.to(dtype)