From 0783a02d9fad08f8215ba577dacf78fa2219800c Mon Sep 17 00:00:00 2001 From: Extraltodeus Date: Thu, 21 Aug 2025 03:23:34 +0200 Subject: [PATCH] allow shorter timesteps on uncond --- comfy/samplers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/comfy/samplers.py b/comfy/samplers.py index d5390d64e..51451db80 100644 --- a/comfy/samplers.py +++ b/comfy/samplers.py @@ -361,8 +361,10 @@ def cfg_function(model, cond_pred, uncond_pred, cond_scale, x, timestep, model_o args = {"cond": x - cond_pred, "uncond": x - uncond_pred, "cond_scale": cond_scale, "timestep": timestep, "input": x, "sigma": timestep, "cond_denoised": cond_pred, "uncond_denoised": uncond_pred, "model": model, "model_options": model_options} cfg_result = x - model_options["sampler_cfg_function"](args) - else: + elif uncond_pred.any(): cfg_result = uncond_pred + (cond_pred - uncond_pred) * cond_scale + else: + cfg_result = cond_pred for fn in model_options.get("sampler_post_cfg_function", []): args = {"denoised": cfg_result, "cond": cond, "uncond": uncond, "cond_scale": cond_scale, "model": model, "uncond_denoised": uncond_pred, "cond_denoised": cond_pred,