Diffusion Sampler Theory: ODE Solvers and Acceleration
Module: Generative AI | Difficulty: Advanced
Probability Flow ODE
Shares marginals with the SDE but is deterministic.
DDIM
DPM-Solver++ (2nd Order)
Consistency Models
class DPM_Solver:
def __init__(self, model, alphas):
self.model, self.alphas = model, alphas
def step(self, x_t, t_i, t_next):
a_i, a_n = self.alphas[t_i], self.alphas[t_next]
s_i, s_n = (1-a_i).sqrt(), (1-a_n).sqrt()
eps = self.model(x_t, t_i)
x0 = (x_t - s_i*eps)/a_i
return a_n*x0 + s_n*eps
| Method | Steps | FID | Time |
|---|---|---|---|
| DDPM | 1000 | 3.17 | 2800ms |
| DDIM | 50 | 3.52 | 150ms |
| DPM-Solver++ | 20 | 3.21 | 60ms |
| Consistency | 1 | 4.12 | 3ms |