Normalizing Flows for World Models

A flow bends hard data into a plain Gaussian and back, so it scores every outcome exactly and samples new ones with the same map. Drag a point and read its exact score.

Learn why a robot needs to predict what happens next, how a flow does it with an exact likelihood, and how Penn’s STARFlow family turns that into video, images and a planner.

Choose how many layers the flow has, then slide the query point across the blue cloud. Press Draw a sample to run the map backwards. Then we build every piece from zero: the change of variables, the coupling layer, the triangular matrix, the autoregressive stack, and the planner on top.

You need a feel for a probability density (a curve whose height says how likely a value is) and a little calculus (a slope, a derivative). We build the rest from zero.

Based on the special topic lecture “Are Normalizing Flows Good Candidates for World Models?” by Jiatao Gu (University of Pennsylvania, AMI Labs) in CIS 6280: World Models (Fall 2026). Lecture slides. Every idea is re-taught here in our own words and devices; it follows Lecture 14, Fast Sampling and Interactive World Models in this series.

Score a point, sample a point

0.60
−0.40

A toy flow whose shifts and scales are hand-set formulas, not trained, so every number is exact for this toy. The heat map is the exact density of the data space, computed by pushing each map cell through the layers to the Gaussian and adding the volume corrections. Samples are real random draws in your browser, pushed backwards through the same layers.

Chapter 0

Why an Agent Needs to Predict

Watch a robot state what it expects before it moves, and see why a good guess about the next moment is the whole job of a world model

Two housekeeping notes open the lecture. There is no in-class session on Thursday, October 29, because the classroom is unavailable, and a Zoom link is posted instead. The class on November 24 is an invited talk by Dr. Randall Balestriero. That is all the logistics there are. Now the lesson.

Picture a robot arm on a table. A red block sits in front of it and a bowl sits to the side. The task is short: place the red block inside the bowl. The lecture shows a real run in which a language model, GPT-6 Astra, drives the arm. It sees camera images and the robot’s own joint readings. It answers with text, and that text moves the robot.

What happens between two motions

The model does not stream motor commands. Each turn it sends one tool call: a structured message, like a form with fixed fields, that another program knows how to run. The lecture draws the fields. A public action note holds the model’s current assessment and its reason for moving. A motion target holds a position, an orientation or a gripper setting. The model’s private reasoning is not shown, so everything below comes from the public notes, which the slides paraphrase.

A controller then does the physical work. An inverse kinematics solver (IK) turns the target hand position into joint angles, and a motion controller moves the joints there. New camera images return, and the loop starts again. Send one call, move, look, send the next.

Now read one turn closely. At step 37 the fingers have closed around the block. The note says three things. Assessment: partial closure suggests contact. Reason: lift to test whether the grasp holds. And a third line the lecture singles out, the expected observation: the block should rise with the gripper.

That third line is the idea of the whole lecture. The robot said what it expects to see before it acted. At step 73 the same pattern appears: the intention is to release the block into the bowl, the action is to open the gripper (the field left_gripper = 1), and at step 79 the camera shows the block resting inside the bowl. The expected result was written down, the action ran, and the result was checked.

expected consequence
What the agent believes will change. This is a prediction, made before the motion.
execute action
The tool call runs on the real arm. Nothing is undone after this point.
observe the result
New camera frames come back. The agent compares them with its prediction.

Predict, then choose

Why write down an expectation at all? Because a good choice needs it. “What should I do?” cannot be answered without “What might happen if I do this?” The lecture splits the work in two for the sake of the talk. World modeling takes a candidate action and predicts the possible consequence. Planning scores that consequence against the goal and picks the action.

The lecture states the target plainly: learn predictions that are useful for decisions. A prediction that looks sharp but does not help you choose is not the prize. Feedback also closes the loop. If the block does not rise, the expectation was wrong, and the agent revises it and tries again.

Three jobs for a world model

The slide on world models lists three roles. A simulator for learning lets a policy practise inside the model; Ha and Schmidhuber (2018) trained one in VizDoom. A predictor for planning anticipates what actions cause; TD-MPC2 (Hansen et al., 2024) plans online this way. A world generator creates a whole interactive world, like Google DeepMind’s Genie 3 (2025). This lecture’s focus is the middle one, the predictor for planning.

The idea is old. Kenneth Craik wrote in 1943 that a mind carries a “small-scale model” of external reality and of its own possible actions. Yann LeCun, in 2026, says such a model lets an agentic system anticipate the consequences of its own actions. In the lecture’s agent diagram, the agent model holds world modeling and planning together, and a harness (the tool loop) connects it to outside tools such as a simulator.

pθ
A probability model with learned weights θ. It gives each possible next observation a probability.
xt+1
The next observation: a camera frame, or a learned summary of it (a representation).
x≤t
Everything observed so far, up to and including now.
a≤t
The actions taken so far, plus the candidate action. This is what makes it a world model and not just a video predictor.

The slide writes this as the next-observation formula above. Planning then compares futures under different action choices. Try it on the smallest world we can search by hand: the lecture’s blocks puzzle.

The goal is orange on red, and red on blue. At the start the orange block sits on yellow, and red and blue sit on the table. The RAP system (Hao et al., 2023) lets a language model propose actions, predict the state each action produces in plain text, and search the tree of futures. Pick a first move below. The device predicts the state after it, then counts how many moves are left by searching every future.

Predict a move, then plan

Each chip is a candidate first move. Tap one: the left panel shows the predicted state, the bars show the shortest total plan after each move. Then press Follow the best plan.

The puzzle is the lecture’s RAP example (Hao et al., 2023, Fig. 4). Here the search is exhaustive breadth first search over every legal move in your browser, not a language model; it counts one move as picking up a block and putting it down, which the slide counts as two actions.

Look at the bars. Moving red onto blue first needs 2 moves in total. Moving orange onto red first looks tempting, since it is half the goal, yet it needs 4: red is now covered, so orange must come off again. That one prediction, red becomes blocked, is the lecture’s whole argument in miniature. The model that predicts consequences saves moves.

Where this lesson goes

The blocks world has a few symbolic states, and text can name them. Real robots see pixels, contacts and motion. Predicting those needs a probability model over continuous numbers, and that is where normalizing flows enter. The lecture ends by asking whether they make good world models, and it answers with evidence and open questions. We follow it in order.

  1. Beyond words: why prediction must handle continuous signals, and how diffusion and flow matching do it.
  2. Change of variables: the formula that gives a continuous model an exact score.
  3. The coupling layer: one invertible layer you can build and run.
  4. Triangular Jacobians: why its volume term costs almost nothing.
  5. Stacks and autoregression: many layers, and flows that go one coordinate at a time.
  6. A chosen resolution: why density needs noise and a correction.
  7. TARFlow and STARFlow: Transformers inside a flow, and the image results.
  8. Video, scaling and STARFlow2: time, compute laws and mixed text and image generation.
  9. NFWM: the world model that predicts, plans and plays.
  10. Futures and open questions: branches, ranking, policies and what is still unknown.
  11. Field guide: numbers, terms, a checklist and the core code.
In the blocks puzzle, why is moving orange onto red first a worse opening than moving red onto blue first?

Chapter 1

Predicting What Words Cannot Say

Compare two ways to predict a continuous world, then run the popular one, flow matching, and see why one step is never enough

The lecture asks a small question with a big answer: how do animals learn what happens when they act? Short clips show animals and a child learning the consequences of a step, a jump, a push. None of them has a word for it. They watch, they move, and they update.

The lecture sorts what such learning must capture into two lists. First, natural signals: video carries motion and persistence (the cup is still there when you look away), audio carries impact and material (a thud is not a clink), interaction carries actions and changes. Second, quantities more than words: pose and velocity, contact and occlusion, deformation and geometry. These need not be described in language. How to encode them is a separate modeling choice. That is the sentence to keep.

Two interfaces to a continuous world

Suppose we want a model that predicts video, sound and interaction. The lecture offers two valid routes. In the first, quantized tokens, we cut the signal into pieces and give each piece a number from a finite list, a vocabulary. The model then predicts a category, like a language model picking the next word. That is categorical prediction with an autoregressive token model.

In the second, numerical representations, we keep the numbers as numbers, at finite precision, and predict a density: a curve whose height says how likely each value is. Diffusion, flow matching and normalizing flows live here. The slide says this talk explores the second route, and that it is a choice, not a necessity. Our Lecture 11 built the diffusion side; this one adds a third family.

