← Back to Projects

On the Hidden Biases of Flow Matching Samplers

Flow matching is always trained on finitely many samples. If you replace the target distribution by those samples, the velocity field the model is trained toward can be written down exactly. Looking at that exact field shows that the finite sample quietly changes four things at once: what the sampler estimates, the geometry of its flow, which particle dynamics realize it, and how much kinetic energy its trajectories carry.

Based on On the Hidden Biases of Flow Matching Samplers by Soon Hoe Lim.

Author

Soon Hoe Lim

Affiliation

KTH Royal Institute of Technology
Nordita, KTH and Stockholm University

Resources

Paper · Code · Notebook
Updated November 2026

TL;DR: Empirical flow matching has an exact minimizer: a posterior-weighted mixture of conditional velocities. Reading flow matching as plug-in estimation exposes four coupled finite-sample effects. (1) The sampler targets a kernel density estimator, not the data law. (2) Its velocity need not be a gradient field, so its geometry can depart from optimal transport. (3) The density path does not determine the particle dynamics: flux-null corrections change trajectories but not marginals. (4) The source distribution controls the upper tails of the kinetic energy: exponential bounds for a Gaussian source, polynomial bounds for a heavy-tailed one. [1]

Same density, different sampler. Both panels show the same evolving density $\hat p_t$ (background) and start from the same Gaussian particles, coloured by their initial angle. Left: the exact empirical flow matching velocity. Right: the same velocity plus a flux-null correction (Section 6). The density path is identical, yet the particles swirl, and their median integrated kinetic energy rises from 1.0 to 6.8. Click to pause.

1.Why look at the finite-sample sampler?

Generative modelling starts from finitely many samples of an unknown distribution and tries to build a sampler for that distribution. Flow matching (FM) [2] does this by learning a velocity field whose ODE carries a simple source distribution, usually a Gaussian, to the data. It is simple and scales well, and it is usually analysed at the population level, as if the data distribution were known.

Classical statistics suggests a sharper lens. With an unknown law $P$ and a loss $\ell$, there are three natural objects: the population risk $R(f)=\int \ell(f,z)\,P(dz)$; the empirical risk, which replaces $P$ by the empirical measure $\hat P_n=\frac1n\sum_i\delta_{Z_i}$; and a smoothed plug-in risk, which replaces $P$ by a regularized estimator such as a kernel density estimator (KDE). The same three regimes appear in flow matching, except that the unknown object is now an entire target law $p_1$:

  1. Objective-level plug-in. Keep $p_1$ fixed in principle and replace the expectations in the FM loss by Monte Carlo averages.
  2. Raw empirical plug-in. Replace $p_1$ itself by $\hat p_1=\frac1N\sum_{i=1}^N\delta_{x^{(i)}}$.
  3. Smoothed plug-in. Replace $p_1$ by a smoothed estimator $\tilde p_{1,h}$, such as a KDE with bandwidth $h$.
Three panels for the two-moons data: a smooth population density, 500 sample points, and a kernel density estimate built from them.
Three targets, one dataset. The population density (left), the raw empirical measure of $N=500$ samples (middle), and a smoothed plug-in KDE built from them (right). These regimes are mathematically different, and the rest of this post shows that they lead to genuinely different samplers.

The paper's point is that these regimes should not be conflated. Working them out for the affine conditional flows used in practice, the raw and smoothed plug-in models have an exact minimizer, and studying that minimizer exposes four coupled biases.

2.Flow matching in one page

FM looks for a velocity field $v(t,z)$ whose ODE $\dot z = v(t,z)$, started from $z(0)\sim p_0$, ends with $z(1)\sim p_1$. The law $p_t$ of $z(t)$ then obeys the continuity equation

$$\partial_t p_t + \nabla\cdot(p_t\, v_t) = 0,$$

which says that probability mass is transported, never created or destroyed. Conditional flow matching (CFM) builds $p_t$ as a mixture of simple conditional paths, $p_t(z)=\int p_t(z\mid x)\,p_1(dx)$, and the matching velocity is the posterior average of the conditional velocities,

$$v(t,z) = \int v(t,z\mid x)\,\frac{p_t(z\mid x)}{p_t(z)}\,p_1(dx).$$

A network $v_\theta$ is trained by regressing on the conditional velocities, which gives the same minimizer as regressing on $v$ itself:

$$\mathcal L_{\mathrm{CFM}}[v_\theta] = \mathbb E_{t\sim U[0,1],\ X\sim p_1,\ Z_t\sim p_t(\cdot\mid X)}\,\big\|v_\theta(t,Z_t)-v(t,Z_t\mid X)\big\|^2 .$$

Affine conditional flows. Almost every practical choice is affine: draw a latent $Z\sim K$ (a positive density, not necessarily Gaussian) and set $\psi_t(Z\mid X)=m_t(X)+\sigma_t(X)\,Z$. The conditional density is $p_t(z\mid X)=\sigma_t(X)^{-d}K\big((z-m_t(X))/\sigma_t(X)\big)$, and the conditional velocity is affine in $z$:

$$v(t,z\mid X) = a_t(X)\,z + b_t(X),\qquad a_t=\frac{\dot\sigma_t}{\sigma_t},\qquad b_t=\dot m_t - m_t\,a_t .$$

The canonical example is rectified flow [3]: $K=\mathcal N(0,I)$, $m_t(x)=tx$, and straight lines $Z_t=(1-t)x_0+tx_1$ between a Gaussian sample and a data point. Its variance-floored version uses $\sigma_t = 1-(1-\sigma_{\min})t$ with a small $\sigma_{\min}>0$ to keep the velocity bounded at $t=1$. This is the running example below.

3.The exact empirical minimizer

Now replace the target by the training set, $p_1\to\hat p_1=\frac1N\sum_i\delta_{x^{(i)}}$. The marginal path becomes a finite mixture, $\hat p_t(z)=\frac1N\sum_i p_t(z\mid x^{(i)})$, and the FM objective can be minimized in closed form.

Proposition (informal) · Prop. 4.3 in the paper

For affine conditional flows, the empirical FM objective has a unique minimizer over all square-integrable fields:

$$\hat v^*(t,z)=\sum_{i=1}^N w_i(t,z)\,\big(a_t(x^{(i)})\,z+b_t(x^{(i)})\big),\qquad w_i(t,z)=\frac{p_t(z\mid x^{(i)})}{\sum_{j=1}^N p_t(z\mid x^{(j)})} .$$

The weight $w_i(t,z)$ is the posterior probability that a point at $z$ at time $t$ came from the $i$-th conditional path.

So the field that a neural network is ultimately trained toward is a spatially weighted average of $N$ simple affine fields. For variance-floored rectified flow it reads

$$\hat v(t,z)=\sum_{i=1}^N w_i(t,z)\,\frac{x^{(i)}-(1-\sigma_{\min})\,z}{\sigma_t},\qquad w_i(t,z)=\operatorname{softmax}_i\!\Big(-\frac{\|z-t\,x^{(i)}\|^2}{2\sigma_t^2}\Big).$$

Integrating this field needs no training at all: it is an exact, training-free sampler. All experiments in the paper, and all animations here, use it directly.

Five snapshots of the empirical marginal density for the two-moons data, from a round Gaussian at t=0 to a sharp two-moons shape at t=0.97.
The empirical marginal path $\hat p_t$ for the two-moons data ($N=500$, $\sigma_{\min}=0.02$). It starts as the source Gaussian and ends as a narrow mixture around the training points.

4.Bias 1: the sampler estimates a different target

The first consequence is statistical. Take the source to be the latent density itself, $p_0=K$, and any affine path with $m_0=0$, $m_1(x)=x$, $\sigma_0=1$ and a positive terminal scale $\sigma_1=\sigma_{\min}$.

Proposition (informal) · Example 4.2 in the paper

The terminal law of the empirical sampler is exactly a kernel density estimator, with the source density as the kernel and the terminal scale as the bandwidth:

$$\tilde p_1(z)=\frac{1}{N\,\sigma_{\min}^d}\sum_{i=1}^N K\!\Big(\frac{z-x^{(i)}}{\sigma_{\min}}\Big).$$

So finite-sample FM is not population FM plus Monte Carlo noise: it estimates a different object. Choosing $\sigma_{\min}$ is choosing a KDE bandwidth, with the familiar bias–variance tradeoff and the familiar curse of dimensionality [6]. As $\sigma_{\min}\to0$ the KDE collapses onto the training points: in the animation above, the generated samples end on average 0.04 from the nearest training point, about the width of the terminal kernel.

5.Bias 2: gradient structure

Optimal transport (OT) gives the natural benchmark for transport geometry. By Brenier's theorem, the quadratic-cost OT map is the gradient of a convex function. In the dynamic Benamou–Brenier formulation [4], the optimal velocity minimizes the total kinetic energy $\int_0^1\!\int\|v_t\|^2p_t\,dz\,dt$ subject to the continuity equation, and it is a gradient field: any curl would add looping motion and waste energy. Being a gradient is necessary for optimality, though not sufficient.

Each conditional field $a_t z+b_t$ is a gradient. Their weighted average need not be, because the weights depend on $z$.

Proposition (informal) · Prop. 5.3 in the paper

In dimension $d\ge2$, the empirical minimizer $\hat v^*(t,\cdot)$ is a gradient field if and only if

$$\sum_{i=1}^N\Big(v_i(t,z)\,\nabla_z w_i(t,z)^\top-\nabla_z w_i(t,z)\,v_i(t,z)^\top\Big)=0\quad\text{for all } z,$$

where $v_i=a_t(x^{(i)})z+b_t(x^{(i)})$. Any rotation in $\hat v^*$ comes entirely from the spatial variation of the posterior weights.

When does this skew-symmetric term vanish? For the running example it does, identically. With a Gaussian kernel and a scale $\sigma_t$ shared by all data points, the posterior mean satisfies Tweedie's identity $\sum_i w_i\,x^{(i)}=\big(\sigma_t^2\nabla\log\hat p_t(z)+z\big)/t$, so

$$\hat v(t,z)=\nabla_z\Big[\frac{\sigma_t}{t}\log\hat p_t(z)+\frac{c_t}{2}\|z\|^2\Big],\qquad c_t=\frac{1/t-(1-\sigma_{\min})}{\sigma_t},$$

which is a gradient field. This has the same structure as the paper's Example 5.1, where the rectified-flow regression minimizer under the independent coupling is a gradient for any target $p_1$, including $\hat p_1$. The skew term becomes nonzero once the posterior weights are no longer Gaussian with a shared covariance, or the mean path is not linear in $x$: for example non-Gaussian kernels, scales $\sigma_t(x^{(i)})$ that depend on the data point, or nonlinear mean paths $m_t(x)$.

Two curl maps on the eight-Gaussians data at t=0.55: uniformly zero for the Gaussian kernel, and a strong four-fold pattern of positive and negative curl for the Student-t kernel.
Where the curl comes from. The curl $\partial_x\hat v_2-\partial_y\hat v_1$ of the exact empirical minimizer on the eight-Gaussians data at $t=0.55$, on the same colour scale. With the Gaussian kernel the curl is zero up to rounding (largest value $4\times10^{-8}$). With the Student-$t_2$ kernel, which corresponds to the heavy-tailed sources of Section 7, the same data give curl up to $2.2$, about a fifth of the field's own derivatives. The rotation is strongest away from the data, in the directions between clusters, where neighbouring components compete for the weight.

Key insight: the finite sample alone does not break gradient structure; the shape of the posterior weights does. Gaussian rectified flow keeps it, and is therefore the least-energy representative of its own density path (Section 6). Heavy-tailed sources, which are attractive for other reasons, give a velocity field with genuine rotation: the field a network is trained toward is then geometrically biased away from Benamou–Brenier optimality.

6.Bias 3: same marginals, different particles

The square loss picks one velocity, but a density path does not determine a unique velocity. Write the probability flux (current) as $j_t=p_t v_t$, so the continuity equation reads $\partial_t p_t+\nabla\cdot j_t=0$. Any field $r_t$ whose current has zero divergence,

$$\nabla\cdot(p_t\,r_t)=0\qquad\Longleftrightarrow\qquad \nabla\cdot r_t + r_t\cdot\nabla\log p_t = 0,$$

can be added without changing $\partial_t p_t$. The paper calls such fields flux-null, and calls two velocities flux-equivalent when $\nabla\cdot(p_t u_t)=\nabla\cdot(p_t v_t)$. The equivalence class of $v_t$ is $v_t+\mathcal R_{p_t}$, where $\mathcal R_{p_t}$ is the space of flux-null fields. This is closely related to the gauge freedom studied for diffusion models [5].

Proposition (informal) · Prop. 5.4 in the paper

If $r_t$ is flux-null for the empirical path $\hat p_t$, then $u_t=\hat v_t+r_t$ realizes the same marginal path $\hat p_t$. The particle trajectories, the numerical stiffness and the kinetic energy can all differ.

There is a canonical representative. In $L^2(p_t)$, flux-null fields are exactly the orthogonal complement of gradient fields, so every velocity splits as $v_t=\nabla\phi_t+r_t$ with $\nabla\cdot(p_t\nabla\phi_t)=\nabla\cdot(p_tv_t)$, and

$$\|\nabla\phi_t+r\|^2_{L^2(p_t)}=\|\nabla\phi_t\|^2_{L^2(p_t)}+\|r\|^2_{L^2(p_t)} .$$

The gradient part is the minimum-kinetic-energy representative of the class. This is a statement for a fixed path, not the full Benamou–Brenier problem, which also optimizes over the path. Combined with Section 5, it means the Gaussian empirical rectified-flow field is already the least-energy way to realize its own density path. For Gaussian mixture paths, flux-null directions can be written down explicitly.

Proposition (informal) · Prop. 5.5 and Cor. 5.11 in the paper

Let $\hat p_t=\frac1N\sum_i\mathcal N(m_i(t),\Sigma_i(t))$ with posterior weights $w_i$. For any antisymmetric matrices $A_i(t)^\top=-A_i(t)$,

$$r^A_t(z)=\sum_{i=1}^N w_i(t,z)\,\Sigma_i(t)A_i(t)\,\big(z-m_i(t)\big)$$

is flux-null for $\hat p_t$. For variance-floored rectified flow this is $r^A_t(z)=\sigma_t^2\sum_i w_i(t,z)\,A_i(t)\,(z-t\,x^{(i)})$.

The reason is short: each component current $p_i\,\Sigma A(z-m_i)$ has divergence $p_i\big(\operatorname{tr}(\Sigma A)-y^\top Ay\big)$ with $y=z-m_i$, and both terms vanish for symmetric $\Sigma$ and antisymmetric $A$. Each component's mass is simply rotated within its own level sets. In the opening animation, the right panel uses $A_i=\omega J$ with $J$ the 90° rotation and $\omega=5$. On a grid, the computed divergence of the current $\hat p_t r^A_t$ is about $10^{-4}$ of the size of its individual terms, which is discretization error. Yet the particles behave very differently:

Two moons, Gaussian sourcemedian $E_T$99% quantile of $E_T$mean distance of samples to data
exact empirical velocity $\hat v_t$1.034.470.042
flux-null corrected $\hat v_t+r^A_t$, $\omega=5$6.7735.70.040

Here $E_T=\int_0^T\|v(t,Z_t)\|^2dt$ is the integrated kinetic energy of a trajectory ($T=0.97$, 900 particles, forward Euler with 180 steps). The two samplers produce equally good samples, but one spends about seven times more energy getting there.

7.Bias 4: energy tails come from the source

How often does a sampler produce a high-energy trajectory? Such trajectories are long or fast. They are where ODE solvers struggle and where samples are most sensitive. The paper shows that, conditional on the training set, the tail of the kinetic energy is controlled by the source distribution.

The population Gaussian case is fully explicit. For $p_0=\mathcal N(0,I)$ and $p_1=\mathcal N(m_1,\Sigma_1)$, rectified flow coincides with the OT map, and half the energy of a sample equals its negative log-density up to an explicit quadratic term, so high-energy samples are exponentially rare (Prop. 5.6). The same holds for the empirical sampler, even though its velocity is nonlinear.

Theorem (informal) · Thm. 5.7 in the paper

With a Gaussian source and any fixed dataset of bounded points, the instantaneous energy $K_t=\|\hat v(t,Z_t)\|^2$ and the integrated energy $E_T=\int_0^TK_t\,dt$ (for $T<1$) have exponential upper tails:

