Title: AdjointDEIS: Efficient Gradients for Diffusion Models
Venue: NeurIPS 2024
Accepted: yes
Keywords: continuous adjoint equations

neural differential equations

neural ODEs

adjoint sensitivity method

diffusion models

guided generation
Abstract: The optimization of the latents and parameters of diffusion models with respect to some differentiable metric defined on the output of the model is a challenging and complex problem. The sampling for diffusion models is done by solving either the *probability flow* ODE or diffusion SDE wherein a neural network approximates the score function allowing a numerical ODE/SDE solver to be used. However, naive backpropagation techniques are memory intensive, requiring the storage of all intermediate states, and face additional complexity in handling the injected noise from the diffusion term of the diffusion SDE. We propose a novel family of bespoke ODE solvers to the continuous adjoint equations for diffusion models, which we call *AdjointDEIS*. We exploit the unique construction of diffusion SDEs to further simplify the formulation of the continuous adjoint equations using *exponential integrators*. Moreover, we provide convergence order guarantees for our bespoke solvers. Significantly, we show that continuous adjoint equations for diffusion SDEs actually simplify to a simple ODE. Lastly, we demonstrate the effectiveness of AdjointDEIS for guided generation with an adversarial attack in the form of the face morphing problem. Our code will be released on our project page [https://zblasingame.github.io/AdjointDEIS/](https://zblasingame.github.io/AdjointDEIS/)

AdjointDEIS: Efficient Gradients for Diffusion Models

Abstract

The optimization of the latents and parameters of diffusion models with respect to some differentiable metric defined on the output of the model is a challenging and complex problem. The sampling for diffusion models is done by solving either the probability flow ODE or diffusion SDE wherein a neural network approximates the score function allowing a numerical ODE/SDE solver to be used. However, naïve backpropagation techniques are memory intensive, requiring the storage of all intermediate states, and face additional complexity in handling the injected noise from the diffusion term of the diffusion SDE. We propose a novel family of bespoke ODE solvers to the continuous adjoint equations for diffusion models, which we call AdjointDEIS . We exploit the unique construction of diffusion SDEs to further simplify the formulation of the continuous adjoint equations using exponential integrators . Moreover, we provide convergence order guarantees for our bespoke solvers. Significantly, we show that the continuous adjoint equations for diffusion SDEs actually simplify to a simple ODE. Lastly, we demonstrate the effectiveness of AdjointDEIS for guided generation with an adversarial attack in the form of the face morphing problem. Our code will be released at https: //github.com/zblasingame/AdjointDEIS .

1 Introduction

Diffusion models are a large family of state-of-the-art generative models which learn to map samples drawn from Gaussian white noise into the data distribution [1, 2]. These diffusion models have achieved state-of-the-art performance on prominent tasks such as image generation [3-5], audio generation [6, 7], or video generation [8]. Often, state-of-the-art models are quite large and training them is prohibitively expensive [9]. As such, it is fairly common to adapt a pre-trained model to a specific task for post-training. In this way, the generative model can learn new concepts, identities, or tasks without having to train the entire model [10-12]. Additional work has also proposed algorithms for guiding the generative process of diffusion models [13, 14].

One method of guiding or directing the generative process is to solve an optimization problem w.r.t. some guidance function L defined in the image space R d . This guidance function works on the output of the diffusion model and assesses how 'good' the output is. However, the diffusion model works by iteratively removing noise until a clean sample is reached. As such, we need to be able to efficiently backpropagate gradients through the entire generative process. As Song et al. [15] showed, the diffusion SDE can be simplified to an associated ODE, and as such, many efficient ODE/SDE solvers have been developed for diffusion models [16-18]. However, naïvely applying backpropagation to the diffusion model is inflexible and memory intensive; moreover, such an approach is not trivial to apply to the diffusion models that used an SDE solver instead of an ODE solver.

AdjointDEIS

x

t

N

/epsilon1

θ

z

/epsilon1

t

N

x

t

N

-

1

/epsilon1

θ

z

/epsilon1

t

1

x

t

0

. . .

x

˜

t

0

L

/epsilon1

θ

x

˜

t

1

x

˜

t

N

/epsilon1

θ

a

x

( ˜

t

0

)

a

x

( ˜

t

1

)

a

x

( ˜

t

M

)

. . .

. . .

∂

L

∂

x

t

0

1.1 Contributions

Inspired by the work of Chen et al. [19] we study the application of continuous adjoint equations to diffusion models, with a focus on training-free guided generation with diffusion models. We introduce several theoretical contributions and technical insights to both improve the ability to perform certain guided generation tasks and to gain insight into guided generation with diffusion models.

First, we introduce AdjointDEIS a bespoke family of ODE solvers which can efficiently solve the continuous adjoint equations for both diffusion ODEs and SDEs. Moreover, we show that the continuous adjoint equations for diffusion SDEs simplify to a mere ODE. Next, we show how to calculate the continuous adjoint equation for conditional information which evolves with time (rather than being constant). To the best of our knowledge, we are the first to consider conditional information which evolves with time for neural ODEs. Overall, multiple theoretical contributions and technical insights are provided to bring a new family of techniques for the guided generation of diffusion models, which we evaluate experimentally on the task of face morphing.

1.2 Diffusion Models

In this subsection, we provide a brief overview of diffusion models. Diffusion models learn a generative process by first perturbing the data distribution into an isotropic Gaussian by progressively adding Gaussian noise to the data distribution. Then a neural network is trained to perform denoising steps, allowing for sampling of the data distribution via sampling of a Gaussian distribution [2, 9]. Assume that we have an d -dimensional random variable x ∈ R d with some distribution p data ( x ) . Then diffusion models begin by diffusing p data ( x ) according to the diffusion SDE [2], an Itô SDE given as

where t ∈ [0 , T ] denotes time with fixed constant T > 0 , f ( · ) and g ( · ) denote the drift and diffusion coefficients, and w t denotes the standard Wiener process. The trajectories of x t follow the distributions p t ( x t ) with p 0 ( x 0 ) ≡ p data ( x ) and p T ( x T ) ≈ N ( 0 , I ) . Under some regularity conditions Song et al. [15] showed that Equation (1.1) has a reverse process as time runs backwards from T to 0 with initial marginal distribution p T ( x T ) governed by

where ¯ w t is the standard Wiener process as time runs backwards. Solving Equation (1.2) is what allows diffusion models to draw samples from p data ( x ) by sampling p T ( x T ) . The unknown term in Equation (1.2) is the score function ∇ x log p t ( x t ) , which in practice is modeled by a neural network that estimates the scaled score function, ϵ θ ( x t , t ) ≈ -σ t ∇ x log p t ( x t ) , or some closely related quantity like x 0 -prediction [1, 2, 20].

Probability Flow ODE. The practical choice of a step size when discretizing SDEs is limited by the randomness of the Wiener process as a large step size, i.e. , a small number of steps, can cause non-convergence, particularly in high-dimensional spaces [16]. Sampling an equivalent Ordinary Differential Equation (ODE) over an SDE would enable faster sampling. Song et al. [15] showed there exists an Ordinary Differential Equation (ODE) whose marginal distribution at time t is identical to that of Equation (1.2) given as

The ODE in Equation (1.3) is known as the probability flow ODE [15]. As the noise prediction network, ϵ θ ( x t , t ) , is trained to model the scaled score function, Equation (1.3) can be parameterized as

w.r.t. the noise prediction network. For brevity, we refer to this as a diffusion ODE.

Although there exist several popular choices for the drift and diffusion coefficients, we opt to use the de facto choice which is known as the Variance Preserving (VP) type diffusion SDE [1, 15, 21]. The coefficients for VP-type SDEs are given as

which corresponds to sampling x t from the distribution q ( x t | x 0 ) = N ( α t x 0 , σ 2 t I ) .

2 Adjoint Diffusion ODEs

Problem statement. Given the diffusion ODE in Equation (1.4), we wish to solve the following optimization problem:

I.e. , we seek to find the optimal x T , z , and θ that satisfies our guidance function L . N.B. , the noise-prediction model is conditioned on additional information z .

Unlike GANs which can update the latent representation through GAN inversion [22, 23], as seen in Equation (2.1) diffusion models require more care as they model an ODE or SDE and require numerical solvers. Therefore, to update the latent representation, model parameters, and conditional information, we must backpropagate the gradient of loss defined on the output, ∂ L ( x 0 ) /∂ x 0 through the entire ODE or SDE.

A key insight of this work is the connection between the adjoint ODE used in neural ODEs by Chen et al. [19] and specialized ODE/SDE solvers by [16-18] for diffusion models. It has been well observed that diffusion models are a type of neural ODE [15, 24]. Since a diffusion model can be thought of as a neural ODE, we can solve the continuous adjoint equations [25] to find useful gradients for guided generation. We can then exploit the unique structure of diffusion models to develop efficient bespoke ODE solvers for the continuous adjoint equations.

Let f θ describe a parameterized neural field of the probability flow ODE, i.e. , the R.H.S of Equation (1.4), defined as

Then f θ ( x t , z , t ) describes a neural ODE which admits an adjoint state, a x := ∂ L /∂ x t (and likewise for a z ( t ) and a θ ( t ) ), which solve the continuous adjoint equations [25, Theorem 5.2] in the form of

the following Initial Value Problem (IVP):

We refer to this system of equations in Equation (2.3) as the adjoint diffusion ODE 1 as it describes the continuous adjoint equations for the empirical probability flow ODE.

N.B. , in the literature of diffusion models, the sampling process is often done in reverse time i.e. , the initial noise is x T and the final sample is x 0 . Due to this convention, solving the adjoint diffusion ODE backwards actually means integrating forwards in time. Thus, while diffusion models learn to compute x t from x s with s > t , the adjoint diffusion ODE seeks to compute a x ( s ) from a x ( t ) .

2.1 Simplified Formulation of the Empirical Adjoint Probability Flow ODE

We show that rather than treating f θ as a black box, the specific structure of the probability flow ODE is carried over to the adjoint probability flow ODE, allowing the adjoint probability flow ODE to be simplified into a special exact formulation.

By evaluating the gradient of f θ w.r.t. x t for each term in Equation (2.2) we can rewrite the adjoint diffusion ODE for a x ( t ) in Equation (2.3) as

Due to the gradient of the drift term in Equation (2.4), further manipulations are required to put the empirical adjoint probability flow ODE into a sufficiently 'nice' form. We follow the approach used by [16, 18] to simplify the empirical probability flow ODE with the use of exponential integrators and a change of variables. By applying the integrating factor exp (∫ t 0 f ( τ ) d τ ) to Equation (2.4), we find:

Then, the exact solution at time s given time t < s is found to be

Like with solvers for diffusion models which leverage exponential integrators, we are able to transform the adjoint diffusion ODE into a non-stiff form by separating the linear and non-linear component. Moreover, we can compute the linear in closed form, thereby eliminating the discretization error in the linear term. However, we still need to approximate the non-linear term which consists of a difficult integral about the complex noise-prediction model. This is where the insight of Lu et al. [16] to integrate in the log-SNR domain becomes invaluable. Let λ t := log( α t /σ t ) be one half of the log-SNR. Then, with using this new variable and computing the drift and diffusion coefficients in closed form, we can rewrite Equation (2.6) as

As λ t is a strictly decreasing function w.r.t. t it therefore has an inverse function t λ that satisfies t λ ( λ t ) = t , and, with abuse of notation, we let x λ := x t λ ( λ ) , a x ( λ ) := a x ( t λ ( λ )) , &c. and let the reader infer from context if the function is mapping the log-SNR back into the time domain or already in the time domain. Then by rewriting Equation (2.7) as an exponentially weighted integral and performing an analogous derivation for a z ( t ) and a θ ( t ) , we arrive at the following.

Proposition 2.1 (Exact solution of adjoint diffusion ODEs) . Given initial values [ a x ( t ) , a z ( t ) , a θ ( t )] at time t ∈ (0 , T ) , the solution [ a x ( s ) , a z ( s ) , a θ ( s )] at time s ∈ ( t, T ] of adjoint diffusion ODEs in Equation (2.3) is

The complete derivations of Proposition 2.1 can be found in Appendix B.1.

There is a nice symmetry between Equations (2.8) to (2.10), while the adjoint of the solution trajectories evolves with a weighting of α t /α s in the linear term and the integral term is weighted by α 2 t /α 2 s reflecting the double partial ∂ x t in the adjoint and Jacobian terms. Conversely, the adjoint state for the conditional information and model parameters evolves with no weighting on the linear term and the integral is only weighted by α t /α s . This follows from the vector fields being independent of a z and a θ . These equations, while reflecting the special nature of this formulation of diffusion models, also have an appealing parallel with the exact solution for diffusion ODEs Lu et al. [16, Proposition 3.1].

2.2 Numerical Solvers for AdjointDEIS

The numerical solver for the adjoint empirical probability flow ODE, now in light of Equation (2.8), only needs to focus on approximating the exponentially weighted integral of ϵ θ from λ t to λ s , a well-studied problem in the literature on exponential integrators [26, 27]. To approximate this integral, we evaluate the Taylor expansion of the Jacobian vector product to further simplify the ODE. For notational convenience let V ( x ; t ) denote the scaled vector-Jacobian product of the adjoint state a x ( t ) and the gradient of the model w.r.t. x t , i.e. ,

and likewise we let V ( n ) ( x ; λ ) denote the n -th derivative w.r.t. to λ . For k ≥ 1 , the ( k -1) -th Taylor expansion at λ t is

Plugging this expansion into Equation (2.8) and letting h = λ s -λ t yields

With this expansion, the number of terms which need to be estimated is further reduced as the exponentially weighted integral ∫ λ s λ t ( λ -λ t ) n n ! e -λ d λ can be solved analytically by applying n times integration-by-parts [16, 28]. Therefore, the only errors in solving this ODE occur in the approximation of the n -th order total derivatives of the vector-Jacobian product and the higher-order error terms O ( h k +1 ) . By dropping the O ( h k +1 ) error term and approximating the first ( k -1) -th derivatives of the vector-Jacobian product, we can derive k -th order solvers for adjoint diffusion ODEs. We decide to name such solvers as Adjoint Diffusion Exponential Integrator Sampler (AdjointDEIS) reflecting our use of the exponential integrator to simplify the ODEs and pay homage to DEIS from [18] that explored the use of exponential integrators for diffusion ODEs. Consider the case of k = 1 , by dropping the error term O ( h 2 ) we construct the AdjointDEIS-1 solver with the following algorithm.

AdjointDEIS-1. Given an initial augmented adjoint state [ a x ( t ) , a z ( t ) , a θ ( t )] at time t ∈ (0 , T ) , the solution [ a x ( s ) , a z ( s ) , a θ ( s )] at time s ∈ ( t, T ] is approximated by

Higher-order expansions of Equation (2.12) require estimations of the n -th order derivatives of the vector Jacobian product which can be approximated via multi-step methods, such as Adams-Bashforth methods [29]. This has the added benefit of reduced computational overhead, as the multi-step method just reuses previous values to approximate the higher-order derivatives. Moreover, multi-step methods are empirically more efficient than single-step methods [29]. Combining the Taylor expansions in Equation (2.12) with techniques for designing multi-step solvers, we propose a novel multi-step second-order solver for the adjoint empirical probability flow ODE which we call AdjointDEIS-2M . This algorithm combines the previous values of the vector Jacobian product at time t and time r to predict a s without any additional intermediate values.

AdjointDEIS-2M. We assume having a previous solution a x ( r ) and model output ϵ θ ( x r , z , r ) at time r < t < s , let ρ denote ρ = λ t -λ r h . Then the solution a s at time s to Equation (2.4) is estimated to be

For brevity, we omit the details of the AdjointDEIS-2M solver for a z ( t ) and a θ ( t ) ; rather, we provide the complete derivation and details in Appendix B. Likewise, the full algorithm can be found in Appendix G.1. The advantage of a higher-order solver is that it is generally more efficient, requiring fewer steps due to its higher convergence order. We show that AdjointDEISk is a k -th order solver, as stated in the following theorem. The proof is in Appendix C.

Theorem 2.1 (AdjointDEISk as a k -th order solver) . Assume the function ϵ θ ( x t , z , t ) and its associated vector-Jacobian products follow the regularity conditions detailed in Appendix C, then for k = 1 , 2 , AdjointDEISk is a k -th order solver for adjoint diffusion ODEs, i.e., for the sequence { ˜ a x ( t i ) } i M =1 computed by AdjointDEISk , the global truncation error at time T satisfies ˜ a x ( t M ) -a x ( T ) = O ( h 2 max ) , where h max = max 1 ≤ j ≤ M ( λ t i -λ t i -1 ) . Likewise, AdjointDEISk is a k -th order solver for the estimated gradients w.r.t. z and θ .

As previous work has shown that higher-order solvers may be unsuitable for large guidance scales [1618] we do explicitly construct or analyze any solvers for k > 2 and leave such explorations for future study.

2.3 Scheduled Conditional Information

Thus far, we have held the conditional information constant across time, i.e. , at each time t ∈ [0 , T ] the conditional information supplied to the neural network is z . What if, however, we had some scheduled conditional information z t ? We show that with some mild assumptions, using scheduled conditional information z t does not actually change the continuous adjoint equation for z t from the equations derived from z sans a substitution of z t with z .

While motivated by the case of scheduled conditional information in guided generation with diffusion models, this result applies to neural ODEs more generally, which could open future research directions. We state this result more formally in Theorem 2.2 with the proof in Appendix D. Note, as this applies more generally than to just AdjointDEIS, so we express this result for some arbitrary neural ODE with vector field f θ ( x t , z t , t ) and use the forward-time flow convention rather than the reverse-time convention of diffusion models.

Theorem 2.2. Suppose there exists a function z : [0 , T ] → R z which can be defined as a càdlàg 2 piecewise function where z is continuous on each partition of [0 , T ] given by Π = { 0 = t 0 < t 1 < · · · < t n = T } and whose right derivatives exist for all t ∈ [0 , T ] . Let f θ : R d × R z × R → R d be continuous in t , uniformly Lipschitz in x , and continuously differentiable in x . Let x : R → R d be the unique solution for the ODE

with initial condition x (0) = x 0 . Let L : R d → R be a scalar-valued loss function defined on the output of the neural ODE. Then ∂ L /∂ z ( t ) := a z ( t ) and there exists a unique solution a z : R → R z to the following IVP:

3 Adjoint Diffusion SDEs

As recent work [30, 31] has shown, diffusion SDEs have useful properties over probability flow ODEs for image manipulation and editing. In particular, it has been shown that probability flow ODEs are invariant in Nie et al. [31, Theorem 3.2] and that diffusion SDEs are contractive in Nie et al. [31, Theorem 3.1], i.e. , any gap in the mismatched prior distributions p t ( x t ) and ˜ p t ( x t ) for the true distribution p t and edited distribution ˜ p t will remain between p 0 ( x 0 ) and ˜ p 0 ( x 0 ) , whereas for diffusion SDEs the gap can be reduced between ˜ p t ( x t ) and p t ( x t ) as t tends towards 0 . Motivated by this reasoning, we present a framework for solving the adjoint diffusion SDE using exponential integrators.

The diffusion SDE with noise prediction model is given by

where ' d t ' is an infinitesimal negative timestep. Note how the drift term of the SDE looks remarkably similar to the probability flow ODE sans a missing factor of 1 / 2 in front of the noise prediction model. This is due to differing manipulations of the forward Kolomogorov equations-which describe the evolution of p t ( x t ) -used by Anderson [32] to derive the reverse-time SDE and later by Song et al. [15] to derive the probability-flow ODE. This connection is very important as it enables one to simplify the AdjointDEIS solvers for the adjoint diffusion SDE.

We show that for the special case of Stratonovich SDEs 3 with a diffusion coefficient g ( t ) which does not depend on the process state x t , then the adjoint process has a unique strong solution that evolves with what is essentially an ODE. Intuitively, this tracks as the stochastic term g ( t ) ◦ d w t has nothing to do with x t . We state this observation somewhat informally in the following theorem. The proof can be found in Appendix E.

Theorem 3.1. Let f : R d × R → R d be in C ∞ , 1 b and g : R → R d × w be in C 1 b . Let L : R d → R be a scalar-valued differentiable function. Let w t : [0 , T ] → R w be a w -dimensional Wiener process. Let x : [0 , T ] → R d solve the Stratonovich SDE

with initial condition x 0 . Then the adjoint process a x ( t ) := ∂ L ( x T ) /∂ x t is a strong solution to the backwards-in-time ODE

This is a boon for us, as diffusion models use only a mere scalar diffusion coefficient, g ( t ) . Therefore, the continuous adjoint equations for the diffusion SDE just simplify to an ODE. Not only that, but as mentioned before, the drift term of the diffusion SDE and probability flow ODE differ only by a factor of 2 in the term with the noise prediction network. As only the drift term of the diffusion

SDE is used when constructing the continuous adjoint equations, it follows that the only difference between the continuous adjoint equations for the probability flow ODE and diffusion SDE is a factor of 2. Therefore, the exact solutions are given by:

Proposition 3.1 (Exact solution of adjoint diffusion SDEs) . Given initial values [ a x ( t ) , a z ( t ) , a θ ( t )] at time t ∈ (0 , T ) , the solution [ a x ( s ) , a z ( s ) , a θ ( s )] at time s ∈ ( t, T ] of adjoint diffusion SDEs is

3.1 Solving Backwards Diffusion SDEs

Lu et al. [17] propose the following first-order solver for diffusion SDEs

where ϵ s ∼ N ( 0 , I ) . To solve the SDE backwards in time, we follow the approach initially proposed by Wu and la Torre [33] and used by later works [31]. Given a particular realization of the Wiener process that admits x t ∼ N ( α t x 0 | σ 2 t I ) , then for two samples x t and x s the noise ϵ s can be calculated by rearranging Equation (3.6) to find

With this the sequence { ϵ t i } N i =1 of added noises can be calculated which will exactly reconstruct the original input from the initial realization of the Wiener process. This technique is referred to as Cycle-SDE after the CycleDiffusion paper [33].

4 Related Work

Our proposed solutions can be viewed as a training-free method for guided generation. As an active area of research, there have been several proposed approaches to the problem of training-free guided generation, which either dynamically optimize the solution trajectory during sampling [34-36], or optimize the whole solution trajectory [37-40]. Our solutions fall into the latter category of optimizing the whole solution trajectory along with additional conditional information.

While Nie et al. [37] explored the use of the continuous adjoint equations to optimize the solution trajectories of diffusion SDEs they don't consider the ODE case and make use of the special structure of diffusion SDEs to simplify the continuous adjoint equations as we did. Recent work by Pan et al. [39] explore the using continuous adjoint equations for guided generation but does not consider the SDE case and uses a different scheme to simplify the continuous adjoint equations. We provide a more detailed comparison against these approaches and further discussion on related methods in Appendix A.

5 Experiments

To illustrate the efficacy of our technique, we examine an application of guided generation in the form of the face morphing attack. The face morphing attack is a new emerging attack on Face Recognition (FR) systems. This attack works by creating a singular morphed face image x ( ab ) 0 that

(a) Identity a

(b) Face morphing with AdjointDEIS

(c) Identity b

shares biometric information with the two contributing faces x ( a ) 0 and x ( b ) 0 [41-43]. A successfully created morphed face image can trigger a false accept with either of the two contributing identities in the targeted Face Recognition (FR) system, see Figure 2 for an illustration. Recent work in this space has explored the use of diffusion models to generate these powerful attacks [41, 44, 45]. All prior work on diffusion-based face morphing used a pre-trained diffusion autoencoder [46] trained on the FFHQ [47] dataset at a 256 × 256 resolution. We illustrate the use of AdjointDEIS solvers by modifying the Diffusion Morph (DiM) architecture proposed by Blasingame and Liu [41] to use the AdjointDEIS solvers to find the optimal initial noise x ( ab ) T and conditional z ab . The AdjointDEIS solvers are used to calculate the gradients with respect to the identity loss [45] defined as

where v a = F ( x ( a ) 0 ) , v b = F ( x ( b ) 0 ) , v ab = F ( x ( ab ) 0 ) , and F : X → V is an FR system which embeds images into a vector space V which is equipped with a measure of distance, d . We used the ArcFace [48] FR system for identity loss.

We compare against three preexisting DiM methods, the original DiM algorithm [41], Fast-DiM [44], and Morph-PIPE [45] as well as a GAN-inversion-based face morphing attack, MIPGAN-I and MIPGAN-II [49] based on the StyleGAN [47] and StyleGAN2 [50] architectures respectively. FastDiM improves DiM by using higher-order ODE solvers to decrease the number of sampling steps required to create a morph. Morph-PIPE performs a very simple version of guided generation by generating a large batch of morphed images derived from a discrete set of interpolations between x ( a ) T and x ( b ) T , and z a and z b . For reference purposes, we compare against a reference GAN-based method [49] which uses GAN-inversion w.r.t.to the identity loss to find the optimal morphed face, and we include prior state-of-the-art Webmorph, a commercial off-the-shelf system [51].

We run our experiments on SYN-MAD 2022 [51] morphed pairs that are constructed from the Face Research Lab London dataset [52], more details in Appendix H.4. The morphed images are evaluated against three FR systems, the ArcFace [48], ElasticFace [53], and AdaFace [54] models;

further details are found in Appendix H.5. To measure the efficacy of a morphing attack, the Mated Morph Presentation Match Rate (MMPMR) metric [55] is used. The MMPMR metric as proposed by Scherhag et al. [55] is defined as

where δ is the verification threshold, S n m is the similarity score of the n -th subject of morph m , N m is the total number of contributing subjects to morph m , and M is the total number of morphed images.

In our experiments, we used a learning rate of 0 . 01 , N = 20 sampling steps, M = 20 steps for AdjointDEIS, and 50 optimization steps for gradient descent. For the sampling process we used the DDIM solver [2], a widely used first-order solver. Following [56] we observed that using recorded values of { x t i } N i =1 for the backward pass improved performance. Note, this does not mean we stored the vector-Jacobians or any other internal states of the neural network. Moreover, due to our use of Cycle-SDE this choice was mandated for the SDE case. We discussion this decision further in Appendix F.1.

In Table 1 we present the effectiveness of the morphing attacks against the three FR systems. Guided generation with AdjointDEIS massively increases the performance of DiM, supplanting the old state-of-the-art for face morphing. Interestingly, the SDE variant did not fare as well as the ODE variant. This is likely due to the difficulty in discretizing SDEs with large step sizes [15-17]. We present further results in Appendix F that explore the impact of the choice of learning rate and the number of discretization steps for AdjointDEIS.

6 Conclusion

Wepresent a unified view on guided generation by updating latent, conditional, and model information of diffusion models with a guidance function using the continuous adjoint equations. We propose AdjointDEIS, a family of solvers for the continuous adjoint equations of diffusion models. We exploit the unique construction of diffusion models to create efficient numerical solvers by using exponential integrators. We prove the convergence order of solvers and show that the continuous adjoint equations for diffusion SDEs evolve with an ODE. Furthermore, we show how to handle conditional information that is scheduled in time, further expanding the generalizability of the proposed technique. Our results in face morphing show that the gradients produced by AdjointDEIS can be used for guided generation tasks.

Limitations. There are several limitations. Empirically, we only explored a small subset of the true potential AdjointDEIS by evaluating on a single scenario, i.e. , face morphing. Likewise, we only explored a few different hyperparameter options. In particular, we did not explore much the impact of the number of optimization steps and the number of sampling steps for diffusion SDEs on the visual quality of the generated face morphs.

Broader Impact. Guided generation techniques can be misused for a variety of harmful purposes. In particular, our approach provides a powerful tool for adversarial attacks. However, better knowledge of such techniques should hopefully help direct research in hardening systems against such kinds of attacks.

Acknowledgments

The authors would like to thank Fangyikang Wang for his helpful feedback on the Taylor expansion of the vector Jacobians. The authors would also like to acknowledge the fruitful discussions with Pierre Marion and Quentin Berthet on using the adjoint methods from a bilevel optimization perspective.

References

Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems , volume 33, pages 6840-6851. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/file/ 4c5bcfec8584af0d967f1ab10179ca4b-Paper.pdf . 1, 3, 33

Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In International Conference on Learning Representations , 2021. URL https://openreview. net/forum?id=St1giarCHLP . 1, 2, 3, 10

Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. Highresolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) , pages 10684-10695, June 2022. 1

Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical Text-Conditional Image Generation with CLIP Latents. arXiv e-prints , art. arXiv:2204.06125, April 2022. doi: 10.48550/arXiv.2204.06125.

Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily L Denton, Kamyar Ghasemipour, Raphael Gontijo Lopes, Burcu Karagol Ayan, Tim Salimans, Jonathan Ho, David J Fleet, and Mohammad Norouzi. Photorealistic text-toimage diffusion models with deep language understanding. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in Neural Information Processing Systems , volume 35, pages 36479-36494. Curran Associates, Inc., 2022. URL https://proceedings.neurips.cc/paper_files/paper/2022/file/ ec795aeadae0b7d230fa35cbaf04c041-Paper-Conference.pdf . 1

Haohe Liu, Zehua Chen, Yi Yuan, Xinhao Mei, Xubo Liu, Danilo Mandic, Wenwu Wang, and Mark D. Plumbley. AudioLDM: Text-to-Audio Generation with Latent Diffusion Models. arXiv e-prints , art. arXiv:2301.12503, January 2023. doi: 10.48550/arXiv.2301.12503. 1

Scott H. Hawley. Pictures of midi: Controlled music generation via graphical prompts for image-based diffusion inpainting, 2024. URL https://arxiv.org/abs/2407.01499 . 1

Andreas Blattmann, Robin Rombach, Huan Ling, Tim Dockhorn, Seung Wook Kim, Sanja Fidler, and Karsten Kreis. Align your Latents: High-Resolution Video Synthesis with Latent Diffusion Models. arXiv e-prints , art. arXiv:2304.08818, April 2023. doi: 10.48550/arXiv.2304. 08818. 1

Tero Karras, Miika Aittala, Timo Aila, and Samuli Laine. Elucidating the design space of diffusion-based generative models. In Proc. NeurIPS , 2022. 1, 2

Nataniel Ruiz, Yuanzhen Li, Varun Jampani, Yael Pritch, Michael Rubinstein, and Kfir Aberman. Dreambooth: Fine tuning text-to-image diffusion models for subject-driven generation. arXiv preprint arXiv:2208.12242 , 2022. 1