The same choice reaches into thinking itself. The lecture sketches a model that reads text tokens, passes through a continuous representation made by an encoder from video, audio and interaction, and returns to text. The open question under that picture is: how should we predict the continuous part?

The popular route: flow matching

Start with a picture. Throw a handful of dust into the air: that is noise, a cloud of random numbers drawn from a Gaussian (a bell shape in every direction). You want the dust to settle into the shape of your data. Flow matching trains a network to say, at every point and every moment, which way and how fast to move so the dust settles there. That arrow is a velocity field.

The recipe is short. Take a noise sample ε and a data sample u. Mix them along a straight line, with a time τ from 0 to 1. At τ = 0 you hold pure noise, at τ = 1 pure data. The straight line has a constant speed, u − ε, and that is the answer the network is trained to give.

xτ
The point on the line at time τ: a blend of noise and data.
ε
A noise sample, drawn from a standard Gaussian.
u
A data sample: a clean video latent, say.
ℒFM
The flow matching loss: the average squared gap between what the network says and the true line speed.
vθ(xτ, τ, c)
The network. It reads the point, the time and a condition c (a prompt, past frames, actions) and outputs a velocity.

A worked check. Let ε = (−1.0, 0.5) and u = (2, 1), at τ = 0.25. Then xτ = 0.75 × (−1.0, 0.5) + 0.25 × (2, 1) = (−0.25, 0.625). The target velocity is u − ε = (3, 0.5). Walk the rest of the line: (−0.25, 0.625) + 0.75 × (3, 0.5) = (2.0, 1.0), exactly u. To generate, we start from fresh noise and integrate the learned field: move a little along it, ask again, move again. The lecture notes that flow matching trains a continuous normalizing flow; Chapter 2 shows what makes that name fit.

One snag. The network never sees one line. It sees many noise and data pairs, and lines from different pairs cross. At a crossing point it can only give the average of the speeds. The device below uses three data points, where the exact average velocity can be computed, so you can watch what crude integration does.

Settle the dust with few steps

Purple dots start as noise. Blue crosses are the three data points. Choose the number of Euler steps, then press Integrate and watch where the dots end.

1

Toy: three fixed data points and 160 noise samples. The velocity is the exact average line speed at each point, v = Σk wk (uk − (x − τuk)/(1 − τ)), where wk is the chance that data point k produced the point x. A trained network only approximates this field.

With one step, every dot jumps to the same place: the average of the three data points. The field at τ = 0 points at the mean, because noise carries no hint of which data point it will meet. With 40 small steps, the field re-aims after each move and the dots split into three groups. This is the cost of flow matching and diffusion: many network calls per sample.

What video does with it

Video diffusion applies the same recipe in a compressed space. An autoencoder squeezes video and audio into latents (short lists of numbers). Noise is added, and a Transformer denoiser, told the noise level and the condition, learns the update. To sample, start from Gaussian noise, denoise several times, then decode. The slide keeps two clocks apart: video time is the events in the clip, and denoising time is the generation updates. Veo 3 generates video with audio this way.

The condition can be a prompt, observed frames or actions. With actions, you get action-conditioned video prediction: given history and new actions, generate future video chunk by chunk, as in NVIDIA’s Cosmos (2026). A world-action model goes one step further. DreamZero (Ye et al., 2026) takes observations, a task and the robot state, and generates both future video and an action chunk, which a real robot then runs. Transfusion (Zhou et al., 2024) mixes the two kinds of prediction in one Transformer: text tokens are predicted one by one with the usual loss, while image patches are denoised together, with L = Ltext + λLdiffusion.

The costs that remain

The lecture closes this section with four open costs. The two objectives differ in scale, so their weights must be balanced. Time and noise weighting asks where finite model capacity goes across noise levels. Mode coverage asks whether all valid futures survive, including rare branches. And a mixed model runs two inference loops: the next-block loop and, inside it, denoise after denoise. A single exact likelihood would remove the mismatch, and that is the case the rest of the lecture makes.

Why does a one-step Euler integration of the flow matching field land every sample at the same point?

Chapter 2

Stretch the Line, Keep the Sand

Derive the formula that gives a continuous model an exact score, by stretching a number line and counting what the stretch does to a density

Take a long strip of dough and sprinkle sand on it, one cup in all. Where the sand is thick, the dough is crowded with grains. Now stretch the dough to twice its length. The same cup of sand is spread over twice the room, so each spot holds half as much. Squeeze the dough and the sand piles up.

That is the whole idea of this chapter. A probability density is sand on a line: the total is always 1, and the height at a spot tells how crowded it is. A map that stretches or squeezes the line changes the heights, but not the total. The rule that tracks the change is the change of variables formula.

One principle for text and for numbers

The lecture first states what it wants. A language model trains by one rule: add up, over every position, the log of the probability it gave the actual next element, given what came before. For text, each element is a token, and the model gives each token a probability mass (a share of 1 on a finite list). For a continuous representation the same rule holds, but the model gives a density, not a mass. The lecture’s point is that nothing else needs to change: one likelihood principle, a sum of log terms, for mixed sequences. Which representation to use, and how much noise to add, remain modeling choices (Chapter 6).

The formula, from a stretch

We want a density over data x that we can write down exactly. Easy densities exist: a Gaussian, for one. So build x from a Gaussian by a map you can undo. Let z = fθ(x) be an invertible map (each x gives exactly one z and back), and let z follow a simple base density p0. The lecture’s formula, for a fixed preceding context:

log pθ(x)
The score of the observation x under the model. Training makes this large for real data.
log p0(fθ(x))
The base term. Map x to z, then read the simple density there. The slide labels this “simple base density”.
log | det ∂fθ/∂x |
The volume correction. It tells how much the map stretches space near x. The slide labels it “volume correction”.

Why this shape? Take a tiny interval of width dx around x. It holds probability pX(x) dx. The map sends it to an interval of width |f′(x)| dx around z. The same sand now sits there, and it holds p0(z) |f′(x)| dx. Set the two equal and cancel dx: pX(x) = p0(f(x)) |f′(x)|. Take logs and you have the formula. Nothing is assumed; it is the sand rule.

From a line to many dimensions

In many dimensions, one number cannot say how space stretches, because it stretches differently in each direction. The tool is the Jacobian: a grid of slopes whose entry in row i and column j tells how much output coordinate i changes when input coordinate j moves. The slide notes that rows describe output coordinates and columns describe input coordinates. The determinant of that grid is the volume scale. A map with grid [[2, 0], [0, 3]] stretches area by 2 × 3 = 6. A shear [[1, 1], [0, 1]] slides rows sideways and keeps area, so its determinant is 1. So the determinant is the many-dimensional f′.

Two consequences follow, and both shape every design later. First, z must have the same number of coordinates as x: an invertible map cannot squeeze 1,000 numbers into 100. Second, the slide asks for two things from the map: an explicit inverse, so that sampling works (draw z from the base, then run the map backwards), and a tractable log-determinant, so that scoring works. A general D by D determinant costs about D cubed steps. The next two chapters build a layer where it costs D.

The slide’s picture shows both uses on one map: a curved cloud of data, an intermediate straightened cloud, and a plain square grid of Gaussian dots. Likelihood goes left to right: map the observation to the base, then add the volume correction. Sampling goes right to left: draw from the base, invert.

First, one worked number. Let f(x) = 2x and p0 = N(0, 1). At x = 0.5: z = 1, p0(1) = 0.2420, and f′ = 2, so pX(0.5) = 0.2420 × 2 = 0.4839. Check it by hand: x = z/2 is a Gaussian with spread 0.5, whose height at 0.5 is 1/(0.5 × 2.5066) × e−0.5 = 0.7979 × 0.6065 = 0.4839. The formula and the direct route agree. Now bend the line.

Bend the line, watch the sand move

The map is z = x + a tanh(3x). Top: the data density p(x) from the formula, with a histogram of samples made by inverting the map. Bottom: the base density with your point. Drag bend a, then slide the point.

0.00
0.50

Toy map, not trained. The curve is the exact formula p(x) = N(f(x)) × |f′(x)|. The bars come from 1,500 fixed Gaussian draws pushed back through f by bisection. The area is the numerical integral of the curve from −8 to 8. Below a = −1/3 the map folds back on itself and is no longer invertible.

At a = 0 the map is the identity and the data are a plain Gaussian. Push a up: the map stretches space near x = 0 by 1 + 3a, so the density there falls and the sand moves outward. Push a negative, down to −0.33: the map almost flattens at 0, f′ falls toward 0.01, and the data split into two humps with an empty dip between. Past −1/3, f folds, f′ goes negative, and the area drifts above 1. That is the failure mode: the symptom is a bump that looks wrong, the measurement is an area of 1.07 where it must be exactly 1, and the fix is to build only maps that cannot fold.

A map stretches space near x by a factor of 4. What does the change of variables formula say happens to the data density near x, compared with the base density at z?

Chapter 3

Copy One Half, Rescale the Other

Build one invertible layer, the Real NVP coupling layer, and see why it can be undone for any network you choose

Imagine a message of four numbers. You split it into two halves, call them A and B. You leave half A exactly as it is. You then use half A to decide how to shift and stretch half B. A friend who gets your output sees half A untouched, so she can recompute the same shift and stretch and undo them. She never needs to guess.

This is the affine coupling layer of Real NVP (Dinh et al., 2017, §3), the layer the lecture builds slide by slide. “Affine” means a shift and a stretch: new = (old − shift) × factor. “Coupling” means one half is coupled to the other, because half A steers half B.

Step 1: split and copy

Write the input as x = [xA; xB] and the output as z = [zA; zB]. The data flow is plain. If x has D numbers, then xA holds the first d and xB holds the rest, and the output has the same D numbers. The rule for the first half is the shortest one in the lecture: zA = xA. The slide labels it “copy exactly”. The copied block gives the conditioning information.

Step 2: a conditioner reads the copy

A neural network hθ, called the conditioner, reads xA and writes two lists, one number per coordinate of block B. The first list is a shift μ. The second is a log-scale s. We use the log of the scale on purpose: es is always positive, so the layer can never multiply by zero or by a negative number, and either would destroy information. The slide says: (μ, s) = hθ(xA), with es > 0. The conditioner reads xA. It does not read xB.

Step 3: normalize the other block

zA = xA
Block A passes through. This is the block the conditioner reads.
zB = …
Subtract the shift, then divide by es. The circled dot means one multiplication per coordinate, with no mixing. This direction is scoring: x to z.
xB = …
The same relation, rearranged. This direction is sampling: z to x.

A worked number, one coordinate in each block. Let xA = 0.8 and xB = 1.5. Suppose the conditioner returns μ = 0.5 and s = 0.2. Then e−s = 0.8187, and zB = (1.5 − 0.5) × 0.8187 = 0.8187. Now undo it. The copy tells us xA = 0.8, so we run the conditioner again and get the same μ and s. Then xB = 0.5 + e0.2 × 0.8187 = 0.5 + 1.2214 × 0.8187 = 1.5000. We are back.

Now the shapes, because they make the layer concrete. Take a batch of B examples with D = 4 numbers each, so x has shape B × 4. Block A is the first two columns, B × 2, and block B the last two, B × 2. The conditioner takes the B × 2 block and returns B × 4 numbers. Cut that in half and you have μ and s, each B × 2, one shift and one log-scale for every coordinate of block B. The output z is again B × 4, and the volume charge is one number per example, B in all.

The trick: the conditioner never has to be invertible

Stop here, because this is the point of the layer. The network hθ can be anything: a deep Transformer, a ten-layer perceptron, a lookup table. It goes from xA to (μ, s), and it is never run backwards. Both directions feed it xA, which is known on both sides, because the copy leaves it unchanged. All the invertibility lives in the cheap shift and stretch. So the hard part of an invertible network is solved: you may use any network you like for the part that does the thinking.

The cost is plain, too. In one layer, only block B changes; block A is untouched. A single layer cannot reshape the whole input. Chapter 5 answers this by stacking layers that take turns.

Run the coupling layer both ways

Left: data space with a square grid. Right: the same grid after one layer. Choose which coordinate is copied, scale the conditioner, and move the teal point. Then look at the round trip in the read-out.

1.00
0.80
1.50

Toy conditioner, not trained: μ(a) = 1.1 sin(1.5a) and s(a) = 0.35 cos(1.2a), both multiplied by your strength. The round trip error is measured by running the layer forwards and then backwards in 64-bit floating point.

Notice what the grid does. With x1 copied, every vertical line stays vertical, because z1 = x1. Each line is only shifted and stretched, by its own amount. Horizontal lines bend into curves, because each vertical line was moved differently. At strength 0 the layer is the identity. At strength 1.3 the bends are strong, and yet the round trip stays exact.

pythonimport numpy as np
def forward(x, h):                # x: (batch, D), D = 2d. scoring: x -> z
    xa, xb = x[:, :d], x[:, d:]       # (batch, d) each
    mu, s = h(xa)                      # conditioner reads only xa: two (batch, d) arrays
    zb = (xb - mu) * np.exp(-s)
    return np.concatenate([xa, zb], 1), -s.sum(1)   # z, and log|det| (Chapter 4)
def inverse(z, h):                # sampling: z -> x
    za, zb = z[:, :d], z[:, d:]
    mu, s = h(za)                      # same conditioner, same input: za == xa
    return np.concatenate([za, mu + np.exp(s) * zb], 1)

Two details of the data flow matter in practice. The conditioner returns 2d numbers for a block of d, so its output layer is twice as wide as its input half. And a failure shows up when s grows large: e−s multiplies zB by a huge number, the loss stops being a finite number, and the symptom is a training run that dies at once. You measure it by printing the largest |s| per batch. Implementations often bound s with a tanh to keep it small. That is a common practice and not a claim from the slides.

The conditioner network is a large, non-invertible Transformer. Why can the coupling layer still be inverted exactly?

Chapter 4

Why the Volume Term Costs Almost Nothing

Derive the Jacobian of a coupling layer block by block, see the zero that makes it triangular, and turn a determinant into a sum

Chapter 2 left a bill. The exact score needs log|det J|, the log of how much the layer stretches volume. For a layer on D numbers, J is a D by D grid of slopes, and a general determinant takes about D cubed steps. A picture with 65,536 numbers would need 2.8 × 1014 steps, for every layer, for every example. That is not a design. It is a wall.

The coupling layer gets through the wall with one zero. This chapter finds it, and then the cost drops from D cubed to D.

A fact about staircases

First, a fact about matrices. A lower triangular matrix has zeros everywhere above its diagonal. Its determinant is the product of the diagonal entries, and nothing else. Check on [[2, 0], [5, 3]]: the full formula gives 2 × 3 − 0 × 5 = 6, the same as the diagonal product, whatever the 5 is. The entry below the diagonal never matters. The same holds for 3 by 3 and every size.

The same holds when the entries are blocks. If the top right block is all zeros, the determinant is the determinant of the top left block times the determinant of the bottom right block. That is the move the lecture uses.

Four blocks, one at a time

Rows of J are the output blocks (zA, zB), and columns are the input blocks (xA, xB). So J has four blocks, and the lecture fills them one slide at a time.

Top left and top right. Since zA = xA, the output A moves one-for-one with input A, so ∂zA/∂xA is the identity I. And zA does not depend on xB at all, so ∂zA/∂xB is exactly zero. This zero is the whole trick.

Bottom right. Take one coordinate: zB,j = (xB,j − μj(xA)) e−sj(xA). Hold xA fixed, so μj and sj are constants. Then zB,j depends on xB,j alone, with slope e−sj. The derivative with respect to a different coordinate xB,k is 0. So this block is diagonal, with entries e−sj(xA). Different coordinates of B do not mix.

Bottom left. Now the hard block, how zB depends on xA. The product rule gives, for entry (j, k): −e−sj ∂μj/∂xA,k − zB,j ∂sj/∂xA,k. This block may be dense, because it carries the whole conditioner network. It is exactly where we do not have to look.

Jf
The Jacobian of the whole layer, x to z.
I
Top left: the copy. Output A follows input A one for one.
0
Top right: the copy ignores block B. This zero makes J block lower triangular.
∗
Bottom left: the dense block. Its entries never enter the determinant.
diag(e−s)
Bottom right: one stretch factor per coordinate of B.
log | det Jf |
The volume correction. The product of e−sj becomes the sum of −sj once we take the log.

Assemble the pieces. The determinant is det(I) × det(diag(e−s)) = ∏j∈B e−sj = exp(−Σj∈B sj). Take the log and the slide’s result appears: for x to z, the log-determinant is −Σ sj(xA). One conditioner call already produced every sj, so the volume term costs a sum of d numbers.

