Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DDIM with the "trailing" timestep spacing and TCD #568

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yslai
Copy link

@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
@@ -219,7 +224,7 @@ void print_usage(int argc, const char* argv[]) {
printf(" 1.0 corresponds to full destruction of information in init image\n");
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

wbruna commented Jan 19, 2025

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

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.

3 participants