Vibeleaderboard
← All Intel
Clip / Education

Optimal transport is why the straight line and constant velocity are not arbitrary

From In-Depth Analysis of the Flow Matching Training Algorithm · ≈13:36

“There's a branch of mathematical optimization called optimal transport that seeks to answer the following question. Out of all the ways to move a density to another, which one minimizes the squared distance traveled?”

Julia Turc

“This is an appealing way of framing the problem because it formalizes a notion of efficiency, and an efficient velocity field will lead to shorter paths and faster inference.”

Julia Turc

“It tells us that the optimal way to deform one Gaussian into another is to linearly interpolate between X0 and its image T of X0.”

Julia Turc

“A non-zero sigma helps avoid all sorts of edge cases in theoretical math, but doesn't make a difference in reality.”

Julia Turc

“Drawing a straight line is not an arbitrary decision anymore. It's a way of implementing optimal transport, not between two arbitrary points, but between two Gaussian densities.”

Julia Turc
What’s in it
  • Derives the algorithm's design choices from theory — the optimal map between Gaussians is affine, a 1997 result makes the intermediate path a linear interpolation, and sigma is set to zero in practice with no real-world cost.
Clip transcript
that transports P0 into a Gaussian and that acts as a training signal. The first thing to notice is that this field is not unique. The paths could go straight, bend downwards, or even go through a loop. So, we need a principled way to choose one of these. There's a branch of mathematical optimization called optimal transport that seeks to answer the following question. Out of all the ways to move a density to another, which one minimizes the squared distance traveled? This is an appealing way of framing the problem because it formalizes a notion of efficiency, and an efficient velocity field will lead to shorter paths and faster inference. That's why we'll choose the conditional field using optimal transport theory. Now, answering this question is generally very hard. If it were easier, optimal transport could give us a recipe for transporting P0 directly into P1. But for Gaussians in particular, there's a straightforward answer. The optimal transport is an affine map. That just means a scaling operation plus a translation. So, every point X0 sampled from our density P0 is scaled by sigma and translated by X1. But this map only tells us about the end points. In order to gradually morph one density into another, we can use a result that dates back to 1997. It tells us that the optimal way to deform one Gaussian into another is to linearly interpolate between X0 and its image T of X0. This gives an expression for all the intermediate points XT on the conditional path. This is actually the expression that I used to draw these shaded cones. And it's actually the linear interpolation in the flow matching algorithm, just with standard deviation sigma set to zero. Setting it to zero is very common practice in real-world models. A non-zero sigma helps avoid all sorts of edge cases in theoretical math, but doesn't make a difference in reality. Once we understand optimal transport between two Gaussians, the first three steps of the training algorithm should now make sense. X1 is the mean of the target conditional distribution. Sampling a single X0 and drawing a straight line to X1 is a way of taking a transport sample from this shaded cone. Drawing a straight line is not an arbitrary decision anymore. It's a way of implementing optimal transport, not between two arbitrary points, but between two Gaussian densities. The next uncomfortable part of the training algorithm is this constant velocity label. It's derived from the optimal transport paths. Since velocity is distance over time, or DX over DT, the math simplifies to X1 - X0.
Recommended reads
Comments

Checking sign-in…

Loading comments…