Into the likelihood

Put it in the Chapter 2 formula. With a standard Gaussian base, log p0(z) = −½‖z‖2 − (D/2) log 2π. The negative log-likelihood is:

−log pX(x) = ½ ‖fθ(x)‖2 + Σj∈B sj(xA) + (D/2) log(2π)

Back to the numbers of Chapter 3: x = (0.8, 1.5) gave z = (0.8, 0.8187) with s = 0.2. Then ½‖z‖2 = ½(0.64 + 0.6703) = 0.6551, the sum is s = 0.2, and (D/2) log 2π = log 2π = 1.8379, so −log p = 2.6930. Training lowers this number, averaged over real data. This is exact maximum likelihood: no bound, no sampling error, no stand-in objective. The lecture adds that the volume correction is part of it.

Now see the matrix. The device builds a layer on four numbers, with x1 and x2 in block A and x3 and x4 in block B. It measures the Jacobian by nudging each input, then takes the determinant of the full 4 by 4 grid and compares it with −Σs.

Read the Jacobian

Rows are the outputs z₁ to z₄, columns the inputs x₁ to x₄. identity dense diagonal. Move the inputs, then break the layer.

0.60
−0.80
1.10
0.30

Toy conditioner, not trained: four hand-set sine and cosine formulas of x₁ and x₂ give the two shifts and two log-scales. The Jacobian is measured by central finite differences (a nudge of 0.00001), and its determinant by Gaussian elimination on those 16 numbers, not by the formula.

With the true layer, the top right block reads 0.00 in all four cells, the bottom right block is diagonal, and the measured determinant matches exp(−Σs) to many digits, however wild the dense block looks. Now press Mix x₃ and x₄. The shift for z3 now includes 0.9 x4, and the shift for z4 includes 0.9 x3. Two entries in the lower right block light up, and the measured determinant is off from the formula by a factor of 1 − 0.9 × 0.9 = 0.19. That is the failure mode. The symptom is a score that looks plausible but is wrong, the measurement is a determinant and a formula that disagree, and the fix is to transform each coordinate of B on its own, from block A only. Inverting a mixed layer would also need a linear solve, not a single division.

Which fact makes log|det J| of a coupling layer a simple sum of the log-scales?

Chapter 5

Take Turns, Then Go One at a Time

Stack layers so every coordinate gets to change, then see the autoregressive flow, which trains in one pass and samples in many

One coupling layer left half of the numbers untouched. That is a poor deal if we want to reshape all of them. The fix is as old as taking turns: let the other half change in the next layer.

Alternate the halves

Layer 1 copies A and transforms B. Layer 2 swaps the groups: it copies B and transforms A. Each layer has its own conditioner and its own shift and scale. After two layers, every coordinate has been moved at least once, and the slide says it: all coordinates can change across the stack. The data flow is a chain, z = fL(… f2(f1(x))). To undo it, undo the layers in the opposite order, last one first.

The volume term stacks too, and by the cheapest rule in mathematics. The determinant of a chain of maps is the product of the determinants, so the log-determinant is a sum. Each layer adds its own −Σs. Suppose layer 1 has Σs = 0.2 and layer 2 has Σs = −0.5 at a given point. Layer 1 charges −0.2, layer 2 charges +0.5, and the total volume correction is +0.3. The lecture says to alternate the transformed group and add each layer’s log-determinant. Watch it with real numbers:

Walk a cloud through the stack

The first panel is Gaussian noise z. Each next panel is the cloud after one more layer, run backwards as in sampling. The teal point is followed all the way. Drag layers to add or remove turns.

2

The same hand-set toy layers as the hero, not trained. Layers alternate which coordinate is copied. Volume charges are measured by running the teal point’s final x forwards through the stack and adding each layer’s −Σs.

Two layers bend the cloud into a wave. Four give a richer shape, and each layer still costs only a sum to score. Capacity grows with depth, and the volume term stays cheap.

Autoregressive flows: every coordinate waits for the ones before

There is a second way to build the same trick. An autoregressive flow orders the coordinates, x1, x2, up to xD. The conditioner for coordinate i reads only the earlier inputs x<i = (x1, …, xi−1) and writes (μi, si). Then zi = (xi − μi(x<i)) e−si(x<i). This is the MAF of Papamakarios et al. (2017), and the choice of TARFlow (Zhai et al., 2025). A coupling layer is the special case with two groups.

The Jacobian is triangular again, for the same reason as before: coordinate i never looks at later coordinates, so everything above the diagonal is zero. The diagonal holds e−si, the derivative already worked out. The log-determinant is −Σi=1D si(x<i). The lecture says to reuse the affine derivative and the triangular determinant rule.

zi = …
Scoring. All of x is known, so every μi and si can be computed at once.
xi = …
Sampling. To get xi you need x<i, which you must have just built.

Parallel in training, sequential in sampling

Here is the price of this design. In training, the whole input x is observed. One masked pass through a Transformer (a mask that hides later positions from each position) computes all D shifts and scales together. In sampling, the order bites: recover x1 from z1 alone, then x2 from x1 and z2, then x3 from x1, x2 and z3. Each step needs the network and the last result. Compare with the coupling layer, whose sampling needs one conditioner call.

Count the passes

Each square is one coordinate (or image patch). Choose a layer type and a size, then press Sample and watch which squares can be computed at the same time.

16

Counts follow from the definitions on the slides: one layer, one conditioner network call per step. A real model adds more layers and its own batching, so treat these as the pattern, not as a timing.

A picture of 256 patches means 256 sequential steps per autoregressive layer, against 1 for training. That asymmetry is why the lecture asks, at its end, where the computation should go.

Put a price on it. Take a picture cut into D = 256 patches, and suppose, for illustration only, that one network pass takes 20 ms. Training one layer costs a single pass, 20 ms. Sampling the same layer costs 256 passes in a row, 5.12 s. Stack eight layers, and sampling takes about 41 s, while a coupling stack of eight layers needs eight passes, 0.16 s. The symptom is a model that scores well and feels slow to draw from. The measurement is passes per sample. The fix is a design choice: use fewer sequential steps, or let one deep block be the only slow part. STARFlow’s split into shallow blocks and one deep block (Chapter 7) is aimed at exactly this trade.

Do stacked autoregressive flows lose power?

One AR layer has a limit: each conditional p(xi | x<i) is a single Gaussian. The STARFlow paper (Gu et al., NeurIPS 2025, Proposition 1) shows stacking removes it. With one block, one Gaussian per conditional. With two blocks in opposite orders, the conditionals become Gaussian mixtures, except for the final coordinate, because the hidden intermediate coordinates act as mixing variables. With three or more alternating blocks, the remaining restriction goes, and the model can approximate any density. The slide adds a caveat worth repeating: this is expressivity with enough capacity, and whether training finds such a solution is a separate question.

An autoregressive flow trains on 256 patches in one forward pass. Why does sampling from it take 256 sequential steps per layer?

Chapter 6

Pick How Sharp the Model May Be

See why a density can reward a spike without limit, and how adding noise of a chosen size gives the model a resolution to fit

A shop scale reads 10 grams. You weigh a pinch of salt and it says 10. Is the salt exactly 10.0000000 grams? No. The scale only tells you the weight is in some small range around 10. Asking for the chance of exactly 10 grams on a continuous scale gets the answer zero. Every exact value has zero chance. So how can a model that handles continuous numbers be graded on likelihood?

Mass and density

For tokens, grading is easy. A probability mass is a share of 1 given to one symbol, and it stays between 0 and 1. For a continuous value, the model gives a density instead. The lecture defines it as mass in a small region divided by the volume of that region. Keep the same mass and shrink the region, and the density climbs. Squeeze 0.1 of probability into a sliver 0.01 wide and the density there is 10. So a density can exceed 1, and that is no error.

This opens a trap. With finite data, a model can score higher and higher by fitting ever narrower peaks. Put a very thin spike on every training point, and the training score has no ceiling. The lecture says: with finite data, fitting ever-narrower peaks can inflate it. Likelihood then rewards memorizing, not understanding.

The cure the lecture takes from Flow++ (Ho et al., 2019, §3.1) and Loaiza-Ganem et al. (2022) is to choose a finite resolution for the representation: fit the noise-smoothed distribution at that scale. Now see the trap with your own hands.

Make the peaks narrower

