S CORE -B ASED G ENERATIVE M ODELING WITH C RITICALLY -D AMPED L ANGEVIN D IFFUSION
A BSTRACT
Score-based generative models (SGMs) have demonstrated remarkable synthesis quality.
SGMs rely on a diffusion process that gradually perturbs the data towards a tractable distribution, while the generative model learns to denoise.
The complexity of this denoising task is, apart from the data distribution itself, uniquely determined by the diffusion process.
We argue that current SGMs employ overly simplistic diffusions, leading to unnecessarily complex denoising processes, which limit generative modeling performance.
Based on connections to statistical mechanics, we propose a novel critically-damped Langevin diffusion (CLD) and show that CLD-based SGMs achieve superior performance.
CLD can be interpreted as running a joint diffusion in an extended space, where the auxiliary variables can be considered “velocities” that are coupled to the data variables as in Hamiltonian dynamics.
We derive a novel score matching objective for CLD and show that the model only needs to learn the score function of the conditional distribution of the velocity given data, an easier task than learning scores of the data directly.
We also derive a new sampling scheme for efficient synthesis from
CLD-based diffusion models.
We find that CLD outperforms previous SGMs in synthesis quality for similar network architectures and sampling compute budgets.
We show that our novel sampler for CLD significantly outperforms solvers such as
Euler–Maruyama.
Our framework provides new insights into score-based denoising diffusion models and can be readily used for high-resolution image synthesis.
Project page and code: https://nv-tlabs.github.io/CLD-SGM .
I NTRODUCTION
Score-based generative models ( SGMs) and denoising diffusion probabilistic models have emerged as a promising class of generative models (Sohl-Dickstein et al., 2015; Song et al., 2021c;b; Vahdat et al., 2021; Kingma et al., 2021).
SGMs offer high quality synthesis and sample diversity, do not require adversarial objectives, and have found applications in image (Ho et al., 2020; Nichol &
Dhariwal, 2021; Dhariwal & Nichol, 2021; Ho et al., 2021), speech (Chen et al., 2021; Kong et al., 2021; Jeong et al., 2021), and music synthesis (Mittal et al., 2021), image editing (Meng et al., 2021; Sinha et al., 2021; Furusawa et al., 2021), super-resolution (Saharia et al., 2021; Li et al., 2021), image-to-image translation (Sasaki et al., 2021), and 3D shape generation (Luo & Hu, 2021;
Zhou et al., 2021).
SGMs use a diffusion process to gradually add noise to the data, transforming a complex data distribution into an analytically tractable prior distribution.
A neural network is then utilized to learn the score function—the gradient of the log probability density—of the perturbed data.
The learnt scores can be used to solve a stochastic differential equation (SDE) to synthesize new samples.
This corresponds to an iterative denoising process, inverting the forward diffusion.
In the seminal work by Song et al.
(2021c)
, it has been shown that the score function that needs to be learnt by the neural network is uniquely determined by the forward diffusion process.
Consequently, the complexity of the learning problem depends, other than on the data itself, only on the diffusion.
Hence, the diffusion process is the key component of SGMs that needs to be revisited to further improve SGMs, for example, in terms of synthesis quality or sampling speed.
Inspired by statistical mechanics (Tuckerman, 2010), we propose a novel forward diffusion process, the critically-damped Langevin diffusion (CLD) .
In CLD, the data variable, x t (time t along the diffusion), is augmented with an additional “velocity” variable v t and a diffusion process is run in the joint data-velocity space.
Data and velocity are coupled to each other as in Hamiltonian dynamics, and noise is injected only into the velocity variable.
As in Hamiltonian Monte Carlo (Duane et al., 1987; Neal, 2011), the Hamiltonian component helps to efficiently traverse the joint data-velocity space and to transform the data distribution into the prior distribution more smoothly.
We derive the corresponding score matching objective and show that for CLD the neural network is tasked with learning only the score of the conditional distribution of velocity given data ∇ v t log p t ( v t | x t ) , which is arguably easier than learning the score of diffused data directly.
Using techniques from molecular dynamics (Bussi & Parrinello, 2007; Tuckerman, 2010; Leimkuhler & Matthews, 2013), we also derive a new SDE integrator tailored to CLD’s reverse-time synthesis SDE.
We extensively validate CLD and the novel SDE solver: (i) We show that the neural networks learnt in CLD-based SGMs are smoother than those of previous SGMs.
(ii)
On the CIFARimage modeling benchmark, we demonstrate that CLD-based models outperform previous diffusion models in synthesis quality for similar network architectures and sampling compute budgets.
We attribute these positive results to the Hamiltonian component in the diffusion and to CLD’s easier score function target, the score of the velocity-data conditional distribution ∇ v t log p t ( v t | x t ) .
(iii)
We show that our novel sampling scheme for CLD significantly outperforms the popular Euler– Maruyama method.
(iv) We perform ablations on various aspects of CLD and find that CLD does not have difficult-to-tune hyperparameters.
In summary, we make the following technical contributions: (i)
We propose CLD, a novel diffusion process for SGMs.
(ii)
We derive a score matching objective for CLD, which requires only the conditional distribution of velocity given data.
(iii)
We propose a new type of denoising score matching ideally suited for scalable training of CLD-based SGMs.
(iv) We derive a tailored SDE integrator that enables efficient sampling from CLD-based models.
(v) Overall, we provide novel insights into SGMs and point out important new connections to statistical mechanics.
B ACKGROUND
Consider a diffusion process u t ∈ R d defined by the Itˆo SDE
[Equation]
with continuous time variable t ∈ [0 , T ] , standard Wiener process w t , drift coefficient f : R d × [0 , T ] → R d and diffusion coefficient G : R d × [0 , T ] → R d × d .
Defining ¯ u t :=
u T − t , a correspond- ing reverse-time diffusion process that inverts the above forward diffusion can be derived (Anderson, 1982; Haussmann & Pardoux, 1986; Song et al., 2021c)
(with positive dt and t ∈ [0 , T ] ):
[Equation]
where ∇ ¯ u t log p T − t ( ¯ u t ) is the score function of the marginal distribution over ¯ u t at time T − t .
The reverse-time process can be used as a generative model.
In particular, Song et al.
(2021c) model data x , setting p ( u 0 )=
p data ( x ) .
Currently used SDEs (Song et al., 2021c; Kim et al., 2021) have drift and diffusion coefficients of the simple form f ( x t , t )=
f ( t ) x t and G ( x t , t )
=
g ( t ) I d .
Generally, f and G are chosen such that the SDE’s marginal, equilibrium density is approximately Normal at time T , i.e., p ( u T ) ≈N ( 0 , I d ) .
We can then initialize x 0 based on a sample drawn from a complex data distribution, corresponding to a far-from-equilibrium state.
While the state x 0 relaxes towards equilibrium via the forward diffusion, we can learn a model s θ ( x t , t ) for the score ∇ x t log p t ( x t ) , which can be used for synthesis via the reverse-time SDE in Eq.
If f and G take the simple form from above, the denoising score matching (Vincent, 2011) objective for this task is:
[Equation]
If f and G are affine, the conditional distribution p t ( x t | x 0 ) is Normal and available analytically (S¨arkk¨a & Solin, 2019).
Different λ ( t ) result in different trade-offs between synthesis quality and likelihood in the generative model defined by s θ ( x t , t ) (Song et al., 2021b; Vahdat et al., 2021).
C RITICALLY -D AMPED L ANGEVIN D IFFUSION
We propose to augment the data x t ∈ R d with auxiliary velocity 1 variables v t ∈ R d and utilize a diffusion process that is run in the joint x t - v t -space.
With u t = ( x t , v t ) ⊤ ∈ R 2 d , we set f ( u t , t ) :
[Equation]
where ⊗ denotes the Kronecker product.
The coupled SDE that describes the diffusion process is
[Equation]
) which corresponds to Langevin dynamics in each dimension.
That is, each x i is independently coupled to a velocity v i , which explains the blockwise structure of f and G .
The mass M ∈ R
+ is a hyperparameter that determines the coupling between the x t and v t variables; β ∈ R
+ is a constant time rescaling chosen such that the diffusion converges to its equilibrium distribution within t ∈ [0 , T ] (in practice, we set T =1 ) when initialized from a data-defined non-equilibrium state and is analogous to β ( t ) in previous diffusions (we could also use time-dependent β ( t ) , but found constant β ’s to work well, and therefore opted for simplicity); Γ ∈ R + is a friction coefficient that determines the strength of the noise injection into the velocities.
Notice that the SDE in Eq.
(5) consists of two components.
The H term represents a Hamiltonian component.
Hamiltonian dynamics are frequently used in Markov chain Monte Carlo methods to accelerate sampling and efficiently explore complex probability distributions (Neal, 2011).
The Hamiltonian component in our diffusion process plays a similar role and helps to quickly and smoothly converge the initial joint data-velocity distribution to the equilibrium, or prior (see Fig. 1).
Furthermore, Hamiltonian dynamics on their own are trivially invertible (Tuckerman, 2010), which intuitively is also beneficial in our situation when using this diffusion for training SGMs.
The O term corresponds to an Ornstein-Uhlenbeck process (S ¨ arkk ¨ a & Solin, 2019) in the velocity component, which injects noise such that the diffusion dynamics properly converge to equilibrium for any Γ > 0 .
It can be shown that the equilibrium distribution of this diffusion is p EQ ( u ) =
N ( x ; 0 d , I d ) N ( v ; 0 d , M I d ) (see App.
B.2).
There is a crucial balance between M and Γ (McCall, 2010):
For Γ 2 < 4 M ( underdamped Langevin dynamics) the Hamiltonian component dominates, which implies oscillatory dynamics of x t and v t that slow down convergence to equilibrium.
For Γ 2 > 4 M ( overdamped Langevin dynamics)
the Oterm dominates which also slows down convergence, since the accelerating effect by the Hamiltonian component is suppressed due to the strong noise injection.
For Γ 2 =4 M ( critical damping ), an ideal balance is achieved and convergence to p EQ ( u ) occurs as fast as possible in a smooth manner without oscillations (also see discussion in App. A.1)
(McCall, 2010).
Hence, we propose to set Γ 2 =4 M and call the resulting diffusion critically-damped Langevin diffusion (CLD) (see Fig. 1).
Diffusions such as the VPSDE (Song et al., 2021c) correspond to overdamped Langevin dynamics with high friction coefficients Γ (see App.
A.2).
Furthermore, in previous works noise is injected directly into the data variables (pixels, for images).
In CLD, only the velocity variables are subject to direct noise and the data is perturbed only indirectly due to the coupling between x t and v t .
3. S CORE M ATCHING O BJECTIVE
Considering the appealing convergence properties of
CLD, we propose to utilize
CLD as forward diffusion process in SGMs.
To this end we initialize the joint p ( u 0 )
=
p ( x 0 ) p ( v 0 )
=
p data ( x 0 ) N ( v 0 ; 0 d , γM I d ) with hyperparameter γ< 1 and let the distribution diffuse towards the tractable equilibrium—or prior—distribution p EQ ( u ) .
We can then learn the corresponding score functions and define CLD-based SGMs
Following a similar derivation as Song et al.
(2021b) we obtain the score matching (SM) objective (see App.
B.3):
[Equation]
Notice that this objective requires only the velocity gradient of the log-density of the joint distribution, i e., ∇ v t log p t ( u t ) .
This is a direct consequence of injecting noise into the velocity variables only .
Without loss of generality, p t ( u t )=
p t ( x t , v t )=
p t ( v t | x t ) p t ( x t ) .
Hence,
[Equation]
This means that in CLD the neural network-defined score model s θ ( u t , t ) only needs to learn the score of the conditional distribution p t ( v t | x t ) , an arguably easier task than learning the score of p t ( x t ) , as in previous works, or of the joint p t ( u t ) .
This is the case, because our velocity distribution is initialized from a simple Normal distribution, such that p t ( v t | x t ) is closer to a Normal distribution for all t ≥ 0 (and for any x t ) than p t ( x t ) itself.
This is most evident at t =0 :
The data and velocity distributions are independent at t =
and the score of p 0 ( v 0 | x 0 )
=
p 0 ( v 0 ) simply corresponds to the score of the Normal distribution p 0 ( v 0 ) from which the velocities are initialized, whereas the score of the data distribution p 0 ( x 0 ) is highly complex and can even be unbounded (Kim et al., 2021).
We empirically verify the reduced complexity of the score of p t ( v t | x t ) in
Fig.
We find that the score that needs to be learnt by the model is more similar to a score corresponding to a
Normal distribution for CLD than for the VPSDE.
We also measure the complexity of the neural networks that were learnt to model this score via the squared Frobenius norm of their Jacobians.
We find that the CLD-based SGMs have significantly simpler and smoother neural networks than
VPSDE-based SGMs for most t , in particular when leveraging a mixed score formulation (see next section).
3. S CALABLE T RAINING
A Practical Objective.
We cannot train directly with
Eq.
(6), since we do not have access to the marginal distribution p t ( u t ) .
As presented in Sec. 2, we could employ denoising score matching (DSM) and instead sample u 0 , and diffuse those samples, which would lead to a tractable objective.
However, recall that in CLD the distribution at t =0 is the product of a complex data distribution and a Normal distribution over the initial velocity.
Therefore, we propose a hybrid version of score matching (Hyv¨arinen, 2005) and denoising score matching (Vincent, 2011), which we call hybrid score matching (HSM).
In
HSM, we draw samples from p 0 ( x 0 )=
p data ( x 0 ) as in DSM, but then diffuse those samples while marginalizing over the full initial velocity distribution p 0 ( v 0 )=
N ( v ; 0 d , γM I d ) as in regular SM (HSM is discussed in detail in App. C).
Since p 0 ( v 0 ) is Normal (and f and G affine), p ( u t | x 0 ) is also Normal and this remains tractable.
We can write this HSM objective as:
[Equation]
In HSM, the expectation over p 0 ( v 0 ) is essentially solved analytically, while DSM would use a sample-based estimate.
Hence, HSM reduces the variance of training objective gradients compared to pure DSM, which we validate in App.
C.1. Furthermore, when drawing a sample u 0 to diffuse in DSM, we are essentially placing an infinitely sharp Normal with unbounded score (Kim et al., 2021) at u 0 , which requires undesirable modifications or truncation tricks for stable training (Song et al., 2021c; Vahdat et al., 2021).
Hence, with DSM we could lose some benefits of the CLD framework discussed in Sec. 3.1, whereas HSM is tailored to CLD and fundamentally avoids such unbounded scores.
Closed form expressions for the perturbation kernel p t ( u t | x 0 ) are provided in App.
B.1.
Score Model Parametrization.
(i)
Ho et al.
(2020) found that it can be beneficial to parameterize the score model to predict the noise that was used in the reparametrized sampling to generate perturbed samples u t .
For CLD, u t = µ t ( x 0 )
+ L t ϵ 2 d , where Σ t =
L t L ⊤ t is the Cholesky decomposition of p t ( u t | x 0 ) ’s covariance matrix, ϵ 2 d ∼ N ( ϵ 2 d ; 0 2 d , I 2 d ) , and µ t ( x 0 ) is p t ( u t | x 0 )
’s mean.
Furthermore, ∇ [Equation] ( u [Equation]
[Equation] :2 d , where ϵ d :2 d denotes those d components of ϵ 2 d that actually affect [Equation] (since we take velocity gradients only, not all are relevant).
With
[Equation]
⊗ [Equation] we have
[Equation]
(ii) Vahdat et al. (2021) showed that it can be beneficial to assume that the diffused marginal distribution is Normal at all times and parametrize the model with a Normal score and a residual “correction”.
For CLD, the score is indeed Normal at t =
(due to the independently initialized x and v at t =0 ).
Similarly, the target score is close to Normal for large t , as we approach the equilibrium.
Based on (i) and (ii) , we parameterize s θ ( u t , t ) = − ℓ t
α θ ( u t , t ) with α θ ( u t , t ) =
ℓ − 1 t v t / Σ vvt + α ′ θ ( u t , t ) , where Σ vvt corresponds to the v - v component of the “per-dimension” covariance matrix of the Normal distribution p t ( u t | x 0 = 0 d ) .
In other words, we assumed p 0 ( x 0 )
=
δ ( x ) when defining the analytic term of the score model.
Formally, − v / Σ vvt is the score of a Normal distribution with covariance ˆΣ vvt I d .
Following Vahdat et al.
, we refer to this parameterization as mixed score parameterization .
Alternative model parameterizations are possible, but we leave their exploration to future work.
With this definition, the HSM training objective becomes (details in App.
B.3):
[Equation]
[Equation]
) which corresponds to training the model to predict the noise only injected into the velocity during reparametrized sampling of u t , similar to noise prediction in Ho et al.
Song et al.
(2021c).
Objective Weightings.
For λ ( t ) =
Γ β , the objective corresponds to maximum likelihood learning (Song et al., 2021b)
(see App. B.3).
Analogously to prior work (Ho et al., 2020; Vahdat et al., 2021;
Song et al., 2021b), an objective better suited for high quality image synthesis can be obtained by setting λ ( t ) =
ℓ − 2 t , which corresponds to “dropping the variance prefactor” ℓ 2 t .
3. S AMPLING FROM CLD- BASED SGM S
To sample from the CLD-based SGM we can either directly simulate the reverse-time diffusion process (Eq.
(2)) or, alternatively, solve the corresponding probability flow ODE (Song et al., 2021c;b) (see App. B.5).
To simulate the SDE of the reverse-time diffusion process, previous works often relied on Euler-Maruyama (EM) (Kloeden & Platen, 1992) and related methods (Ho et al., 2020; Song et al., 2021c;
Jolicoeur-Martineau et al., 2021a).
We derive a new solver, tailored to CLD-based models.
Here, we provide the high-level ideas and derivations (see App.
D for details).
Our generative SDE can be written as (with ¯ u t =
u T − t , ¯ x t = x T − t , ¯ v t = v
[Equation]
− t ):
[Equation]
It consists of a Hamiltonian component A H , an Ornstein-Uhlenbeck process A O , and the score model term S .
We could use EM to integrate this SDE; however, standard Euler methods are not well-suited for Hamiltonian dynamics (Leimkuhler & Reich, 2005; Neal, 2011).
Furthermore, if S was 0 , we could solve the SDE in closed form.
This suggests the construction of a novel integrator.
We use the Fokker-Planck operator 2 formalism (Tuckerman, 2010; Leimkuhler & Matthews, 2013; 2015).
Using a similar notation as Leimkuhler & Matthews (2013), the Fokker-Planck equation corresponding to the generative SDE is ∂p t (¯ u t ) /∂t =(
ˆ L ∗
A + ˆ L ∗ S )
p t (¯ u t ) , where ˆ L ∗ A and ˆ L ∗ S are the non-commuting Fokker-Planck operators corresponding to the A :
=
A
H + A O and S terms, respectively.
Expressions for ˆ L ∗ A and ˆ L ∗ S can be found in App.
D. We can construct a formal, but intractable solution of the generative SDE as ¯ u t =
e t ( ˆ L ∗ A
+ ˆ L ∗ S )
¯ u 0 , where the operator e t ( ˆ L ∗
A + ˆ L ∗ S ) (known as the classical propagator in statistical physics) propagates states ¯ u 0 for time t according to the dynamics defined by the combined operators ˆ L ∗ A + ˆ L ∗ S .
Although this operation is not analytically tractable, it can serve as starting point to derive a practical integrator.
Using the symmetric Trotter theorem or Strang splitting formula as well as the Baker–Campbell–Hausdorff formula (Trotter, 1959; Strang, 1968; Tuckerman, 2010), it can be shown that:
[Equation]
for large N ∈ N + and time step δt := t/N .
The expression suggests that instead of directly evaluating the intractable e t ( ˆ L ∗ A + ˆ L ∗ S ) , we can discretize the dynamics over t into N pieces of step size δt , such that we only need to apply the individual e δt 2 ˆ L ∗ A and e δt ˆ L ∗ S
many times one after another for small steps δt .
A finer discretization results in a smaller error (since N = t/δt , the error effectively scales as O ( δt 2 ) for fixed t ).
Hence, this implies an integration method.
Indeed, e δt 2 ˆ L ∗
A ¯ u t is available in closed form, as mentioned before; however, e δt ˆ L ∗ S ¯ u t is not.
Therefore, we approximate this latter component of the integrator via a standard Euler step.
Thus, the integrator formally has an error of the same order as standard EM methods.
Nevertheless, as long as the dynamics is not dominated by the S component, our proposed integration scheme is expected to be more accurate than EM, since we split off the analytically tractable part and only use an Euler approximation for the S term.
Recall that the model only needs to learn the score of the conditional distribution p t ( v t | x t ) , which is close to Normal for much of the diffusion, in which case the S term will indeed be small.
This suggests that the generative SDE dynamics are in fact dominated by A H and A O in practice.
Note that only the propagator e δt ˆ L ∗ S is computationally expensive, as it involves evaluating the neural network.
We coin our novel SDE integrator for CLD-based SGMs Symmetric Splitting CLD Sampler (SSCS).
A detailed derivation, analyses, and a formal algorithm are presented in App.
D.
R ELATED W ORK
Relations to Statistical Mechanics and Molecular Dynamics.
Learning a mapping between a simple, tractable and a complex distribution as in SGMs is inspired by annealed importance sampling (Neal, 2001) and the Jarzynski equality from non-equilibrium statistical mechanics (Jarzynski, 1997a;b; 2011; Bahri et al., 2020).
However, after Sohl-Dickstein et al. (2015), little attention has been given to the origins of SGMs in statistical mechanics.
Intuitively, in SGMs the diffusion process is initialized in a non-equilibrium state u
and we would like to bring the system to equilibrium, i.e., the tractable prior distribution, as quickly and as smoothly as possible to enable efficient denoising.
This “equilibration problem” is a much-studied problem in statistical mechanics, particularly in molecular dynamics, where a molecular system is often simulated in thermodynamic equilibrium.
Algorithms to quickly and smoothly bring a system to and maintain at equilibrium are known as thermostats .
In fact, CLD is inspired by the Langevin thermostat (Bussi & Parrinello, 2007).
In molecular dynamics, advanced thermostats are required in particular for “multiscale” systems that show complex behaviors over multiple time- and length-scales.
Similar challenges also arise when modeling complex data, such as natural images.
Hence, the vast literature on thermostats (Andersen, 1980; Nos´e, 1984; Hoover, 1985; Martyna et al., 1992; H¨unenberger, 2005; Bussi et al., 2007; Ceriotti et al., 2009; 2010; Tuckerman, 2010) may be valuable for the development of future SGMs.
Also the framework for developing SSCS is borrowed from statistical mechanics.
The same techniques have been used to derive molecular dynamics algorithms (Tuckerman et al., 1992; Bussi & Parrinello, 2007; Ceriotti et al., 2010; Leimkuhler & Matthews, 2013; 2015; Kreis et al., 2017).
Further Related Work.
Generative modeling by learning stochastic processes has a long history (Movellan, 2008; Lyu, 2009; Sohl-Dickstein et al., 2011; Bengio et al., 2014; Alain et al., 2016;
Goyal et al., 2017; Bordes et al., 2017; Song & Ermon, 2019;
Ho et al., 2020).
We build on Song et al.
(2021c), which introduced the SDE framework for modern SGMs.
Nachmani et al.
(2021) recently introduced non-Gaussian diffusion processes with different noise distributions.
However, the noise is still injected directly into the data, and no improved sampling schemes or training objectives are introduced.
Vahdat et al.
(2021) proposed LSGM, which is complementary to CLD: we improve the diffusion process itself, whereas LSGM “simplifies the data” by first embedding it into a smooth latent space.
LSGM is an overall more complicated framework, as it is trained in two stages and relies on additional encoder and decoder networks.
Recently, techniques to accelerate sampling from pre-trained SGMs have been proposed (San-Roman et al., 2021; Watson et al., 2021; Kong & Ping, 2021; Song et al., 2021a).
Importantly, these methods usually do not permit straightforward loglikelihood estimation.
Furthermore, they are originally not based on the continuous time framework, which we use, and have been developed primarily for discrete-step diffusion models.
A complementary work to CLD is “Gotta Go Fast” (GGF)
(Jolicoeur-Martineau et al., 2021a), which introduces an adaptive SDE solver for SGMs, tuned towards image synthesis.
GGF uses standard
Euler-based methods under the hood (Kloeden & Platen, 1992; Roberts, 2012), in contrast to our
SSCS that is derived from first principles.
Furthermore, our SDE integrator for CLD does not make any data-specific assumptions and performs extremely well even without adaptive step sizes.
Some works study SGMs for maximum likelihood training (Song et al., 2021b; Kingma et al., 2021;
Huang et al., 2021).
Note that we did not focus on training our models towards high likelihood.
Furthermore, Chen et al.
and
Huang et al.
(2020) recently trained augmented Normalizing
Flows, which have conceptual similarities with our velocity augmentation.
Methods leveraging auxiliary variables similar to our velocities are also used in statistics—such as Hamiltonian Monte
Carlo (Neal, 2011)—and have found applications, for instance, in Bayesian machine learning (Chen et al., 2014;
Ding et al., 2014; Shang et al., 2015).
As shown in Ma et al.
(2019), our velocity is equivalent to momentum in gradient descent and related methods (Polyak, 1964; Kingma & Ba, 2015).
Momentum accelerates optimization; the velocity in CLD accelerates mixing in the diffusion process.
Lastly, our CLD method can be considered as a second-order Langevin algorithm, but even higher-order schemes are possible (Mou et al., 2021) and could potentially further improve SGMs.
E XPERIMENTS
Architectures.
We focus on image synthesis and implement CLD-based SGMs using NCSN++ and
DDPM++ (Song et al., 2021c) with 6 input channels (for velocity and data) instead of 3.
Relevant Hyperparameters.
CLD’s hyperparameters are chosen as β =4 , Γ=1 (or equivalently
M − 1 =4 ) in all experiments.
We set the variance scaling of the inital velocity distribution to γ =0 .and
use the proposed HSM objective with the weighting λ ( t )=
ℓ − 2 t , which promotes image quality.
Sampling.
We generate model samples via: (i) Probability flow using a Runge–Kutta 4(5) method; reverse-time generative SDE sampling using either (ii) EM or (iii) our SSCS.
For methods without adaptive stepsize (EM and SSCS), we use evaluation times chosen according to a quadratic function, like previous work (Song et al., 2021a; Kong & Ping, 2021; Watson et al., 2021)
(indicated by QS).
Evaluation.
We measure image sample quality for CIFAR-10 via Fr ´ echet inception distance (FID) with 50k samples (Heusel et al., 2017).
We also evaluate an upper bound on the negative loglikelihood (NLL): − log p ( x 0 ) ≤− E v 0 ∼ p ( v 0 ) log p ε ( x 0 , v 0 ) − H , where H is the entropy of p ( v 0 ) and log p ε ( x 0 , v 0 ) is an unbiased estimate of log p ( x 0 , v 0 ) from the probability flow ODE (Grathwohl et al., 2019; Song et al., 2021c).
As in Vahdat et al.
(2021), the stochasticity of log p ε ( x , v ) prevents us from performing importance weighted NLL estimation over the velocity distribution (Burda et al., 2015).
We also record the number of function—neural network—evaluations (NFEs) during synthesis when comparing sampling methods.
All implementation details in App.
B.5 and E.
5. I MAGE G ENERATION
Following Song et al.
(2021c), we focus on the widely used CIFAR-10 unconditional image generation benchmark.
Our CLD-based SGM achieves an FID of 2.25 based on the probability flow ODE and an FID of 2.23 via simulating the generative SDE (Tab. 1).
The only models marginally outperforming CLD are LSGM (Vahdat et al., 2021) and NSCN++/VESDE with 2,000 step predictorcorrector (PC) sampling (Song et al., 2021c).
However, LSGM uses a model with ≈ 475 M parameters to achieve its high performance, while we obtain our numbers with a model of ≈ 100 M parameters.
For a fairer comparison, we trained a smaller LSGM also with ≈ 100 M parameters, which is reported as “LSGM-100M” in Tab. 1 (details in App. E.2.7).
Our model has a significantly better FID score than “LSGM-100M”.
In contrast to NSCN++/VESDE, we achieve extremely strong results with much fewer NFEs (for example, see n ∈{ 150 , 275 , 500 } in Tab. 3 and also Tab.
2)—the VESDE performs poorly in this regime.
We conclude that when comparing models with similar
[Table]
[Figure]
network capacity and under NFE budgets ≤ 500 , our CLD-SGM outperforms all published results in terms of FID.
We attribute these positive results to our easier score matching task.
Furthermore, our model reaches an NLL bound of 3 . 31 , which is on par with recent works such as Nichol & Dhariwal (2021); Austin et al.
; Vahdat et al.
and indicates that our model is not dropping modes.
However, our bound is potentially quite loose (see discussion in App. B.5) and the true NLL might be significantly lower.
We did not focus on training our models towards high likelihood.
To demonstrate that CLD is also suitable for high-resolution image synthesis, we additionally trained a CLD-SGM on CelebA-HQ-256, but without careful hyperparameter tuning due to limited compute resources.
Model samples in Fig.
4 appear diverse and high-quality (additional samples in App. F).
5. S AMPLING S PEED AND S YNTHESIS Q UALITY T RADE -O FFS
We analyze the sampling speed vs. synthesis quality trade-off for CLD-SGMs and study SSCS’s performance under different NFE budgets (Tabs. 2 and 3).
We compare to Song et al.
(2021c)
and use EM to solve the generative SDE for their VPSDE and PC (reverse-diffusion + Langevin sampler) for the VESDE model.
We also compare to the GGF (Jolicoeur-Martineau et al., 2021a) solver for the generative SDE as well as probability flow ODE sampling with a higher-order adaptive step size solver.
Further, we compare to LSGM (Vahdat et al., 2021) (using our LSGM-100M), which also uses probability flow sampling.
With one exception (VESDE with 2,000 NFE) our CLD-SGM outperforms all baselines, both for adaptive and fixed-step size methods. More results in App. F.2.
Several observations stand out: (i) As expected (Sec. 3.3), for CLD, SSCS significantly outperforms
EM under limited NFE budgets.
When using a fine discretization of the SDE (high NFE), the two perform similarly, which is also expected, as the errors of both methods will become negligible.
(ii)
In the adaptive solver setting, using a simpler ODE solver, we even outperform GGF, which is tuned towards image synthesis.
(iii) Our CLD-SGM also outperforms the LSGM-100M model in terms of FID.
It is worth noting, however, that LSGM was designed primarily for faster synthesis, which it achieves by modeling a smooth distribution in latent space instead of the more complex data distribution directly.
This suggests that it would be promising to combine LSGM with CLD and train a CLD-based LSGM, combining the strengths of the two approaches.
It would also be interesting to develop a more advanced, adaptive SDE solver that leverages SSCS as the backbone
[Table]
and, for example, potentially test our method within a framework like GGF.
Our current SSCS only allows for fixed step sizes—nevertheless, it achieves excellent performance.
5. A BLATION S TUDIES
[Table]
[Table]
We perform ablation studies to study CLD’s new hyperparameters (run with a smaller version of our CLD-SGM used above; App.
E for details).
Mass Parameter: Tab. 4 shows results for a CLD-SGM trained with different M − 1 (also recall that M − 1 and Γ are tied together via Γ 2 = 4 M ; we are always in the critical-damping regime).
Different mass values perform mostly similarly.
Intuitively, training with smaller M − 1 means that noise flows from the velocity variables v t into the data x t more slowly, which necessitates a larger time rescaling β .
We found that simply tying M − 1 and β together via β =8 √ M works well and did not further fine-tune.
Initial Velocity Distribution: Tab. 5 shows results for a CLD-SGM trained with different initial velocity variance scalings γ .
Varying γ similarly has only a small effect, but small γ seems slightly beneficial for FID, while the NLL bound suffers a bit.
Due to our focus on synthesis quality as measued by FID, we opted for small γ .
Intuitively, this means that the data at t =0 is “at rest”, and noise flows from the velocity into the data variables only slowly.
Mixed Score: Similar to previous work (Vahdat et al., 2021), we find training with the mixed score (MS) parametrization (Sec. 3.2) beneficial.
With MS, we achieve an FID of 3.14, without only 3.56.
Hybrid Score Matching: We also tried training with regular DSM, instead of HSM.
However, training often became unstable.
As discussed in Sec. 3.2, this is likely because when using standard
DSM our CLD would suffer from unbounded scores close to t =0 , similar to previous SDEs (Kim et al., 2021).
Consequently, we consider our novel HSM a crucial element for training CLD-SGMs.
We conclude that CLD does not come with difficult-to-tune hyperparameters.
We expect our chosen hyperparameters to immediately translate to new tasks and models.
In fact, we used the same M − 1 , γ , MS and HSM settings for CIFAR-10 and CelebA-HQ-256 experiments without fine-tuning.
C ONCLUSIONS
We presented critically-damped Langevin diffusion , a novel diffusion process for training SGMs.
CLD diffuses the data in a smoother, easier-to-denoise manner compared to previous SGMs, which results in smoother neural network-parametrized score functions, fast synthesis, and improved expressivity.
Our experiments show that CLD outperforms previous SGMs on image synthesis for similar-capacity models and sampling compute budgets, while our novel SSCS is superior to EM in
CLD-based SGMs.
From a technical perspective, in addition to proposing CLD, we derive CLD’s score matching objective termed as HSM, a variant of denoising score matching suited for CLD, and we derive a tailored SDE integrator for CLD.
Inspired by methods used in statistical mechanics, our work provides new insights into SGMs and implies promising directions for future research.
We believe that CLD can potentially serve as the backbone diffusion process of next generation
SGMs.
Future work includes using CLD-based SGMs for generative modeling tasks beyond images, combining CLD with techniques for accelerated sampling from SGMs, adapting CLD-based SGMs towards maximum likelihood, and utilizing other thermostating methods from statistical mechanics.
E THICS AND R EPRODUCIBILITY
Our paper focuses on fundamental algorithmic advances to improve the generative modeling performance of SGMs.
As such, the proposed CLD does not imply immediate ethical concerns.
However, we validate CLD on image synthesis benchmarks.
Generative modeling of images has promising applications, for example for digital content creation and artistic expression (Bailey, 2020), but can also be used for nefarious purposes (Vaccari & Chadwick, 2020; Mirsky & Lee, 2021;
Nguyen et al., 2021).
It is worth mentioning that compared to generative adversarial networks (Goodfellow et al., 2014), a very popular class of generative models, SGMs have the promise to model the data more faithfully, without dropping modes and introducing problematic biases.
Generally, the ethical impact of our work depends on its application domain and the task at hand.
To aid reproducibility of the results and methods presented in our paper, we made source code to reproduce the main results of the paper publicly available, including detailed instructions; see our project page https://nv-tlabs.github.io/CLD-SGM and the code repository https: //github.com/nv-tlabs/CLD-SGM .
Furthermore, all training details and hyperparameters are already in detail described in the Appendix, in particular in App.
E.
C ONTENTS 1 Introduction
Background
3 Critically-Damped Langevin Diffusion 3.
Score Matching Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scalable Training . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sampling from CLD-based SGMs . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Related Work 5 Experiments 5. Image Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sampling Speed and Synthesis Quality Trade-Offs . . . . . . . . . . . . . . . . . .
Ablation Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6 Conclusions 7 Ethics and Reproducibility
References
A Langevin Dynamics
A.1 Different Damping Ratios
A.2 Very High Friction Limit and Connections to previous SDEs in SGMs
B Critically-Damped Langevin Diffusion
B.1 Perturbation Kernel
B.2 Convergence and Equilibrium
B.3 CLD Objective
B
.4 CLD-specific Implementation
Details . . . . . . . . . . . . . . . . . . . . . . . .
B.5 Lower Bounds and Probability Flow
ODE . . . . . . . . . . . . . . . . . . . . . .
B.
On Introducing a Hamiltonian Component into the Diffusion . . . . . . . . . . . .
C HSM: Hybrid Score Matching
C.1 Gradient Variance Reduction via HSM
D
Symmetric Splitting CLD Sampler
(SSCS)
D
1 Background
D.2 Derivation and Analysis
E Implementation and Experiment Details
E
[Table]
Score and Jacobian Experiments . .
E
[Table]
Image Modeling Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E
[Table]
Training Details and Model Architectures . .
E.2.
CIFAR-10 Results for VESDE and VPSDE . . . . . . . . . . . . . . . . .
E.2.
Quadratic Striding . .
E.2.
Denoising . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E
[Table]
[Table]
Solver Error Tolerances for Runge–Kutta 4(5) . . . . . . . . . . . . . . . .
E
[Table]
[Table]
Ablation Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E
[Table]
LSGM-100M Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
F Additional Experiments
[Table]
Toy Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
F
[Table]
Analytical Sampling . .
F
[Table]
Maximum Likelihood Training . .
F
[Table]
CIFAR-10 — Extended Results . . . . . . . . . . . . . . . . . . . . . . . . . . . .
[Table]
CelebA
[Table]
Results . . . . . . . . . . . . . . . . . . . . . . . .
G Proofs of Perturbation Kernels
G.1 Forward Diffusion . .
G.1.1 Proof of Correctness of the Mean . . . . . . . . . . . . . . . . . . . . . .
G.1.2 Proof of Correctness of the Covariance . . . . . . . . . . . . . . . . . . .
G.2 Analytical Splitting Term of SSCS . . . . . . . . . . . . . . . . . . . . . . . . . .
G.2.1 Proof of Correctness of the Mean . . . . . . . . . . . . . . . . . . . . . .
G.2.2 Proof of Correctness of the Covariance . . . . . . . . . . . . . . . . . . .
A L ANGEVIN D YNAMICS
Here, we discuss different aspects of Langevin dynamics.
Recall the Langevin dynamics, Eq.
(5), from the main paper:
[Equation]
Ornstein
[Equation]
Uhlenbeck
[Equation]
A. D IFFERENT D AMPING R ATIOS
As discussed in Sec. 3, Langevin dynamics can be run with different ratios between mass M and squared friction Γ 2 .
To recap from the main paper:
(i) For Γ 2 < 4 M ( underdamped Langevin dynamics), the Hamiltonian component dominates, which implies oscillatory dynamics of x t and v t that slow down convergence to equilibrium.
(ii) For Γ 2 > 4 M ( overdamped Langevin dynamics), the O -term dominates which also slows down convergence, since the accelerating effect by the Hamiltonian component is suppressed due to the strong noise injection.
(iii) For Γ 2 = 4 M ( critical-damping ), an ideal balance is achieved and convergence to p EQ ( u ) occurs quickly in a smooth manner without oscillations.
In Fig.
5, we visualize diffusion trajectories according to Langevin dynamics run in the different damping regimes.
We observe that underdamped Langevin dynamics show undesired oscillatory behavior, while overdamped Langevin dynamics perform very inefficiently, too.
Critical-damping achieves a good balance between the two and mixes and converges quickly.
In fact, it can be shown to be optimal in terms of convergence; see, for example, McCall (2010).
Consequently, we propose to set Γ 2 =
Γ 2 critical :
= 4 M in CLD.
A. V ERY H IGH F RICTION L IMIT AND C ONNECTIONS TO PREVIOUS SDE S IN SGM S
Let us re-write the above Langevin dynamics and consider the more general case with timedependent β ( t ) :
[Equation]
To solve this SDE
[Equation]
let us assume a simple Euler-based integration scheme
[Equation]
with the update equation for a single step at time t (this integration scheme would not be optimal, as discussed in Sec. 3.3.
, however, it would be accurate for sufficiently small time steps
and we just need this to make the connection to previous works like the VPSDE): [Equation]
[Equation]
Now, let us assume a friction coefficient Γ =
Γ max :=
M β ( t ) δt .
Since the time step δt is usually very small, this correspond to a very high friction.
In fact, it can be considered the maximum friction limit, at which the friction is so large that the current step velocity (i) is completely cancelled out by the friction term (iii) .
We obtain:
[Equation]
Now the velocity update, Eq.
(17), does not depend on the current step velocity on the right-handside anymore.
Hence, we can insert Eq.
(17) directly into Eq.
(16) and obtain:
[Equation]
Re-defining δt ′ :
=
δt 2 and β ′ ( t ) :
= β ( t ) 2 , we obtain
[Equation]
which corresponds to the high-friction overdamped Langevin dynamics that are frequently run, for example, to train energy-based generative models (Du & Mordatch, 2019; Xiao et al., 2021).
Let’s further absorb the mass M − 1 and the time step δt ′ into the time rescaling, defining ˆ β ( t ) :
= 2 β ′ ( t )
M − 1 δt ′ .
We obtain:
[Equation]
where the last approximation is true for sufficiently small ˆ β ( t ) .
However, this expression corresponds to
[Equation]
which is exactly the transition kernel of the VPSDE’s
Markov chain (Ho et al., 2020; Song et al., 2021c).
We see that the VPSDE corresponds to the high-friction limit of a more general Langevin dynamics-based diffusion process of the form of Eq.
If we assume a diffusion as above but with the potential term (ii) set to 0 , we can similarly derive the VESDE Song et al.
(2021c) as a high-friction limit of the corresponding diffusion.
Generally, all previously used diffusions that inject noise directly into the data variables correspond to such high-friction diffusions.
In conclusion, we see that previous high-friction diffusions require an excessive amount of noise to be injected to bring the dynamics to the prior, which intuitively makes denoising harder.
For our
CLD in the critical damping regime we can run the diffusion for a much shorter time or, equivalently, can inject less noise to converge to the equilibrium, i.e., the prior.
B C RITICALLY -D AMPED L ANGEVIN D IFFUSION
Here, we present further details about our proposed critically-damped Langevin diffusion (CLD).
We provide the derivations and formulas that were not presented in the main paper in the interest of brevity.
B. P ERTURBATION K ERNEL
To recap from the main text, in this work we propose to augment the data x t ∈ R d with auxiliary velocity variables v t ∈ R d .
We then run the following diffusion process in the joint x t - v t -space
[Equation]
where w t is a standard Wiener process in R 2 d and β : [0 , T ] → R +0 is a time rescaling.
In particular, we consider the critically-damped Langevin diffusion which can be obtained by setting M =
Γ 2 / 4 , resulting in the following drift kernel
[Equation]
Since we only consider the critically-damped case in this work, we redefine f := f CLD and f := f CLD for simplicity.
Since our drift f and diffusion G coefficients are affine, u t is Normally distributed for all t ∈ [0 , T ] if u 0 is Normally distributed at t = 0 (S¨arkk¨a & Solin, 2019).
In particular, given that u 0 ∼ N ( u 0 ; µ 0 , Σ 0 = Σ 0 ⊗ I d ) , where Σ 0 = diag(Σ
xx 0 , Σ vv 0 ) is a positive semi-definite diagonal 2-by-2 matrix (we restrict our derivation to diagonal covariance matrices at t = 0 for simplicity, since in our situation velocity and data are generally independent at t = 0 ), we derive expressions for µ t and Σ t , the mean and the covariance matrix of u t , respectively.
Following S¨arkk¨a & Solin (2019) (Section 6.1), the mean and covariance matrix of u t obey the following respective ordinary differential equations (ODEs) [Equation]
[Equation]
Notating µ 0 = ( x 0 , v 0 ) ⊤ , the solutions to the above ODEs are
[Equation]
28) and
[Equation]
[Equation] [Equation] [Equation] [Equation]
[Equation]
where B ( t ) = (cid:82) t 0 β (ˆ t ) d ˆ t .
For constant β ( t ) =
β (as is used in all our experiments), we simply have
B ( t ) =
tβ .
The correctness of the proposed mean and covariance matrix can be verified by simply plugging them back into their respective ODEs; see App. G.1.
With the above derivations, we can find analytical expressions for the perturbation kernel p ( u t |· ) .
For example, when conditioning on initial data and velocity samples x 0 and v 0 (as in denoising score matching (DSM)), the mean and covariance matrix of the perturbation kernel p ( u t | u 0 ) can be obtained by setting µ 0 = ( x 0 , v 0 ) ⊤ , Σ xx
= 0 , and Σ vv 0 = 0 .
In our experiments, the initial velocity distribution is set to N ( 0 d , γM I d ) .
Conditioning only on initial data samples x 0 and marginalizing over the full initial velocity distribution (as in our hybrid score matching (HSM), see Sec. C), the mean and covariance matrix of the perturbation kernel p ( u t | x 0 ) can be obtained by setting µ
= ( x 0 , 0 d ) ⊤ , Σ xx
= 0 , and Σ vv 0 = γM .
B. C ONVERGENCE AND E QUILIBRIUM
Our CLD-based training of SGMs—as well as denoising diffusion models more generally—relies on the fact that the diffusion converges towards an analytically tractable equilibrium distribution for sufficiently large t .
In fact, from the above equations we can easily see that,
[Equation]
[Equation]
[Equation]
which establishes p EQ ( u )
= N ( x ; 0 d , I d ) N ( v ; 0 d , M I d ) .
Notice that our CLD is an instantiation of the more general Langevin dynamics defined by
[Equation]
which has the equilibrium distribution ˆ p EQ ( u )
= p pot ( x ) N ( v ; 0 d , M I d ) (Leimkuhler & Matthews, 2015; Tuckerman, 2010).
However, the perturbation kernel of this Langevin dynamics is not available analytically anymore for arbitrary p pot ( x ) .
In our case, however, we have the analytically tractable p pot ( x ) =
N ( x ; 0 d , I d ) .
Note that this corresponds to the classical “harmonic oscillator” problem from physics.
B. CLD O BJECTIVE
To derive the objective for training CLD-based SGMs, we start with a derivation that targets maximum likelihood training in a similar fashion to Song et al.
(2021b).
Let p 0 and q 0 be two densities, then
[Equation]
where p t and q t are the marginal densities of p 0 and q 0 , respectively, diffused by our criticallydamped Langevin diffusion.
As has been shown in Song et al.
(2021b), Eq. (39) can be written as a mixture (over t ) of score matching losses.
To this end, let us consider the Fokker–Planck equation associated with the critically-damped Langevin diffusion:
[Equation]
Similarly
[Equation]
we have ∂q t ( u t ) ∂t = ∇ u t · [ h q ( u t , t ) q t ( u t )] .
Assuming log p t ( u t ) and log q t ( u t ) are smooth functions with at most polynomial growth at infinity
[Equation]
we have
[Equation]
Using the above fact
[Equation]
we can compute the time-derivative of the Kullback–Leibler divergence between p t and q t as
[Equation]
[Equation]
Notice that due to the form of G ( t ) , we now have only gradients with respect to the velocity component v t .
Combining the above with Eq.
[Equation]
we have
[Equation]
Note that the approximation holds if p T is sufficiently “close” to q T . We obtain a more general objective function by replacing Γ β ( t ) with an arbitrary function λ ( t ) , i.e.,
[Equation]
[Equation]
As shown in App.
C, the above can be rewritten, up to irrelevant constant terms, as either of the following two objectives:
[Equation]
For both HSM and DSM, we have shown in App.
B.1 that the perturbation kernels p t ( u t | x 0 ) and p t ( u t | u 0 ) are Normal distributions with the following structure of the covariance matrix:
[Equation]
We can use this fact to compute the gradient ∇ u t log p t ( u t |
[Equation]
where [-(cid:15) 
-]ϵ 2 d ∼ N ( 0 , I 2 d ) and Σ t =
L t L ⊤ t is the Cholesky factorization of the covariance matrix Σ t .
Note that the structure of Σ t implies that L t =
L t ⊗ I d , where L t L ⊤ t is the Cholesky factorization of Σ t , i.e,
[Equation] [Equation]
Furthermore, we have
[Equation]
Using the above, we can compute
[Equation]
where
[Equation]
[Equation] and ϵ d :2 d denotes those (latter)
d components of ϵ 2 d that actually affect ∇ v t log p t ( u t |· ) .
Note that ℓ t depends on the conditioning in the perturbation kernel, and therefore ℓ t is different for
DSM, which is based on p ( u t | u 0 ) , and HSM, which is based on p ( u t | x 0 ) .
Therefore, we will henceforth refer to ℓ HSM t and ℓ DSM t if distinction of the two cases is necessary (otherwise we will simply refer to ℓ t for both).
As discussed in Section 3.2, we model ∇ v t log q t ( u t ) as s θ ( u t , t ) =
− ℓ t α θ ( u t , t ) .
Plugging everything back into our objective functions, Eq.
(45) and Eq.
(46), we obtain
HSM
[Equation]
[Figure]
where u t is sampled via reparameterization:
[Equation]
Note again that L t is different for HSM and DSM.
Analogously to prior work (Ho et al., 2020; Vahdat et al., 2021; Song et al., 2021b)
an objective better suited for high quality image synthesis can be obtained by “dropping the variance prefactor”:
[Equation]
B. CLD- SPECIFIC I MPLEMENTATION D ETAILS
Analytically, ℓ HSM t is bounded (in particular, ℓ HSM0 = 1 / √ γM ), whereas ℓ DSM t is diverging for t → 0 .
In practice, however, we found that computation of ℓ HSM t can also be numerically unstable, even when using double precision.
As is common practice for computing Cholesky decompositions, we add a numerical stabilization matrix ϵ num I 2 d to Σ t before computing ℓ t .
In Fig. 6, we visualize ℓ HSM t and ℓ DSM t for different values of ϵ num using our main experimental setup of M = 0 . 25 and γ = 0 .
04 (also, recall that in practice we have T = 1 ).
Note that a very small numerical stabilization of ϵ num = 10 − 9 in combination with the use of double precision makes HSM work in practice.
B. L OWER B OUNDS AND P ROBABILITY F LOW ODE
Given the score model s θ ( u t , t ) , we can synthesize novel samples via simulating the reverse-time diffusion SDE, Eq.
(2) in the main text.
This can be achieved, for example, via our novel SSCS,
Euler-Maruyama, or methods such as GGF (Jolicoeur-Martineau et al., 2021a).
However, Song et al.
(2021b;c) have shown that a corresponding ordinary differential equation can be defined that generates samples from the same distribution, in case s θ ( u t , t ) models the ground truth scores perfectly.
This ODE is:
[Equation]
This ODE is often referred to as the probability flow ODE.
We can use it to generate novel data by sampling the prior and solving this ODE, like previous works (Song et al., 2021c).
Note that in practice s θ ( u t , t ) won’t be a perfect model, though, such that the generative models defined by simulating the reverse-time SDE and the probability flow ODE are not exactly equivalent (Song et al., 2021b).
Nevertheless, they are very closely connected and it has been shown that their performance is usually very similar or almost the same, when we have learnt a good s θ ( u t , t ) .
In addition to sampling the generative SDE in our paper, we also sample from our CLD-based SGMs via this probability flow approach.
With the definition of our CLD, the ODE becomes:
[Equation]
Notice the interesting form of this probability flow ODE for CLD:
It corresponds to Hamiltonian dynamics ( A ′ H ) plus the score function term S ′ .
Compared to the generative SDE (Sec. 3.3), the
Ornstein-Uhlenbeck term disappears.
Generally, symplectic integrators are best suited for integrating Hamiltonian systems (Neal, 2011; Tuckerman, 2010; Leimkuhler & Reich, 2005).
However, our ODE is not perfectly Hamiltonian, due to the score term, and modern non-symplectic methods, such as the higher-order adaptive-step size Runge-Kutta 4(5) ODE integrator (Dormand & Prince, 1980), which we use in practice to solve the probability flow ODE, can also accurately simulate
Hamiltonian systems over limited time horizons.
Importantly, the ODE formulation also allows us to estimate the log-likelihood of given test data, as it essentially defines a continuous Normalizing flow (Chen et al., 2018;
Grathwohl et al., 2019), that we can easily run in either direction.
However, in CLD the input into this ODE is not just the data x 0 , but also the velocity variable v 0 .
In this case, we can still calculate a lower bound on the log-likelihood:
[Equation]
where H ( p ( v 0 )) denotes the entropy of p ( v 0 )
(we have H ( p ( v 0 ))
= 12 log (2 πeγM ) ).
We can obtain a stochastic, but unbiased estimate of log p ( x 0 , v 0 )
≈ log p ε ( x 0 , v 0 ) via solving the probability flow ODE with initial conditions ( x 0 , v 0 ) and calculating a stochastic estimate of the logdeterminant of the Jacobian via Hutchinson’s trace estimator (and also calculating the probability of the output under the prior), as done in Normalizing flows (Chen et al., 2018; Grathwohl et al., 2019) and previous works on SGMs (Song et al., 2021c;b).
In the main paper, we report the negative of
Eq.
(60) as our upper bound on the negative log-likelihood (NLL).
Note that this bound can be potentially quite loose.
In principle, it would be desirable to perform an importance-weighted estimation of the log-likelihood, as in importance-weighted autoencoders (Burda et al., 2015), using multiple samples from the velocity distribution.
However, this isn’t possible, as we only have access to a stochastic estimate log p ε ( x 0 , v 0 ) .
The problems arising from this are discussed in detail in Appendix F of Vahdat et al.
We could consider training a velocity encoder network, somewhat similar to Chen et al.
(2020), to improve our bound,
but we leave this for future research.
B. O N I NTRODUCING A H AMILTONIAN C OMPONENT INTO THE D IFFUSION
Here, we provide additional high-level intuitions and motivations about adding the Hamiltonian component to the diffusion process, as is done in our CLD.
Let us recall how the data distribution evolves in the forward diffusion process of SGMs: The role of the diffusion is to bring the initial non-equilibrium state quickly towards the equilibrium or prior distribution.
Suppose for a moment, we could do so with “pure” Hamiltonian dynamics (no noise injection).
In that case, we could generate data from the backward model without learning a score or neural network at all, because Hamiltonian dynamics is analytically invertible (flipping the sign of the velocity, we can just integrate backwards in reverse time direction).
Now, this is not possible in practice, since Hamiltonian dynamics alone usually cannot convert the non-equilibrium distribution to the prior distribution.
Nevertheless, Hamiltonian dynamics essentially achieves a certain amount of mixing on its own; moreover, since it is deterministic and analytically invertible, this mixing comes at no cost in the sense that we do not have to learn a complex score function to invert the Hamiltonian dynamics.
Our thought experiment shows that we should strive for a diffusion process that behaves as deterministically (meaning that deterministic implies easily invertible) as possible with as little noise injection as possible.
And this is exactly what is achieved by adding the Hamiltonian component in the overall diffusion process.
In fact, recall that it is the diffusion coefficient G of the forward SDE that ultimately scales the score function term of the backward generative SDE (and it is the score function that is hard to approximate with complex neural nets).
Therefore, in other words, relying more on a deterministic Hamiltonian component for enhanced mixing (mixing just like in MCMC in that it brings us quickly towards the target distribution, in our case the prior) and less on pure noise injection will lead to a nicer generative SDE that relies less on a score function that requires complex and approximate neural network-based modeling, but more on a simple and analytical Hamiltonian component.
Such an SDE could then be solved easier with an appropriate integrator (like our SSCS).
In the end, we believe that this is the reason why our networks are “smoother” and why given the same network capacity and limited compute budgets we essentially outperform all previous results in the literature (on CIFAR-10).
We would also like to offer a second perspective, inspired by the Markov chain Monte Carlo (MCMC) literature.
In MCMC, “mixing” helps to quickly traverse the high probability parts of the target distribution and, if an MCMC chain is initialized far from the high probability manifold, to quickly converge to this manifold.
However, this is precisely the situation we are in with the forward diffusion process of SGMs: The system is initialized in a far-from-equilibrium state (the data distribution) and we need to traverse the space as efficiently as possible to converge to the equilibrium distribution, this is, the prior.
Without efficient mixing, it takes longer to converge to the prior, which also implies a longer generation path in the reverse direction—which intuitively corresponds to a harder problem.
Therefore, we believe that ideas from the MCMC literature that accelerate mixing and traversal of state space may be beneficial also for the diffusions in SGMs.
In fact, leveraging Hamiltonian dynamics to accelerate sampling is popular in the MCMC field (Neal, 2011).
Note that this line of reasoning extends to thermostating techniques from statistical mechanics and molecular dynamics, which essentially tackle similar problems like MCMC methods from the statistics literature (see discussion in Sec. 4).
C HSM: H YBRID S CORE M ATCHING
We begin by recalling our objective function from App.
B.3 (Eq. (44)):
[Equation]
(61) where s θ ( u , t ) is our score model.
In the following, we dissect the “score matching” part of the above objective:
[Equation]
where C 2 ( t ) :
=
E u t ∼ p t ( u t ) (cid:104) ∥∇ v t log p t ( u t ) ∥ 22 (cid:105) and S ( θ ) is the cross term discussed below.
Following Vincent (2011), we can rewrite L SM as an equivalent (up to addition of a time-dependent
[Table]
[Table]
matching objective
L
[Table]
[Equation]
where
C 3 ( t ) :
= E u 0 ∼ p ( u 0 ) , u t ∼ p t ( u t | u 0 ) (cid:104) ∥∇ v t log p t ( u t | u 0 ) ∥ 22 (cid:105) .
Something that might not necessarily be quite obvious is that there is no fundamental need to “denoise” with the distribution p ( u 0 )
(this is, use samples from the joint x 0 - v 0 distribution p ( u 0 ) , perturb them, and learn the score for denoising).
Instead, we can “denoise” only with the data distribution p ( x 0 ) and marginalize over the entire initial velocity distribution p ( v 0 ) , which results in
[Equation]
where C 4 ( t ) :
=
E x
[Equation]
∥∇ [Equation] t log p t ( u t | x 0 ) ∥ 2 2 (cid:105) and ⟨· , ·⟩ donates the inner product (notation chosen to be consistent with Vincent (2011)).
In our case, this makes sense since p ( v 0 ) is Normal, and therefore (as shown in App B.1), the perturbation kernel p t ( u t | x 0 ) is still Normal.
In the following, for completeness
[Equation]
we redo the derivation of Vincent (2011) and show that L SM is equivalent to L HSM (up to addition of a constant).
Starting from S ( θ ) , we have
[Equation]
Hence [Equation] we have that
[Equation]
This further implies that
[Equation]
[Equation] Using the analysis from App B.1, we realize that C 3 and C 4 can be simplified to d (cid:0) ℓ DSM t (cid:1) 2 and d (cid:0) ℓ HSM t (cid:1) 2 , respectively.
Here, we used the fact that the expected squared norm of a multivariate standard Normal random variable is equal to its dimension, i.e., E ε ∼N ( 0 d , I d ) ∥ ε [-(cid:107) 
-]∥ 22 = d .
This analysis then simplifies Eq. (67) to
[Equation]
Using this relation, we can also find a connection between our CLD objective functions from App. B.3.
In particular, we have
[Equation]
C. G RADIENT V ARIANCE R EDUCTION VIA HSM
Above, we derived that L HSM =
L DSM + const , so one might wonder why we advocate for HSM over DSM.
As discussed in Sec. 3.2, one advantage of HSM is that it avoids unbounded scores at t → 0 .
However, there is a second advantage: In practice, we never solve expectations analytically but rather approximate them using Monte Carlo estimates.
In the remainder of this section, we will show that in practice (Monte Carlo) gradients based on HSM have lower variance than those based on DSM.
From Eq.
(69), we have
[Equation]
where θ are the learnable parameters of the neural network.
Instead of comparing the above expectations directly, we instead compare λ ( t ) ∇ θ L HSM with λ ( t ) ∇ θ L DSM for t ∈ [0 , 1] (we use T = 1 in all experiments) at discretized time values (as is done in practice).
Replacing
L HSM and L DSM with a single Monte Carlo estimate (as is used in practice), we have
[Equation]
where we applied the chain-rule.
Note that in Eq.
(71) and Eq.
(72), u t is sampled from the same distribution.
Hence, λ ( t ) ∇ θ
s θ ( u t , t ) acts as a common scaling factor, with the variance difference between HSM and DSM originating from the squared norm term.
Hence, we ignore λ ( t ) ∇ θ s θ ( u t , t ) and only focus our analysis on the gradient of the norm terms, which we can further simplify:
[Equation]
and
[Equation]
We explore this difference in a realistic setup; in particular, we evaluate K HSM and K DSM for all data points in the CIFAR-10 training set.
We choose s θ to be our trained ablation CLD model (with the standard setup of M − 1 =
β = 4 , see Sec.
E.2.1 for model details).
We then use these samples to compute the empirical covariance matrices Cov HSM and Cov DSM of the random variables K HSM and K DSM , respectively.
As is common practice in statistics, we consider only the trace of the estimated covariance matrices.
The trace of the covariance matrix (of a random variable) is also commonly referred to as the total variation (of a random variable).
We visualize our results in Fig.
For HSM, there is barely any visual difference in Tr(Cov) for γ = 0 . 04 and γ = 1 .
For DSM, both γ = 0 . 04 and γ = 1 result in very large Tr(Cov) values for small t .
For large t , Tr(Cov) is considerably smaller for γ = 0 .
04 than for γ = 1 .
However, in practice, we found that DSM is even unstable for small γ .
Given this analysis, we believe this is due to the large gradient variance for small t .
In conclusion, these results demonstrate a clear variance reduction by the HSM objective, in particular for large γ . Ultimately, this is expected:
In HSM, we are effectively integrating out the initial velocity distribution when estimating gradients, while in
DSM we use noisy samples for the initial velocity.
Note that re-introducing λ ( t ) weightings would allow us to scale the Tr(Cov) curves according to the “reweighted” objective or the maximum likelihood objective.
However, we believe it is most instructive to directly analyze the gradient of the relevant norm term itself.
D S YMMETRIC S PLITTING CLD S AMPLER (SSCS)
In this section [Equation] we present a more complete derivation and analysis of our novel Symmetric Splitting
CLD Sampler (SSCS).
D. B ACKGROUND
Our derivation is inspired by methods from the statistical mechanics and molecular dynamics literature.
In particular, we are leveraging symmetric splitting techniques as well as (Fokker–Planck) operator concepts.
The high-level idea of symmetric splitting as well as the operator formalism are well-explained in Tuckerman (2010), in particular in their Section 3.10, which includes simple examples.
Symmetric splitting methods for stochastic dynamics in particular are discussed in detail in Leimkuhler & Matthews (2015).
We also recommend Leimkuhler & Matthews (2013) [Equation] which discusses splitting methods for Langevin dynamics in a concise but insightful manner [Equation]
D. D ERIVATION AND A NALYSIS
Generative SDE.
From Sec. 3.3, recall that our generative SDE can be written as (with ¯ u t = u T − t , ¯ x t
[Equation]
=
[Equation]
T − t ):
[Equation]
Fokker–Planck Equation and Fokker–Planck Operators.
The evolution of the probability distribution p T − t (¯ u t ) is described by the general Fokker–Planck equation (S¨arkk¨a & Solin, 2019):
[Equation]
with
[Equation]
For our SDE [Equation] we can write the Fokker–Planck equation in short form as
[Equation]
with the Fokker–Planck operators (defined via their action on functions of the variables ϕ (¯ u t ) ):
[Equation]
We are providing these formulas for transparency and completeness.
We do not directly leverage them.
However, working with these operators can be convenient.
In particular, the operators describe the time evolution of states ¯ u t under the stochastic dynamics defined by the SDE.
Given an initial state ¯ u 0 , we can construct a formal solution to the generative SDE via (Tuckerman, 2010;
Leimkuhler & Matthews, 2015):
[Equation]
where the operator e t ( ˆ L ∗ A + ˆ L ∗ S ) is known as the classical propagator that propagates states ¯ u 0 for time t according to the dynamics defined by the combined Fokker–Planck operators ˆ L ∗ A + ˆ L ∗ S (to avoid confusion, note that in Eq.
(83) the operator e t ( ˆ L ∗ A + ˆ L ∗ S ) is applied on ¯ u 0 in an element-wise or “vectorized” fashion on all elements of ¯ u 0 in parallel).
The problem with that expression is that we cannot analytically evaluate it.
However, we can leverage it to design an integration method.
Symmetric Splitting Integration.
Using the symmetric Trotter theorem or Strang splitting formula as well as the Baker–Campbell–Hausdorff formula (Trotter, 1959; Strang, 1968; Tuckerman, 2010), it can be shown that:
[Equation]
for large N ∈ N + and time step δt := t/N .
The expression suggests that instead of directly evaluating the intractable e t ( ˆ L ∗ A + ˆ L ∗ S ) , we can discretize the dynamics over t into N pieces of step size δt , such that we only need to apply the individual e δt 2 ˆ L ∗ A and e δt ˆ L ∗ S
many times one after another for small time steps δt .
A finer discretization implies a smaller error (since N = t/δt the error effectively scales as O ( δt 2 ) for fixed t ).
Hence, this implies an integration method.
The general idea of such splitting schemes is to split an initially intractable propagator into separate terms, each of which is analytically tractable.
In that case, the overall integration error for many steps is only due to the splitting scheme error, 5 but not due to the evaluation of the individual updates.
Such techniques are, for example, popular in molecular dynamics to develop symplectic integrators as well as accurate samplers (Tuckerman et al., 1992; Tuckerman, 2010; Leimkuhler & Matthews, 2013; 2015; Bussi &
Parrinello, 2007).
Analyzing the Splitting Terms.
Next, we need to analyze the two individual terms: (i) Let us first analyze e δt 2 ˆ L ∗
A ¯ u t : This term describes the stochastic evolution of ¯ u t under the dynamics of an SDE like Eq.
(75), but with S set to zero.
However, if S is set to zero, the remaining
SDE has affine drift and diffusion coefficients.
In that case, if the input is Normal (or a discrete state corresponding to a Normal with 0 variance) then the distribution is Normal at all times and we can calculate the evolution analytically.
In particular, we can solve the differential equations for the mean ¯ µ δt 2 and covariance ¯ Σ δt 2 of the Normal (see Sec.
B.1)
and obtain
[Equation]
as well as
[Equation]
The correctness of the proposed mean and covariance matrix can be verified by simply plugging them back in their respective ODEs; see App.
G.2.
Now, we can write the action of the the propagator e δt
ˆ L ∗ A on a state ¯ u t as:
[Equation]
(ii) : Next, we need to analyze e δt ˆ L ∗ S ¯ u t .
Unfortunately, we cannot calculate the action of the propagator e δt ˆ L ∗ S on ¯ u t analytically and we need to make an approximation.
From Eq.
(75), we can easily see that the propagator e δt ˆ L ∗ S describes the evolution of the velocity component ¯ v t for time step δt under the ODE (this can be easily seen by noticing that the S term in Eq.
(75) only acts on the velocity component of the joint state ¯ u t ):
[Equation]
We propose to simply solve this ODE for the step δt via a simple step of Euler’s method, resulting in:
[Equation]
with the informal definition
[Equation]
Error Analysis.
It is now instructive to study the overall error of our proposed integrator.
With the additional Euler integration in one of the splitting terms, we have
[Equation]
where we used N = tδt and only kept the dominating error terms of lowest order in δt .
We see that, just like Euler’s method, also our SSCS is a first-order integrator with local error ∼ δt 2 and global error ∼ δt , which can be also seen from the last two lines of Eq.
This is expected, considering that we used an Euler step for the S term.
Nevertheless, as long as the dynamics is not dominated by the S component, our proposed integration scheme is still expected to be more accurate than EM, since we split off the analytically tractable part and only use an Euler approximation for the S term.
To this end, recall that the model only needs to learn the score of the conditional distribution p t ( v t | x t ) , which is close to Normal for much of the diffusion, in which case the S term will indeed be small.
This suggests that the generative SDE dynamics are in fact dominated by A H and
A O in practice.
From another perspective, note that (recalling that s θ ( u t , t ) =
− ℓ t α θ ( u t , t ) with α θ ( u t , t ) =
ℓ − 1 t v t / Σ vvt + α ′ θ ( u t , t ) from Sec. 3.2):
[Equation]
For large parts of the diffusion, Σ vvt is indeed close to M , such that the ¯ v t term is very small (this cancellation is the reason why we pulled the M − 1 ¯ v t term into the S component).
In Sec. 3, we have also seen that our neural network component α ′ θ ( u t , t ) can be much smoother than that of previous SGMs.
Overall, this suggests that the error of SSCS indeed might be smaller than the error we would obtain when applying a naive Euler–Maruyama integrator to the full generative SDE.
Our positive experimental results in Sec.
5.2 validate that.
Only in the limit for very small steps, both our SSCS and EM make only very small errors and are expected to perform equally well, which is exactly what we observe in our experiments.
Our SSCS turns out to be well-suited for integrating the generative SDE of CLD-SGMs with relatively few synthesis steps.
Note that error analysis of stochastic differential equation solvers is usually performed in terms of weak and strong convergence (Kloeden & Platen, 1992).
Due to the use of Euler’s method for the S component, as argued above, we expect our SSCS to formally have the same weak and strong convergence properties like EM, this is, weak convergence of order 1 and strong convergence of order 1 as well, since the noise is additive in our case (and assuming appropriate smoothness conditions for the drift and diffusion coefficients; furthermore, without additive noise, we would have strong convergence of order 0 . 5 ).
We leave a more detailed analysis to future work.
In practice, we do not use SSCS to integrate all the way from t =0 to t = T , but only up to t =
T − ϵ , and perform a denoising step, similar to previous works (Jolicoeur-Martineau et al., 2021a; Song et al., 2021c).
It is worth noting that our SSCS scheme would also be applicable when we used time-dependent β ( t ) , as in our more general derivation of the CLD perturbation kernel in App.
B.
However, since we only used constant β in the main paper, we also presented SSCS in that way.
A promising direction for future work would be to extend SSCS to adaptive step sizes and to use techniques to facilitate higher-order integration, while still leveraging the advantages of SSCS.
SSCS Algorithm.
Finally, we summarize SSCS in terms of a concise algorithm:
Input: Score function s θ (¯ u t , T − t ) , CLD parameters Γ , β , M = Γ 2 / 4 , number of sampling steps N , step sizes { δt n ≥ 0 } N − 1 n =0 chosen such that ϵ
:= T − (cid:80) N − 1 n =
δt n ≥ 0 (stepsizes can vary, for example in QS).
Output: Synthesized model sample ¯ x ′ N , along with a velocity sample ¯ v ′ N .
¯ x 0 ∼ N (¯ x 0 ; 0 d , I d ) , ¯ v 0 ∼ N (¯ v 0 ; 0 d , M I d ) , ¯ u 0 = (¯ x 0 , ¯ v 0 )
▷ Draw initial prior samples from p EQ ( u ) t =▷ Initialize time for n = 0 to N − 1 do ¯ u n + 12 ∼ N (¯ u n + 12 ; ¯ µ δtn 2 (¯ u n ) , ¯ Σ δtn 2 )
▷ First half-step: apply exp { δt n 2 ˆ L ∗ A } on ¯ u n ¯ u ′ n + 12 ← ¯ u n {++ 12 + δt n (cid:18) 
 d 2 β Γ (cid:2) s ( [Table]+}
u t , [Table] − t ) + M
[Equation] 1 ¯ [Table] t (cid:3)(cid:19)
▷ Full step: apply exp { δt n ˆ L ∗ S } on ¯ u n +¯ u n +1 ∼ N (¯ u n [Table] 1 ; ¯ µ δtn 2 (¯ u ′ n [Table]
[Table] Σ δtn 2 ) ▷ Second half-step: apply exp { δt n 2 ˆ L ∗ A } on ¯ u ′ n +t ← t + δt n ▷ Update time end for ¯ u ′ N ← ¯ u N − ϵ (cid:18)(cid:18)
[Equation]
[Equation] (cid:19)
▷ Denoising [Equation] ▷ Extract output data and velocity samples
Note that the algorithm uses the expressions in Eqs.
(85) and (86) for ¯ µ t and ¯ Σ t .
Furthermore, in practice in the denoising step at the end, we usually only update the ¯ x ′ N component of ¯ u ′ N , since we are only interested in the data sample.
This saves us the final neural network call during denoising, which only affects the ¯ v ′ N component (also see App. E.2.4).
However, we wrote the algorithm in the general way, which also allows to correctly generate the velocity sample ¯ v ′ N . In Fig.
8, we show a conceptual visualization of our SSCS and contrast it to EM.
Also note that we could combine the second half-step from one iteration of SSCS with the first halfstep from the next iteration of SSCS.
This is commonly done in the Leapfrog integrator (Leimkuhler & Reich, 2005; Tuckerman, 2010; Neal, 2011; Leimkuhler & Matthews, 2015), 6 which follows a similar structure as our SSCS.
However, it is not important in our case, as the only computationally costly operation is in the center full step, which involves the neural network evaluation.
The first and last half-steps come at virtually no computational cost. [Figure]
E I MPLEMENTATION AND E XPERIMENT D ETAILS E. S CORE AND J ACOBIAN E XPERIMENTS
In this section, we provide details for the experiments presented in Sec. 3.1.
For both experiments, we consider a two-dimensional simple mixture of Normals of the form
[Equation]
(97) where p ( k ) ( x ) =
N ( x ; µ k ; 0 . 04 2 I 2 ) and µ 1 = (cid:18) −
[Equation]
(cid:19) , µ 2 = (cid:18) − a/ 2 a/(cid:19) , µ 3 = (cid:18)a (cid:19) , µ 4 =
(cid:18) − a/− a/(cid:19) , µ 5 = (cid:18) (cid:19) , µ 6 = (cid:18) a/a/(cid:19) , µ 7 = (cid:18)− a (cid:19) , µ 8 = (cid:18) a/− a/(cid:19) , µ 9 = (cid:18) a (cid:19) , and a = 2 − 12 .
The choice of this data distribution is not arbitrary.
In fact, mixture of Normal distributions are diffused by simply diffusing the components, i.e., setting p 0 ( x 0 ) =
p data ( x ) , we have
[Equation]
98) where p ( k ) t are the diffused components (analogously for CLD with velocity augmentation).
This means that for both CLD as well as VPSDE Song et al.
(2021c)
we can diffuse p data ( x ) with analytical access to the diffused marginal p t ( x t ) or p t ( u t ) .
This allows us to perform interesting analyses that would be impossible when working, for example, with image data.
We visualize the data distribution in Fig.
Score experiment: We empirically verify the reduced complexity of the score of p t ( v t | x t ) , which is learned in CLD, compared to the score of p t ( x t ) , which is learned in VPSDE.
To avoid scaling issues between VPSDE and CLD, we chose M = γ = 1 for CLD in this experiment; this results in an equilibrium distribution of N ( 0 2 , I 2 ) (for both data and velocity components, which are independent at equilibrium), which is the same as the equilibrium distribution of the VPSDE. We then [Figure]
measure the difference of the respective scores at time t and the equilibrium (or prior) scores, i.e. (recall that the score of a Normal distribution p ( x ) =
N ( 0 2 , I 2 ) is simply ∇ x log p ( x ) = − x ),
[Equation]
The expectations are approximated using 10 5 samples from p ( x t ) and p ( u t ) for VPSDE and CLD, respectively.
As can be seen in Fig.
9a, ξ CLD ( t ) is smaller than ξ VPSDE ( t ) for all t ∈ [0 , T ] .
The difference is particularly striking for small time values t .
Other previous SDEs, such as the VESDE, sub-VPSDE, etc., are expected to behave similarly.
This result implies that the ground truth scores that need to be learnt in CLD are closer to Normal scores than the ground truth scores in previous
SDEs like the VPSDE.
Since the score of a Normal is very simple—and indeed directly leveraged in our mixed score formulation—we would intuitively expect that the CLD training task is easier.
Complexity experiment: Therefore, to understand the above observations in terms of learning neural networks, we train a small ResNet architecture (less than 100k parameters) for each of the following four setups: both CLD and VPSDE each with and without a mixed score parameterization.
The mixed score of the VPSDE simply assumes a standard Normal data distribution (which is also the equilibrium distribution of VPSDE) resulting in adding − x t to the score function.
Formally, − x t is the score of a Normal distribution with unit variance.
We train the models for 1M iterations using fresh data synthesized from p data at a batch size of 512.
The model and data distributions are visualized in Fig.
We see that all models have learnt good representations of the data.
We measure the complexity of the trained neural networks using the squared Frobenius norm of the networks’ Jacobians.
For CLD, we have
[Equation]
Similarly, for the VPSDE we compute
[Equation]
For both CLD and VPSDE, expectations are again approximated using 10 5 samples.
As can be seen in Fig.
9b the neural network complexity is significantly lower for CLD compared to VPSDE.
A mixed score formulation further helps decreasing the neural network complexity for both CLD and VPSDE.
This result implies that the arguably simpler training task in CLD indeed also translates to reduced model complexity in that the neural network is smoother as measured by J F ( t ) .
In largescale experiments, this would mean that, given similar model capacity, a CLD-based SGM could potentially have a higher expressivity.
Or, on the other hand, similar performance could be achieved with a smoother and potentially smaller model.
Indeed these findings are in line with our strong results on the CIFAR-10 benchmark.
E. I MAGE M ODELING E XPERIMENTS
We perform image modeling experiments on CIFAR-10 as well as CelebA-HQ-256.
We report
FID scores on CIFAR-10 for our main model for various different solvers; see Tab. 3 and Tab. 2.
We further present generated samples for both models in Sec.
5 using Euler–Maruyama with [Table] quadratic striding steps and Runge–Kutta 4(5) for CIFAR10 and CelebA-HQ-256, respectively.
We present additional samples for various solver settings in App.
F. All (average) NFEs for the Runge–
Kutta solver are computed using a batch size of 128.
E.2. T RAINING D ETAILS AND M ODEL A RCHITECTURES
Our models are based on the NCSN++ and the DDPM++ architectures from Song et al.
(2021c).
Importantly, we changed the number of input channels from three to six to facilitate the additional velocity variables.
Note that the number of additional neural network parameters due to this change is negligible.
For fair a comparison, we train our models using the same t -sampling cutoff during training as is used for VESDE and VPSDE in Song et al.
(2021c).
Note, however, that this is not strictly necessary for CLD as we do not have any “blow-up” of the SDE due to unbounded scores as t → 0 (also see Fig.
18 and Fig. 19). We summarize our three model architectures as well as our SDE and training setups in Tab. 6.
E.2. CIFAR-10 R ESULTS FOR VESDE AND VPSDE
The results reported for VESDE and VPSDE using the GGF sampler are taken from JolicoeurMartineau et al.
(2021a).
All other results for VESDE and VPSDE are generated using the provided PyTorch code as well as the provided checkpoints from Song et al.
(2021c).
7 We used EM and PC to sample from the VPSDE and VESDE models, respectively (see Sec. 5.2), since these choices correspond to their recommended settings.
Furthermore, in App.
F.2 we also used DDIM (Song et al., 2021a) to sample the VPSDE.
DDIM’s update rule is
[Equation] where α t = [Equation] [Equation]
=
[Equation]
(cid:16)
[Equation]
(cid:82) t
[Equation]
( t ) dt (cid:17) , and β ( t )
= 0 .
1 + 19 .
9 t .
E. [Equation] Q UADRATIC S TRIDING When we simulate our generative SDE numerically, using for example EM or our SSCS, we need to choose a time discretization.
Given a certain NFE budget N NFE , how do we choose time step sizes?
The standard approach is to use an equidistant discretization, corresponding to a set of evaluation time steps { δt i ≥ 0 } N NFE − 1 i = with δt i = 1 N NFE ∀ i ∈ [0 , N NFE − 1] .
However, prior work (Song et al., 2021a; Kong & Ping, 2021; Watson et al., 2021) has shown that it can be beneficial to focus function evaluations (neural network calls) on times t “close to the data”.
This is because the diffusion process distribution is most complex close to the data and almost perfectly Normal close to the prior.
Among other techniques, these works used a useful heuristic, denoted as quadratic striding (QS), which discretizes the integration interval such that the evaluation times follow a quadratic schedule and the individual time steps follow a linear schedule.
We also used this QS approach in our experiments.
We can formally define it as follows (assuming a time interval [0 . 0 , 1 . 0] here for simplicity):
Denote the evaluation times as τ i (including 0 . 0 and 1 . 0 ) and define:
[Equation]
Hence,
[Equation]
and c τ = 1 N 2 NFE to ensure that τ
NFE
= 1 . 0 .
This describes the time steps as going from t = 0 to t = 1 .
During synthesis, however, we are going backwards.
Hence, we can define our time steps as
[Equation]
where j now counts time steps in the other direction.
Note that this can be easily adapted to general integration intervals [ ϵ, T ] .
E.2. D ENOISING
As has been pointed out in Jolicoeur-Martineau et al.
(2021b), samples that are generated with models similar to ours can contain noise that is hard to detect visually but worsens FID scores significantly.
Denoising Formulas.
For a fair comparison we use the same denoising setup for all experiments we conducted (including VESDE (PC/ODE) and VPSDE (EM/ODE)) except for LSGM.
9 We simulate the underlying generative ODE/SDE until the time cutoff ε = 10 − 3 and then take a single denoising step of the form
[Equation]
This denoising step can be considered as an Euler–Maruyama step without noise injection.
For
SDEs acting on data directly (VESDE, VPSDE, etc.)
the corresponding denoising formula is
[Equation]
[Table]
Influence of Denoising on Results.
For SDEs acting in the data space directly, it has been reported that this denoising step is crucial to obtain good FID scores Jolicoeur-Martineau et al.
(2021b)
; Song et al.
(2021c).
When we simulate the generative probability flow ODE we found that denoising is important in order for the Runge–Kutta solver not to “blow-up” as t → 0 .
On the other hand, when simulating CLD using our new SSCS solver, we found that denoising only slightly influences FID (see Tab. 7).
We believe that this might be because the neural network does not have any influence on the denoising step for CLD.
More specifically, the neural network only denoises the velocity component.
However, we are primarily interested in the data component.
Putting the drift and diffusion coefficients of CLD in the denoising formula in Eq.
(107), we obtain
[Equation]
S OLVER E RROR T OLERANCES FOR R UNGE –K UTTA 4(5)
In Tab. 2, we report FID scores for a Runge–Kutta 4(5) solver (Dormand & Prince, 1980) as well as the “Gotta Go Fast” solver from Jolicoeur-Martineau et al.
(2021a)
(see their Table 1).
For simulating CLD with Runge–Kutta 4(5)
we chose the solver error tolerances to hit certain regimes of NFEs to facilitate comparisons with VPSDE and VESDE.
We obtain a mean number of function evaluations of 312 and 137 using Runge–Kutta 4(5) solver error tolerances of 10 − 5 and 10 − 3 , respectively.
For VESDE, VPSDE and LSGM we used 10 − 5 as the ODE solver error tolerance, following the recommended default setups (Song et al., 2021c; Vahdat et al., 2021).
These values are used for both relative and absolute error tolerances.
E.2. A BLATION E XPERIMENTS
The model architecture used for all ablation experiments can be found in Tab. 6.
As pointed out in Sec.
5 we found that the hyperparameters γ and M only have small effects on CIFAR-10 FID scores.
On the other hand, we found that the mixed score parameterization helps significantly in obtaining competitive FIDs.
E.2. LSGM-100M M ODEL
Our CLD-based SGM has ≈ 108 M parameters, while the original CIFAR-10 Latent SGM from Vahdat et al.
(2021), to which we compare in Tab. 1, uses ≈ 476 M parameters.
To establish a fairer comparison between our CLD-based SGMs and LSGM (Vahdat et al., 2021), we train another smaller LSGM model with ≈ 109 M parameters.
To do this, we followed the exact setup of the “CIFAR-10 (balanced)” model from LSGM (see Table 7 in Vahdat et al.
, with a few minor modifications: We used a VAE backbone model with only 10 groups instead of 20, which corresponds to a reduction in parameters by a factor of 2 in the encoder and decoder networks.
We also reduced the convolutional channels in the latent space SGM from 512 to 256 and reduced the number of the residual cells per scale from 8 to 4.
With these modifications the resulting “LSGM100M” uses only ≈ 109 M parameters overall with approximately half of them in the encoder and decoder networks and the other half in the latent SGM.
Other than these architecture modifications, our model is trained in exactly the same way as the bigger, original models in Vahdat et al.
[Table]
For evaluation, we follow the recommended setting by Vahdat et al.
and use the same RungeKutta 4(5)
ODE solver with an error tolerance of 10 − 5 to solve the probability flow ODE in LSGM’s latent space.
LSGM-100M achieves an FID of 4.60, an NLL bound of 2.96 bpd, and requires on average 131 NFE for sampling new images.
We report these results in Tabs.
1 and 2 in the main text.
Note that we also tried training a model following the “CIFAR-10 (best FID)” setup, but found training to be unstable (however, the orignal “CIFAR-10 (best FID)” model from Vahdat et al.
(2021) only performs marginally better in FID than their “CIFAR-10 (balanced)” model anyway).
Furthermore, we also tried training another small LSGM with a similar number of parameters but with more parameters in the latent SGM and less in the encoder and decoder networks, compared to the reported LSGM-100M.
However, this model performed significantly worse.
F A DDITIONAL E XPERIMENTS F. T OY E XPERIMENTS F.1. A NALYTICAL S AMPLING
In order to test combinations of diffusions and numerical samplers in isolation, we consider a dataset for which we know the ground truth score function (for all t ) analytically.
In particular, we use the mixture of Normals introduced in App.
E.1; see Fig. 10a for a visualization of the data distribution.
In Fig.
11, we show samples for VPSDE (Euler–Maruyama (EM) sampler) and CLD (EM and SSCS samplers).
For quantitative comparison, we also compute negative log-likelihoods for the three combinations (which can be done easily due to our access to the ground truth distribution): as can be seen in Tab. 8, for each number of steps n ∈ { 20 , 50 , 100 , 200 } CLD with SCSS outperforms both VPSDE and CLD with EM.
As discussed in Sec. 3.3, we can see in Tab. 8 that EM is not wellsuited for CLD.
This is true, in particular, when using a small number of synthesis steps n (function evaluations).
In Fig.
11, we see that CLD with EM leads to sampling distributions which are too broad.
These results are exactly in line with the “diverging” dynamics that is observed when solving
Hamiltonian dynamics with a non-symplectic integrator, such as the standard Euler method (Neal, 2011).
This problematic behavior of Euler-based techniques is more pronounced when using fewer steps with larger stepsizes, which is also what we observe in our experiments.
These results further motivate the use of our novel SSCS, which addresses these challenges, for sampling from our CLDbased SGMs.
F.1. M AXIMUM L IKELIHOOD T RAINING
For maximum likelihood training, models based on overdamped Langevin dynamics such as VPSDE need to learn an unbounded score for t → 0 .
Our model, on the other hand, only ever needs to learn a bounded score even for t = 0 .
For our image data experiments, we use a reweighted objective function to improve visual quality of samples (as is general practice).
Here, we also study training towards maximum likelihood on toy dataset tasks.
To explore this, we repeat the neural network complexity experiment from App.
E.1 with maximum likelihood training (instead of the reweighted objective).
Furthermore, we also train VPSDE-based and CLD-based
SGMs on a challenging toy dataset and find that CLD significantly outperforms VPSDE.
We leave [Figure]
Complexity Experiment.
The setup of this experiment is equivalent to the setup in App.
E.1 up to the training objective: in this experiment we do maximum likelihood learning, i.e., we train CLD models with the objective from Eq.
(8) with λ ( t ) =
Γ β .[-
-]
Furthermore, we test CLD in this setup for three different values of γ .
The results of this experiment can be found in Fig.
For CLD, we find that larger values of γ generally lead to less complex networks, in particular for smaller times t .
However, even for γ = 0 . 04 the learned neural network is still significantly smoother than the network learned for the VPSDE when a mixed score parameterization is used.
Challenging Toy Dataset.
Using the same simple ResNet architecture (less than 100k parameters) from the above experiment, we trained a VPSDE-based as well as a CLD-based SGM to maximize the likelihood of a more challenging toy dataset (the dataset is essentially “multi-scale”, as it involves both large scale—the placement of the swiss rolls—and fine scale—the swiss rolls themselves— structure).
Similar to the other toy datasets, the models are trained for 1M iterations using fresh data synthesized from the data distribution in each batch at a batch size of 512.
In Fig. 13, we compare samples of the models to the data distribution.
Even with our simple model architecture, CLD is able to capture the multi-scale structure of the dataset: the five rolls are adequately resembled and only a few samples are in between modes.
VPSDE, on the other hand, only captures the main modes, but not the fine structure.
Furthermore, VPSDE has the undesired behavior of “connecting” the modes.
Overall, we conclude that also in the maximum likelihood training setting CLD is a promising diffusion showing superior behavior compared to the VPSDE in our toy experiments. [Figure]
[Table]
F. CIFAR-10 — E XTENDED R ESULTS
In this section [Table] we provide additional results on the CIFAR-10 image modeling benchmark.
An extended version of Tab. {+
+}
(sampling the generative SDE with different fixed-step size solvers for different compute budgets) including additional baselines can be found in Tab. 9.
Note that time stepping with quadratic striding (QS) improves sampling from VPSDE- and CLD-based models for all settings except for the combination of VPSDE and EM sampling in the setting n = { 1000 , 2000 } .
For the VESDE (using PC sampling), QS significantly worsens FID scores.
The reason for this could be that the variance of the VESDE already follows an exponential schedule (see Fig. 5 in Song et al.
(2021c)).
We additionally present results for the VPSDE using the DDIM (Denoising Diffusion Implicit Models) sampler (Song et al., 2021a). As was observed by Song et al. (2021a), QS also helps for DDIM.
Importantly, for any n ≥ 150 , our CLD with our novel SSCS (and QS) even outperforms DDIM. Only for n = 50 , DDIM performs better. It needs to be mentioned, however, that the
DDIM sampler was specifically designed for few-step sampling, whereas our CLD with SSCS is derived in a general fashion without this particular regime in mind. In particular, DDIM sampling can be interpreted as a non-Markovian sampling method and it is not clear how to calculate the loglikelihood of hold-out validation data under this non-Markovian synthesis approach. Nevertheless, it would be interesting to also explore non-Markovian DDIM-inspired techniques for CLD-SGMs to further improve sampling speed in CLD-SGMs. Note that our DDIM results shown in Tab. 9 are better than those presented in Song et al.
(2021a) itself, because we are relying on the DDPM++ model trained in Song et al.
(2021c), whereas Song et al. (2021a) uses the DDPM model from Ho et al. Finally, we present additional generated samples from our CLD-SGM model: see Fig.
14 and Fig.for samples from EM-QS with 2000 evaluations and SSCS-QS with 150 evaluations, respectively.
F. C ELEB A-HQ-256 — E XTENDED R ESULTS
In this section, we provide additional qualitative results on CelebA-HQ-256.
For high quality samples using our new SSCS solver see Fig.
Samples generated with an adaptive step size Runge–Kutta 4(5) solver at different solver tolerances can be found in Fig.
We found that our model still generates very good samples even for a solver error tolerance of 10 − 3 using an average of 129 neural network evaluations. Lastly, we show “generation paths” of samples from our CelebA-HQ-256 model: see Fig. 18 and Fig.
19 for samples from the probability flow ODE and the generative SDE, respectively.
We visualize the continuous generation paths via snapshots of data and velocity variables at eight different time steps. Interestingly, we can see that the velocity variables “encode” the data at intermediate t . On the other hand, at time t = 1 . 0 , by construction, both data and velocity are distributed according to the “equilibrium distribution” of the diffusion, namely, p EQ ( u ) = N ( x ; 0 d , I d ) N ( v ; 0 d , M I d ) .
Furthermore, as t → 0 the data variables approximately converge to the data distribution, while the velocity variables approximately converge to another Normal distribution N ( v ; 0 d , γM I d ) (with γ = 0 . 04 in our experiments).
Recall that for CLD, the neural network approximates the score ∇ v t log p t ( v t | x t ) .
We believe that the generation paths are further evidence that CLD-SGMs need to learn simpler models: for fixed t the velocity variable v t appears to be a “noisy” version of the data x t , and therefore we believe p t ( v t | x t ) to be relatively smooth and simple when compared to the marginal p t ( x t ) .
Finally, note that in Figs.
18 and 19, when visualizing the velocity variables, we used a colorization scheme that corresponds exactly to the inverse of the color scheme used for visualizing the images themselves.
Alternatively, we could also interpret this in such a way that we are not actually visualizing velocities, but negative velocities with flipped signs.
When using this inverse colorization scheme for the velocities, we see that at intermediate t , where the velocities encode the data, the color values visualizing image data and velocities are, apart from the additional noise in the velocities, similar (i.e. the velocities appear as noisy versions of the actual images).
This implies that image pixel values x t translate into corresponding negative velocities v t that pull the pixel values back towards the mean of the equilibrium distribution.
This is a consequence of the Hamiltonian coupling between the data and velocity variables.
In other words, it is a result of the negative sign in front of x t in the H term in Eq.
(5) (and analogously for the reverse-time generative SDE).
Also see the visualizations on our project page ( https://nv-tlabs.github.io/CLD-SGM ).
[Figure]
G P ROOFS OF P ERTURBATION K ERNELS
In this section, we prove the correctness of the perturbation kernels of the forward diffusion (App. B.1) as well as for the analytical splitting term in our SSCS (App. D.2).
All derivations are presented for general time-dependent β ( t ) .
G. F ORWARD D IFFUSION
We have the following ODEs describing the evolution of the mean and the covariance matrix
[Equation]
[Equation]
where
[Equation]
[Equation]
In App.
B.1, we claim the following solutions:
[Equation]
and
[Equation]
[Equation]
[Equation]
where B ( t ) = (cid:82) t 0 β (ˆ t ) d ˆ t and µ 0 = [ x 0 , v 0 ]
⊤ as well as Σ xx 0 and Σ vv 0 are initial conditions.
G.1. P ROOF OF C ORRECTNESS OF THE M EAN
Plugging the claimed solution (Eqs. (114)-(118)) back into the ODE (Eq. 110), we obtain
[Equation]
The above can be decomposed into two equations:
[Equation]
[Equation]
[Table]
This completes the proof of the correctness of the mean.
G.1. P ROOF OF C ORRECTNESS OF THE C OVARIANCE
Plugging the claimed solution (Eqs.
back in the ODE (Eq.
, we obtain (cid:34) d ˆ Σ t
[Equation]
Noting that
[Equation]
and
[Equation]
(133) as well as the fact that dD t dt = − 4 β ( t )Γ − 1 D t , we can decompose Eq.
(131) into three equations:
[Equation]
[Equation]
Eq.
(134): Plugging the claimed solution into Eq.
(134), we obtain
[Equation]
[Table]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
This completes the proof of the correctness of the covariance.
G. A NALYTICAL S PLITTING T ERM OF SSCS
We have the following ODEs describing the evolution of the mean and the covariance matrix d ¯ µ t
[Equation]
140) d
[Equation]
[Equation]
where
[Equation]
[Equation]
These ODEs are very similar to the ODEs of the forward diffusion in App.
G.1, the only difference being flipped signs in the off-diagonal terms of f ( T − t ) (highlighted in red).
In App.
D.2, we claim the following solutions
[Equation]
[Equation]
148) and
[Equation]
[Equation]
[Equation]
[Equation]
[Equation]
[Equation]
where B ( t ) = (cid:82) t t ′ β
( T − ˆ t )
d ˆ t and ¯ µ t ′ =
[¯ x t ′ , ¯ v t ′ ]
⊤ is an initial condition.
Differences of the above solution to the solutions of the forward diffusion are again highlighted in red.
Note that by construction the initial covariance for the analytical splitting term of SSCS is the zero matrix, i.e., ¯Σ xxt ′ =
¯Σ xvt ′ =
¯Σ vvt ′ = 0 , since we always initialize from an “updated sample”, which itself does not have any uncertainty.
Also note that in this derivation we use general initial t ′ (whereas in App.
G. we set t ′ = 0 for simplicity).
G.2. P ROOF OF C ORRECTNESS OF THE M EAN
Plugging the claimed solution (Eqs.
(144)-(148)) into the ODE (Eq.
, we obtain
[Equation]
The above can be decomposed into two equations:
[Equation]
[Equation]
where we used the fact that dC t dt = − 2 β ( T − t )
Γ − 1 C t .
Eq.
(157): Plugging the claimed solution into Eq.
[Equation]
we obtain:
[Equation]
Eq.
(128): After simplification
[Equation]
plugging the claimed solution into Eq.
[Equation]
we obtain:
[Equation]
This completes the proof of the correctness of the mean.
G.2.
the claimed solution (Eqs. (149)-(155)) into the ODE (Eq.
, we obtain
[Equation]
[Equation]
with f = f ( T − t ) and G = G ( T − t ) .
Noting that
[Equation]
[Equation]
and
[Equation]
163) as well as the fact dD t dt = − 4 β ( T − t )
Γ − 1 D t
[Equation]
we can decompose Eq.
(161) into three equations:
[Equation]
[Equation]
[Equation]
[Equation]
Eq.
(164): Plugging the claimed solution into Eq.
(164), we obtain
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Equation]
[Table]
[Equation]
[Equation]
This completes the proof of the correctness of the covariance.
To connect back to the SSCS as presented in App. D.2, recall that in practice we use constant β (and
T = 1 ) and that we solve for small time steps of size δt 2 , such that B ( t ) =
β δt 2 , which leads to the expressions presented in App. D.2.