Rinon Gal, Yuval Alaluf, Yuval Atzmon, Or Patashnik, Amit H. Bermano, Gal Chechik, and Daniel Cohen-Or. An Image is Worth One Word: Personalizing Text-to-Image Generation using Textual Inversion. arXiv e-prints , art. arXiv:2208.01618, August 2022. doi: 10.48550/ arXiv.2208.01618.

Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685 , 2021. 1

Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications , 2021. URL https://openreview. net/forum?id=qw8AKxfYbI . 1

Arpit Bansal, Hong-Min Chu, Avi Schwarzschild, Soumyadip Sengupta, Micah Goldblum, Jonas Geiping, and Tom Goldstein. Universal Guidance for Diffusion Models. arXiv e-prints , art. arXiv:2302.07121, February 2023. doi: 10.48550/arXiv.2302.07121. 1

Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations , 2021. URL https://openreview. net/forum?id=PxTIG12RRHS . 1, 2, 3, 7, 10, 18, 33

Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan LI, and Jun Zhu. Dpmsolver: A fast ode solver for diffusion probabilistic model sampling in around 10 steps. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in Neural Information Processing Systems , volume 35, pages 5775-5787. Curran Associates, Inc., 2022. URL https://proceedings.neurips.cc/paper_files/paper/2022/file/ 260a14acce2a89dad36adc8eefe7c59e-Paper-Conference.pdf . 1, 3, 4, 5, 6, 20, 21, 22

Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. Dpm-solver++: Fast solver for guided sampling of diffusion probabilistic models, 2023. 8, 10, 23

