Skip to content

Conversation

@yslai
Copy link
Contributor

@yslai yslai commented Jan 12, 2025

I noticed that due to the structure of k-diffusion, stable-diffusion.cpp does not support DDIM and TCD, which are particularly useful for acceleration techniques like Hyper-SD. This patch implements DDIM ("trailing" timestep spacing version) and TCD on top of the k-diffusion structure, by recalculating the beta_t schedule and cumulative alpha_t products, and then use them to undo the scaling functions in k-diffusion to match DDIM/TCD. The (stochastic) eta parameter in DDIM and TCD is also implemented, in order for TCD to be useful for Hyper-SD in multi-step settings.

@yslai yslai changed the title Implement DDIM with the "trailing" timestep spacing Implement DDIM with the "trailing" timestep spacing and TCD Jan 14, 2025
printf(" -H, --height H image height, in pixel space (default: 512)\n");
printf(" -W, --width W image width, in pixel space (default: 512)\n");
printf(" --sampling-method {euler, euler_a, heun, dpm2, dpm++2s_a, dpm++2m, dpm++2mv2, ipndm, ipndm_v, lcm}\n");
printf(" --sampling-method {euler, euler_a, heun, dpm2, dpm++2s_a, dpm++2m, dpm++2mv2, ipndm, ipndm_v, lcm, ddim_trailing}\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to add TCD here. At some point it will be cleaner to iterate over sample_method_str[] for printing the help message.

@wbruna
Copy link
Contributor

wbruna commented Jan 19, 2025

Both DDIM and TCD work very well with PCM LoRAs, too. Tested with SD 1.5 and SDXL.

@leejet leejet merged commit 19d876e into leejet:master Feb 22, 2025
@leejet
Copy link
Owner

leejet commented Feb 22, 2025

Thank you for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants