stable-diffusion.cpp icon indicating copy to clipboard operation
stable-diffusion.cpp copied to clipboard

feat: add LCM scheduler and use it by default for LCM sampling

Open wbruna opened this issue 1 month ago • 0 comments

Implement the linear LCM scheduler, as defined e.g. in Diffusers' LCMScheduler, and select it by default with the LCM sampler.

The main change is ensuring the timesteps match the LCM training schedule. The default discrete scheduler can choose unmatched timesteps, which tend to require higher step counts to avoid artifacts and blurring. It is more noticeable with detailed images, or when the model isn't pushed too hard (e.g. with minimal prompts). simple and sgm_uniform tend to generate much better results, but I’d guess that’s mostly by chance.

Not every generation is better, and when compared with simple, it isn’t clear there’s even a benefit; but it’s easier to notice the difference when comparing with discrete. A few examples with 4 steps, somewhat cherry‑picked to avoid the worst abominations:

discrete lcm
lcm_1763329553 lcm_1763329568
lcm_1763329678 lcm_1763329680
lcm_1763330029 lcm_1763330042
lcm_1763329682 lcm_1763329719

I can’t properly test video generation, so I didn’t change its default; just let me know if I should.

Another consideration: since this change mostly affects how the timesteps are rounded, a better alternative might be adding an extra parameter to all schedulers to request this behavior. This could make LCM models (and perhaps other distillations) behave better across all schedulers at once.

wbruna avatar Nov 16 '25 23:11 wbruna