1am/x-vs-v-prediction

Predict the data, not the velocity, until you can't

· from Advanced Machine Learning, ANU · Mayukh Das

AI image generators start from pure static and gradually turn it into a picture. Flow matching is one of the methods that teaches a network to do that, and it comes with a design choice that sounds like a detail: what, exactly, should the network be asked to predict? For an Advanced Machine Learning project at the ANU I tried both options. On paper they are the same thing. In practice they behaved completely differently.

The idea, without the maths

Take one real example from your data and one random blob of static, and imagine a straight line between them. Flow matching trains a network so that, dropped anywhere along a line like that, it knows how to carry on towards the data end. Train it on enough of these lines and it can start from brand-new static and find its own way to something that looks real.

start: pure static the data the network is dropped here velocity: which way, how fast destination: the clean data
One training example. The network is dropped somewhere on the line and asked either for the destination or for the arrow.

There are two natural things to ask the network for at each point on the line:

These are two descriptions of the same line. If you know where you are and where you are going, you can work out the arrow, and the other way round. One detail turns out to matter a great deal, though: the arrow is the destination minus the static you started from, so the velocity has the static baked into it.

The experiment

I didn't use images. I used shapes simple enough to judge by eye: dots arranged in a spiral (a "swiss roll"), a ring of blobs, and circles. Each one is flat, like a drawing on a sheet of paper. Then I placed that sheet inside bigger and bigger spaces: 2, 8 and 32 dimensions. A sheet of paper in a room is still flat, even though the room has three dimensions; this is the same idea with a 32-dimensional room. Real images work like this too: a photo is millions of numbers, but real photos take up only a thin, structured slice of all the combinations those numbers could make.

The same small network (5 layers, 256 units wide) was trained with every combination of prediction target and loss, the loss being how its mistakes are scored.

the setup, in 3D · data on a flat sheet, noise everywhere
DRAG TO SPIN

Samples at 32 dimensions for the four combinations of prediction target and loss
At 32 dimensions: both x-prediction setups still draw the shapes, while both v-prediction setups lose them.

What happened

At 2 dimensions, everything worked. At 8, v-prediction started to blur. At 32, both v-prediction setups failed completely, while both x-prediction setups still drew clean spirals, rings and clusters. How the mistakes were scored mattered much less than what was being predicted: matching the loss to the target helped a little, but never rescued v-prediction.

Why

However big the room, the clean data still lives on its flat sheet, so a network predicting the destination only ever has to learn that simple shape. The velocity is different. It has the static baked in, and static fills every direction of the room, all 32 of them. So a network predicting the velocity has to describe something that gets more complicated every time the room grows.

where each target's variance lives, as the space grows

Illustrative, with data and noise at the same scale: each bar is one direction of the space.

Same information, different difficulty: the destination stays as simple as the data, while the velocity gets harder as the space grows.

Can v-prediction be rescued?

Yes, so the failure is about the size of the network, not about what is possible. Making the network four times wider, from 256 to 1024 units, gave clean spirals with v-prediction. But that takes it from about 330 thousand adjustable numbers to 5.2 million: roughly 16 times the compute for what x-prediction managed at the small size. Changing how the static is mixed in during training, a trick from large-scale work called shifting the noise schedule, didn't help on its own.

v-prediction at 32 dimensions, from the report's sweep
v-prediction samples at the chosen width
x-prediction reference at width 256
x-prediction at width 256, for reference

So why do big image models predict velocity?

Because their world is different. Production models like Stable Diffusion 3 and FLUX don't work on pixels. They work on a compressed description of the image that another network has learned, and in that compressed space the data no longer sits on a simple flat sheet, so predicting the destination loses its advantage. Predicting the velocity also keeps the job about equally hard at every stage, whereas a network predicting the destination has to guess a whole clean image from almost pure static at the very start. At scale, that steadier training wins.

How many steps does sampling need?

Generating means starting from static and following the network's directions in small straight steps. With the best setup (x-prediction at 32 dimensions), recognisable structure appeared by about 10 steps, and quality stopped improving somewhere between 20 and 50. Beyond that, extra steps bought almost nothing.

circles at 32 dimensions, from the report
Samples after the chosen number of Euler steps

A footnote on one-step generation

I also implemented MeanFlow, a method that learns the average velocity over a whole stretch of the journey, so it can make the trip in a single step. It drew the swiss roll and the circles in one step, but struggled with the separate clusters, where averaging pulls them together. The paper's recommended way of choosing which points along the line to train on made that worse here, which was a useful reminder in itself: recipes from large-scale work are tuned for failure modes that may not exist in a small problem.

MeanFlow samples at 1, 2 and 5 steps for three datasets
MeanFlow at 1, 2 and 5 steps. The spiral and rings hold up in one step; the eight separate clusters smear together.

What I took from it

Two things can be identical on paper and very different to learn. Asking for the destination was easier here because the destination was simple and the route was noisy. When the destination stops being simple, as it does in large image models, the answer flips. A design choice is only right for the problem in front of it.