Qinsheng Zhang and Yongxin Chen. Fast sampling of diffusion models with exponential integrator. In International Conference on Learning Representations , 2023. 1, 3, 4, 5, 6

Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David K Duvenaud. Neural ordinary differential equations. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems , volume 31. Curran Associates, Inc., 2018. URL https://proceedings.neurips.cc/paper_files/paper/ 2018/file/69386f6bb1dfed68692a24c8686939b9-Paper.pdf . 2, 3

Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. In International Conference on Learning Representations , 2022. URL https://openreview. net/forum?id=TIdIXIpzhoI . 3

Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution . Curran Associates Inc., Red Hook, NY, USA, 2019. 3

R. Abdal, Y. Qin, and P. Wonka. Image2stylegan: How to embed images into the stylegan latent space? In IEEE/CVF Int'l Conf. on Comp. Vision (ICCV) , pages 4431-4440, 2019. doi: 10.1109/ICCV.2019.00453. 3

Rameen Abdal, Yipeng Qin, and Peter Wonka. Image2stylegan++: How to edit the embedded images? In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition , pages 8296-8305, 2020. 3

Yaron Lipman, Ricky T. Q. Chen, Heli Ben-Hamu, Maximilian Nickel, and Matthew Le. Flow matching for generative modeling. In The Eleventh International Conference on Learning Representations , 2023. URL https://openreview.net/forum?id=PqvMRDCJT9t . 3

Patrick Kidger. On Neural Differential Equations . PhD thesis, Oxford University, 2022. 3, 28

Marlis Hochbruck and Alexander Ostermann. Exponential integrators. Acta Numerica , 19: 209-286, 2010. doi: 10.1017/S0962492910000048. 5, 20

Iyabo Ann Adamu. Numerical approximation of SDEs & the stochastic Swift-Hohenberg equation . PhD thesis, Heriot-Watt University, 2011. 5

Martin Gonzalez, Nelson Fernandez Pinto, Thuy Tran, elies Gherbi, Hatem Hajri, and Nader Masmoudi. Seeds: Exponential sde solvers for fast high-quality sampling from diffusion models. In A. Oh, T. Naumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine, editors, Advances in Neural Information Processing Systems , volume 36, pages 68061-68120. Curran Associates, Inc., 2023. URL https://proceedings.neurips.cc/paper_files/paper/2023/file/ d6f764aae383d9ff28a0f89f71defbd9-Paper-Conference.pdf . 5

K. Atkinson, W. Han, and D.E. Stewart. Numerical Solution of Ordinary Differential Equations . Pure and Applied Mathematics: A Wiley Series of Texts, Monographs and Tracts. Wiley, 2011. ISBN 9781118164525. URL https://books.google.com/books?id=QzjGgLlKCYQC . 6

Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, and Stefano Ermon. SDEdit: Guided image synthesis and editing with stochastic differential equations. In International Conference on Learning Representations , 2022. 7

Shen Nie, Hanzhong Allan Guo, Cheng Lu, Yuhao Zhou, Chenyu Zheng, and Chongxuan Li. The blessing of randomness: SDE beats ODE in general diffusion-based image editing. In The Twelfth International Conference on Learning Representations , 2024. URL https: //openreview.net/forum?id=DesYwmUG00 . 7, 8

Brian D.O. Anderson. Reverse-time diffusion equation models. Stochastic Processes and their Applications , 12(3):313-326, 1982. ISSN 0304-4149. doi: https://doi.org/10.1016/ 0304-4149(82)90051-5. URL https://www.sciencedirect.com/science/article/ pii/0304414982900515 . 7

Chen Henry Wu and Fernando De la Torre. A latent space of stochastic diffusion models for zero-shot image editing and guidance. In ICCV , 2023. 8

Jiwen Yu, Yinhuai Wang, Chen Zhao, Bernard Ghanem, and Jian Zhang. Freedom: Trainingfree energy-guided conditional diffusion model. Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV) , 2023. 8, 16

Zander W. Blasingame and Chen Liu. Greedy-dim: Greedy algorithms for unreasonably effective face morphs. In 2024 IEEE International Joint Conference on Biometrics (IJCB) , pages 1-10, September 2024. 16, 17, 31

Xingchao Liu, Lemeng Wu, Shujian Zhang, Chengyue Gong, Wei Ping, and Qiang Liu. Flowgrad: Controlling the output of generative odes with gradients. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pages 24335-24344, 2023. 8, 16

Weili Nie, Brandon Guo, Yujia Huang, Chaowei Xiao, Arash Vahdat, and Anima Anandkumar. Diffusion models for adversarial purification. In International Conference on Machine Learning (ICML) , 2022. 8, 16, 17

Bram Wallace, Akash Gokul, Stefano Ermon, and Nikhil Naik. End-to-end diffusion latent optimization improves classifier guidance, 2023. 16, 17

Jiachun Pan, Jun Hao Liew, Vincent Tan, Jiashi Feng, and Hanshu Yan. AdjointDPM: Adjoint sensitivity method for gradient backpropagation of diffusion probabilistic models. In The Twelfth International Conference on Learning Representations , 2024. URL https://openreview. net/forum?id=y33lDRBgWI . 8, 16, 17

Pierre Marion, Anna Korba, Peter Bartlett, Mathieu Blondel, Valentin De Bortoli, Arnaud Doucet, Felipe Llinares-López, Courtney Paquette, and Quentin Berthet. Implicit diffusion: Efficient optimization through stochastic sampling. arXiv preprint arXiv:2402.05468 , 2024. 8, 16, 18

Zander W. Blasingame and Chen Liu. Leveraging diffusion for strong and high quality face morphing attacks. IEEE Transactions on Biometrics, Behavior, and Identity Science , 6(1): 118-131, 2024. doi: 10.1109/TBIOM.2024.3349857. 9, 10, 31, 32

R. Raghavendra, K. B. Raja, and C. Busch. Detecting morphed face images. In IEEE 8th Int'l Conf. on Biometrics Theory, Applications and Systems (BTAS) , pages 1-7, 2016. doi: 10.1109/BTAS.2016.7791169.

Eklavya Sarkar, Pavel Korshunov, Laurent Colbois, and Sébastien Marcel. Are gan-based morphs threatening face recognition? In ICASSP 2022 - 2022 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) , pages 2959-2963, 2022. doi: 10.1109/ ICASSP43922.2022.9746477. 9, 32

Zander W. Blasingame and Chen Liu. Fast-dim: Towards fast diffusion morphs. IEEE Security &Privacy , 22(4):103-114, June 2024. doi: 10.1109/MSEC.2024.3410112. 9, 10

Haoyu Zhang, Raghavendra Ramachandra, Kiran Raja, and Busch Christoph. Morph-pipe: Plugging in identity prior to enhance face morphing attack based on diffusion model. In Norwegian Information Security Conference (NISK) , 2023. 9, 10, 32

Konpat Preechakul, Nattanat Chatthee, Suttisak Wizadwongsa, and Supasorn Suwajanakorn. Diffusion autoencoders: Toward a meaningful and decodable representation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) , pages 10619-10629, June 2022. 9

T. Karras, S. Laine, and T. Aila. A style-based generator architecture for generative adversarial networks. In 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) , pages 4396-4405, 2019. doi: 10.1109/CVPR.2019.00453. 9

Jiankang Deng, Jia Guo, Niannan Xue, and Stefanos Zafeiriou. Arcface: Additive angular margin loss for deep face recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition , pages 4690-4699, 2019. 9, 32

Haoyu Zhang, Sushma Venkatesh, Raghavendra Ramachandra, Kiran Raja, Naser Damer, and Christoph Busch. Mipgan-generating strong and high quality morphing attacks using identity prior driven gan. IEEE Transactions on Biometrics, Behavior, and Identity Science , 3(3): 365-383, 2021. doi: 10.1109/TBIOM.2021.3072349. 9, 10, 32

T. Karras, S. Laine, M. Aittala, J. Hellsten, J. Lehtinen, and T. Aila. Analyzing and improving the image quality of stylegan. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) , pages 8107-8116, 2020. doi: 10.1109/CVPR42600.2020.00813. 9

Marco Huber, Fadi Boutros, Anh Thi Luu, Kiran Raja, Raghavendra Ramachandra, Naser Damer, Pedro C. Neto, Tiago Gonçalves, Ana F. Sequeira, Jaime S. Cardoso, João Tremoço, Miguel Lourenço, Sergio Serra, Eduardo Cermeño, Marija Ivanovska, Borut Batagelj, Andrej Kronovšek, Peter Peer, and Vitomir Štruc. Syn-mad 2022: Competition on face morphing attack detection based on privacy-aware synthetic training data. In 2022 IEEE International Joint Conference on Biometrics (IJCB) , pages 1-10, 2022. doi: 10.1109/IJCB54206.2022.10007950. 9, 10, 32

Lisa DeBruine and Benedict Jones. Face Research Lab London Set. 5 2017. doi: 10. 6084/m9.figshare.5047666.v5. URL https://figshare.com/articles/dataset/Face_ Research_Lab_London_Set/5047666 . 9, 32

Fadi Boutros, Naser Damer, Florian Kirchbuchner, and Arjan Kuijper. Elasticface: Elastic margin loss for deep face recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops , pages 1578-1587, June 2022. 9, 32

Minchul Kim, Anil K Jain, and Xiaoming Liu. Adaface: Quality adaptive margin for face recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , 2022. 9, 32

Ulrich Scherhag, Andreas Nautsch, Christian Rathgeb, Marta Gomez-Barrero, Raymond N. J. Veldhuis, Luuk Spreeuwers, Maikel Schils, Davide Maltoni, Patrick Grother, Sebastien Marcel, Ralph Breithaupt, Raghavendra Ramachandra, and Christoph Busch. Biometric systems under morphing attacks: Assessment of morphing techniques and vulnerability reporting. In 2017 International Conference of the Biometrics Special Interest Group (BIOSIG) , pages 1-7, 2017. doi: 10.23919/BIOSIG.2017.8053499. 10

Suyong Kim, Weiqi Ji, Sili Deng, Yingbo Ma, and Christopher Rackauckas. Stiff neural ordinary differential equations. Chaos: An Interdisciplinary Journal of Nonlinear Science , 31(9), 2021. 10, 29

Bram Wallace, Akash Gokul, and Nikhil Naik. Edict: Exact diffusion inversion via coupled transformations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pages 22532-22541, 2023. 17

Patrick Kidger, James Morrill, James Foster, and Terry Lyons. Neural controlled differential equations for irregular time series. Advances in Neural Information Processing Systems , 33: 6696-6707, 2020. 25

Xuechen Li, Ting-Kam Leonard Wong, Ricky T. Q. Chen, and David Duvenaud. Scalable gradients for stochastic differential equations. In Silvia Chiappa and Roberto Calandra, editors, Proceedings of the Twenty Third International Conference on Artificial Intelligence and Statistics , volume 108 of Proceedings of Machine Learning Research , pages 3870-3882. PMLR, 26-28 Aug 2020. URL https://proceedings.mlr.press/v108/li20i.html . 26, 27