Top: a model that puts one narrow bell on each of six training points (blue ticks). Warm ticks are fresh data it never saw. Bottom: average log-likelihood against the bell width. Slide the width, then slide a noisy point and watch it snap back.

0.40
0.40

Toy: six training points and 300 fresh points drawn from the same two-clump source (centres −0.9 and 1.1, spread 0.35), seeded so they are the same on every visit. The model is an equal mix of six Gaussian bells of width σ, one on each training point. The denoised estimate is the exact posterior mean of that mixture.

Start wide, around σ = 0.4. The two clumps are covered, and the training and fresh scores are close. Now shrink the width. The training score climbs and climbs: at σ = 0.01 each bell is 40 times taller than at 0.4. But the fresh points fall between the spikes, and their score collapses to a large negative number. The model got better at the six points it saw and worse at everything else. The symptom is a training score that keeps rising. The measurement is the fresh score, which falls. The fix is the next idea.

Noise sets the resolution

The lecture’s fix is to decide the sharpness in advance, and to make it part of the data. Add Gaussian noise of size σ to every observation. The model then fits qσ = pdata ∗ N(0, σ2I): the data density smoothed by a bell of width σ, where ∗ means blur by. Now the target itself has a ceiling on how sharp it can be, so there is no reward for a spike narrower than σ. The noise scale is the modeling resolution: details finer than σ are not part of the question.

The price is that samples are noisy too. The lecture’s recipe, used by TARFlow (Zhai et al., ICML 2025, §§2.4 and 2.5), has three boxes: sample from qσ, apply one score correction, and read off a clean estimate. A score is the gradient of the log density: an arrow at each point that says which way is more crowded. The correction is Tweedie’s estimate, the best guess of the clean value given the noisy one:

x̂clean
The estimate of the clean sample.
x
The noisy sample you drew from qσ.
σ2
The noise variance. More noise, a bigger correction.
∇x log qσ(x)
The score. For a flow it comes from the exact log-density by one backward pass.

A worked check with two data points, −1 and +1, and σ = 0.5. You draw the noisy point 0.4. The chance that it came from +1 is proportional to e−(0.6)2/0.5 = 0.487, and from −1 to e−(1.4)2/0.5 = 0.020. Normalized, the weights are 0.961 and 0.039. The score is (0.961 × 0.6 + 0.039 × (−1.4)) / 0.25 = 2.087. So x̂ = 0.4 + 0.25 × 2.087 = 0.922. Check from the other side: the posterior mean is 0.961 × 1 + 0.039 × (−1) = 0.922. Same number. The device above shows this: move the noisy point and watch its estimate jump to the nearest training point when σ is small.

How do you pick σ? The lecture calls it a modeling choice, and the toy shows why. Too small, and the model spikes: the fresh score is −14.6 at σ = 0.05 and falls far lower below that. Too large, and the picture blurs: the two clumps merge and both scores sink to about −1.8 at σ = 2. In this toy the fresh score peaks near σ = 0.4, at −1.11. A real model has no such clean curve, so the lecture’s advice is to choose the resolution for the task: a world model for control does not need hair-width detail, but it must keep the detail that decides the outcome.

There is one more honest point. A likelihood fitted to noisy data is exact for the noisy variable, not for the clean one. The lecture says the same about video: exact density applies before the denoising correction. So the number you read from a flow is the score at the chosen resolution, and it should be compared only with scores at the same resolution.

A flow is a good fit for this recipe because its score is exact: the log-density is an explicit formula, so its gradient is one backward pass, not an approximation. We return to this in Chapter 7. The lecture also stresses that the representation and the noise scale remain modeling choices, to be tuned for the task.

A flow’s training log-likelihood keeps rising as it puts narrower and narrower peaks on its training points. What does the lecture recommend?

Chapter 7

Put a Transformer Inside the Flow

Follow the path from a causal Transformer flow on pixels to STARFlow on codec latents, and read the image scores that justify each step

Suppose you try to build a flow for pictures with what we have so far. Pictures hold tens of thousands of numbers, with rich links between far-apart pixels. The coupling layers of Chapter 3 can use any conditioner, but older flows used small convolutional ones, and they fell behind other image generators. The lecture states the tension in two words. Capacity: the model must capture rich dependencies in high-dimensional visual data. Structure: the map must stay invertible with a tractable log-determinant. The challenge is an architecture that scales while providing both.

TARFlow: a causal Transformer predicts the affine parameters

TARFlow (Zhai, Zhang, Nakkiran, Berthelot, Gu et al., ICML 2025) revisits the design with the strongest sequence model we have. Cut the image into small squares called patches and treat each patch as one token, so the image becomes a sequence of T tokens with C numbers each. Then use the autoregressive flow of Chapter 5. A causal Transformer, a Transformer whose attention is masked so that each token sees only earlier ones, reads the patches before patch i and writes (μi, si) for patch i. Then zi = (xi − μi) e−si, exactly as before. The data flow is T tokens in, T tokens out, and one scalar volume charge per token.

One block is not enough, so TARFlow stacks several. Between blocks, the order of the tokens is permuted, so later blocks see the image in a different order. That is the alternating-orders idea behind Proposition 1 of Chapter 5. TARFlow also uses the noise trick of Chapter 6: train on noisy images, then denoise with the model’s own score.

STARFlow: a flow whose last block is a language model of numbers

STARFlow (Gu et al., NeurIPS 2025) makes two moves. First, it models codec latents and not pixels. A codec is a pretrained autoencoder that squeezes an image into a smaller grid of numbers and can decode it back. The flow models those latents, and the decoder turns samples into pictures. Second, it splits the stack into shallow blocks and one deep block. The slide gives two equivalent views of the same model.

In the first view the whole flow is one map from latents x to a fixed Gaussian z. In the second view, the shallow blocks fS map x to an intermediate u, and the deep block defines a learned autoregressive prior over u. The lecture writes pθ(x) = π0(z) |det Jf| = pAR(u) |det JfS(x)|. Scoring goes x to u to z. Sampling goes z to u to x.

ℒNLL
The training loss: the negative log-likelihood of the latents, exact.
Σi log pAR(…)
Fit predictable conditionals. The deep block learns what ui looks like given the earlier u.
log | det JfS |
Correct for tokenizer volume. The shallow blocks change the coordinates, and they must pay for it.
N(μi, diag σi2)
The next-Gaussian prediction: the deep block outputs a mean and a spread for the next token, like a language model, but for numbers.

This gives a useful way to read the model. The shallow blocks are an invertible tokenizer: reversible continuous tokenization, without quantization. The deep block is a next-Gaussian predictor. The model learns the coordinates and their conditional density together, and the volume term is what keeps those two jobs honest.

A picture of the shapes, with illustrative numbers that are ours and not the paper’s setting. Cut a 256 × 256 colour image into 8 × 8 patches. That gives (256 / 8)2 = 1,024 tokens of 8 × 8 × 3 = 192 numbers each. A TARFlow block takes a 1,024 × 192 grid in, and a causal Transformer writes a shift and a log-scale for every number, two grids of 1,024 × 192, using only the earlier tokens. Out comes z, the same shape, plus one volume charge per token. A deep and shallow design keeps that shape through every block; STARFlow changes what the first grid holds, from pixels to codec latents.

Trace the three designs

Choose a design. The top row is its pipeline; a dot travels along it. The bars compare the three reported scores, where lower is better.

Numbers are the lecture’s ImageNet 256×256 results, FID-50K (lower is better): TARFlow on pixels 5.56 at 1.3B parameters, deep and shallow on pixels 4.69 at 1.4B, STARFlow on latents 2.40 at 1.4B. These are class-conditioned models; the slide adds a 3.8B text-conditioned model. The boxes are a schematic, not a layer count.

Read the bars. Adding a deep and shallow split on pixels cuts the score from 5.56 to 4.69, 16% lower at about the same size. Moving to codec latents cuts it to 2.40, a further 49% below that. FID compares the statistics of generated pictures with real ones, so lower means closer. The size stays near 1.4B, so the gain comes from the design. The table shows what happened; it does not prove which part caused it, and the lecture does not claim it does.

Be careful about what the bars control. The three models differ in size by about 8%, but also in design, input space and training run, and the table is one dataset at one resolution. So read it as strong evidence that the combined design works, not as a clean test of each piece. That is why the lecture lists the exact sections (§§2.1 to 2.3 and 4 of TARFlow, §3.2 of STARFlow) behind each claim.

