arXiv:2610.20035stat.MLOct 2026

Manuscript Offprint

arXiv:2610.20035

Weighted Adjoint Matching: Finetuning Flow Matching Models with Time-Dependent Control Cost

Eliot Beyler, Francis Bach

Abstract

We introduce Weighted Adjoint Matching, a method to finetune a pretrained diffusion or flow matching model given a differentiable reward. We derive it from Adjoint Matching, which reformulates finetuning as a stochastic optimal control problem with a quadratic control cost. Building on the observation that these models generate coarse features before fine details, we place a time-dependent weight on the control cost. A high cost early in the generative process preserves balance and diversity in the coarse features, which carry most of the semantics, while a low cost at the end lets the model increase the reward by refining details. We prove that our method is equivalent to maximizing the reward under time-varying Kullback–Leibler regularization on the generative paths. Experiments on Gaussian mixtures and on MNIST show a better tradeoff between reward and mode balance than Adjoint Matching.

1 INTRODUCTION

Diffusion models [7, 10, 11, 14] and flow matching models [20, 17, 21] are now the state-of-the-art methods for learning and sampling a distribution known from a large dataset of empirical samples. They work by approximating a denoising process, modeled as an ordinary or stochastic differential equation whose drift is learned with score matching [5]. In this article, we focus on the task of finetuning a pretrained flow matching model, denoting ptargetp_{\text{target}} the distribution on RdR^d it samples from.

Finetuning a generative model. To finetune the model, we assume that we are given a differentiable reward function r:Rd→Rr : \mathbb{R}^d \to \mathbb{R}. Our goal is to increase r(x)r(x) when xx is a sample from the model.

A first naive way to define the finetuning could be the maximization max⁡pEp[r(X)]\max_p \mathbb{E}_p[r(X)]. But this objective makes the distribution diverge or collapse onto a maximum x∗x^* of the reward rr; hence it does not capture any structure in the original data distribution ptargetp_{\text{target}}. Therefore, it is natural to constrain the finetuned distribution to be close to the original distribution ptargetp_{\text{target}}, for example by penalizing the Kullback–Leibler (KL) divergence from ptargetp_{\text{target}}: for some a>0a > 0,

max⁡pEp[r(X)]−1aKL(p∥ptarget).(1)\max_{p}\mathbb{E}_{p}[r(X)]-\frac{1}{a}\mathrm{KL}(p\|p_{\mathrm{target}}). \tag{1}

This can be shown to be equivalent to sampling from the tilted distribution pap_{a},

pa(x)∝ptarget(x)ear(x).(2)p_{a}(x)\propto p_{\mathrm{t a r g e t}}(x)e^{a r(x)}. \tag{2}

Adjoint matching. In practice, optimizing (1) directly is intractable, and different methods aim to sample from pap_a by using the structure of the generative process. The generative model can be seen as a stochastic process dXt=b(Xt,t)dt+γ(t)dBtdX_t = b(X_t, t)dt + \gamma(t)dB_t, X0∼N(0,I)X_0 \sim \mathcal{N}(0, I) for some drift b:Rd×R→Rdb : \mathbb{R}^d \times \mathbb{R} \to \mathbb{R}^d and diffusion coefficient γ:[0,1]→R\gamma : [0, 1] \to \mathbb{R} such that the data distribution is the end distribution of the process, p1:=L(X1)=ptargetp_1 := \mathcal{L}(X_1) = p_{\text{target}}. Domingo-Enrich et al. [35] propose to reframe the finetuning as a stochastic optimal control (SOC) problem,

min⁡u∈UE[∫0112∥u(Xtu,t)∥2dt−ar(X1u)]s.t.dXtu=(b(Xtu,t)+γ(t)u(Xtu,t))dt+γ(t)dBt,X0u∼N(0,I).\begin{align*}\min_{u\in\mathcal{U}}\quad&\mathbb{E}\left[\int_{0}^{1}\frac{1}{2}\|u(X_{t}^{u},t)\|^{2}dt-ar(X_{1}^{u})\right]\\ s.t.\quad&dX_{t}^{u}=(b(X_{t}^{u},t)+\gamma(t)u(X_{t}^{u},t))dt+\gamma(t)dB_{t},\\&X_{0}^{u}\sim\mathcal{N}(0,I).\end{align*}

(3)

This is motivated by Girsanov's theorem [see, e.g., 8], which links the squared norm of the control and the KL divergence between the base and the controlled processes. They develop a method to learn the optimal control u∗u^* and prove that it retrieves the tilted distribution (2) with p1u∗:=L(X1u∗)=pap_1^{u^*} := \mathcal{L}(X_1^{u^*}) = p_a.

Tilting creates imbalance. However, we may wonder if sampling from pa(x)∝ptarget(x)ear(x)p_a(x) \propto p_{\text{target}}(x)e^{ar(x)} is what

Figure

