Skip to content

Separate denoised and noise estimation in Euler CFG++ #9008

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

Merged
merged 1 commit into from
Jul 23, 2025

Conversation

chaObserv
Copy link
Contributor

This will change their behavior with the sampling CONST type. It also combines Euler CFG++ and Euler ancestral CFG++ into one main function.

The current CFG++

The current Euler CFG++ can work on the CONST sampling type (RF), which matches the algorithm from the appendix of the paper, but the guidance scale must be very low (~0.1), and it’s unstable.
It tends to oversaturate when given more steps under the same guidance scales that seem to work with fewer steps.

ComfyUI_current_cfgpp_00001_resized

CFG++ for flow models

Recently, the official proposed a new approach for flow models, which separates denoised and noise estimation during sampling.

It changes the algorithm back to

eps_uncond = (x_s - alpha_s * uncond_denoised) / sigma_s
x_t = alpha_t * denoised_cfg + sigma_t * eps_uncond

instead of

x_t = denoised_cfg + sigma_t * v_uncond

With this change, the behavior of the guidance scale is more similar to the other sampling types.
ComfyUI_pr_cfgpp_00001_resized

This should make it more usable with flow.

Euler ancestral CFG++

The current euler_ancestral_RF is more similar to the "Overshoot Sampling" approach (from the AMO sampler), which takes a larger step along the velocity and rescales to the next state with noise compensation.
This method doesn't separate denoised and noise, so it's probably not suitable for CFG++.

alpha_ratio * (denoised_cfg + sigma_down * v_uncond) + renoise

Euler ancestral in k-diffusion seems to implement DDIM's eta parameter, which controls the interpolation between deterministic DDIM (eta = 0) and stochastic DDPM (eta = 1). A simple strategy is to preserve the original algorithm and apply RF's alpha and sigma, just like SANA's adaptation of dpm-solver to flow-dpm-solver. It can also match the "Stochastic Curved Euler Sampler", a DDPM variant for RF. (Algorithm 1 in 2506.15864).
圖片

The ancestral CFG++ seems fine in the current implementation.
ComfyUI_pr_cfgpp_ancestral_00001_

All the examples are generated by SD3.5 medium with simple scheduler.

This will change their behavior with the sampling CONST type.
It also combines euler_cfg_pp and euler_ancestral_cfg_pp into one main function.
@comfyanonymous comfyanonymous merged commit e729a5c into comfyanonymous:master Jul 23, 2025
6 checks passed
SurpassHR pushed a commit to SurpassHR/ComfyUI-Playground that referenced this pull request Jul 24, 2025
…#9008)

This will change their behavior with the sampling CONST type.
It also combines euler_cfg_pp and euler_ancestral_cfg_pp into one main function.
rakki194 pushed a commit to rakki194/ComfyUI that referenced this pull request Jul 29, 2025
…#9008)

This will change their behavior with the sampling CONST type.
It also combines euler_cfg_pp and euler_ancestral_cfg_pp into one main function.
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