mcmonkeyprojects / sd-dynamic-thresholding

Dynamic Thresholding (CFG Scale Fix) for Stable Diffusion (eSwarmUI, ComfyUI, and Auto WebUI)
MIT License
1.12k stars 107 forks source link

Vladmandic SDNext Issue RuntimeError: Cannot use secondary sampler PLMS with Dynamic Thresholding #63

Open Lucius338 opened 1 year ago

Lucius338 commented 1 year ago

Clean install of the Vladmandic fork installed today, but for some reason I cannot get dynamic thresholding to work for the life of me. Tried disabling all extensions, including Controlnet, no dice. I think it has to do with PLMS being set as the default sampler in this fork, and I can't find a way to change it in the config file. At first, I received the same error but it said "Cannot use secondary sampler DDIM with Dynamic Thresholding." Is one of the optimizations responsible for assigning a second sampler?

16:44:43-323693 ERROR Running script process batch: C:\sdnext082023\extensions-builtin\sd-dynamic-thresholding\scripts\dynamic_thresholding.py: RuntimeError ┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐ │ C:\sdnext082023\modules\scripts.py:451 in process_batch │ │ │ │ 450 │ │ │ │ args = p.per_script_args.get(script.title(), p.script_args[script.args_f │ │ > 451 │ │ │ │ script.process_batch(p, *args, **kwargs) │ │ 452 │ │ │ │ s.append(f'{script.title()}:{round(time.time()-t0, 2)}s') │ │ │ │ C:\sdnext082023\extensions-builtin\sd-dynamic-thresholding\scripts\dynamic_thresholding.py:99 in process_batch │ │ │ │ 98 │ │ if orig_latent_sampler_name in ["DDIM", "PLMS"]: │ │ > 99 │ │ │ raise RuntimeError(f"Cannot use secondary sampler {orig_latent_sampler_name} │ │ 100 │ │ if 'UniPC' in (orig_sampler_name, orig_latent_sampler_name) and p.enable_hr: │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ RuntimeError: Cannot use secondary sampler PLMS with Dynamic Thresholding

mcmonkey4eva commented 1 year ago

... Why the heck is PLMS default? 0.o that sampler is really weird, and has a lot of compatibility issues as you see here.

I'd recommend DPM++ 2M Karras as a go-to default for most usages (or Euler if you want the slower basic one that's highly replicable)

Lucius338 commented 1 year ago

... Why the heck is PLMS default? 0.o that sampler is really weird, and has a lot of compatibility issues as you see here.

I'd recommend DPM++ 2M Karras as a go-to default for most usages (or Euler if you want the slower basic one that's highly replicable)

Yeah, idk why, I swear there was a way to change the default sampler in the config before but I can't find it anymore.

Anyways, I found the issue. I didn't even think about second pass because I hadn't been using it, but even with Second Pass disabled, if its sampler is set to default, it's enough to trip up Dynamic Thresholding. The workaround for now is manually changing the second pass sampler even if you're not using it.

vladmandic commented 1 year ago

... Why the heck is PLMS default? 0.o that sampler is really weird, and has a lot of compatibility issues as you see here.

default in sdnext is whatever is set as default in a loaded model. sdnext doesn't choose plms itself. (a1111 does not have that concept of "default", sampler must always be set to a user-value)

regardless of that, i suggest to change logic to fallback to primary sampler is selected latent sampler is not set to a compatible one - raising RuntimeError is not a user-friendly behavior.

slightly off-topic, unipc is also blacklisted by extension because it doesn't support img2img - that was the case long time ago, sdnext supports unipc fully for txt2img and img2img.

btw, you've closed the issue really fast without the chance to provide actual information. imo, the recommendation i've posted is still very much valid.