The cost from Chapter 5 is still there. Sampling runs the deep autoregressive block token by token. The lecture raises this itself in its closing questions, and Chapter 10 returns to it.

In STARFlow, what do the shallow invertible blocks fS do, and what must be added to the loss because of them?

Chapter 8

From One Picture to Video, Scale and Words

Extend the density from an image to the next frame, read the honest video scores, and use the scaling law to price more compute

A world model does not paint one picture. It tells you what the next moment looks like, given what you have seen. In the lecture’s terms, the image density pθ(x), a rich distribution over pictures, becomes the next-frame density pθ(xt | x<t), a rich distribution conditioned on the observed past. The slide asks the model to predict how the scene can evolve over time. Actions join the condition in Chapter 9.

STARFlow-V: local transforms, global autoregression

STARFlow-V (Gu et al., CVPR 2026) keeps the same density decomposition as Chapter 7 and applies it to video. Codec latents x go through local shallow flows, with attention restricted to each frame, so that frames are cleaned up one at a time. The result u then goes to a global autoregressive prior, which reads past frames and the earlier tokens inside the current frame. The formula keeps its shape: pθ(x) = pglobal AR(u) |det Jflocal(x)|. The lecture adds a caution: videos also use a learned causal denoiser, and the exact density applies before that correction.

One architecture serves three tasks. For text-to-video, you sample a video from a prompt. For image-to-video, you encode a frame and continue it. For video-to-video editing, you give an input clip and get an edited one, using a fine-tuned checkpoint.

Read the evidence as it is

The lecture reports VBench text-to-video results (VBench is a standard scoring suite for generated video, where higher is better) and marks each model by whether it generates causally, that is, strictly in time order:

ModelTotalCausalFamily
Wan2.183.69NoDiffusion
CogVideoX80.91NoDiffusion
STARFlow-V78.67YesNormalizing flow
STARFlow-V with a GPT prompt rewriter79.70YesNormalizing flow

Do the arithmetic honestly. STARFlow-V trails Wan2.1 by 5.02 points and CogVideoX by 2.24; the rewriter closes the CogVideoX gap to 1.21. The slide’s own words are: a causal flow generates competitive videos, quality still has room to improve. It also warns that model sizes and training budgets differ, so the table is not a fair race. The causal column matters for world models: a causal model can roll forward in time as actions arrive, and a model that sees the whole clip at once cannot.

How much does more compute buy?

The newest result is a scaling study over models from 0.11B to 8.26B parameters, with compute counted in model FLOPs and the frozen encoder left out. Two smooth laws appear. More compute lowers the held-out negative log-likelihood. And the best model size grows as a power of compute: Nopt ∝ C0.64 to 0.65. Held-out NLL above a floor falls as (L − 0.503) ∝ C−0.065.

Nopt ∝ C0.64–0.65
The compute-optimal parameter count grows a bit faster than the square root of compute. N is parameters, C is model FLOPs.
(L − 0.503) ∝ C−0.065
The held-out loss above a floor of 0.503, at the best size for each budget. The exponent is small, so gains are slow.

Put numbers on it. Ten times the compute asks for a model 100.645 = 4.4 times larger, and cuts the loss above the floor to 10−0.065 = 86% of its old value. One hundred times the compute: 19.5 times larger, and 74% of the old gap. Play with it:

Price more compute

Drag the compute multiplier. The warm line is the best model size, and the blue line is the loss above the floor, both relative to today’s budget. Choose which end of the reported exponent range to use.

100

Relative values only: the lecture gives the exponents and the 0.503 floor, not the starting size or loss, so every curve starts at 1.0 at today’s budget. Slopes are the slide’s fits; the extrapolation beyond the measured 0.11B to 8.26B range is arithmetic, not a measurement.

Look at the blue line. It falls slowly: to halve the loss above the floor you would need about 43,000 times the compute. Smooth is good news, because you can plan. Slow is the other half of the news.

STARFlow2: one stream for text and pictures

STARFlow2 (Shen et al., NeurIPS 2026) joins a frozen vision-language model (VLM, a model that reads text and images, kept fixed) with a trainable TARFlow. Cross-stream connections align the two, and both share one latent space for visual tokens, with token-wise visual decoding. The loss is a plain sum: L = LNF + LNTP, where NTP is next-token prediction on text. Both terms are log-likelihoods, which is the single likelihood principle of Chapter 2 at work. Compare Transfusion in Chapter 1, which needed two different kinds of loss and two loops.

The slides show what this buys: text to image (a tiny astronaut in a garden of glowing mushrooms), image to text (“How many dogs are there in the image?” answered “There are two dogs in the image”), instruction editing (three separate edits of one input: add a tiny captain’s hat, add a tropical island, remove the sunglasses), and interleaved visual thinking. In that last case, asked how many cat-shaped figurines remain after removing the yellow one on the far right, the model writes thinking text, generates an image inside its thinking, and answers 6.

The slide titled “The TARFlow family” groups all of it, images, video and interleaved multimodal generation, and sends readers to the project site starflow-v.github.io. Then it asks the question the rest of the lecture answers: can likelihood-based prediction improve decisions?

Using (L − 0.503) ∝ C−0.065, what happens to the loss above the floor when compute grows by 10×?

Chapter 9

Predict, Plan and Play

Turn an exact-likelihood flow into a planner: encode, roll out futures, score them, and see why the geometry of the latent space decides success

In Flappy Bird, one tap makes the bird jump and nothing taps back. A player who looks ahead imagines the next few moments: if I flap now and coast twice, I clear the pipe; if I coast now, I fall short. The lecture’s closing section builds that player. It is called NFWM, a normalizing flow world model, and the slides label it ongoing work. We follow the order of the slides: predict, plan, then play.

Add the action to the condition

Chapter 8’s video model answers “what happens next?”, p(xt+1 | x≤t). A controller needs a sharper question: what happens if I take this action? So the action joins the condition, p(xt+1 | x≤t, a≤t), and candidate actions can be compared by their predicted consequences. That is Chapter 0’s formula, now with a flow behind it.

The model: an invertible encoder and Gaussian dynamics

NFWM has two parts. An invertible encoder Eθ turns an observation into a latent state: zt = Eθ(xt), and xt = Eθ−1(zt) gets it back. The conditional dynamics predict the next latent from the history and the action as a Gaussian with a mean and a spread, pθ(zt+1 | z≤t, a≤t) = N(μt+1, diag σt+12).

ℒNLL
The training loss. The encoder and the dynamics train together.
log pθ(…)
How likely the real next latent is under the dynamics Gaussian.
log | det JEθ |
The volume correction of the encoder, the same term as Chapters 2 to 4.

This is the STARFlow loss of Chapter 7 with an action in the condition. The volume term keeps the encoder from cheating: it cannot shrink every observation to one point to make the dynamics look easy.

Plan with the cross-entropy method

The control recipe on the slide is plain. Learn the world model. Freeze it. Learn a small reward readout r̂ψ that scores a latent. Then plan: choose the action sequence at:t+H−1 with the highest expected sum of rewards over H imagined steps. Searching is done with the cross-entropy method (CEM), a simple loop with three boxes:

  1. Sample. Draw many action sequences from a distribution, such as flap, coast, coast.
  2. Predict and score. Roll each one through the frozen model and the reward readout, and total the imagined rewards.
  3. Keep elites and refit. Keep the best few sequences, and shift the distribution toward them.

A small invented example, to see the arithmetic. Draw six sequences of three steps, where 1 is flap and 0 is coast. Their imagined returns are: 100 gives −4.0, 110 gives −2.5, 010 gives −5.5, 000 gives −9.0, 101 gives −3.0, 011 gives −6.0. Keep the best two: 110 and 101. Among those two, step 1 was flap both times, step 2 flap once, step 3 flap once. So the new flap chances are (1.0, 0.5, 0.5), up from (0.5, 0.5, 0.5). Repeat, then execute only the first action, take the next real observation, and plan again. This outer loop is model predictive control, which Lecture 9 covered.

Plan by imagining

A bird must pass gaps (green dashes) over the next six steps. Press Run one CEM iteration a few times: watch the trajectories pull toward the gaps and the flap chances move. Then press Execute first action.

Toy: the “world model” here is hand-written physics for a bird (flap sets the speed to +2.0, coasting loses 0.6), and the reward is minus the distance to each gap, so no network is trained. In NFWM the frozen flow and a learned reward readout play this part. 48 sequences per iteration, 8 elites, random each run.