Hiroshi Kunita. Stochastic differential equations and stochastic flows. Stochastic Flows and Jump-Diffusions , pages 77-124, 2019. 26, 27

Patrick Kidger, James Foster, Xuechen (Chen) Li, and Terry Lyons. Efficient and accurate gradients for neural sdes. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P.S. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems , volume 34, pages 1874718761. Curran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper_ files/paper/2021/file/9ba196c7a6e89eafd0954de80fc1b224-Paper.pdf . 28

Ionut Cosmin Duta, Li Liu, Fan Zhu, and Ling Shao. Improved residual networks for image and video recognition. In 2020 25th International Conference on Pattern Recognition (ICPR) , pages 9415-9422, 2021. doi: 10.1109/ICPR48806.2021.9412193. 32

Xiang An, Xuhan Zhu, Yuan Gao, Yang Xiao, Yongle Zhao, Ziyong Feng, Lan Wu, Bin Qin, Ming Zhang, Debing Zhang, and Ying Fu. Partial fc: Training 10 million identities on a single machine. In 2021 IEEE/CVF International Conference on Computer Vision Workshops (ICCVW) , pages 1445-1449, 2021. doi: 10.1109/ICCVW54120.2021.00166. 32

Organization of the appendix. In Appendix A we provide a detailed comparison between our work and related work. Appendix B provides the full derivations for the construction of the AdjointDEISk solvers. Likewise, in Appendix C we present the proof for Theorem 2.1. In a similar manner Appendix D presents the proof for Theorem 2.2. A more detailed discussion of the case of adjoint diffusion SDEs is held in Appendix E along with the proof of Theorem 3.1. We include additional experiments on the impact of AdjointDEIS on the face morphing problem in Appendix F. The details of the implementation of our approach are included in Appendix G. Additional details specific to our experiments are likewise included in Appendix H. Finally, for completeness, we include Appendix I to show the closed-form solutions of the drift and diffusion coefficients.

A Additional Related Work

In this section, we compare several recent methods for training-free guided generation which we broadly classify into two categories:

Techniques which directly optimize the solution trajectory during sampling [34-36]

Techniques which search for the optimal latents x T and or z (this can include optimizing the solution trajectory as well) [38, 39].

In Table 2 we compare several different techniques for training-free guided diffusion in whether they explicitly optimize the whole solution trajectory, i.e. , optimizing x T , if they optimize additional information like z or θ , and whether the formulation is for diffusion ODEs, SDEs, or both.

Using Table 2 as a high-level overview, we spend the rest of this section providing a more detailed comparison and discussion of the related works which we separate by the two categories.

A.1 Optimizing the Solution Trajectory During Sampling

FlowGrad. The FlowGrad [36] technique controls the generative process by solving the following optimal control problem

where u is the control function. This optimization objective learns to alter the flow, f θ , by u . In practice, this amounts to injecting a control step governed by u ( t ) for a discretized schedule. This technique does not allow for learning an optimal x T , z , or θ .

FreeDoM. Another recent work, FreeDoM [34] looks at gradient guided generation of images by calculating the gradient w.r.t. x t by using the approximated clean image

at each timestep. Let h i = λ t i -λ t i -1 . The strategy can be described as

where η t i is a learning rate defined per timestep. Importantly, FreeDoM operates on diffusion SDEs. They have an addition algorithm in which the add noise back to the image, in essence going back one timestep and applying the guidance step again.

Greedy. Similar to FreeDoM, greedy guided generation [35] looks to alter the generative trajectory by injecting the gradient defined on the approximated clean image; however, this technique does so w.r.t. the prediction noise, i.e. ,

The technique would work for either diffusion ODEs or SDEs.

A.2 Optimizing the Entire Solution Trajectory

DOODL. The algorithm DOODL [38] looks at the gradient calculation based on the invertibility of EDICT [57]. This method can find the gradient w.r.t. x T ; however, it cannot for the other quantities. DOODL additionally has further overhead due to the dual diffusion process of EDICT. Further analysis of DOODL compared to continuous adjoint equations for diffusion models can be found in [39].

The remaining methods are much closer to our work as they use continuous adjoint equations for guidance. We provide a high-level summary that compares these methods to ours in Table 3.

DiffPure. Work by Nie et al. [37] examined the use of continuous adjoint equations for cleaning adversarial images, an application of guided generation. There exist a few key differences between their work and ours. First, while they consider the SDE case they use an Euler-Maruyama numerical scheme, meaning there is a discretization error incurred in the linear term of the drift coefficient. Moreover, the solver for the continuous adjoint equation results in an Euler scheme which suffers from a low convergence order and poor stability, particularly for stiff equations. Our approach used exponential integrators to greatly simplify the continuous adjoint equations whilst improving numerical stability by transforming the continuous adjoint equations into non-stiff form.

AdjointDPM. More closely related to our work is the recent AdjointDPM [39] which also explores the use of adjoint sensitivity methods for backpropagation through the probability flow ODE. While

they also propose to use the continuous adjoint equations to find gradients for diffusion models, our work differs in several ways which we enumerate in Table 3. For clarity, we use orange to denote their notation. They reparameterize Equation (1.4) as

where c denotes the conditional information, ρ = γ ( t ) , and d γ d t = e -∫ t 0 f ( τ ) d τ g 2 ( t ) 2 σ t . which gives them the following ODE for calculating the adjoint.

In our approach we integrate over λ t whereas they integrate over ρ . Moreover, we provide custom solvers designed specifically for diffusion ODEs instead of using a black-box ODE solver. Our approach is also interoperable with other forward ODE solvers, meaning our AdjointDEIS solver is agnostic to the ODE solver used to generate the output; however, the AdjointDPM model is tightly coupled to its forward solver. Lastly and most importantly, our method is more general and supports diffusion SDEs, not just ODEs.

Although the original paper omitted a closed form expression for γ -1 ( ρ ) , we provide to give a comparison between both methods, and to ensure that AdjointDPM can be fully implemented. In the VP SDE scheme with a linear noise schedule log α t is found to be

on t ∈ [0 , 1] with β 0 = 0 . 1 , β 1 = 20 , following Song et al. [15]. Then γ -1 ( ρ ) is found to be

Implicit Diffusion. Concurrent work to ours by Marion et al. [40] has also explored the use of continuous adjoint equations for the guidance of diffusion models. They, however, focus on an efficient scheme to parallelize the solution to the adjoint ODE from the perspective of bi-level optimization rather than the adjoint technique itself. So, while we focused on the numerical solvers for the continuous adjoint equations, they focused on an efficient implementation of the optimization problem from the perspective of bi-level optimization.

B Derivation of AdjointDEIS

In this section, we provide the full derivations for the family of AdjointDEIS solvers. First recall the full definition of the continuous adjoint equations for the empirical probability flow ODE:

We can simplify the equations by explicitly solving gradients of the neural vector field f θ for the drift term to obtain

Remark B.1. The last two equations in Equations (B.2) the vector fields are independent of ( a z , a θ ) , reducing these equations to mere integrals; however, it is often useful to compute the whole system a aug = ( a x , a z , a θ ) as an augmented ODE.

Remark B.2. Likewise, the last two equations in Equations (B.2) are functionally identical with a simple swap of z for θ or vice versa.

As such, for the sake of brevity, the derivations for the AdjointDEIS solvers for ( a z , a θ ) will only explicitly include the derivations for a z .

B.1 Simplified Formulation of the Continuous Adjoint Equations

Focusing first on the continuous adjoint equation for a x we apply the integrating factor exp ( ∫ t 0 f ( τ ) d τ ) to Equation (B.2) to find

Then, the exact solution at time s given time t < s is found to be

To simplify Equation (B.4), recall that f ( t ) is defined as

for VP type SDEs. Furthermore, let λ t := log( α t /σ t ) be one half of the log-SNR. Then the diffusion coefficient can be simplified using the log-derivative trick such that

Using this updated expression of g 2 ( t ) along with computing the integrating factor in closed form enables us to express Equation (B.4) as

Lastly, by rewriting the integral in terms of an exponentially weighted integral α u σ u = α 2 u σ u /α u = α 2 u e -λ u we find

This change of variables is possible as λ t is a strictly decreasing function w.r.t. t and therefore it has an inverse function t λ which satisfies t λ ( λ t ) = t , and, with abuse of notation, we let x λ := x t λ ( λ ) , a x ( λ ) := a x ( t λ ( λ )) , &c. and let the reader infer from context if the function is mapping the log-SNR back into the time domain or already in the time domain.

Now we will show the derivations to find a simplified form of the continuous adjoint equation for the conditional information. Using the continuous adjoint equation from Equations (B.2) for a z ( t ) along with the log-SNR, we can express the evolution of a z ( t ) as

As we would like to express this as an exponential integrator, we simply multiply σ t by α t /α t to obtain α t · σ t /α t = α t e -λ t , as such we can rewrite Equation (B.9) as

Using Equations (B.8) and (B.10), we arrive at Proposition 2.1 from the main paper.

Proposition B.1. Given initial values [ a x ( t ) , a z ( t ) , a θ ( t )] at time t ∈ (0 , T ) , the solution [ a x ( s ) , a z ( s ) , a θ ( s )] at time s ∈ ( t, T ] of the adjoint empirical probability flow ODE in Equation (B.4) is

Then to find the AdjointDEIS solvers we take a k -th order Taylor expansion about λ t and integrate in the log-SNR domain.

B.2 Taylor Expansion

For k ≥ 1 , the ( k -1) -th Taylor expansion at λ t of the inner term of the exponentially weighted integral in Equation (B.11) is

Then plugging this into Equation (B.11) yields

where h = λ s -λ t .

The exponentially weighted integral ∫ λ s λ t ( λ -λ t ) n n ! e -λ d λ can be solved analytically by applying n times integration by parts [16, 26] such that

with the special φ -functions [26]. These functions are defined as

which satisfy the recurrence relation φ k +1 ( h ) = ( φ k ( h ) -φ k (0)) /h and have closed forms for k = 1 , 2 :

Likewise, the Taylor expansion of the exponentially weighted integral in Equation (B.12) yields

B.3 AdjointDEIS-1

For k = 1 and omitting the higher-order error term, Equation (B.15) becomes:

Likewise, the continuous adjoint equation for z , Equation (B.20), becomes when k = 1 by omitting the higher-order error term:

And the first-order solver for a θ ( t ) can be found in a similar fashion, thus we have derived the AdjointDEIS-1 solvers.

B.4 AdjointDEIS-2M

Consider the following definition of the limit in the log-SNR domain

where ρ = λ t -λ r h with h = λ s -λ t and where r is some previous step r < t < s . Again, V ( x ; λ t ) is overloaded to mean V ( x ; t λ ( λ t )) . Then by omitting higher-order error O ( h k +1 ) , Equation (B.15) becomes:

By applying the same approximation used in Lu et al. [16] of

then we can rewrite the second term of the Taylor expansion as

Then Equation (B.24) becomes

