Skip to content

feat: adapt res samplers for flow models for eta > 0#1436

Open
wbruna wants to merge 1 commit intoleejet:masterfrom
wbruna:sd_res_flow
Open

feat: adapt res samplers for flow models for eta > 0#1436
wbruna wants to merge 1 commit intoleejet:masterfrom
wbruna:sd_res_flow

Conversation

@wbruna
Copy link
Copy Markdown
Contributor

@wbruna wbruna commented Apr 18, 2026

This adjusts the noise addition steps to follow the flow math. I believe the deterministic steps do not need further changes, apart from the sigma_up and sigma_down values.

@rmatif , could you please take a look?

@clort81
Copy link
Copy Markdown

clort81 commented Apr 21, 2026

I'm confused: existing get_ancestral_step is this:

    static std::pair<float, float> get_ancestral_step(float sigma_from, float sigma_to, float eta = 1.0f) {
    float sigma_up   = 0.0f;
    float sigma_down = sigma_to;
            
    if (eta <= 0.0f) {
        return {sigma_down, sigma_up};
    }   
    
    float sigma_from_sq = sigma_from * sigma_from;
    float sigma_to_sq   = sigma_to * sigma_to;
    if (sigma_from_sq > 0.0f) {
        float term = sigma_to_sq * (sigma_from_sq - sigma_to_sq) / sigma_from_sq;
        sigma_up   = std::min(sigma_to, eta * std::sqrt(std::max(term, 0.0f)));
    }   
    
    float sigma_down_sq = sigma_to_sq - sigma_up * sigma_up;
    sigma_down          = sigma_down_sq > 0.0f ? std::sqrt(sigma_down_sq) : 0.0f;
    return {sigma_down, sigma_up};
}

Does your pull request upgrade this function?

@wbruna
Copy link
Copy Markdown
Contributor Author

wbruna commented Apr 21, 2026

Does your pull request upgrade this function?

Kind of: when running a flow model, it switches the samplers to use the similar get_ancestral_step_flow, and apply the additional signal scale. It's the same change that was done in #1374 for Euler Ancestral.

Note that eta=0 produces the same results on the two variants, and it's the default for these samplers, so you'll only notice a difference if you change it:

eta master PR
0.0 test_1776809473 test_1776809935
1.0 test_1776809502 test_1776809976

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