Search

Search papers and lessons

Consistency Model

Level 4 · 11 min read

A consistency model learns a function that maps any point on a diffusion model's noise-to-data trajectory straight to its endpoint, so one network call can produce a sample.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Linear algebra
  • Generative models
  • Discrete math
  • Inference
  • Sign in to see your progress

TL;DR

A diffusion model makes samples by solving a differential equation from noise back to data, and that takes many network calls. A consistency model learns a function that takes any point on one of those trajectories and returns the trajectory's starting point, which is the clean sample. Because every point on the same trajectory must map to the same answer, the model can produce a sample in one call, and can trade extra calls for better quality.

Where you'll see it: fast image generation from diffusion-style models, where cutting the sampler from dozens of steps to one or two matters for latency, and zero-shot editing such as inpainting or super-resolution done by iterating the same function.

Intuition

Every point on a path leads to the same place

Imagine water flowing down a hillside with many channels. Each drop of water follows a path from its starting point on the ridge to a single valley at the bottom. Now suppose you could place a sign at every point on the hill that says where that point's water will end up. Two drops on the same channel would have the same sign. If you could read a sign from any point, you would not have to walk the channel to find the valley.

A consistency model is that sign. The "hill" is the space of noisy images. The "channels" are trajectories of a probability-flow equation that carries a noisy image back to a clean one. The "valley" is the clean image the trajectory started from. The model is trained so that every noisy point on a trajectory gets the same answer.

Why this speeds things up

A diffusion model computes its answer by following the channel in many small steps, each needing a network call. Its accuracy depends on how many steps it takes. A consistency model skips the walk: given a noisy image at the top of the hill, one call gives the valley. If you want more quality, you can read the sign at a point partway down, add a little noise to push the point back up to a random place on the hill, and read the sign again. Each extra read is an extra call that buys quality.

flowchart LR
  A[Noise x_T] -->|one call| Z[Clean sample x_eps]
  B[Point x_t on trajectory] -->|same answer| Z
  C[Point x_t prime on same trajectory] -->|same answer| Z

The math

Setup: the probability-flow ODE

Let pdata(x)p_{\text{data}}(\mathbf{x}) be the data distribution. Following the continuous-time diffusion formulation of Song and colleagues, add noise with the SDE that has zero drift and noise scale σ(t)=2t\sigma(t) = \sqrt{2t}. The noisy distribution at time tt is then

pt(x)=pdata(x)⊗N(0,t2I),p_t(\mathbf{x}) = p_{\text{data}}(\mathbf{x}) \otimes \mathcal{N}(\mathbf{0}, t^2 \mathbf{I}),

where ⊗\otimes is convolution. Time runs over [ϵ,T][\epsilon, T] with a small ϵ\epsilon and a large TT. At t=Tt = T the distribution is close to N(0,T2I)\mathcal{N}(\mathbf{0}, T^2 \mathbf{I}), which is easy to sample.

The forward noise process has a deterministic counterpart, the probability-flow ODE. Its solution trajectories, run from time TT down to ϵ\epsilon, have the same marginal distributions ptp_t as the noising process:

dxtdt=−t ∇xlog⁡pt(xt).\frac{d\mathbf{x}_t}{dt} = -t\, \nabla_{\mathbf{x}} \log p_t(\mathbf{x}_t).

The term ∇xlog⁡pt\nabla_{\mathbf{x}} \log p_t is the score. A diffusion model learns an approximation sϕ(x,t)≈∇log⁡pt(x)\mathbf{s}_\phi(\mathbf{x}, t) \approx \nabla \log p_t(\mathbf{x}) and then solves the ODE numerically, using many steps. Solving it from xT∼N(0,T2I)\mathbf{x}_T \sim \mathcal{N}(\mathbf{0}, T^2 \mathbf{I}) backward to ϵ\epsilon produces a sample.

The consistency function

Definition: Consistency function

Given a trajectory {xt}t∈[ϵ,T]\{\mathbf{x}_t\}_{t \in [\epsilon, T]} of the probability-flow ODE, the consistency function is

f(xt,t)=xϵ.\mathbf{f}(\mathbf{x}_t, t) = \mathbf{x}_\epsilon.

