diff --git a/modules/sd_samplers_cfg_denoiser.py b/modules/sd_samplers_cfg_denoiser.py index b6fbf337243..9e2d8e9f98e 100644 --- a/modules/sd_samplers_cfg_denoiser.py +++ b/modules/sd_samplers_cfg_denoiser.py @@ -160,7 +160,10 @@ def forward(self, x, sigma, uncond, cond, cond_scale, s_min_uncond, image_cond): if sd_samplers_common.apply_refiner(self, sigma): cond = self.sampler.sampler_extra_args['cond'] uncond = self.sampler.sampler_extra_args['uncond'] - + + # Ensures the scheduler respects the requested step count and halts excess iterations + if self.step >= self.total_steps: + raise sd_samplers_common.InterruptedException # at self.image_cfg_scale == 1.0 produced results for edit model are the same as with normal sampling, # so is_edit_model is set to False to support AND composition. is_edit_model = shared.sd_model.cond_stage_key == "edit" and self.image_cfg_scale is not None and self.image_cfg_scale != 1.0