After one or two iterations the elites hug the gaps, and the flap chance at the first step moves from 0.50 toward 0 or 1. That is the whole planner. The model supplies imagined futures; CEM only searches. The slide puts it in one line: the planner searches actions, and the representation supplies the cost.

The representation supplies the cost

That last point decides everything. The cost compares latents, so the latent space must be shaped so that distance means progress. The lecture says it directly: recovering an observation does not define distance to a goal. A latent can be perfectly invertible and still put a state one push from the goal far away.

NFWM adds an inverse dynamics head. Given two neighbouring latents (zt, zt+1), it predicts the action embedding that caused the step. The loss is Linv = ‖êat − sg(eat)‖2, with sg meaning stop-gradient, and the total is L = LNLL + λinv Linv. The training signal shapes the encoder so that action-induced changes become easy to read. Planning to a goal then uses distance to the encoded goal: a* = argmin ‖μt+H(a) − Eθ(xg)‖2.

The ablation on Push-T (a task of pushing a T-shaped block to a target pose) shows how much each term matters. Both matter a great deal:

ObjectivePush-T planning successWhat was removed
Full objective86%nothing
Without inverse dynamics34%the geometry shaping, Linv
Without NLL28%the density learning, LNLL

Density learning and geometry shaping each add about 50 points. The lecture notes that the PCA picture of the latent paths is illustrative; the planning success is the real test of whether the geometry is useful. The same frozen model also serves three uses. Goal planning with CEM scores an average of 84.5% on four deterministic tasks, including Push-T. Action ranking compares candidate outcomes, tested on LIBERO. Policy learning in imagination updates a policy on model rollouts, tested on Atari Boxing.

NFWM without its inverse dynamics term drops from 86% to 34% planning success on Push-T. What does that show?

Chapter 10

Many Futures, and What Is Still Open

See why one predicted future is not enough, read the early NFWM evidence with its limits, and list the questions the lecture leaves open

Picture a toy version of the lecture’s task. You push a puck down a track. At the end of the track a hidden switch, set after your push, sends it to the upper exit or the lower exit. You see the same history and make the same push, and the future still differs. The lecture calls this task Teleport: identical context, different futures. The hidden branch is chosen after the action sequence is fixed.

One point cannot be two places

A predictor trained with mean squared error (MSE, the loss that punishes the squared distance to the truth) learns the average of the two exits. The average sits halfway between them, on the wall, where the puck never goes. The slide says it: one point prediction cannot represent both outcomes, and an MSE predictor may average them.

A flow does not predict a point. It predicts a distribution, and each sample is one possible future. The lecture’s recipe: start with a Gaussian in learned coordinates, then apply the nonlinear inverse map, and the observed futures become richer. A bell shape pushed through the right bend becomes two humps. Try it with the bend as the knob:

Average or branch

The puck can end in the upper or the lower band (green frames). Choose a predictor, then draw 50 futures. For the flow, turn the bend up and watch the samples split into two groups.

3.0

Toy mechanism only. The samples are x = tanh(k z) with z drawn from a standard Gaussian, a one-dimensional invertible map with slope k at the centre. A sample is valid if it lands within 0.3 of an exit at +1 or −1. The lecture’s real result is different: for NFWM on the Teleport task, 22 of 50 samples were assigned to a valid branch, and it calls that fidelity limited.

At k = 0.4 the samples bunch near the middle and almost none are valid, much like the point predictor. At k = 3 about three quarters land on an exit, split between the two. That is the whole point of a bent inverse: a plain bell has one hump, and the bend turns it into two. The lecture’s baselines (LeWM and SMWM, latent world models) do not produce the two branches as cleanly. Its honest summary of NFWM is that fidelity remains limited.

Use the futures

Imagined futures have two uses in the lecture. First, ranking. Take 50 candidate action sequences, predict each outcome with the frozen NFWM, and rank them by distance to the goal. The task: place the mug on the plate. In the slide’s example the five best ranks had predicted distances 32.81, 35.42, 40.04, 44.98 and 48.29, and the real outcomes were failure, failure, success, failure, success. The ranking is useful, not perfect. The slide reports a top-1 score of 36.0% for NFWM, against 26.04% for a random pick from the same candidate pool. It does not define the metric further, so read it as a ranking quality score, not as a success rate.

Second, training a policy in imagination: let a frozen NFWM roll out futures, and update the policy on those rollouts. The lecture reports improvement in all three seeds on Atari Boxing, with a return of 77.37 ± 9.28 (mean ± standard deviation). It also tracks distribution drift, how far imagined states stray from real ones as rollouts lengthen. Three seeds is a small test, and the lecture marks the work as ongoing.

What changes when the encoder is invertible

Lecture 6 and our JEPA lesson describe the main rival. A JEPA-style model predicts a learned target, and recovering the input is not required. NFWM predicts a conditional density, and the input stays recoverable. The lecture’s guidance: keep details recoverable, and learn coordinates that simplify prediction. Reward and goal readouts then pick which details matter for the task.

A side experiment in Flappy Bird shows why this might matter. A frozen readout predicts the chance that the bird dies on the next step, just before a collision. All three models detect it in a real frame. After six imagined steps, only one still does:

World modelReal frame6-step imagined rolloutPassed the first pipe
NFWM0.990.9710 of 10
MSE + SIGReg, invertible encoder1.000.071 of 10
MSE + SIGReg, ViT encoder1.000.050 of 10

Read it like a detective. The symptom: two models fly into the pipe. The measurement: the death signal is 1.00 in a real frame and falls to 0.07 and 0.05 after imagination, so the rollout lost the detail. The slide shows the gap and does not name a cause. One natural reading, ours and not the slide’s, is the averaging of Teleport: a regression loss pulls a rare, critical detail toward the mean, and a density model can keep it. This is one side experiment, and the lecture labels it that way.

Where it connects, and what is open

The lecture then widens the view. STARFlow2 already connects continuous image tokens to a language model. The proposed direction is NFWM with language, with continuous predictive tokens for action-conditioned latent futures. The shared principle is conditional likelihood with the continuous volume correction. The lecture also lists the variables a model may predict: a video model maps past video to future video; an action-conditioned world model maps past video plus actions to future video; a world-action model (conceptual) maps past video to actions plus future video. The advice is to state clearly what is conditioned on and what is predicted.

One further use is NF-CoT (Tu et al., 2026, ongoing): continuous thoughts. A prompt q goes into one causal backbone, which writes thoughts u1 to uk through a Gaussian head, p(ui | q, u<i) = N(μi, diag σi2), and then answer tokens x through a categorical head. The thoughts are learned from text rationales, and the answers stay text.

Then come the questions. The lecture’s verdict slide has three columns: useful structure (exact likelihood, invertible coordinates), current evidence (generation and simulated planning), and open questions (scaling, latency and calibration; closed-loop decision quality). Its answer: promising candidates, with important empirical questions still open. Four discussion slides sharpen them:

  1. Where should the computation go? A STARFlow-style flow has an explicit inverse and samples token by token. A flow trained by flow matching integrates a learned vector field. At the same budget, which predicts and decides better?
  2. Flows in a JEPA space. Let JEPA learn the representation and a conditional flow model its possible futures. Planning still depends on what the encoder preserves.
  3. What do probabilities buy an agent? Event risk adds up probability across futures. Is it calibrated, and does it improve decisions?
  4. How do we test world understanding? The lecture’s own Video-Index finds that 96% of full-video accuracy is retained after frame shuffling, as a median over 51 benchmarks with temporal probes, so many video scores do not need video. InteractionBench asks whether a streaming assistant answers at the right time, and tests content, timing and silence for the whole system.

The final two slides place all this in an agent. The first adds a callable world model to an LLM-centered agent: the agent proposes candidate actions, the world model returns possible consequences, and the execution harness runs the chosen one in the real environment. The question is whether better predictions improve the decisions of an existing agent. The slide says this is a future direction, not a claim about GPT-6 Astra’s internals. The second is an architecture hypothesis: the LLM is the human-language interface, carrying goals in and explanations out, and a predictive core of fast memory, a world model and planning does the acting. Interaction updates state and memory; learning from accumulated experience is a separate process. That closes the loop from Chapter 0: expect, act, check.

In the Flappy Bird side experiment, two models flag the death signal at 1.00 in a real frame but at 0.07 and 0.05 after six imagined steps. What is the most direct reading?

Chapter 11

The Whole Lecture on One Page

