Add Heun and DPM-Solver-2-like samplers((high-order solvers widely used in diffusion-based image generation)) - #11
Open
Fangjiage-1 wants to merge 5 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds two deterministic second-order sampling baselines to the PyTorch ELF implementation:
Together with the existing ODE/Euler method, the sampling code now exposes three methods:
odeheundpm_solver_2_likeChanges
_heun_step()tosrc/utils/sampling_utils.py._dpm_solver_2_like_step()tosrc/utils/sampling_utils.py.src/utils/generation_utils.pyto import and dispatch the three supported methods.Sampler details
Heun
The Heun sampler uses two network evaluations per regular interval:
DPM-Solver-2-like
The DPM-Solver-2-like sampler performs:
This method is inspired by DPM-Solver-2, but it is specifically adapted to ELF's flow-matching formulation and is not a direct reproduction of the original image-diffusion implementation.
Compute matching
The provided configurations use:
The second-order methods use two network evaluations for each regular interval, while the final interval uses the original ODE/Euler update.
Files changed
src/utils/sampling_utils.pysrc/utils/generation_utils.pysrc/configs/sampling_configs/uncond_sampling_configs.ymlsrc/configs/sampling_configs/cond_sampling_configs.ymlValidation
_sde_stepimport or dispatch remains.