Likewise, consider the scaled vector-Jacobian product of the adjoint state a x ( t ) and the gradient of the model w.r.t. z , i.e. ,

along with a corresponding definition of first-derivative w.r.t. λ as defined in Equation (B.23). As such Equation (B.20), when k = 2 , becomes the following when omitting the higher-order error term:

The second term of the Taylor expansion can be rewritten as

Then Equation (B.29) becomes

and the corresponding second-order solver for a θ ( t ) can be found in a similar manner.

C Proof of Theorem 2.1

For notational brevity we denote the scaled vector-Jacobian products of the solution trajectory of AdjointDEIS as

C.1 Assumptions

For the AdjointDEIS solvers, we make similar assumptions to Lu et al. [16].

Assumption C.1. The total derivatives of the vector-Jacobian products V ( n ) ( { x λ , z , θ } , λ ) as a function of λ exist and are continuous for 0 ≤ n ≤ k -1 (and hence bounded).

Assumption C.2. The function ϵ θ ( x , z , t ) is continuous in t and uniformly Lipschitz and continuously differentiable w.r.t. its first parameter x .

Assumption C.3. h max := max 1 ≤ j ≤ M h j = O (1 /M ) .

Assumption C.4. ρ i > c > 0 for all i = 1 , . . . , M and some constant c .

The first assumption is required by Taylor's theorem. The second assumption is a mild assumption to ensure that Theorem C.1 holds, which is used to replace ˜ V ( { x t , z , θ } , t ) with V ( { x t , z , θ } , t ) + O (˜ a x ( t ) -a x ( t )) so the Taylor expansion w.r.t. λ s is applicable. The third assumption is a technical assumption to exclude a significantly large step size. The last assumption is necessary for the case when k = 2 . For our proofs, we follow a similar outline to that taken by Lu et al. [17, Appendix A].

C.2 The Vector-Jacobian Product is Lipschitz

Lemma C.1 (Vector-Jacobian Product is Lipschitz.) . Let f θ : R d × R z × [0 , T ] → R d be continuous in t and uniformly Lipschitz and continuously differentiable in x . Let x : [0 , T ] → R d be the unique solution to

with initial condition x 0 . Then the following map

is Lipschitz in a . Moreover, the Lipschitz constant L > 0 is given by

Proof. Now, as x t is continuous and f θ is continuously differentiable in x , so t ↦→ ∂ f θ ∂ [ x t , z ,θ ] ( x t , z , t ) is a continuous function on the compact set [0 , T ] , so it is bounded by some L > 0 . Likewise, for a ∈ R d the map ( a , t ) ↦→ -a ⊤ ∂ f θ ( x t , z ,t ) ∂ [ x t , z ,θ ] is Lipschitz in a with Lipschitz constant L and this constant is independent of t .

C.3 Proof of Theorem 2.1 when k = 1

Proof. First, we consider the case of the adjoint state a x ( t ) . Recall that the AdjointDEIS-1 solver for a x with higher-order error terms is given by

where we let t i = t , t i +1 = s , h i = λ t i +1 -λ t i from Equation (B.21). By Theorem C.1 and Equation (B.21) it holds that

Repeat, this argument, from ˜ a x ( t 0 ) = a x (0) then we find

Although the argument for the adjoint state a z ( t ) follows an analogous form to the one above, we explicitly state it for completeness. Recall that the AdjointDEIS-1 solver for a z with higher-order error terms is given by

By Theorem C.1 and Equation (B.22) it holds that

Repeat, this argument, from ˜ a z ( t 0 ) = 0 then we find

An identical argument can be constructed for a θ , thereby finishing the proof.

C.4 Proof of Theorem 2.1 when k = 2

We prove the discretization error of the AdjointDEIS-2M solver. Note that for the AdjointDEIS-2M solver we have h i = λ t i +1 -λ t i -1 and ρ i = λ t i -λ t i -1 h i . Furthermore, let ∆ i = ∥ ˜ a x ( t i ) -a x ( t i ) ∥ . Without loss of generality, we will prove this only for a x ; the derivation for a z and a θ is analogous.

Proof. First, we consider the case of the adjoint state a x ( t ) . Recall that the AdjointDEIS-2, see Equation (B.24), solver for a x with higher-order error terms is given by

Taylor's expansion yields

where C is a constant that depends on V (2) ( x t , t ) . Also note that

Since ρ i is bounded away from zero, and e -h i = 1 -h i + h 2 i / 2 + O ( h 3 i ) , we know

where M i = 1 + sup t i ≤ t ≤ t i +1 ∥ V (1) ( x ; t ) ∥ and L are the Lipschitz constants of V ( x ; t ) by Theorem C.1. Then, ∆ i +1 can be estimated as

Thus, ∆ i +1 = O ( h 2 max ) as long as h max is sufficiently small and ∆ 0 +∆ 1 = O ( h 2 max ) , which can be verified via Taylor expansion, thereby finishing the proof.

D Proof of Theorem 2.2

For additional clarity, we let x ( t ) ≡ x t and likewise, z ( t ) ≡ z t .

Proof. Recall that z ( t ) is a piecewise function of time with partitions of the time domain given by Π = { 0 = t 0 < t 1 < · · · < t n = T } . Without loss of generality we consider some time interval [ t m -1 , t m ] for some 1 ≤ m ≤ n . Consider the augmented state defined on the interval π :

where - → ∂ z : [0 , T ] → R z denotes the right derivative of z at time t . Let a aug denote the associated augmented adjoint state

The Jacobian of f aug has the form

As the conditional information z ( t ) evolves with - → ∂ z ( t ) on [ t m -1 , t m ] in the forward flow of time. The derivative of the - → ∂ z w.r.t. z is clearly 0 as - → ∂ z is a function only of time t . Remark, that as the bottom row of the Jacobian f aug is all 0 and f θ is continuous in t we can consider the evolution of a aug over the whole interval [0 , T ] rather than just the partition [ t m -1 , t m ] . Using Equations (D.2) and (D.3) we can define the evolution of the adjoint augmented state on [0 , T ] as

Therefore, a z ( t ) evolves with the ODE

We have thus shown the evolution of a z ( t ) for some continuously differentiable function z ( t ) .

Now we prove the solution is unique and exists. As x ( t ) is continuous and f θ is continuously differentiable in x , it follows that the map t ↦→ ∂ f θ ∂ x ( x ( t ) , z ( t ) , t ) is a continuous function on the compact set [0 , T ] , and therefore it is bounded by some L > 0 . Correspondingly, for a x ∈ R d it follows that the map ( a x , t ) ↦→-a ⊤ x ∂ f θ ∂ [ x , z ] ( x ( t ) , z ( t ) , t ) is Lipschitz in a x with Lipschitz constant L and this constant is independent of t . Therefore, by the Picard-Lindelölf theorem the solution a z ( t ) exists and is unique.

D.1 Continuous-time Extension of Discrete Conditional Information

The proof above makes some fairly lax assumptions about z ( t ) . While we assumed the process was càdlàg and had right derivatives this restraints are too loose for adaptive step-size solvers. While this is not an issue for our AdjointDEIS, Kidger et al. [58] pointed out that an adaptive solver would take a long time to compute the backward pass as it would have to slow down at the discontinuities. One could follow the approach taken in [58] and construct natural cubic splines from a fully observed, but irregularly sampled time series { z t i } N i =1 with 0 = t 0 < · · · < t n = T . Then define Z : [0 , T ] → R z as the natural cubic spline with knots at t 0 , . . . , t n such that Z ( t i ) = z t i .

D.2 Connection to Neural CDEs

Kidger et al. [58, Theorem C.1] showed that any equation of the form

can be rewritten as a neural controlled differential equation (CDE) of the form

where ∫ d z s is the Riemann-Stieltjes integral. N.B. , the converse is not true.

While there a certainly benefits to modeling with a neural CDE over a neural ODE, diffusion models in particular pre-train the model in the neural ODE sense. Moreover, we are also interested in updating z t i at each t i via gradient descent to solve our optimization problem.

E Details on Adjoints for SDEs

In this section, we provide further details on the continuous adjoint equations for diffusion SDEs that we omitted from the main paper due to their technical nature and for the purpose of brevity.

Consider the Itô integral given by

where x t is a continuous semi-martingale adapted to the filtration generated by the Wiener process { w t } t ∈ [0 ,T ] , {F t } t ∈ [0 ,T ] . The following quantity, however, is not defined

This is because x t and w t are adapted to {F t } t ∈ [0 ,T ] which is defined in forwards time. This means x t does not anticipate future events only depends on past events. While this is generally sufficient when we wish to integrate backwards in time, we want future events to inform past events.

E.1 Stratonovich Symmetric Integrals and Two-sided Filtration

Clearly, we need a different tool to model this backwards SDE. As such, taking inspiration from the work on neural SDEs [59], we follow the treatment of Kunita [60] for the forward and backward Fisk-Stratonovich integrals using two-sided filtration . Let {F s,t } s ≤ t ; s,t ∈ [0 ,T ] be a two-sided filtration, where F s,t is the σ -algebra generated by { w v -w u : s ≤ u ≤ v ≤ t } for s, t ∈ [0 , T ] such that s ≤ t .

Forward time. For a continuous semi-martingale { x t } t ∈ [0 ,T ] adapted to the forward filtration {F 0 ,t } t ∈ [0 ,t ] , the Stratonovich stochastic integral is given as

where Π = { 0 = t 0 < · · · < t N = T } is a partition of the interval [0 , T ] and | Π | = max k t k -t k -1 . The forward filtration {F 0 ,t } t ∈ [0 ,t ] is analogous to the filtration defined in the prior section; therefore, any continuous semi-martingale adapted to it only considers past events and does not anticipate future events.

Reverse time. Consider the backwards Wiener process q w t = w t -w T that is adapted to the backward filtration {F s,T } s ∈ [0 ,T ] , then for a continuous semi-martingale { q x t } t ∈ [0 ,T ] adapted to the backward filtration, the backward Stratonovich integral is

The backward filtration {F s,T } s ∈ [0 ,T ] is the opposite of the forward filtration in the sense that continuous semi-martingales adapted to it only depend on future events and do not anticipate past events. As such, time is effectively reversed.

Remark E.1. While the Stratonovich symmetric integrals give us a powerful tool for integrating forwards and backwards in time with stochastic integrals, it is important that we use the same realization of the Wiener process.

E.2 Stochastic Flow of Diffeomorphisms

Consider the Stratonovich SDE defined as

where f , g ∈ C ∞ , 1 b , i.e. , they belong to the class of functions with infinitely many bounded derivatives w.r.t. the state and bounded first derivatives w.r.t. time. Thus, the SDE has a unique strong solution. Given a realization of the Wiener process, there exists a smooth mapping Φ called the stochastic flow such that Φ s,t ( x s ) is the solution at time t of the process described in Equation (E.5) started at x s at time s ≤ t . This then defines a collection of continuous maps S = { Φ s,t } s ≤ t ; s,t ∈ [0 ,T ] from R d to itself.