$$\mathbb P(K_t\ge u\mid\mathcal D_N)\le C_t\,e^{-c_tu},\qquad \mathbb P(E_T\ge u\mid\mathcal D_N)\le C_T\,e^{-c_Tu}$$

beyond a threshold. This holds even if the data come from a heavy-tailed distribution.

Theorem (informal) · Thm. 5.8 and Prop. 5.9 in the paper

If instead the source has a polynomial tail, $\mathbb P(\|X_0\|\ge s)\le C_\alpha s^{-\alpha}$, then

$$\mathbb P(K_t\ge u\mid\mathcal D_N)\le \frac{C_t}{u^{\alpha/2}},\qquad \mathbb P(E_T\ge u\mid\mathcal D_N)\le \frac{C_T}{u^{\alpha/2}} .$$

The mechanism is linear growth: $\|\hat v(t,z)\|\le L\|z\|+B$ gives $K_t,E_T\le C(1+\|X_0\|^2)$, so the source tail passes to the energy tail with the exponent halved. The same bounds hold for flux-equivalent samplers whose correction also grows at most linearly (Thm. 5.10), for example $r^A$ with bounded $A_i$.

The paper tests this on the exact empirical sampler for three toy datasets, comparing a Gaussian source with coordinate-wise Student-$t_\nu$ sources ($\nu=10,5,2$), with the kernel $K$ equal to the source density. The settings are $N=500$ training points, 1,000 samples per seed, 5 seeds, $\sigma_{\min}=0.02$, $T=0.97$ and 100 forward Euler steps. The figures below are a full re-run of that experiment from the paper's code, with the same seeds.

Survival curves of the integrated kinetic energy for three datasets and four sources, on log-linear and log-log axes; the Student-t2 curve has by far the heaviest tail in every panel.
Survival curves $\mathbb P(E_T>u)$ for the exact empirical sampler (first seed). On log-linear axes (left) the Gaussian source drops fastest. On log-log axes (right) heavier-tailed sources give flatter, more polynomial curves. The ordering Gaussian, $t_{10}$, $t_5$, $t_2$ is the same on every dataset: the data set the scale, the source sets the tail.
Bar charts of the 99% quantile of the integrated energy for each source and dataset, on a log scale; Student-t2 is roughly 40 to 50 times the Gaussian value.
High-energy quantiles. The 99% quantile of $E_T$ (mean ± standard deviation over 5 seeds). For two moons it rises from 4.1 (Gaussian) through 6.4 ($t_{10}$) and 12.6 ($t_5$) to 154 ($t_2$), with the same pattern on the other datasets.

For the nonlinear empirical sampler, the theorem gives only an upper bound, so fitted slopes are diagnostics rather than predictions. To isolate the exponent, the paper also uses a nondegenerate affine ODE $\dot Z_t=AZ_t+b$, where $E_T=(AX_0+b)^\top G_T(AX_0+b)$ is comparable to $\|X_0\|^2$, so a $t_\nu$ source should give a tail slope near $-\nu/2$.

Survival curves for the affine sharpness experiment; the Student-t2 curve is close to a straight line of slope -1 on log-log axes.
Sharpness of the exponent (100,000 samples, $T=1$, 400 trapezoidal steps). The heaviest tail, $t_2$, has fitted slope $-0.98$ against the predicted $-1$. The lighter tails, with fits of $-1.77$ ($t_5$) and $-2.10$ ($t_{10}$), are still pre-asymptotic over this range. These fits match the paper's values exactly.

8.A caveat: flux equivalence does not control energy

The bounds above need the correction to grow at most linearly. Without that, a flux-null field can change the energy tail drastically while leaving every marginal untouched. The paper's example (Remark 5.1) has a single data point $x^{(1)}=0$ in two dimensions. Then $\hat p_t=\mathcal N(0,\sigma_t^2I)$, the empirical velocity is purely radial, $\hat v_t(z)=-\frac{1-\sigma_{\min}}{\sigma_t}z$, and for $0<a<\tfrac14$

$$r_t(z)=\exp\!\Big(a\,\frac{\|z\|^2}{\sigma_t^2}\Big)\,Jz$$

