diff --git a/comfy/samplers.py b/comfy/samplers.py index 934310930..fa09c71af 100644 --- a/comfy/samplers.py +++ b/comfy/samplers.py @@ -949,19 +949,8 @@ class CFGGuider: for k in conds: self.original_conds[k] = comfy.sampler_helpers.convert_cond(conds[k]) - def __call__(self, *args, **kwargs): + def __call__(self, *args, **kwargs): return self.outer_predict_noise(*args, **kwargs) - def handle_dynamic_cfg(self, timestep, model_options): - if hasattr(self.model_patcher.model.diffusion_model, "stop_cfg_index"): - stop_index = self.model_patcher.model.diffusion_model.stop_cfg_index - transformer_options = model_options.get("transformer_options", {}) - sigmas = transformer_options.get("sample_sigmas", None) - if sigmas is not None or self.cfg != 1.0: - dist = torch.abs(sigmas - timestep) - i = torch.argmin(dist).item() - - if stop_index == i or (stop_index == -1 and i == len(sigmas) - 2): - self.set_cfg(1.0) def outer_predict_noise(self, x, timestep, model_options={}, seed=None): return comfy.patcher_extension.WrapperExecutor.new_class_executor( @@ -971,7 +960,6 @@ class CFGGuider: ).execute(x, timestep, model_options, seed) def predict_noise(self, x, timestep, model_options={}, seed=None): - self.handle_dynamic_cfg(timestep, model_options) return sampling_function(self.inner_model, x, timestep, self.conds.get("negative", None), self.conds.get("positive", None), self.cfg, model_options=model_options, seed=seed) def inner_sample(self, noise, latent_image, device, sampler, sigmas, denoise_mask, callback, disable_pbar, seed, latent_shapes=None): @@ -996,9 +984,6 @@ class CFGGuider: self.inner_model, self.conds, self.loaded_models = comfy.sampler_helpers.prepare_sampling(self.model_patcher, noise.shape, self.conds, self.model_options) device = self.model_patcher.load_device - if denoise_mask is not None: - denoise_mask = comfy.sampler_helpers.prepare_mask(denoise_mask, noise.shape, device) - noise = noise.to(device) latent_image = latent_image.to(device) sigmas = sigmas.to(device) diff --git a/comfy_extras/nodes_model_advanced.py b/comfy_extras/nodes_model_advanced.py index a42bf2b6a..ae5d2c563 100644 --- a/comfy_extras/nodes_model_advanced.py +++ b/comfy_extras/nodes_model_advanced.py @@ -5,22 +5,6 @@ import nodes import torch import node_helpers -class CFGCutoff: - @classmethod - def INPUT_TYPES(s): - return {"required": {"model": ("MODEL",), "cfg_stop_index": ("INT", {"default": -1, "min": -1, })}} - - RETURN_TYPES = ("MODEL",) - FUNCTION = "patch" - - CATEGORY = "advanced/model" - - def patch(self, model, cfg_stop_index): - diff_model = model.model.diffusion_model - if hasattr(diff_model, "set_cfg_stop_index"): - diff_model.set_cfg_stop_index(cfg_stop_index) - - return (model,) class LCM(comfy.model_sampling.EPS): def calculate_denoised(self, sigma, model_output, model_input): @@ -342,5 +326,4 @@ NODE_CLASS_MAPPINGS = { "ModelSamplingFlux": ModelSamplingFlux, "RescaleCFG": RescaleCFG, "ModelComputeDtype": ModelComputeDtype, - "CFGCutoff": CFGCutoff }