Kunita [60, Theorem 3.7.1] shows that with probability 1 this collection S satisfies the flow property

and that each Φ s,t is a smooth diffeomorphism from R d to itself. Hence, S is the stochastic flow of diffeomorphisms generated by Equation (E.5). Moreover, the backward flow q Ψ s,t := Φ -1 s,t satisfies the backwards SDE:

for all s, t ∈ [0 , T ] such that s ≤ t . This formulation makes intuitive sense as the backwards SDE differs only from the forwards SDE by a negative sign.

E.3 Continuous Adjoint Equations

Now consider the adjoint flow A s,t ( x s ) = ∂ L (Φ s,t ( x s )) /∂ x s , then q A s,t ( x t ) = A s,t ( q Ψ s,t ( x t )) . Li et al. [59] show that q A s,t ( x t ) satisfies the backward SDE:

As the drift and diffusion coefficient of this SDE are in C ∞ , 1 b , the system has a unique strong solution.

E.4 Proof of Theorem 3.1

We are now ready to put all of this together to prove the result from the main paper.

Proof.

By Equation (E.8) the adjoint state admitted by the flow of diffeomorphisms generated by Equation (E.9) evolves with the SDE

Clearly, the adjoint state evolves with an ODE revolving around only the drift coefficient, i.e. , f . Therefore, we can rewrite the evolution of the adjoint state as

E.5 Converting the Itô SDE to Stratonovich

The diffusion SDE in Equation (3.1) is defined as an Itô SDE. However, Theorem 3.1 is defined as Stratonovich SDEs. However, an Itô SDE can be easily converted into the Stratonovich form, i.e. , for some Itô SDE of the form

with a differentiable function σ , there exists a corresponding Stratonovich SDE of the form

As Equation (3.1) is defined such that g ( x t , t ) = g ( t ) and is independent of the state x t , then the SDE may be written in Stratonovich form as

F Additional Experiments

In this section, we include some additional experiments which did not fit within the main paper.

(a) M = 5

(b) M = 10

(c) M = 15

(d) M = 20

F.1 Impact of Discretization Steps

One of the advantages of AdjointDEIS is that the solver for the diffusion ODE and continuous adjoint equations are distinct. This means that we do not have to force N = M enabling greater flexibility when using AdjointDEIS. As such, we explore the impact of using fewer steps to estimate the gradient while keeping the number of sampling steps N = 20 fixed. In Figure 4 we illustrate the impact of the change in the number of discretization steps when estimating the gradients. Unsurprisingly, the fewer steps we take, the less accurate the gradients are. This matches the empirical data presented in Table 4 which measures the impact of the performance of face morphing measured in MMPMR.

To explore the degradation in performance further. As Kidger [25] points out, due to recalculating the solution trajectory of the underlying state x t backwards can differ, in not significant ways from the x t calculated in the forward pass due to truncation errors. This is especially true for non-algebraically reversible solvers [61], although these can suffer from poor regions of stability. Consider the toy

example of the ODE ˙ x ( t ) = λx ( t ) , where λ < 0 and some numerical ODE solver. During the forward solve, most numerical ODE solvers with a non-trivial region of stability will find a reasonably useful solution as the errors decay exponentially; however, during the backward solve any small error is magnified exponentially instead.

One possible solution to this is to use interpolated adjoints wherein the solution states, x t , but not the internal states of f θ are stored. The backward solve can then interpolate between them as needed. Kim et al. [56] report that interpolated adjoints performed well on a stiff differential equation. In the case when N = M it is quite convenient to simply store { x t i } i m =1 during the forward solve. Moreover, in our use case where N is quite small this adds little overhead. In Table 5 we compare recording the solution states vs finding them via solving DDIM forwards in time. We observe that AdjointDEIS performed better when using the recorded states.

(a)

η

= 0

.

01

(b)

η

= 0

.

1

(c)

η

= 1

F.2 Impact of Learning Rate

We measure the impact of the learning rate on guided generation with AdjointDEIS in Table 4. Unsurprisingly, high learning rates lower performance, especially for less accurate gradients. I.e. , when M is small. We illustrate an example of the impact in Figure 5. Clearly, the learning rate of η = 1 starts to distort the images even if it still fools the FR system.

F.3 Number of Steps

As alluded to in the main paper, one of the drawbacks of diffusion SDEs is that they require small step sizes to work properly. We observe that the missing high frequency content is added back in when the step size is increased, see Figure 6.

G Implementation Details

G.1 AdjointDEIS-2M Algorithm

For completeness we have the full AdjointDEIS-2M solver implemented in Algorithm 1 for solving the continuous adjoint equations for diffusion ODEs. We assume that there is another solver that

(a) N = 20

(b) N = 50

solves the backward ODE to yield { ˜ x t i } i M =0 . Remark that a aug := [ a x , a z , a θ ] . Also Algorithm 1 can be used to solve the continuous adjoint equations for diffusion SDEs by simply adding the factor of 2 into the update equations.

G.2 Code

Our code for AdjointDEIS will be available here at https://github.com/zblasingame/ AdjointDEIS .

G.3 Repositories Used

For reproducibility purposes, we provide a list of links to the official repositories of other works used in this paper.

The SYN-MAD 2022 dataset used in this paper can be found at https://github.com/ marcohuber/SYN-MAD-2022 .

The ArcFace models, MS1M-RetinaFace dataset, and MS1M-ArcFace dataset can be found at https://github.com/deepinsight/insightface .

The ElasticFace model can be found at https://github.com/fdbtrs/ElasticFace .

The AdaFace model can be found at https://github.com/mk-minchul/AdaFace .

The official Diffusion Autoencoders repository can be found at https://github.com/ phizaz/diffae .

The official MIPGAN repository can be found at https://github.com/ ZHYYYYYYYYYYYY/MIPGAN-face-morphing-algorithm .

Algorithm 1 AdjointDEIS-2M.

Require: Initial values a x (0) , monotonically increasing time steps { t i } i M =0 , and noise prediction model ϵ ( x , z , t ) .

.

H Experimental Details

In this section, we outline the details for the experiments run in Section 5.

H.1 DiM Algorithm

For completeness, we provide the DiM algorithm from [41] following the notation used in [35]. The original bona fide images are denoted x ( a ) 0 and x ( b ) 0 . The conditional encoder is E : X → Z , Φ is the numerical diffusion ODE solver, Φ + is the numerical diffusion ODE solver as time runs forwards from 0 to T . The algorithm is presented in Algorithm 2.

H.2 NFE

In our reporting of the NFE we record the number of times the diffusion noise prediction U-Net is evaluated both during the encoding phase, N E , and solving of the PF-ODE or diffusion SDE, N . We chose to report N + N E over N +2 N E as even though two bona fide images are encoded resulting in 2 N E NFE during encoding, this process can simply be batched together, reducing the NFE down to N E . When reporting the NFE for the Morph-PIPE model, we report N E + BN where B is the number of blends. While a similar argument can be made that the morphed candidates could be generated in a large batch of size B , reducing the NFE of the sampling process down to N , we chose to report BN as the number of blends, B = 21 , used in the Morph-PIPE is quite large, potentially resulting in Out Of Memory (OOM) errors, especially if trying to process a mini-batch of morphs. Using N E + N reporting over N E + BN , the NFE of Morph-PIPE is 350, which is comparable to DiM. The reporting of NFE for AdjointDEIS was calculated as N E + n opt ( N + M ) where n o pt

Algorithm 2 DiM Framework.

is the number of optimization steps and M is the number of discretization steps for the continuous adjoint equations.

H.3 Hardware

All of the main experiments were done on a single NVIDIA Tesla V100 32GB GPU. On average, the guided generation experiments for our approach took between 6 - 8 hours for the whole dataset of face morphs with a batch size of 8. Some additional follow-up work for the camera-ready version used an NVIDIA H100 Tensor Core 80GB GPU with a batch size of 16.

H.4 Datasets

The SYN-MAD 2022 dataset is derived from the Face Research Lab London (FRLL) dataset [52]. FRLL is a dataset of high-quality captures of 102 different individuals with frontal images and neutral lighting. There are two images per subject, an image of a 'neutral' expression and one of a 'smiling' expression. The ElasticFace [53] FR system was used to select the top 250 most similar pairs, in terms of cosine similarity, of bona fide images for both genders, resulting in a total of 489 bona fide image pairs for face morphing [51], as some pairs did not generate good morphs on the reference set; we follow this minimal subset.

H.5 FR Systems

All three FR systems use the Improved ResNet (IResNet-100) architecture [62] as the neural net backbone for the FR system. The ArcFace model is a widely used FR system [41, 43, 45, 49]. It employs an additive angular margin loss to enforce intra-class compactness and inter-class distance, which can enhance the discriminative ability of the feature embeddings [48]. ElasticFace builds upon the ArcFace model by using an elastic penalty margin over the fixed penalty margin used by ArcFace. This change results in an FR system with state-of-the-art performance [53]. Lastly, the AdaFace model employs an adaptive margin loss by weighting the loss relative to an approximation of the image quality [54]. The image quality is approximated via feature norms and is used to give less weight to misclassified images, reducing the impact of 'low' quality images on training. This improvement allows the AdaFace model to achieve state-of-the-art performance in FR tasks.

The AdaFace and ElasticFace models are trained on the MS1M-ArcFace dataset, whereas the ArcFace model is trained on the MS1M-RetinaFace dataset. N.B. , the ArcFace model used in the identity loss is not the same ArcFace model used during evaluation. The model used in the identity loss is an IResNet-100 trained on the Glint360k dataset [63] with the ArcFace loss. We use the cosine distance to measure the distance between embeddings from the FR models. All three FR systems require images of 112 × 112 pixels. We resize every image, post alignment from dlib which ensures

the images are square, to 112 × 112 using bilinear down-sampling. The image tensors are then normalized such that they take values in [ -1 , 1] . Lastly, the AdaFace FR system was trained on BGR images so the image tensor is shuffled from the RGB format to the BGR format.

I Analytic Formulations of Drift and Diffusion Coefficients

For completeness, we show how to analytically compute the drift and diffusion coefficients for a linear noise schedule Ho et al. [1] in the VP scenario Song et al. [15]. With a linear noise schedule log α t is found to be

on t ∈ [0 , 1] with β 0 = 0 . 1 , β 1 = 20 , following Song et al. [15]. The drift coefficient becomes

and as σ t = √ 1 -α 2 t we find

Therefore, the diffusion coefficient g 2 ( t ) is

Importantly, d σ t d t does not exist at time t = 0 , as σ t is discontinuous at that point, and so an approximation is needed when starting from this initial step. In practice, adding a small ϵ ≪ 1 to t = 0 should suffice.

NeurIPS Paper Checklist

1. Claims

Question: Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope?

Answer: [Yes]

