automatic icon indicating copy to clipboard operation
automatic copied to clipboard

[Feature]: New sampler: "Restart"

Open Centurion-Rome opened this issue 2 years ago • 10 comments

Feature description

Saw on Reddit: https://www.reddit.com/r/StableDiffusion/comments/14n6vt7/new_sampler_restart/ and sounds interesting:

Generative processes that involve solving differential equations, such as diffusion models, frequently necessitate balancing speed and quality. ODE-based samplers are fast but plateau in performance while SDE-based samplers deliver higher sample quality at the cost of increased sampling time. We attribute this difference to sampling errors: ODE-samplers involve smaller discretization errors while stochasticity in SDE contracts accumulated errors. Based on these findings, we propose a novel sampling algorithm called Restart in order to better balance discretization errors and contraction.

Empirically, Restart sampler surpasses previous diffusion SDE and ODE samplers in both speed and accuracy. Restart not only outperforms the previous best SDE results, but also accelerates the sampling speed by 10-fold / 2-fold on CIFAR-10 / ImageNet.

In addition, it attains significantly better sample quality than ODE samplers within comparable sampling times. Moreover, Restart better balances text-image alignment/visual quality versus diversity than previous samplers in the large-scale text-to-image Stable Diffusion model pre-trained on LAION .

b5zhupg5

Results on Stable Diffusion v1.5: z2a639r4

More details

Paper: https://arxiv.org/abs/2306.14878 Github: https://github.com/newbeeer/diffusion_restart_sampling

Sampler implementation code: https://github.com/Newbeeer/diffusion_restart_sampling/blob/b1e0022406e619cafb118a69b70a90484fb84c94/diffuser/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py#L676-L817

Version Platform Description

No response

Centurion-Rome avatar Jun 30 '23 18:06 Centurion-Rome

Yeah I wasn't sure where to post it so I made a discussion thread, probably should've started with a feature request duh.

drax-xard avatar Jun 30 '23 18:06 drax-xard

Not too late 😁

vladmandic avatar Jun 30 '23 19:06 vladmandic

Unofficial ComfyUI implementation: https://github.com/ssitu/ComfyUI_restart_sampling

drax-xard avatar Jul 01 '23 15:07 drax-xard

Now if only ComfyUI's samplers and A1111's samplers didn't take completely different arguments.

lendrick avatar Jul 04 '23 18:07 lendrick

Oh, I've no idea how they implement stuff, haven't tried ComfyUI yet, I just thought it could be useful.

drax-xard avatar Jul 04 '23 20:07 drax-xard

Is this coming to SD.NEXT? This is one of the more unique samplers.

ghost avatar Oct 19 '23 01:10 ghost

How do I get this working in SD.Next?

gohan2091 avatar Dec 04 '23 18:12 gohan2091

How do I get this working in SD.Next?

is it marked as COMPLETE? no? then what are you asking for?

vladmandic avatar Dec 04 '23 19:12 vladmandic

anyone interested in this, note that author still has this as status:

TODO: merge into the diffuser repo.

i cannot proceed as much as i'd like as this work is done in a separate/incompatible version of diffusers. if you're interested, create feature request on the authors git repo to actually merge his changes so others can actually use that sampler.

vladmandic avatar Feb 15 '24 17:02 vladmandic

Thank you. I am still interested in this so I opened an issue here: https://github.com/Newbeeer/diffusion_restart_sampling/issues/5

I encourage others to add their support so the author sees it.

ghost avatar Feb 16 '24 01:02 ghost

closing since author is gone for 2y+.

vladmandic avatar Feb 14 '25 16:02 vladmandic