The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Switch to the real cfg++ method in the samplers.
comfyanonymous05e831697a03
diff --git a/comfy/k_diffusion/sampling.py b/comfy/k_diffusion/sampling.pyindex f8091bb3f..763d8cc78 100644--- a/comfy/k_diffusion/sampling.py+++ b/comfy/k_diffusion/sampling.py@@ -998,7 +998,7 @@ def sample_deis(model, x, sigmas, extra_args=None, callback=None, disable=None,return x_next@torch.no_grad()-def sample_euler_pp(model, x, sigmas, extra_args=None, callback=None, disable=None):+def sample_euler_cfg_pp(model, x, sigmas, extra_args=None, callback=None, disable=None):extra_args = {} if extra_args is None else extra_argstemp = [0]@@ -1013,16 +1013,16 @@ def sample_euler_pp(model, x, sigmas, extra_args=None, callback=None, disable=Nofor i in trange(len(sigmas) - 1, disable=disable):sigma_hat = sigmas[i]denoised = model(x, sigma_hat * s_in, **extra_args)- d = to_d(x - denoised + temp[0], sigma_hat, denoised)+ d = to_d(x, sigma_hat, temp[0])if callback is not None:callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigma_hat, 'denoised': denoised})dt = sigmas[i + 1] - sigma_hat# Euler method- x = x + d * dt+ x = denoised + d * sigmas[i + 1]return x@torch.no_grad()-def sample_euler_ancestral_pp(model, x, sigmas, extra_args=None, callback=None, disable=None, eta=1., s_noise=1., noise_sampler=None):+def sample_euler_ancestral_cfg_pp(model, x, sigmas, extra_args=None, callback=None, disable=None, eta=1., s_noise=1., noise_sampler=None):"""Ancestral sampling with Euler method steps."""extra_args = {} if extra_args is None else extra_argsnoise_sampler = default_noise_sampler(x) if noise_sampler is None else noise_sampler@@ -1041,10 +1041,10 @@ def sample_euler_ancestral_pp(model, x, sigmas, extra_args=None, callback=None,sigma_down, sigma_up = get_ancestral_step(sigmas[i], sigmas[i + 1], eta=eta)if callback is not None:callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigmas[i], 'denoised': denoised})- d = to_d(x - denoised + temp[0], sigmas[i], denoised)+ d = to_d(x, sigmas[i], temp[0])# Euler methoddt = sigma_down - sigmas[i]- x = x + d * dt+ x = denoised + d * sigma_downif sigmas[i + 1] > 0:x = x + noise_sampler(sigmas[i], sigmas[i + 1]) * s_noise * sigma_upreturn xdiff --git a/comfy/samplers.py b/comfy/samplers.pyindex 7f7114dbb..c0aa12916 100644--- a/comfy/samplers.py+++ b/comfy/samplers.py@@ -537,7 +537,7 @@ class Sampler:sigma = float(sigmas[0])return math.isclose(max_sigma, sigma, rel_tol=1e-05) or sigma > max_sigma-KSAMPLER_NAMES = ["euler", "euler_pp", "euler_ancestral", "euler_ancestral_pp", "heun", "heunpp2","dpm_2", "dpm_2_ancestral",+KSAMPLER_NAMES = ["euler", "euler_cfg_pp", "euler_ancestral", "euler_ancestral_cfg_pp", "heun", "heunpp2","dpm_2", "dpm_2_ancestral","lms", "dpm_fast", "dpm_adaptive", "dpmpp_2s_ancestral", "dpmpp_sde", "dpmpp_sde_gpu","dpmpp_2m", "dpmpp_2m_sde", "dpmpp_2m_sde_gpu", "dpmpp_3m_sde", "dpmpp_3m_sde_gpu", "ddpm", "lcm","ipndm", "ipndm_v", "deis"]diff --git a/web/scripts/app.js b/web/scripts/app.jsindex 43df61065..3a91aa239 100644--- a/web/scripts/app.js+++ b/web/scripts/app.js@@ -1966,6 +1966,14 @@ export class ComfyApp {if (widget.value.startsWith("sample_")) {widget.value = widget.value.slice(7);}+ if (widget.value === "euler_pp" || widget.value === "euler_ancestral_pp") {+ widget.value = widget.value.slice(0, -3);+ for (let w of node.widgets) {+ if (w.name == "cfg") {+ w.value *= 2.0;+ }+ }+ }}}if (node.type == "KSampler" || node.type == "KSamplerAdvanced" || node.type == "PrimitiveNode") {