Justification: The main claims made in the abstract and introduction accurately reflect the paper's contributions and scope.

2. Limitations

Question: Does the paper discuss the limitations of the work performed by the authors?

Answer: [Yes]

Justification: We discussed the limitations of this work in Section 6.

3. Theory Assumptions and Proofs

Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof?

Answer: [Yes]

Justification: The full set of assumptions, derivations, and proofs are found in Appendices B to E.

4. Experimental Result Reproducibility

Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)?

Answer: [Yes]

Justification: We presented the implementation details in Appendix G, including the algorithm as well as the repositories used.

5. Open access to data and code

Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material?

Answer: [Yes]

Justification: The dataset we use are all public dataset, we have provided links to all the repositories used in the experiments in Appendix G. We provide detailed derivations of the AdjointDEIS solvers Appendix B. Interested readers can implement the algorithms themselves. We intend to release our code at https://github.com/zblasingame/AdjointDEIS .

6. Experimental Setting/Details

Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer, etc.) necessary to understand the results?

Answer: [Yes]

Justification: The experimental details are presented in Appendix H.

7. Experiment Statistical Significance

Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments?

Answer: [No]

Justification: Due the computationally demanding nature of the guided generation we do not report error bars.

8. Experiments Compute Resources

Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments?

Answer: [Yes]

Justification: The hardware used in this paper is explained in Appendix H.3.

9. Code Of Ethics

Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines ?

Answer: [Yes]

Justification: We conducted the research conforming in every aspect with the NeurIPS Code of Ethics.

10. Broader Impacts

Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed?

Answer: [Yes]

Justification: We address the broader impacts in Section 6.

11. Safeguards

Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)?

Answer: [NA]

Justification: The dataset used in the experiments are public datasets.

12. Licenses for existing assets

Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected?

Answer: [Yes]

Justification: The details of the datasets and models used from other researchers are decsribed in Appendices G and H.

13. New Assets

Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets?

Answer: [No]

Justification: No new assets were created at the time of submission.

14. Crowdsourcing and Research with Human Subjects

Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)?

Answer: [NA]

Justification: We did not perform crowdsourcing. Human faces are used in the experiments, but the datasest we used are all public dataset.

15. Institutional Review Board (IRB) Approvals or Equivalent for Research with Human Subjects

Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained?

Answer: [NA]

Justification: Used public datasets, as such no IRB approvals were needed.

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper presents a way to optimize the initial seed or control parameters to a diffusion network to optimize a differentiable loss applied to the final samples drawn from a discretization of the diffusion SDE / probability flow ODE. Put differently the idea is to apply the white box integration trick from DPM / DPM++ paper, and the method from the neural ODE paper to differentiate through an ODE solver.\n\nIn addition, the paper presents methods for backpropagating through an SDE. \n\nIn terms of experiments the method is demonstrated on a face morphing application.\n\nSTRENGTHS:\nThe paper is well written and the derivation is mostly clear. I did not go through section 4 for the derivation of the SDE Adjoint Diffusion SDE too closely since I am not very familiar with the Stratonovich stochastic integral.\n\nThe paper is also fairly comprehensive since it presents the derivations for both the probability flow formulation as well as the SDE formulation. \n\nOverall I think the problem tackled in the paper is interesting and the solutions are elegant.\n\nWEAKNESSES:\nThe experimental results seem to be weak.\n\nThis paper presents a way to control the final outcome from a diffusion sampler using a differentiable loss, but the only application demonstrated in the paper is on face-morphing where the NFE are not controlled across the baselines. Some of the baselines have fewer NFE and it's not possible to say conclusively whether they underperform because they are worse methods or just because they had less computational budget.\n\nAdjointDEIS-2M is not even implemented and compared. \n\nAlso, a lot more compelling demonstrations could be shown of these new algorithms. For example, a number of \"controlnet\" type applications could have been tried to create an image that matches a sketch of an output.\n\nQUESTIONS:\nMainly I would like to understand a little bit more about the rationale for selecting the face morph application selection, and whether the authors think the empirical comparisons in Table 1 are apples-to-apples given the different NFE for the methods.\n\n\nSome more minor comments\n- eq (3.1) has a factor of 2 missing.\n- around eq(2.5) it might be good to explicitly clarify that while VP typically uses alpha^2 + sigma^2 = 1 ibut you are not making that assumption here.\n\nLIMITATIONS:\nYes limitations have been addressed.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2024-07-10"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nIn this paper, the authors proposed an accelerated  method for differentials of pretrained diffusion models with respect to its latent valuables or parameters by making use of \n1. the Taylor expansion of the log-SNR parameter, and\n2. the exact integral formula of the derivatives related to the probability flow ODE, which they call Adjoint Diffusion ODE.\n\nThey applied this method to morphing of two generated images. As they summarized in Table 1, their results achieved good performance.\n\nFor more details:\n- The setting\n    - Data diffusion SDE $d\\mathbf{x}_t = f(t) \\mathbf{x}_t + g(t) d\\mathbf{w}_t$\n        - Its integral $q(\\mathbf{x}_t|\\mathbf{x}_0) = \\mathcal{N}(\\mathbf{x}_t|\\alpha_t \\mathbf{x}_0, \\sigma_t^2)$ where $f(t), g(t)$ are related to $\\alpha_t, \\sigma_t$ by Eq.(2.5).\n    - A pretrained diffusion model $\\epsilon_\\theta(\\mathbf{x},\\mathbf{z}, t)$\n        - Its generating process: the probability flow ODE $\\frac{d\\mathbf{x}\\_t}{dt} = f(t)\\mathbf{x}\\_t + \\frac{g(t)^2}{2 \\sigma_t}\\epsilon_\\theta(\\mathbf{x}, \\mathbf{z}, t)$\n        - They name the velocity (the RHS of the ODE) as $\\mathbf{h}_\\theta(\\mathbf{x}, \\mathbf{z}, t)$\n- The purpose\n    - Calculation of gradients of $\\mathcal{L}(\\mathbf{x}_0(\\mathbf{x}_T, \\mathbf{z}, \\theta))$ with respect to $\\mathbf{z}$ or $\\theta$\n    - which are defined by ODEs in Eq.(3.3) and (3.4).\n- The method\n    - One can recover the derivatives based on a vector $\\hat{\\mathbf{a}}_t = \\frac{\\partial \\mathcal{L}}{\\partial \\mathbf{y}_t}$ where $\\mathbf{y}_t = \\alpha_t^{-1}\\mathbf{x}_t$.\n    - For $t<s$, one can get $\\hat{\\mathbf{a}}_s = \\hat{\\mathbf{a}}_t + \\int\\_{\\lambda_t}^{\\lambda_s} ... d\\lambda$ (Proposition 3.1).\n    - Applying the Taylor expansion on ... with $\\lambda$ around $\\lambda_t$, and drop $O((\\lambda_s - \\lambda_t)^{k+1})$ term, we get a concrete relation between $\\hat{\\mathbf{a}}_s$ and $\\hat{\\mathbf{a}}_t$ (Eq.(3.11)),\n    - which provides explicit (approximated) formulas for the derivatives.\n- The empirical result\n    - They apply the proposed method to morphing (Section 5 Experiments).\n\nSTRENGTHS:\n- **quality(+)** The explanations are well written. The authors provide concrete proofs on their theorems and experiments with real data.\n\nWEAKNESSES:\n- **significance(-)** It is difficult to understand in which respect the proposed method is superior.\n- **clarity(-)** I am almost convinced by the explanations, however there is a concern as explained in Questions.\n\nQUESTIONS:\n- for significance improvements:\n    - **Q1(significance)** In the theoretical sections, the authors apply omitting the higher order terms of the Taylor expansion, so the resultant method should be just an approximation. Why is it good performance in Table 1 compared to other methods nonetheless the method is just an approximation?\n- for clarity improvements:\n    - **Q1(clarity)** In the Adjoint Empirical Diffusion SDE cases, the integral results in Eq.(4.12) and (4.13) look very similar to ODE cases in Eq.(3.13) and (3.14). The only difference seem to be (doubled) 2nd term. Why such similarity happens?\n    - **Q2(clarity)** In the beginning of section 4, the authors wrote their motivation to analyze SDE cases as it possibly improve the result, however, it turns to be that the SDE version works worse than the ODE cases. Why does it happens?\n\nLIMITATIONS:\nThey leave comments on\n1. Lack of conditional generation in numerical experiments\n2. No application of parameter differentiation in numerical experiments\n\nin the final page.", "TITLE": "Official Review", "RECOMMENDATION": 5, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 2, "DATE": "2024-07-11"}

comments: SUMMARY:
The paper proposes an adjoint sensitivity method -- AdjointDEIS -- for efficiently calculating gradients of diffusion SDE models. Current methods for naive backpropagation rely on discrete adjoints which are memory intensive. The authors introduce an approach based on the stochastic adjoint sensitivity method to solve the gradients with respect to initial noise, conditional information, and model parameters. The authors develop custom solvers for the adjoint problems along with the proposed sensitivity method. The methods are validated on a face morphing problem.

STRENGTHS:
* **Great Flow/Presentation**: The general presentation of the paper is well done! Especially starting off with a more straightforward setting of an ODE and extending them to SDEs
* **Specialized Solver**: Diffusion models are quite widespread and developing specialized solvers leveraging the structure of the problem demonstrates a practical application.

WEAKNESSES:
* **Limited Experimental Scope**: While the overall analysis and formulations are sound, the overall experimental validation for the method is limited to just a single experiment.

QUESTIONS:
1. Point 2 in contributions: Aren't the continuous adjoint sensitivity methods used in Neural SDEs already general-purpose enough to handle diffusion problems?

LIMITATIONS:
N/A
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 3
DATE: 2024-07-12

comments: SUMMARY:
AdjointDEIS uses the method of adjoint sensitivity to compute gradients of diffusion models, which is more efficient and less memory intensive, and robust to the injected noise. This work proposes efficient solvers for both the adjoint probability flow ODE and the adjoint diffusion SDE. Experiments demonstrate the efficacy of the solvers on guided generation for a face morphing problem.

STRENGTHS:
- AdjointDEIS reduces the adjoint of the PF ODE to the problem of exponential integrators, which enables use of the vast amount of literature in the areas.
 - Obtaining accurate gradients wrt initial noise x_T and the latent z can open the door to possibly novel applications of diffusion models.

WEAKNESSES:
- The number of experimental applications of the method seem lacking (just one application to face morphing attacks is included). I’d encourage the authors to think about applications to data assimilation or inverse problems for instance.
- Since the primary contribution of the paper is solver, having a proof of convergence rates or empirical studies of convergence rate would be valuable additions to the paper.

QUESTIONS:
- It would be interesting to visually plot example forward and backward trajectories of the diffusion processes. What is the typical magnitude of the numerical errors that accumulate during the backward ODE solve?

LIMITATIONS:
N/A
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 3
DATE: 2024-07-13