Review the numbers and terms, run the checklist, read the core code, and pick the next lesson

You can now rebuild the special topic lecture from memory. An agent that acts needs to expect what happens next (Chapter 0). Continuous signals need a density, not a vocabulary, and diffusion and flow matching are the popular route (Chapter 1). A normalizing flow gives that density exactly, by the change of variables (Chapter 2). The coupling layer makes the map easy to invert (Chapter 3) and its volume term a sum (Chapter 4). Stacks and autoregression give power at the price of slow sampling (Chapter 5). Noise sets the resolution (Chapter 6). TARFlow and STARFlow scale this up for images (Chapter 7), and STARFlow-V and STARFlow2 for video and text (Chapter 8). NFWM turns it into a planner (Chapter 9), and the open questions remain (Chapter 10).

One paragraph

A normalizing flow is an invertible map z = fθ(x) from data to a simple Gaussian. It scores data exactly, by log p(x) = log p0(z) + log|det J|, and samples by running the map backwards. Coupling and autoregressive layers keep the log-determinant to a sum of log-scales. To model continuous video and actions we fit the density at a chosen noise resolution, then plan by searching action sequences with imagined rollouts, using distances in a shaped latent space as the cost.

The numbers that matter

WhatNumberWhy it matters
Coupling layer log-determinant−Σj∈B sj(xA)Cost D, not D cubed
Worked layer, x = (0.8, 1.5)zB = 0.8187, −log p = 2.6930Scoring and sampling are exact inverses
ImageNet 256² FID-50KTARFlow 5.56, deep and shallow 4.69, STARFlow 2.40Latents and a deep block pay off at about 1.4B parameters
VBench text-to-video totalSTARFlow-V 78.67 (79.70 with rewriter); Wan2.1 83.69; CogVideoX 80.91A causal flow is competitive, not ahead
Scaling, 0.11B to 8.26B parametersNopt ∝ C0.64–0.65; (L − 0.503) ∝ C−0.06510× compute: 4.4× model, 86% of the loss gap
Push-T planning success86% full; 34% without inverse dynamics; 28% without NLLDensity and geometry both matter
NFWM goal planning84.5% average on four deterministic tasksCEM over a frozen flow works in simulation
Teleport branches22 of 50 samples on a valid branchFidelity remains limited
Action ranking, top 1NFWM 36.0% vs random 26.04%Useful, far from perfect
Policy in imagination77.37 ± 9.28, better in 3 of 3 seedsEarly and small
Death signal after 6 imagined stepsNFWM 0.97; MSE + SIGReg 0.07 and 0.05Rare details can vanish in rollouts
Video-Index96% retained after frame shuffling (median, 51 benchmarks)Many video scores do not need video

The terms

TermPlain meaning
Invertible mapA function you can undo exactly; input and output have the same size.
Base densityThe simple distribution, a Gaussian, that the data are mapped to.
Volume correctionlog|det J|: how much the map stretches space, added to the score.
ConditionerA network that reads the copied block and writes a shift and a log-scale.
Autoregressive flowEach coordinate is shifted and scaled using the earlier ones; fast to train, slow to sample.
Modeling resolutionThe noise size σ that sets how fine a detail the density may fit.
Tweedie estimatex + σ² × score: the clean guess for a noisy point.
Deep and shallow blocksSTARFlow splits a tokenizer-like shallow stack from one deep autoregressive prior.
CEMCross-entropy method: sample, score, keep elites, refit, repeat.
Inverse dynamics headPredicts the action from two neighbouring latents, to shape the geometry.

Check yourself

The core as code

pythonimport torch, torch.nn as nn, math
class Coupling(nn.Module):
    def __init__(self, D):
        super().__init__(); self.d = D // 2
        self.h = nn.Sequential(nn.Linear(self.d, 128), nn.ReLU(), nn.Linear(128, 2 * self.d))
    def _ms(self, a):
        mu, s = self.h(a).chunk(2, dim=1)            # (B, d) each
        return mu, 3 * torch.tanh(s / 3)             # bound the log-scale
    def forward(self, x):
        xa, xb = x[:, :self.d], x[:, self.d:]      # (B, d) each
        mu, s = self._ms(xa)                         # the conditioner reads only xa
        zb = (xb - mu) * torch.exp(-s)
        return torch.cat([xa, zb], 1), -s.sum(1)     # z (B, D) and log|det J| (B,)
    def inverse(self, z):
        za, zb = z[:, :self.d], z[:, self.d:]
        mu, s = self._ms(za)
        return torch.cat([za, mu + torch.exp(s) * zb], 1)
class Flow(nn.Module):
    def __init__(self, D, L=4):
        super().__init__(); self.D = D; self.layers = nn.ModuleList(Coupling(D) for _ in range(L))
    def forward(self, x):
        ld = 0
        for layer in self.layers:
            x, l = layer(x); ld = ld + l; x = x.flip(1)   # swap the halves
        return x, ld
    def log_prob(self, x):
        z, ld = self(x)
        return -0.5 * (z ** 2).sum(1) - 0.5 * self.D * math.log(2 * math.pi) + ld
    @torch.no_grad()
    def sample(self, n):
        z = torch.randn(n, self.D)
        for layer in reversed(self.layers):
            z = layer.inverse(z.flip(1))   # undo the layers last to first
        return z
def denoise(flow, x, sigma):                         # Chapter 6, one score correction
    x = x.clone().requires_grad_(True)
    score = torch.autograd.grad(flow.log_prob(x).sum(), x)[0]
    return (x + sigma ** 2 * score).detach()
def cem_plan(model, reward, z0, H=6, n=48, k=8, iters=3, A=2):
    p = torch.full((H, A), 1.0 / A)               # flap chance per step, (H, A)
    for _ in range(iters):
        acts = torch.multinomial(p, n, replacement=True).T
        ret = rollout_return(model, reward, z0, acts)
        elite = acts[ret.topk(k).indices]
        p = torch.stack([(elite == a).float().mean(0) for a in range(A)], 1).clamp(0.04, 0.96)
        p = p / p.sum(1, keepdim=True)
    return p[0].argmax()                          # execute only the first action
def rollout_return(model, reward, z0, acts):
    z = z0.expand(len(acts), -1); total = 0
    for t in range(acts.shape[1]):
        z = model.step(z, acts[:, t]); total = total + reward(z)
    return total

# training: x is a batch of real data (B, D); add noise at the chosen resolution (Chapter 6)
loss = -flow.log_prob(x + 0.05 * torch.randn_like(x)).mean()

This is a small teaching sketch. We checked its shapes, its forward and inverse round trip (the error is about 2 × 10−7 in 32-bit numbers) and its log-determinant against an automatic Jacobian on random data, not on a benchmark. It needs model.step and reward from a trained world model to run the planner.

Keep going

Earlier in this series: Lecture 11, Dreamer, Diffusion and Flow Matching for the denoising route, Lecture 13 and Lecture 14 for video world models, Lecture 9 for CEM and model predictive control, and Lecture 6 with our JEPA lesson for the learned-feature rival. For the maths, see Jacobians and Linearization and Flow Matching.

Papers behind the slides: Real NVP, MAF, Normalizing Flows for Probabilistic Modeling and Inference, Flow++, TARFlow, Flow Matching, Transfusion, RAP, TD-MPC2, and the STARFlow family at starflow-v.github.io.

The takeaway. A normalizing flow trades some freedom for an exact answer: every layer must be undoable and cheap to measure, and in return you get a true likelihood and a sampler from one model. The lecture asks whether that trade suits world models. The evidence so far is generation and simulated planning; the decisions that matter, in closed loop, are still to be shown.

Now press Teach and explain one coupling layer on the whiteboard from memory: the split, the shift and scale, the zero block, and the sum of log-scales. Then go back to the flow at the top, set it to 1 layer and to 4, and say aloud where each volume correction comes from.

Credit. This lesson re-teaches the special topic lecture “Are Normalizing Flows Good Candidates for World Models?” by Jiatao Gu (University of Pennsylvania, AMI Labs), given in CIS 6280: World Models, Fall 2026. Slides: the lecture PDF. The results quoted are the lecture’s and its cited papers’, from the slides; NFWM, NF-CoT and the recent scaling results are marked there as ongoing work. All devices, wording and examples here are our own, and the toy numbers in them are illustrative.

CIS 6280 Special Topic: Normalizing Flows for World Models
The course site · Lecture slides · Back to Gleams