is flux-null (its current is a radial function times the rotation $(-y,x)$) and square-integrable under $\hat p_t$. Since $\hat v_t\perp r_t$, with $S=\|Z_t\|^2/\sigma_t^2\sim\chi^2_2$,

$$\|\hat v_t(Z_t)+r_t(Z_t)\|^2=(1-\sigma_{\min})^2S+\sigma_t^2\,S\,e^{2aS},$$

whose second term has a tail that is polynomial up to logarithmic factors (through the Lambert $W$ function), against the exponential tail of the first.

One data point, two samplers. Both panels share the same Gaussian marginal at every time. Colours mark each particle's initial angle and the white trails follow a few particles. On the left particles move straight in; on the right they spin. Over $t\in[0,0.85]$ the 99% quantile of the integrated energy rises from 7.8 to 41.7 ($a=0.12$), as in the paper's notebook.
Survival curves of the exact integrated energy for the radial sampler and two flux-null corrections; the corrected curves have much heavier tails.
Exact energy tails for the one-point example (200,000 samples, $T=0.97$). The 99% quantile of $E_T$ is 8.6 for the radial sampler, 28 for $a=0.1$ and 133 for $a=0.2$: the same marginals with very different energy profiles.

Same marginals do not mean the same sampler. Density-level diagnostics, such as sample quality or likelihood along the path, cannot see the trajectory-level differences in this section. Energy, stiffness and rotation have to be measured on the trajectories themselves. The paper suggests this flux-null freedom as a new angle on memorization versus generalization in flow matching.

9.Explore it yourself

The panel below runs the exact empirical sampler in your browser, with the same formulas as above. Pick a dataset and what to compare. Flux-null correction runs the Gaussian sampler with and without $r^A_t$ (strength $\omega$): the background density is identical, so watch the particles and the energy. Heavy-tailed source compares a Gaussian source with a Student-$t_\nu$ source. Everything runs on this page.

10.What this means in practice

Limitations

The analysis concerns exact empirical minimizers over unrestricted function classes. Neural approximation and numerical ODE solvers can add biases of their own. The energy results are upper-tail bounds; matching lower bounds need extra nondegeneracy assumptions. And because flux-equivalent samplers preserve the marginal path, they cannot remove density-level memorization when that path itself ends at the training points or at a narrow KDE.

Looking forward

Finite-sample flow matching is more than population flow matching with Monte Carlo noise. It changes the target, the geometry, the particle dynamics and the energetics together. Open directions include how these effects survive neural approximation, discretization and stochastic sampling, and how to design sources, time schedules or flux-null corrections that control the energy profile of a sampler.

All figures and animations in this post were produced for it from the exact empirical formulas, using the datasets, seeds and settings of the paper's notebook. The sharpness fits and the one-point energy quantiles reproduce the values printed in the paper and notebook. The curl maps in Section 5 and the energy table in Section 6 are new computations.

Citation

If you find this useful, please cite the paper:

@article{lim2025hidden,
  title   = {On The Hidden Biases of Flow Matching Samplers},
  author  = {Lim, Soon Hoe},
  journal = {arXiv preprint arXiv:2512.16768},
  year    = {2025}
}

References

  1. S. H. Lim. On the Hidden Biases of Flow Matching Samplers. arXiv:2512.16768, 2025. Code: github.com/dynamai/hiddenbias_EFM.
  2. Y. Lipman, R. T. Q. Chen, H. Ben-Hamu, M. Nickel, M. Le. Flow Matching for Generative Modeling. arXiv:2210.02747, 2022.
  3. X. Liu, C. Gong, Q. Liu. Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow. arXiv:2209.03003, 2022.
  4. J.-D. Benamou, Y. Brenier. A computational fluid mechanics solution to the Monge–Kantorovich mass transfer problem. Numerische Mathematik 84(3):375–393, 2000.
  5. C. Horvat, J.-P. Pfister. On Gauge Freedom, Conservativity and Intrinsic Dimensionality Estimation in Diffusion Models. arXiv:2402.03845, 2024.
  6. L. Kunkel, M. Trabs. On the Minimax Optimality of Flow Matching through the Connection to Kernel Density Estimation. arXiv:2504.13336, 2025.