Figure 1: Trajectories of a flow matching model, in black, first sample the coarse features, illustrated here as the class of the digit, and only later its fine details, here differences in brightness. Suppose we want to finetune the model to produce brighter digits. Adjoint matching [35], in red, penalizes the control uniformly in time. Early in the process, when the coarse features are not yet settled, a small push is enough to move a trajectory towards the class that is brighter on average, here the eights. Weighted adjoint matching, in green, makes the control expensive at the beginning of the process, so that the finetuned trajectories follow the base process until the coarse features are settled, then it refines only the details, leading to a more balanced distribution.

we want in the first place. Indeed, this tilting has the unintended effect of moving mass between different regions of the distribution regardless of distance in sample space. We illustrate this on a simple example 1^{1}

ptarget(x)=12N(x;−μ,σ12I)+12N(x;μ,σ22I),p_{\mathrm{t a r g e t}}(x)=\frac{1}{2}\mathcal{N}(x;-\mu,\sigma_{1}^{2}I)+\frac{1}{2}\mathcal{N}(x;\mu,\sigma_{2}^{2}I),

with μ=(m,0)∈R2\mu = (m, 0) \in \mathbb{R}^2, m>0m > 0 and σ2>σ1>0\sigma_2 > \sigma_1 > 0. For x=(x1,x2)x = (x_1, x_2), we define the reward r(x)=−∥x2∥22r(x) = -\frac{\|x_2\|^2}{2} to encourage samples to be closer to the first axis. Note that both modes have their means ±μ\pm \mu on this axis and only differ by their variances. The tilted distribution pap_a is also a mixture of two Gaussian distributions

pa(x)=κa1N(x;−μ,Σ1,a)+κa2N(x;μ,Σ2,a)p_{a}(x)=\kappa_{a}^{1}\mathcal{N}(x;-\mu,\Sigma_{1,a})+\kappa_{a}^{2}\mathcal{N}(x;\mu,\Sigma_{2,a})

with covariance matrices Σi,a=diag(σi2,σi21+aσi2)\Sigma_{i,a} = \text{diag}\left(\sigma_i^2, \frac{\sigma_i^2}{1 + a\sigma_i^2}\right) and weights κa1\kappa_a^1 and κa2\kappa_a^2, such that κa1κa2=1+aσ221+aσ12>1\frac{\kappa_a^1}{\kappa_a^2} = \sqrt{\frac{1 + a\sigma_2^2}{1 + a\sigma_1^2}} > 1. For the finetuned distribution, the first mode has a weight strictly larger than the second, creating an imbalance that was absent from the data distribution, regardless of the distance 2m2m between the centers of the modes.

Coarse-to-fine generation in diffusion and flow matching models. To address this issue, we rely on the fact that for natural data such as images, diffusion and flow matching models generate coarse features (the outline of an image) before fine ones (details and textures) [34]. This phenomenon can be understood by looking at the frequency domain [23, 29]: for natural images the magnitude of the (discrete) Fourier transform decays with frequency, whereas it is flat for Gaussian white noise, so progressively adding noise erases high frequencies of low magnitude before low frequencies of high magnitude. The fact that features of high magnitude are generated before those of low magnitude can be understood within the literature on mode speciation. This approach to the question asks what it means for a feature to be “generated” at a given point in the process: past a certain time in the generative process, the feature is already determined, in the sense that almost all trajectories through the current state terminate in samples sharing it [22, 26, 38, 39]. In particular, Li and Chen [31] give non-asymptotic results and analyze hierarchical data in which features live at different scales, showing that each feature emerges in a critical window of time, from features at large spatial scales to features at small spatial scales.

Weighted adjoint matching. Our idea is to exploit this phenomenon by modifying the SOC problem and introducing a time-dependent weight w(t)w(t) on the control quadratic cost

min⁡u∈UE[∫01w(t)2∥u(Xtu,t)∥2dt−ar(X1u)].\min_{u\in\mathcal{U}}\quad\mathbb{E}\left[\int_{0}^{1}\frac{w(t)}{2}\|u(X_{t}^{u},t)\|^{2}dt-ar(X_{1}^{u})\right].

Modulating the control cost lets us finetune the model differently across the different spatial resolutions of the data distribution. Typically, we penalize the early timesteps more heavily, which preserves the coarse features and lets the finetuning increase the reward by modifying the details. The insight behind this choice is that coarse features carry most of the semantic meaning, while the reward can also be increased by tweaking only finer details. 2^{2}

1^{1}See Appendix A for the derivations.

2^{2}While this is the general motivation behind our

Contributions. In this paper, we make the following contributions:

• We introduce a new algorithm (Section 4), weighted adjoint matching, to finetune flow matching and diffusion models while preserving diversity, motivated by the link between time and spatial resolutions in these models. We derive it as a simple modification of adjoint matching [35] with no extra computational cost.

• We show that the SOC problem defining the algorithm is equivalent to maximizing the reward under a KL regularization on every sub-path [0,t][0, t] of the generative process (Section 4.1).

• We illustrate the method on Gaussian mixtures and on MNIST, for which the reward/mode collapse tradeoff can be precisely measured (Section 5).

References (44)