From e0b975810ca386eadd6606408088c32b50e9b3d3 Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Sat, 27 Jun 2026 22:25:54 +0100 Subject: [PATCH] fix(krea2): align cfg with standard convention Switch to neg-anchored guidance gated on > 1 so cfg 1.0 means no CFG, matching SD3/SDXL/Flux. Default guidance_scale 1.0; reference cfg Turbo 1.0, Base 4.5. --- data/reference-base.json | 2 +- data/reference-distilled.json | 2 +- data/reference-quantized.json | 4 ++-- pipelines/krea2/pipeline_krea2.py | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/reference-base.json b/data/reference-base.json index 5ee1d9ce6..2e22dddf1 100644 --- a/data/reference-base.json +++ b/data/reference-base.json @@ -175,7 +175,7 @@ "path": "CalamitousFelicitousness/Krea-2-Base-Diffusers", "preview": "CalamitousFelicitousness--Krea-2-Base-Diffusers.jpg", "desc": "Krea 2 (K2) Base is the undistilled foundation model of the Krea 2 family, trained from scratch by Krea. A 12.9B-parameter single-stream flow-matching DiT that uses a Qwen3-VL-4B vision-language model as its text encoder and the Qwen-Image VAE. The base checkpoint is intended for fine-tuning and LoRA training; LoRAs trained on it apply to Krea 2 Turbo.", - "extras": "sampler: Default, cfg_scale: 3.5, steps: 52, width: 1024, height: 1024", + "extras": "sampler: Default, cfg_scale: 4.5, steps: 52, width: 1024, height: 1024", "size": 34.0, "date": "2026 June" }, diff --git a/data/reference-distilled.json b/data/reference-distilled.json index 089d7090c..e678149a6 100644 --- a/data/reference-distilled.json +++ b/data/reference-distilled.json @@ -11,7 +11,7 @@ "path": "CalamitousFelicitousness/Krea-2-Turbo-Diffusers", "preview": "CalamitousFelicitousness--Krea-2-Turbo-Diffusers.jpg", "desc": "Krea 2 (K2) Turbo is the 8-step distilled inference model of the Krea 2 family, trained from scratch by Krea. A 12.9B-parameter single-stream flow-matching DiT that uses a Qwen3-VL-4B vision-language model as its text encoder and the Qwen-Image VAE. Runs without classifier-free guidance; LoRAs trained on Krea 2 Base apply directly.", - "extras": "sampler: Default, cfg_scale: 0.0, steps: 8, width: 1024, height: 1024", + "extras": "sampler: Default, cfg_scale: 1.0, steps: 8, width: 1024, height: 1024", "size": 34.0, "date": "2026 June" }, diff --git a/data/reference-quantized.json b/data/reference-quantized.json index 7ea81c87b..2c8942afd 100644 --- a/data/reference-quantized.json +++ b/data/reference-quantized.json @@ -222,7 +222,7 @@ "path": "vladmandic/Krea-2-Turbo-sdnq-hadamard-uint4", "preview": "CalamitousFelicitousness--Krea-2-Turbo-Diffusers.jpg", "desc": "Krea 2 (K2) Turbo is the 8-step distilled inference model of the Krea 2 family, trained from scratch by Krea. A 12.9B-parameter single-stream flow-matching DiT that uses a Qwen3-VL-4B vision-language model as its text encoder and the Qwen-Image VAE. Runs without classifier-free guidance; LoRAs trained on Krea 2 Base apply directly.", - "extras": "sampler: Default, cfg_scale: 0.0, steps: 8, width: 1024, height: 1024", + "extras": "sampler: Default, cfg_scale: 1.0, steps: 8, width: 1024, height: 1024", "size": 34.0, "date": "2026 June" }, @@ -230,7 +230,7 @@ "path": "vladmandic/Krea-2-Base-sdnq-hadamard-uint4", "preview": "CalamitousFelicitousness--Krea-2-Base-Diffusers.jpg", "desc": "Krea 2 (K2) Base is the undistilled foundation model of the Krea 2 family, trained from scratch by Krea. A 12.9B-parameter single-stream flow-matching DiT that uses a Qwen3-VL-4B vision-language model as its text encoder and the Qwen-Image VAE. The base checkpoint is intended for fine-tuning and LoRA training; LoRAs trained on it apply to Krea 2 Turbo.", - "extras": "sampler: Default, cfg_scale: 3.5, steps: 52, width: 1024, height: 1024", + "extras": "sampler: Default, cfg_scale: 4.5, steps: 52, width: 1024, height: 1024", "size": 34.0, "date": "2026 June" } diff --git a/pipelines/krea2/pipeline_krea2.py b/pipelines/krea2/pipeline_krea2.py index 43fcd5965..a7aa2ca59 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 = 4.5, + guidance_scale: float = 1.0, num_images_per_prompt: int = 1, generator: torch.Generator | list[torch.Generator] | None = None, latents: torch.Tensor | None = None, @@ -177,7 +177,7 @@ class Krea2Pipeline(DiffusionPipeline, FromSingleFileMixin): self._interrupt = False is_distilled = bool(getattr(self.transformer.config, "is_distilled", False)) - do_cfg = guidance_scale is not None and guidance_scale > 0 and not is_distilled + do_cfg = guidance_scale is not None and guidance_scale > 1 and not is_distilled text, text_mask = self.encode_prompt(prompts, device) text = text.to(dtype) @@ -237,7 +237,7 @@ class Krea2Pipeline(DiffusionPipeline, FromSingleFileMixin): hidden_states=img, encoder_hidden_states=uncond, timestep=model_t, position_ids=uncond_pos, attention_mask=uncond_full_mask, return_dict=False, )[0] - velocity = cond + guidance_scale * (cond - neg) + velocity = neg + guidance_scale * (cond - neg) else: velocity = cond img = self.scheduler.step(velocity, t, img, return_dict=False)[0]