It satisfies self-consistency: for any two points on the same trajectory, f(xt,t)=f(xt′,t′)\mathbf{f}(\mathbf{x}_t, t) = \mathbf{f}(\mathbf{x}_{t'}, t').

A consistency model fθ\mathbf{f}_\theta is a neural network trained to approximate f\mathbf{f}. Two constraints follow from the definition. The first is the boundary condition: at t=ϵt = \epsilon the function must return its input, fθ(x,ϵ)=x\mathbf{f}_\theta(\mathbf{x}, \epsilon) = \mathbf{x}, because the trajectory has already ended there. Every design has to respect this, and it is the most restrictive architectural requirement.

Parameterisation that meets the boundary condition

A simple way to enforce the boundary condition is a skip connection. Let FθF_\theta be any free-form network with the same output size as x\mathbf{x}, and set

fθ(x,t)=cskip(t) x+cout(t) Fθ(x,t),\mathbf{f}_\theta(\mathbf{x}, t) = c_{\text{skip}}(t)\, \mathbf{x} + c_{\text{out}}(t)\, F_\theta(\mathbf{x}, t),

with cskip(ϵ)=1c_{\text{skip}}(\epsilon) = 1 and cout(ϵ)=0c_{\text{out}}(\epsilon) = 0. The paper uses, with σdata=0.5\sigma_{\text{data}} = 0.5,

cskip(t)=σdata2(t−ϵ)2+σdata2,cout(t)=σdata(t−ϵ)σdata2+t2.c_{\text{skip}}(t) = \frac{\sigma_{\text{data}}^2}{(t - \epsilon)^2 + \sigma_{\text{data}}^2}, \qquad c_{\text{out}}(t) = \frac{\sigma_{\text{data}}(t - \epsilon)}{\sqrt{\sigma_{\text{data}}^2 + t^2}}.

Both have the required values at t=ϵt = \epsilon, and the form resembles diffusion-model denoisers, so their architectures can be reused.

Sampling

One step: draw x^T∼N(0,T2I)\hat{\mathbf{x}}_T \sim \mathcal{N}(\mathbf{0}, T^2 \mathbf{I}) and return fθ(x^T,T)\mathbf{f}_\theta(\hat{\mathbf{x}}_T, T).

Multistep: pick decreasing times τ1>τ2>⋯>τN−1\tau_1 > \tau_2 > \dots > \tau_{N-1}. Start from x^=fθ(x^T,T)\hat{\mathbf{x}} = \mathbf{f}_\theta(\hat{\mathbf{x}}_T, T). For each τn\tau_n, add fresh noise to move back up the hill, x^←x^+τn2−ϵ2 z\hat{\mathbf{x}} \leftarrow \hat{\mathbf{x}} + \sqrt{\tau_n^2 - \epsilon^2}\, \mathbf{z} with z∼N(0,I)\mathbf{z} \sim \mathcal{N}(\mathbf{0}, \mathbf{I}), and then apply x^←fθ(x^,τn)\hat{\mathbf{x}} \leftarrow \mathbf{f}_\theta(\hat{\mathbf{x}}, \tau_n). Each application is one network call; more calls usually give better samples.

Training by consistency distillation

When a pre-trained score model sϕ\mathbf{s}_\phi is available, the trajectory can be sampled in adjacent pairs. Choose a discretisation ϵ=t1<⋯<tN=T\epsilon = t_1 < \dots < t_N = T. Given a data point x\mathbf{x} and an index nn, form xtn+1=x+tn+1z\mathbf{x}_{t_{n+1}} = \mathbf{x} + t_{n+1}\mathbf{z}, then take one ODE step back to tnt_n with a solver Φ\Phi. For Euler, Φ=−t sϕ\Phi = -t\, \mathbf{s}_\phi, so

x^tn=xtn+1+(tn−tn+1) Φ(xtn+1,tn+1;ϕ).\hat{\mathbf{x}}_{t_n} = \mathbf{x}_{t_{n+1}} + (t_n - t_{n+1})\, \Phi(\mathbf{x}_{t_{n+1}}, t_{n+1}; \phi).

The two points (x^tn,xtn+1)(\hat{\mathbf{x}}_{t_n}, \mathbf{x}_{t_{n+1}}) lie on the same trajectory up to the solver's error, so the model should give them the same output. The distillation loss is

LCD(θ,θ−)=E[λ(tn) d(fθ(xtn+1,tn+1),  fθ−(x^tn,tn))],\mathcal{L}_{\text{CD}}(\theta, \theta^-) = \mathbb{E}\left[\lambda(t_n)\, d\big(\mathbf{f}_\theta(\mathbf{x}_{t_{n+1}}, t_{n+1}),\; \mathbf{f}_{\theta^-}(\hat{\mathbf{x}}_{t_n}, t_n)\big)\right],

where dd is a distance such as the squared ℓ2\ell_2 norm, λ\lambda is a weighting, and θ−\theta^- is a target network. The target is updated as an exponential moving average of the online weights, θ−←stopgrad(μθ−+(1−μ)θ)\theta^- \leftarrow \text{stopgrad}(\mu \theta^- + (1 - \mu)\theta), and gradients do not flow through it. The paper reports that the moving average and stop-gradient work better than setting θ−=θ\theta^- = \theta.

Training in isolation

Without a pre-trained score, the score at tt can be estimated from data. Given x∼pdata\mathbf{x} \sim p_{\text{data}} and xt=x+tz\mathbf{x}_t = \mathbf{x} + t\mathbf{z}, the quantity −(xt−x)/t2-(\mathbf{x}_t - \mathbf{x})/t^2 is an unbiased estimate of ∇log⁡pt(xt)\nabla \log p_t(\mathbf{x}_t) conditioned on xt\mathbf{x}_t. Substituting this for the score in the Euler step gives a consistency-training loss that uses no teacher. It pairs fθ(x+tn+1z,tn+1)\mathbf{f}_\theta(\mathbf{x} + t_{n+1}\mathbf{z}, t_{n+1}) with fθ−(x+tnz,tn)\mathbf{f}_{\theta^-}(\mathbf{x} + t_n\mathbf{z}, t_n) using the same noise z\mathbf{z} in both, so the pair stays on one noise path.

Worked examples

Example
A toy trajectory with a closed-form answer

Take a dataset that is a single point a=1a = 1. Its noisy distributions are pt=N(1,t2)p_t = \mathcal{N}(1, t^2), so the score is ∇log⁡pt(x)=−(x−1)/t2\nabla \log p_t(x) = -(x - 1)/t^2. The probability-flow ODE becomes

dxdt=−t⋅(−x−1t2)=x−1t.\frac{dx}{dt} = -t \cdot \left(-\frac{x - 1}{t^2}\right) = \frac{x - 1}{t}.

Let u=x−1u = x - 1. Then du/dt=u/tdu/dt = u/t, so u=Ctu = Ct for a constant CC. Every trajectory is a straight line xt=1+Ctx_t = 1 + Ct.

  1. A trajectory through the point x5=11x_5 = 11 at t=5t = 5 has C=(11−1)/5=2C = (11 - 1)/5 = 2.
  2. Its endpoint at ϵ=0.5\epsilon = 0.5 is xϵ=1+2×0.5=2x_\epsilon = 1 + 2 \times 0.5 = 2.
  3. The consistency function for this trajectory is f(x,t)=1+(x−1) ϵ/t\mathbf{f}(x, t) = 1 + (x - 1)\,\epsilon / t. Check: f(11,5)=1+10×0.5/5=2\mathbf{f}(11, 5) = 1 + 10 \times 0.5/5 = 2.
  4. Another point on the same trajectory, x2=1+2×2=5x_2 = 1 + 2 \times 2 = 5 at t=2t = 2, gives f(5,2)=1+4×0.5/2=2\mathbf{f}(5, 2) = 1 + 4 \times 0.5/2 = 2. Same answer, as self-consistency requires.
  5. Boundary condition: f(x,0.5)=1+(x−1)=x\mathbf{f}(x, 0.5) = 1 + (x-1) = x.

Interpretation: a single point is the simplest case, but the structure is general. A consistency model is trying to learn a function like f\mathbf{f} for a real data distribution, where no closed form exists. This toy shows what the target looks like, and that the two constraints are satisfiable.

Example
One Euler step for a distillation target

Take one adjacent pair of times, tn+1=10t_{n+1} = 10 and tn=9t_n = 9. Suppose the noisy point is xtn+1=3.0\mathbf{x}_{t_{n+1}} = 3.0 and the pre-trained score there is sϕ=−0.2\mathbf{s}_\phi = -0.2 (in one dimension, for simplicity).

  1. Euler increment: Φ=−tn+1 sϕ=−10×(−0.2)=2.0\Phi = -t_{n+1}\, \mathbf{s}_\phi = -10 \times (-0.2) = 2.0.
  2. Move to the earlier time: x^tn=3.0+(9−10)×2.0=3.0−2.0=1.0\hat{\mathbf{x}}_{t_n} = 3.0 + (9 - 10) \times 2.0 = 3.0 - 2.0 = 1.0.
  3. Sanity check: the ODE slope is 2.02.0 per unit time, and we moved back by one unit, so the value fell by 2.02.0.
  4. Suppose the online model gives fθ(3.0,10)=0.8\mathbf{f}_\theta(3.0, 10) = 0.8 and the target model gives fθ−(1.0,9)=0.9\mathbf{f}_{\theta^-}(1.0, 9) = 0.9. With squared distance, the loss for this pair is (0.8−0.9)2=0.01(0.8 - 0.9)^2 = 0.01.
  5. The gradient step moves fθ\mathbf{f}_\theta so the two outputs agree.

Interpretation: the target is not a label from data. It is the model's own answer one step later, made consistent with the teacher's score. Repeating this over many pairs teaches the sign-on-every-point behaviour.

Tradeoffs and failure modes

SituationWhat goes wrongBetter choice
One-step sample quality matters mostA single call can be blurrier than a long solver runUse two or more steps with fresh noise between calls
A strong teacher is availableDistillation depends on the teacher's score errorsDistill from the teacher; the paper reports this beats earlier distillation methods on its benchmarks
No teacher, or the goal is an independent generatorTraining in isolation can be less stable and needs careful weightingConsistency training, with an EMA target and a tuned schedule of step counts
Very large step gapsThe pair is far apart on the trajectory and the solver error growsUse more discretisation steps, or a continuous-time loss
Architecture cannot satisfy the boundary conditionTraining fails near t=ϵt = \epsilonUse the skip-connection parameterisation
Quality may not keep improving with more stepsMultistep sampling re-injects fresh noise between callsChoose the step count by measuring quality, not by assuming more is better

The main risk is that self-consistency is enforced only on sampled pairs, so the model can be consistent on the pairs it sees and inconsistent elsewhere. The EMA target and the choice of time discretisation both affect how much this happens. A second risk is that quality metrics such as FID reward some sampling choices more than others, so a fair comparison needs the same number of network calls.

History

Diffusion models grew out of earlier score-matching and denoising work. Ho, Jain and Abbeel's 2020 paper made the denoising formulation practical for images, and Song and colleagues in 2021 gave the continuous-time view with the probability-flow ODE. That view showed a deterministic path from noise to data, which made fast sampling a question about numerical ODE solvers.

Two lines of work tried to make sampling faster. Better solvers reduced the number of steps. Distillation trained a student to match several teacher steps in one. Progressive distillation, by Salimans and Ho in 2022, was the main earlier distillation method that did not need a large dataset of teacher samples.

Song, Dhariwal, Chen and Sutskever introduced consistency models in 2023. Their central move was to train on self-consistency directly, so one network call could replace a whole solver trajectory. They reported results on CIFAR-10 and ImageNet at 64 by 64 resolution, with one-step FID of 3.55 on CIFAR-10 and 6.20 on ImageNet 64 by 64, and two-step FID of 2.93 and 4.70 respectively, numbers taken from the paper's introduction. The paper also trains consistency models as standalone generators with no pre-trained diffusion model.

Check yourself

QuestionIn the toy example, the trajectory through x5=11x_5 = 11 at t=5t = 5 has endpoint 2. What value must the consistency function return at (x,t)=(5,2)(x, t) = (5, 2), and why?Show answer

It must return 2. Both points lie on the same probability-flow trajectory, and self-consistency requires that every point on a trajectory map to the same endpoint. Computing f(5,2)=1+(5−1)×0.5/2=2\mathbf{f}(5, 2) = 1 + (5 - 1) \times 0.5 / 2 = 2 confirms it.

QuestionWhy does the skip-connection parameterisation with cskip(ϵ)=1c_{\text{skip}}(\epsilon) = 1 and cout(ϵ)=0c_{\text{out}}(\epsilon) = 0 guarantee the boundary condition, regardless of what the network FθF_\theta outputs?Show answer

At t=ϵt = \epsilon the output is cskip(ϵ)x+cout(ϵ)Fθ(x,ϵ)=x+0⋅Fθ=xc_{\text{skip}}(\epsilon)\mathbf{x} + c_{\text{out}}(\epsilon) F_\theta(\mathbf{x}, \epsilon) = \mathbf{x} + 0 \cdot F_\theta = \mathbf{x}. The term multiplied by FθF_\theta vanishes whatever FθF_\theta returns, so the network's output cannot break the boundary condition. The network is free everywhere else.

QuestionIn the Euler distillation example, the trajectory moves back by one unit of time and the ODE slope is 2.0. Why does the earlier value come out lower, and what would change if the step went forward instead?Show answer

The slope is positive, so moving to an earlier time (from 10 to 9) decreases the value by 2.0×1=2.02.0 \times 1 = 2.0. Going forward in time would reverse the sign of the time difference and increase the value by the same amount. The solver uses the direction of the time step, which is why the formula multiplies by tn−tn+1t_n - t_{n+1}.

QuestionA team wants one-step generation to be as good as possible and asks whether to add more sampling steps. What does the paper's setup suggest, and what is the trade-off?Show answer

Adding a second step, with fresh noise between calls, improves quality; the paper reports FID falling from 3.55 to 2.93 on CIFAR-10 in that change. The trade-off is one more network call per sample, so latency roughly doubles. The team should measure quality against the number of calls it can afford, rather than assume that more calls are always better.

Sources