From 036a22077ca36256d85b10caf79023ecfd92dfa2 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Mon, 19 Jun 2023 15:27:43 -0400 Subject: [PATCH] Fix k_diffusion math being off by a tiny bit during txt2img. --- comfy/samplers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/comfy/samplers.py b/comfy/samplers.py index dffd7fe..f83b209 100644 --- a/comfy/samplers.py +++ b/comfy/samplers.py @@ -650,7 +650,10 @@ class KSampler: self.model_k.latent_image = latent_image self.model_k.noise = noise - noise = noise * sigmas[0] + if max_denoise: + noise = noise * torch.sqrt(1.0 + sigmas[0] ** 2.0) + else: + noise = noise * sigmas[0] k_callback = None total_steps = len(sigmas) - 1