Skip to content

Add Custom Scheduler #694

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

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

Add Custom Scheduler #694

wants to merge 3 commits into from

Conversation

rmatif
Copy link

@rmatif rmatif commented May 27, 2025

Inspired by https://github.com/BlakeOne/ComfyUI-CustomScheduler

318997896-c5c258ec-49ba-4062-a3aa-9d019d693bfd

This PR adds a custom scheduler that allows users to manually specify the sigma values for each step.

This is especially useful for debugging when integrating new models that don't work with existing schedulers, or for inference with distilled models such as SID, SIDA or SwD

The number of sigma values must match the number of steps. If n_sigmas < steps, the missing values will currently be filled with zeros. I'm considering whether to keep this behavior or instead repeat the last sigma value to fill the vector.

Example command:

./build/bin/sd -m SiDA_SD15_4.54.54.5_1_lsd100_lsggan0.001_NoEMA_SNR_025634_checkpoint.safetensors -v -p "A photograph of a cat in winter wonderland. 8k resolution" --cfg-scale 1 --steps 1 --sigmas "2.5" --seed 2025

For multi-steps, use for example--sigmas "sigma_0,sigma_1,sigma_2,sigma_3....."

Step sigma_0 = 2.5 Default Scheduler
Step 1 sigma_on sigma_off

I've uploaded a SiDA model checkpoint if someone want to test : SIDA 1.5

@@ -1575,7 +1583,26 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx,

size_t t0 = ggml_time_ms();

std::vector<float> sigmas = sd_ctx->sd->denoiser->get_sigmas(sample_steps);
std::vector<float> sigmas_for_generation;
if (custom_sigmas_count > 0 && custom_sigmas != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could extract this block into a method and share it between txt2img, img2img and img2vid. txt2img seems to have additional logging the other two are missing.

Copy link
Author

Choose a reason for hiding this comment

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

@idostyle thanks for the review. I’ve extracted the sigma preparation into a shared helper, you're right, it's better for maintainability

@rmatif rmatif requested a review from idostyle May 27, 2025 16:26
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.

2 participants