Skip to content

Add Custom Scheduler#694

Merged
leejet merged 6 commits into
leejet:masterfrom
rmatif:sigmas
Dec 13, 2025
Merged

Add Custom Scheduler#694
leejet merged 6 commits into
leejet:masterfrom
rmatif:sigmas

Conversation

@rmatif

@rmatif rmatif commented May 27, 2025

Copy link
Copy Markdown
Contributor

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

Comment thread stable-diffusion.cpp Outdated

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
Copy Markdown
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
Copy Markdown
Contributor 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
@vmobilis

vmobilis commented Jun 1, 2025

Copy link
Copy Markdown
Contributor

@rmatif, hello, maybe add very basic expressions support?
Like in rmatif#1?

(Sorry for making dummy PR, I couldn't find a better way to explain the changes). 😅

And thank you!

@leejet

leejet commented Dec 13, 2025

Copy link
Copy Markdown
Owner

Thank you for your contribution.

@leejet leejet merged commit 8f05f5b into leejet:master Dec 13, 2025
9 checks passed
@Green-Sky

Copy link
Copy Markdown
Contributor

... shouldnt this sampler technically be called "discrete" ? :)

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.

5 participants