Consistency Models
Yang Song, Prafulla Dhariwal, Mark Chen, Ilya Sutskever
Introduction
Diffusion models (Sohl-Dickstein et al., 2015; Song & Ermon, 2019, 2020; Ho et al., 2020; Song et al., 2021), also known as score-based generative models, have achieved unprecedented success across multiple fields, including image generation (Dhariwal & Nichol, 2021; Nichol et al., 2021; Ramesh et al., 2022; Saharia et al., 2022; Rombach et al., 2022), audio synthesis (Kong et al., 2020; Chen et al., 2021; Popov et al., 2021), and video generation (Ho et al., 2022b, a). A key feature of diffusion models is the iterative sampling process which progressively removes noise from random initial vectors. This iterative process provides a flexible trade-off of compute and sample quality, as using extra compute for more iterations usually yields samples of better quality. It is also the crux of many zero-shot data editing capabilities of diffusion models, enabling them to solve challenging inverse problems ranging from image inpainting, colorization, stroke-guided image editing, to Computed Tomography and Magnetic Resonance Imaging (Song & Ermon, 2019; Song et al., 2021, 2022, 2023; Kawar et al., 2021, 2022; Chung et al., 2023; Meng et al., 2021). However, compared to single-step generative models like GANs (Goodfellow et al., 2014), VAEs (Kingma & Welling, 2014; Rezende et al., 2014), or normalizing flows (Dinh et al., 2015, 2017; Kingma & Dhariwal, 2018), the iterative generation procedure of diffusion models typically requires 10–2000 times more compute for sample generation (Song & Ermon, 2020; Ho et al., 2020; Song et al., 2021; Zhang & Chen, 2022; Lu et al., 2022), causing slow inference and limited real-time applications.
Our objective is to create generative models that facilitate efficient, single-step generation without sacrificing important advantages of iterative sampling, such as trading compute for sample quality when necessary, as well as performing zero-shot data editing tasks. As illustrated in Fig. 1, we build on top of the probability flow (PF) ordinary differential equation (ODE) in continuous-time diffusion models (Song et al., 2021), whose trajectories smoothly transition the data distribution into a tractable noise distribution. We propose to learn a model that maps any point at any time step to the trajectory’s starting point. A notable property of our model is self-consistency: points on the same trajectory map to the same initial point. We therefore refer to such models as consistency models. Consistency models allow us to generate data samples (initial points of ODE trajectories, e.g., in Fig. 1) by converting random noise vectors (endpoints of ODE trajectories, e.g., in Fig. 1) with only one network evaluation. Importantly, by chaining the outputs of consistency models at multiple time steps, we can improve sample quality and perform zero-shot data editing at the cost of more compute, similar to what iterative sampling enables for diffusion models.
To train a consistency model, we offer two methods based on enforcing the self-consistency property. The first method relies on using numerical ODE solvers and a pre-trained diffusion model to generate pairs of adjacent points on a PF ODE trajectory. By minimizing the difference between model outputs for these pairs, we can effectively distill a diffusion model into a consistency model, which allows generating high-quality samples with one network evaluation. By contrast, our second method eliminates the need for a pre-trained diffusion model altogether, allowing us to train a consistency model in isolation. This approach situates consistency models as an independent family of generative models. Importantly, neither approach necessitates adversarial training, and they both place minor constraints on the architecture, allowing the use of flexible neural networks for parameterizing consistency models.
We demonstrate the efficacy of consistency models on several image datasets, including CIFAR-10 (Krizhevsky et al., 2009), ImageNet (Deng et al., 2009), and LSUN (Yu et al., 2015). Empirically, we observe that as a distillation approach, consistency models outperform existing diffusion distillation methods like progressive distillation (Salimans & Ho, 2022) across a variety of datasets in few-step generation: On CIFAR-10, consistency models reach new state-of-the-art FIDs of 3.55 and 2.93 for one-step and two-step generation; on ImageNet , it achieves record-breaking FIDs of 6.20 and 4.70 with one and two network evaluations respectively. When trained as standalone generative models, consistency models can match or surpass the quality of one-step samples from progressive distillation, despite having no access to pre-trained diffusion models. They are also able to outperform many GANs, and existing non-adversarial, single-step generative models across multiple datasets. Furthermore, we show that consistency models can be used to perform a wide range of zero-shot data editing tasks, including image denoising, interpolation, inpainting, colorization, super-resolution, and stroke-guided image editing (SDEdit, Meng et al. (2021)).
Diffusion Models
Consistency models are heavily inspired by the theory of continuous-time diffusion models (Song et al., 2021; Karras et al., 2022). Diffusion models generate data by progressively perturbing data to noise via Gaussian perturbations, then creating samples from noise via sequential denoising steps. Let denote the data distribution. Diffusion models start by diffusing with a stochastic differential equation (SDE) (Song et al., 2021)
where , is a fixed constant, and are the drift and diffusion coefficients respectively, and denotes the standard Brownian motion. We denote the distribution of as and as a result . A remarkable property of this SDE is the existence of an ordinary differential equation (ODE), dubbed the Probability Flow (PF) ODE by Song et al. (2021), whose solution trajectories sampled at are distributed according to :
Here is the score function of ; hence diffusion models are also known as score-based generative models (Song & Ermon, 2019, 2020; Song et al., 2021).
Typically, the SDE in Eq. 1 is designed such that is close to a tractable Gaussian distribution . We hereafter adopt the settings in Karras et al. (2022), where and . In this case, we have , where denotes the convolution operation, and . For sampling, we first train a score model via score matching (Hyvärinen & Dayan, 2005; Vincent, 2011; Song et al., 2019; Song & Ermon, 2019; Ho et al., 2020), then plug it into Eq. 2 to obtain an empirical estimate of the PF ODE, which takes the form of
We call Eq. 3 the empirical PF ODE. Next, we sample to initialize the empirical PF ODE and solve it backwards in time with any numerical ODE solver, such as Euler (Song et al., 2020, 2021) and Heun solvers (Karras et al., 2022), to obtain the solution trajectory . The resulting can then be viewed as an approximate sample from the data distribution . To avoid numerical instability, one typically stops the solver at , where is a fixed small positive number, and accepts as the approximate sample. Following Karras et al. (2022), we rescale image pixel values to $T=80,\epsilon=0.002$.
Diffusion models are bottlenecked by their slow sampling speed. Clearly, using ODE solvers for sampling requires iterative evaluations of the score model , which is computationally costly. Existing methods for fast sampling include faster numerical ODE solvers (Song et al., 2020; Zhang & Chen, 2022; Lu et al., 2022; Dockhorn et al., 2022), and distillation techniques (Luhman & Luhman, 2021; Salimans & Ho, 2022; Meng et al., 2022; Zheng et al., 2022). However, ODE solvers still need more than 10 evaluation steps to generate competitive samples. Most distillation methods like Luhman & Luhman (2021) and Zheng et al. (2022) rely on collecting a large dataset of samples from the diffusion model prior to distillation, which itself is computationally expensive. To our best knowledge, the only distillation approach that does not suffer from this drawback is progressive distillation (PD, Salimans & Ho (2022)), with which we compare consistency models extensively in our experiments.
Consistency Models
We propose consistency models, a new type of models that support single-step generation at the core of its design, while still allowing iterative generation for trade-offs between sample quality and compute, and zero-shot data editing. Consistency models can be trained in either the distillation mode or the isolation mode. In the former case, consistency models distill the knowledge of pre-trained diffusion models into a single-step sampler, significantly improving other distillation approaches in sample quality, while allowing zero-shot image editing applications. In the latter case, consistency models are trained in isolation, with no dependence on pre-trained diffusion models. This makes them an independent new class of generative models.
Below we introduce the definition, parameterization, and sampling of consistency models, plus a brief discussion on their applications to zero-shot data editing.
Definition Given a solution trajectory of the PF ODE in Eq. 2, we define the consistency function as . A consistency function has the property of self-consistency: its outputs are consistent for arbitrary pairs of that belong to the same PF ODE trajectory, i.e., for all . As illustrated in Fig. 2, the goal of a consistency model, symbolized as , is to estimate this consistency function from data by learning to enforce the self-consistency property (details in Sections 4 and 5). Note that a similar definition is used for neural flows (Biloš et al., 2021) in the context of neural ODEs (Chen et al., 2018). Compared to neural flows, however, we do not enforce consistency models to be invertible.
Parameterization For any consistency function , we have , i.e., is an identity function. We call this constraint the boundary condition. All consistency models have to meet this boundary condition, as it plays a crucial role in the successful training of consistency models. This boundary condition is also the most confining architectural constraint on consistency models. For consistency models based on deep neural networks, we discuss two ways to implement this boundary condition almost for free. Suppose we have a free-form deep neural network whose output has the same dimensionality as . The first way is to simply parameterize the consistency model as
The second method is to parameterize the consistency model using skip connections, that is,
where and are differentiable functions such that , and . This way, the consistency model is differentiable at if are all differentiable, which is critical for training continuous-time consistency models (Sections B.1 and B.2). The parameterization in Eq. 5 bears strong resemblance to many successful diffusion models (Karras et al., 2022; Balaji et al., 2022), making it easier to borrow powerful diffusion model architectures for constructing consistency models. We therefore follow the second parameterization in all experiments.
Sampling With a well-trained consistency model , we can generate samples by sampling from the initial distribution and then evaluating the consistency model for . This involves only one forward pass through the consistency model and therefore generates samples in a single step. Importantly, one can also evaluate the consistency model multiple times by alternating denoising and noise injection steps for improved sample quality. Summarized in Algorithm 1, this multistep sampling procedure provides the flexibility to trade compute for sample quality. It also has important applications in zero-shot data editing. In practice, we find time points in Algorithm 1 with a greedy algorithm, where the time points are pinpointed one at a time using ternary search to optimize the FID of samples obtained from Algorithm 1. This assumes that given prior time points, the FID is a unimodal function of the next time point. We find this assumption to hold empirically in our experiments, and leave the exploration of better strategies as future work.
Zero-Shot Data Editing Similar to diffusion models, consistency models enable various data editing and manipulation applications in zero shot; they do not require explicit training to perform these tasks. For example, consistency models define a one-to-one mapping from a Gaussian noise vector to a data sample. Similar to latent variable models like GANs, VAEs, and normalizing flows, consistency models can easily interpolate between samples by traversing the latent space (Fig. 11). As consistency models are trained to recover from any noisy input where , they can perform denoising for various noise levels (Fig. 12). Moreover, the multistep generation procedure in Algorithm 1 is useful for solving certain inverse problems in zero shot by using an iterative replacement procedure similar to that of diffusion models (Song & Ermon, 2019; Song et al., 2021; Ho et al., 2022b). This enables many applications in the context of image editing, including inpainting (Fig. 10), colorization (Fig. 8), super-resolution (Fig. 6(b)) and stroke-guided image editing (Fig. 13) as in SDEdit (Meng et al., 2021). In Section 6.3, we empirically demonstrate the power of consistency models on many zero-shot image editing tasks.
Training Consistency Models via Distillation
We present our first method for training consistency models based on distilling a pre-trained score model . Our discussion revolves around the empirical PF ODE in Eq. 3, obtained by plugging the score model into the PF ODE. Consider discretizing the time horizon into sub-intervals, with boundaries . In practice, we follow Karras et al. (2022) to determine the boundaries with the formula , where . When is sufficiently large, we can obtain an accurate estimate of from by running one discretization step of a numerical ODE solver. This estimate, which we denote as , is defined by
where represents the update function of a one-step ODE solver applied to the empirical PF ODE. For example, when using the Euler solver, we have which corresponds to the following update rule
For simplicity, we only consider one-step ODE solvers in this work. It is straightforward to generalize our framework to multistep ODE solvers and we leave it as future work.
Due to the connection between the PF ODE in Eq. 2 and the SDE in Eq. 1 (see Section 2), one can sample along the distribution of ODE trajectories by first sampling , then adding Gaussian noise to . Specifically, given a data point , we can generate a pair of adjacent data points on the PF ODE trajectory efficiently by sampling from the dataset, followed by sampling from the transition density of the SDE , and then computing using one discretization step of the numerical ODE solver according to Eq. 6. Afterwards, we train the consistency model by minimizing its output differences on the pair . This motivates our following consistency distillation loss for training consistency models.
The consistency distillation loss is defined as
The overall training procedure is summarized in Algorithm 2. In alignment with the convention in deep reinforcement learning (Mnih et al., 2013, 2015; Lillicrap et al., 2015) and momentum based contrastive learning (Grill et al., 2020; He et al., 2020), we refer to as the “target network”, and as the “online network”. We find that compared to simply setting , the EMA update and “stopgrad” operator in Eq. 8 can greatly stabilize the training process and improve the final performance of the consistency model.
Below we provide a theoretical justification for consistency distillation based on asymptotic analysis.
Let , and be the consistency function of the empirical PF ODE in Eq. 3. Assume satisfies the Lipschitz condition: there exists such that for all , , and , we have . Assume further that for all , the ODE solver called at has local error uniformly bounded by with . Then, if , we have
The proof is based on induction and parallels the classic proof of global error bounds for numerical ODE solvers (Süli & Mayers, 2003). We provide the full proof in Section A.2. ∎
Since is a running average of the history of , we have when the optimization of Algorithm 2 converges. That is, the target and online consistency models will eventually match each other. If the consistency model additionally achieves zero consistency distillation loss, then Theorem 1 implies that, under some regularity conditions, the estimated consistency model can become arbitrarily accurate, as long as the step size of the ODE solver is sufficiently small. Importantly, our boundary condition precludes the trivial solution from arising in consistency model training.
The consistency distillation loss can be extended to hold for infinitely many time steps () if or . The resulting continuous-time loss functions do not require specifying nor the time steps . Nonetheless, they involve Jacobian-vector products and require forward-mode automatic differentiation for efficient implementation, which may not be well-supported in some deep learning frameworks. We provide these continuous-time distillation loss functions in Theorems 3, 4 and 5, and relegate details to Section B.1.
Training Consistency Models in Isolation
Consistency models can be trained without relying on any pre-trained diffusion models. This differs from existing diffusion distillation techniques, making consistency models a new independent family of generative models.
Recall that in consistency distillation, we rely on a pre-trained score model to approximate the ground truth score function . It turns out that we can avoid this pre-trained score model altogether by leveraging the following unbiased estimator (Lemma 1 in Appendix A):
where and . That is, given and , we can estimate with .
This unbiased estimate suffices to replace the pre-trained diffusion model in consistency distillation when using the Euler method as the ODE solver in the limit of , as justified by the following result.
where the expectation is taken with respect to , , and . The consistency training objective, denoted by , is defined as
where . Moreover, if .
The proof is based on Taylor series expansion and properties of score functions (Lemma 1). A complete proof is provided in Section A.3. ∎
We refer to Eq. 10 as the consistency training (CT) loss. Crucially, only depends on the online network , and the target network , while being completely agnostic to diffusion model parameters . The loss function decreases at a slower rate than the remainder and thus will dominate the loss in Eq. 9 as and .
For improved practical performance, we propose to progressively increase during training according to a schedule function . The intuition (cf., Fig. 3(d)) is that the consistency training loss has less “variance” but more “bias” with respect to the underlying consistency distillation loss (i.e., the left-hand side of Eq. 9) when is small (i.e., is large), which facilitates faster convergence at the beginning of training. On the contrary, it has more “variance” but less “bias” when is large (i.e., is small), which is desirable when closer to the end of training. For best performance, we also find that should change along with , according to a schedule function . The full algorithm of consistency training is provided in Algorithm 3, and the schedule functions used in our experiments are given in Appendix C.
Similar to consistency distillation, the consistency training loss can be extended to hold in continuous time (i.e., ) if , as shown in Theorem 6. This continuous-time loss function does not require schedule functions for or , but requires forward-mode automatic differentiation for efficient implementation. Unlike the discrete-time CT loss, there is no undesirable “bias” associated with the continuous-time objective, as we effectively take in Theorem 2. We relegate more details to Section B.2.
Experiments
We employ consistency distillation and consistency training to learn consistency models on real image datasets, including CIFAR-10 (Krizhevsky et al., 2009), ImageNet (Deng et al., 2009), LSUN Bedroom , and LSUN Cat (Yu et al., 2015). Results are compared according to Fréchet Inception Distance (FID, Heusel et al. (2017), lower is better), Inception Score (IS, Salimans et al. (2016), higher is better), Precision (Prec., Kynkäänniemi et al. (2019), higher is better), and Recall (Rec., Kynkäänniemi et al. (2019), higher is better). Additional experimental details are provided in Appendix C.
We perform a series of experiments on CIFAR-10 to understand the effect of various hyperparameters on the performance of consistency models trained by consistency distillation (CD) and consistency training (CT). We first focus on the effect of the metric function , the ODE solver, and the number of discretization steps in CD, then investigate the effect of the schedule functions and in CT.
Due to the strong connection between CD and CT, we adopt LPIPS for our CT experiments throughout this paper. Unlike CD, there is no need for using Heun’s second order solver in CT as the loss function does not rely on any particular numerical ODE solver. As demonstrated in Fig. 3(d), the convergence of CT is highly sensitive to —smaller leads to faster convergence but worse samples, whereas larger leads to slower convergence but better samples upon convergence. This matches our analysis in Section 5, and motivates our practical choice of progressively growing and for CT to balance the trade-off between convergence speed and sample quality. As shown in Fig. 3(d), adaptive schedules of and significantly improve the convergence speed and sample quality of CT. In our experiments, we tune the schedules and separately for images of different resolutions, with more details in Appendix C.
2 Few-Step Image Generation
3 Zero-Shot Image Editing
Similar to diffusion models, consistency models allow zero-shot image editing by modifying the multistep sampling process in Algorithm 1. We demonstrate this capability with a consistency model trained on the LSUN bedroom dataset using consistency distillation. In Fig. 6(a), we show such a consistency model can colorize gray-scale bedroom images at test time, even though it has never been trained on colorization tasks. In Fig. 6(b), we show the same consistency model can generate high-resolution images from low-resolution inputs. In Fig. 6(c), we additionally demonstrate that it can generate images based on stroke inputs created by humans, as in SDEdit for diffusion models (Meng et al., 2021). Again, this editing capability is zero-shot, as the model has not been trained on stroke inputs. In Appendix D, we additionally demonstrate the zero-shot capability of consistency models on inpainting (Fig. 10), interpolation (Fig. 11) and denoising (Fig. 12), with more examples on colorization (Fig. 8), super-resolution (Fig. 9) and stroke-guided image generation (Fig. 13).
Conclusion
We have introduced consistency models, a type of generative models that are specifically designed to support one-step and few-step generation. We have empirically demonstrated that our consistency distillation method outshines the existing distillation techniques for diffusion models on multiple image benchmarks and small sampling iterations. Furthermore, as a standalone generative model, consistency models generate better samples than existing single-step generation models except for GANs. Similar to diffusion models, they also allow zero-shot image editing applications such as inpainting, colorization, super-resolution, denoising, interpolation, and stroke-guided image generation.
In addition, consistency models share striking similarities with techniques employed in other fields, including deep Q-learning (Mnih et al., 2015) and momentum-based contrastive learning (Grill et al., 2020; He et al., 2020). This offers exciting prospects for cross-pollination of ideas and methods among these diverse fields.
Acknowledgements
We thank Alex Nichol for reviewing the manuscript and providing valuable feedback, Chenlin Meng for providing stroke inputs needed in our stroke-guided image generation experiments, and the OpenAI Algorithms team.
References
Appendix A Proofs
We use to denote a consistency model parameterized by , and the consistency function of the empirical PF ODE in Eq. 3. Here symbolizes its dependency on the pre-trained score model . For the consistency function of the PF ODE in Eq. 2, we denote it as . Given a multi-variate function , we let denote the Jacobian of over , and analogously denote the Jacobian of over . Unless otherwise stated, is supposed to be a random variable sampled from the data distribution , is sampled uniformly at random from , and is sampled from . Here represents the set of integers . Furthermore, recall that we define
A.2 Consistency Distillation
Let , and be the consistency function of the empirical PF ODE in Eq. 3. Assume satisfies the Lipschitz condition: there exists such that for all , , and , we have . Assume further that for all , the ODE solver called at has local error uniformly bounded by with . Then, if , we have
From , we have
According to the definition, we have where . It follows that for every and . Therefore, Eq. 11 entails
Because and , this further implies that
Now let represent the error vector at , which is defined as
We can easily derive the following recursion relation
where (i) is due to Eq. 13 and . Because has Lipschitz constant , we have
where (i) holds because the ODE solver has local error bounded by . In addition, we observe that , because
Here (i) is true because the consistency model is parameterized such that and (ii) is entailed by the definition of . This allows us to perform induction on the recursion formula Eq. 14 to obtain
A.3 Consistency Training
The following lemma provides an unbiased estimator for the score function, which is crucial to our proof for Theorem 2.
where the expectation is taken with respect to , , and . The consistency training objective, denoted by , is defined as
where . Moreover, if .
Then, we apply Lemma 1 to Eq. 15 and use Taylor expansion in the reverse direction to obtain
where (i) is due to the law of total expectation, and . This implies and thus completes the proof for Eq. 9. Moreover, we have whenever . Otherwise, and thus , which is a clear contradiction to . ∎
When the condition is not satisfied, such as in the case where , the validity of as a training objective for consistency models can still be justified by referencing the result provided in Theorem 6.
Appendix B Continuous-Time Extensions
The consistency distillation and consistency training objectives can be generalized to hold for infinite time steps () under suitable conditions.
Depending on whether or (same as setting ), there are two possible continuous-time extensions for the consistency distillation objective . Given a twice continuously differentiable metric function , we define as a matrix, whose -th entry is given by
Similarly, we define as
The matrices and play a crucial role in forming continuous-time objectives for consistency distillation. Additionally, we denote the Jacobian of with respect to as .
When (with no stopgrad operator), we have the following theoretical result.
Let , where , and is a strictly monotonic function with and . Assume is continuously differentiable in $d{\bm{f}}_{{\bm{\theta}}}\lambda(\cdot)\sup_{{\mathbf{x}},t\in[\epsilon,T]}\left\lVert{\bm{s}}_{\bm{\phi}}({\mathbf{x}},t)\right\rVert_{2}<\infty$. Then with the Euler solver in consistency distillation, we have
where is defined as
Here the expectation above is taken over , , , and .
Let and . First, we can derive the following equation with Taylor expansion:
Note that . Then, we apply Taylor expansion to the consistency distillation loss, which gives
where we obtain (i) by expanding to second order and observing and . We obtain (ii) using Eq. 19. By taking the limit for both sides of Eq. 28 as or equivalently , we arrive at Eq. 17, which completes the proof. ∎
Although Theorem 3 assumes the Euler ODE solver for technical simplicity, we believe an analogous result can be derived for more general solvers, since all ODE solvers should perform similarly as . We leave a more general version of Theorem 3 as future work.
Theorem 3 implies that consistency models can be trained by minimizing . In particular, when , we have
However, this continuous-time objective requires computing Jacobian-vector products as a subroutine to evaluate the loss function, which can be slow and laborious to implement in deep learning frameworks that do not support forward-mode automatic differentiation.
If matches the ground truth consistency function for the empirical PF ODE of , then
and therefore . This can be proved by noting that for all , and then taking the time-derivative of this identity:
The above observation provides another motivation for , as it is minimized if and only if the consistency model matches the ground truth consistency function.
Let , where , and is a strictly monotonic function with and . Assume is continuously differentiable in ${\bm{f}}_{{\bm{\theta}}}\lambda(\cdot)\sup_{{\mathbf{x}},t\in[\epsilon,T]}\left\lVert{\bm{s}}_{\bm{\phi}}({\mathbf{x}},t)\right\rVert_{2}<\inftyd({\mathbf{x}},{\mathbf{y}})=\left\lVert{\mathbf{x}}-{\mathbf{y}}\right\rVert_{1}$ in consistency distillation. Then we have
where the expectation above is taken over , , , and .
Let and . We have
where (i) is obtained by plugging Eq. 19 into the previous equation. Taking the limit for both sides of Eq. 31 as or equivalently leads to Eq. 30, which completes the proof. ∎
In the second case where , we can derive a so-called “pseudo-objective” whose gradient matches the gradient of in the limit of . Minimizing this pseudo-objective with gradient descent gives another way to train consistency models via distillation. This pseudo-objective is provided by the theorem below.
Let , where , and is a strictly monotonic function with and . Assume is continuously differentiable in $d{\bm{f}}_{{\bm{\theta}}}\lambda(\cdot)\sup_{{\mathbf{x}},t\in[\epsilon,T]}\left\lVert{\bm{s}}_{\bm{\phi}}({\mathbf{x}},t)\right\rVert_{2}<\infty\sup_{{\mathbf{x}},t\in[\epsilon,T]}\left\lVert\nabla_{\bm{\theta}}{\bm{f}}_{\bm{\theta}}({\mathbf{x}},t)\right\rVert_{2}<\infty{\bm{\theta}}^{-}=\operatorname{stopgrad}({\bm{\theta}})$ in consistency distillation. Then,
Here the expectation above is taken over , , , and .
We denote and . First, we leverage Taylor series expansion to obtain
where (i) is derived by expanding to second order and leveraging and . Next, we compute the gradient of Eq. 37 with respect to and simplify the result to obtain
Here (i) results from the chain rule, and (ii) follows from Eq. 19 and , since . Taking the limit for both sides of Eq. 49 as (or ) yields Eq. 32, which completes the proof. ∎
When , the pseudo-objective can be simplified to
The objective defined in Theorem 5 is only meaningful in terms of its gradient—one cannot measure the progress of training by tracking the value of , but can still apply gradient descent to this objective to distill consistency models from pre-trained diffusion models. Because this objective is not a typical loss function, we refer to it as the “pseudo-objective” for consistency distillation.
Following the same reasoning in Remark 4, we can easily derive that and if matches the ground truth consistency function for the empirical PF ODE that involves . However, the converse does not hold true in general. This distinguishes from , the latter of which is a true loss function.
B.2 Consistency Training in Continuous Time
A remarkable observation is that the pseudo-objective in Theorem 5 can be estimated without any pre-trained diffusion models, which enables direct consistency training of consistency models. More precisely, we have the following result.
where uses the Euler ODE solver, and
Here the expectation above is taken over , , , and .
The proof mostly follows that of Theorem 5. First, we leverage Taylor series expansion to obtain
where , (i) is derived by first expanding to second order, and then noting that and . Next, we compute the gradient of Eq. 58 with respect to and simplify the result to obtain
Here (i) results from the chain rule, and (ii) follows from Taylor expansion. Taking the limit for both sides of Eq. 74 as or yields the second equality in Eq. 51.
Now we prove the first equality. Applying Taylor expansion again, we obtain
where (i) holds because and . Because (i) matches Eq. 64, we can use the same reasoning procedure from Eq. 64 to Eq. 74 to conclude , completing the proof. ∎
Note that does not depend on the diffusion model parameter and hence can be optimized without any pre-trained diffusion models.
When , the continuous-time consistency training objective becomes
Similar to in Theorem 5, is a pseudo-objective; one cannot track training by monitoring the value of , but can still apply gradient descent on this loss function to train a consistency model directly from data. Moreover, the same observation in Remark 8 holds true: and if matches the ground truth consistency function for the PF ODE.
B.3 Experimental Verifications
To experimentally verify the efficacy of our continuous-time CD and CT objectives, we train consistency models with a variety of loss functions on CIFAR-10. All results are provided in Fig. 7. We set for all continuous-time experiments. Other hyperparameters are the same as in Table 3. We occasionally modify some hyperparameters for improved performance. For distillation, we compare the following objectives:
CD (LPIPS): Consistency distillation with and the LPIPS metric.
CD∞ (stopgrad, LPIPS): Consistency distillation in Theorem 5 with the LPIPS metric. We set the learning rate to 5e-6.
For consistency training (CT), we find it important to initialize consistency models from a pre-trained EDM model in order to stabilize training when using continuous-time objectives. We hypothesize that this is caused by the large variance in our continuous-time loss functions. For fair comparison, we thus initialize all consistency models from the same pre-trained EDM model on CIFAR-10 for both discrete-time and continuous-time CT, even though the former works well with random initialization. We leave variance reduction techniques for continuous-time CT to future research.
We empirically compare the following objectives:
CT (LPIPS): Consistency training with and the LPIPS metric. We set the learning rate to 4e-4, and the EMA decay rate for the target network to 0.99. We do not use the schedule functions for and here because they cause slower learning when the consistency model is initialized from a pre-trained EDM model.
CT∞ (LPIPS): Consistency training with the LPIPS metric. We set the learning rate to 5e-6.
As shown in Fig. 7(b), the LPIPS metric leads to improved performance for continuous-time CT. We also find that continuous-time CT outperforms discrete-time CT with the same LPIPS metric. This is likely due to the bias in discrete-time CT, as in Theorem 2 for discrete-time objectives, whereas continuous-time CT has no bias since it implicitly drives to .
Appendix C Additional Experimental Details
We follow Song et al. (2021); Dhariwal & Nichol (2021) for model architectures. Specifically, we use the NCSN++ architecture in Song et al. (2021) for all CIFAR-10 experiments, and take the corresponding network architectures from Dhariwal & Nichol (2021) when performing experiments on ImageNet , LSUN Bedroom and LSUN Cat .
Parameterization for Consistency Models
We use the same architectures for consistency models as those used for EDMs. The only difference is we slightly modify the skip connections in EDM to ensure the boundary condition holds for consistency models. Recall that in Section 3 we propose to parameterize a consistency model in the following form:
In EDM (Karras et al., 2022), authors choose
where . However, this choice of and does not satisfy the boundary condition when the smallest time instant . To remedy this issue, we modify them to
which clearly satisfies and .
Schedule Functions for Consistency Training
As discussed in Section 5, consistency generation requires specifying schedule functions and for best performance. Throughout our experiments, we use schedule functions that take the form below:
where denotes the total number of training iterations, denotes the initial discretization steps, denotes the target discretization steps at the end of training, and denotes the EMA decay rate at the beginning of model training.
Training Details
In both consistency distillation and progressive distillation, we distill EDMs (Karras et al., 2022). We trained these EDMs ourselves according to the specifications given in Karras et al. (2022). The original EDM paper did not provide hyperparameters for the LSUN Bedroom and Cat datasets, so we mostly used the same hyperparameters as those for the ImageNet dataset. The difference is that we trained for 600k and 300k iterations for the LSUN Bedroom and Cat datasets respectively, and reduced the batch size from 4096 to 2048.
We used the same EMA decay rate for LSUN datasets as for the ImageNet dataset. For progressive distillation, we used the same training settings as those described in Salimans & Ho (2022) for CIFAR-10 and ImageNet . Although the original paper did not test on LSUN datasets, we used the same settings for ImageNet and found them to work well.
In all distillation experiments, we initialized the consistency model with pre-trained EDM weights. For consistency training, we initialized the model randomly, just as we did for training the EDMs. We trained all consistency models with the Rectified Adam optimizer (Liu et al., 2019), with no learning rate decay or warm-up, and no weight decay. We also applied EMA to the weights of the online consistency models in both consistency distillation and consistency training, as well as to the weights of the training online consistency models according to Karras et al. (2022). For LSUN datasets, we chose the EMA decay rate to be the same as that for ImageNet , except for consistency distillation on LSUN Bedroom , where we found that using zero EMA worked better.
When using the LPIPS metric on CIFAR-10 and ImageNet , we rescale images to resolution with bilinear upsampling before feeding them to the LPIPS network. For LSUN , we evaluated LPIPS without rescaling inputs. In addition, we performed horizontal flips for data augmentation for all models and on all datasets. We trained all models on a cluster of Nvidia A100 GPUs. Additional hyperparameters for consistency training and distillation are listed in Table 3.
Appendix D Additional Results on Zero-Shot Image Editing
With consistency models, we can perform a variety of zero-shot image editing tasks. As an example, we present additional results on colorization (Fig. 8), super-resolution (Fig. 9), inpainting (Fig. 10), interpolation (Fig. 11), denoising (Fig. 12), and stroke-guided image generation (SDEdit, Meng et al. (2021), Fig. 13). The consistency model used here is trained via consistency distillation on the LSUN Bedroom .
All these image editing tasks, except for image interpolation and denoising, can be performed via a small modification to the multistep sampling algorithm in Algorithm 1. The resulting pseudocode is provided in Algorithm 4. Here is a reference image that guides sample generation, is a binary mask, computes element-wise products, and is an invertible linear transformation that maps images into a latent space where the conditional information in is infused into the iterative generation procedure by masking with . Unless otherwise stated, we choose
in our experiments, where for LSUN Bedroom .
Below we describe how to perform each task using Algorithm 4.
When using Algorithm 4 for inpainting, we let be an image where missing pixels are masked out, be a binary mask where 1 indicates the missing pixels, and be the identity transformation.
Colorization
We define to be a binary mask such that
With and defined as above, we can now use Algorithm 4 for image colorization.
Super-resolution
Above definitions of and allow us to use Algorithm 4 for image super-resolution.
Stroke-guided image generation
Denoising
It is possible to denoise images perturbed with various scales of Gaussian noise using a single consistency model. Suppose the input image is perturbed with . As long as , we can evaluate to produce the denoised image.
Interpolation
We can interpolate between two images generated by consistency models. Suppose the first sample is produced by noise vector , and the second sample is produced by noise vector . In other words, and . To interpolate between and , we first use spherical linear interpolation to get
where and , then evaluate to produce the interpolated image.
Appendix E Additional Samples from Consistency Models
We provide additional samples from consistency distillation (CD) and consistency training (CT) on CIFAR-10 (Figs. 14 and 18), ImageNet (Figs. 15 and 19), LSUN Bedroom (Figs. 16 and 20) and LSUN Cat (Figs. 17 and 21).