Diffusion Controller

You ask an image model for a lizard in sunglasses, and the picture is flat. You want the version people would pick, without ruining what the model knows. The paper treats this as control, and a 12 million parameter side network wins 69.6% of preference duels against Stable Diffusion v1.4 under PPO.

Slide the control cost τ down. The curve moves toward higher reward, and the drift read-out shows how far it left the pretrained curve. Then we build, piece by piece, why that trade is exact and how to learn it.

You need a rough idea of a probability distribution and what a neural network is. We teach diffusion, control and reward learning from zero.

Based on Diffusion Controller: Framework, Algorithms and Parameterization (arXiv 2603.06981, March 2026) by Tong Yang, Moonkyung Ryu, Chih-Wei Hsu, Guy Tennenholtz, Yuejie Chi, Craig Boutilier and Bo Dai, at Carnegie Mellon, Google Research, Yale and Google DeepMind. Every idea is re-taught here in our own words and devices.

Steer the model

Ready
0.95

A one-dimensional toy, not an image model: the pretrained distribution is two made-up bumps, the reward is r(x) = x, and the controlled curve is the paper's optimal form, the pretrained density times a weight (exp(r/τ) for KL, a clipped line for α = 2), computed numerically in your browser. Drift is the KL divergence from the pretrained curve, in nats. The paper itself works on Stable Diffusion v1.4 images.

Chapter 0

Why Steering a Painter Is Hard

See why pushing a pretrained image model toward what you want costs quality, and why that trade needs one clear rule

Picture a painter who can draw anything you describe. You type “a lizard wearing sunglasses” and a picture appears. It is fine, but it is flat. You want the kind of picture people pick when they compare two. How do you make the painter do that without ruining what it already knows?

The painter is a diffusion model: a network that makes an image by starting from pure noise and cleaning it up in many small steps (Chapter 1 builds one from zero). It is pretrained, which means it already learned from a huge set of pictures. The paper in this lesson uses Stable Diffusion v1.4 as that painter.

Three ways to steer, and no common rule

People steer a pretrained painter in three main ways. The first happens while the picture is made. Guidance adds a second prediction at every step and nudges the picture toward the prompt. You change nothing in the model.

The second happens before. You train a small add-on. LoRA adds a few small weight matrices inside the model and trains only those. ControlNet trains a side copy of part of the network that feeds hints into the painter. The painter itself stays put.

The third uses a score. A reward model is a second network that looks at a picture and gives it a number for how much people like it. The paper uses HPS-v2, a model trained on human preference choices. Reinforcement learning fine-tuning (RLFT) changes the painter so its pictures earn higher scores.

Each method works. But the authors say they look like a patchwork. Each one has its own objective and its own tricks, and nothing links them. When something fails, you cannot say why.

The price of a push

All three share one hidden cost. The harder you push, the further the painter moves from what it learned. Far from what it learned, it makes strange pictures. The paper says it plainly: stronger steering needs a bigger departure from the pretrained model, and that can hurt sample quality.

You can feel this in a toy. Each dot below is one possible picture, drawn as a point on a plane. The ring marks the region that holds 95% of what the pretrained model makes. The yellow ramp is a reward that grows to the right. Push the whole cloud to the right and count what stays inside the ring.

Push the cloud

Drag the push strength. Dots turn red when they leave the ring, the region the pretrained model finds plausible.

0.00

Illustrative toy: 300 seeded points from a two-dimensional bell curve, the ring holds 95% of that curve, and the reward is the x position. A real image has millions of numbers, not two. The straight push is the crudest possible steering; the rest of this lesson finds the best one for a given price.

At push 0 the cloud sits in the ring and the average reward is near zero. Push by 1.5 and the reward rises by 1.5, yet a clear share of dots has left the ring. Push by 3 and most have left. Reward went up and quality went down. Every steering method pays this bill, whether it says so or not.

What this paper offers

The paper, Diffusion Controller: Framework, Algorithms and Parameterization, makes the bill explicit. It treats the cleaning-up steps as a process you can control, in the sense of control theory: you choose how each step moves, and you pay a cost for leaving the pretrained choice. Then the best push for any price can be worked out exactly.

Three results follow from that one view. The framework (Chapters 2 and 3) says what the best steered model looks like. The algorithms (Chapters 4 and 5) turn that answer into training rules: a PPO-style rule and a reward-weighted loss. The parameterization (Chapters 6 and 7) says how to build the steered model: keep the pretrained score and add a small correction from a side network.

That last point matters when you cannot open the painter. In the white-box setting you may change the backbone, for example with LoRA. In the gray-box setting the backbone is sealed, and you may only call it and read what it outputs at each step. This is like an API. The paper’s side network works in the gray-box setting, and it still beats LoRA in two of three training recipes (Chapter 9).

The road

  1. Diffusion as a chain: noise in, picture out, and the two equations we need.
  2. Denoising as control: tilt each step, and pay for the tilt.
  3. The best control: solve it backward, and see the best picture distribution.
  4. Reward-weighted loss: turn the answer into a loss you can train on.
  5. Policy gradient and PPO: the other route, with a soft advantage.
  6. The best score has a shape: pretrained score plus a correction.
  7. The side network: tensor shapes, zero start, and gray-box access.
  8. Three recipes: SFT, reward-weighted loss and PPO as code.
  9. What the results show: Table 1, row by row.
  10. Ablations and limits: what the other metrics say, and what is still open.
  11. Field guide: numbers, code and where to go next.
Why does steering a pretrained model harder usually lower sample quality?

Chapter 1

Diffusion as a Chain of Small Steps

Build a diffusion model from one drop of ink, and learn the two equations the rest of the paper rests on

Drop ink into a glass of water. The ink spreads until the whole glass is one grey cloud. Now play the film backward. The cloud pulls itself back into a single drop. A diffusion model learns to play that film backward, for pictures.

The forward film is easy, because we write it ourselves. We take a clean image and add a little random noise. Then we add a little more, again and again, until only noise is left. The hard part is the reverse film, and that is the part a network learns.

The forward film: noise added in small steps

The paper numbers the steps so that time runs the way a reinforcement learning episode runs. The pure noise image is x1 and the clean image is xT. This is the reverse of most diffusion papers, and it is the first thing to hold in mind. A small step goes from a cleaner image xt+1 to a noisier one xt:

xt
The image at noise level t. A tensor of numbers. For Stable Diffusion it has shape 4 × 64 × 64, a compressed “latent” image.
xt+1
The same image one step cleaner.
√αt
A number a little below 1. It shrinks the old image so the total size stays steady.
√βt
How much fresh noise to add. The variance schedule βt is a list of small numbers between 0 and 1 that we pick in advance.
ξt
The noise itself: a tensor of the same shape, every number drawn from a standard bell curve.
αt
Defined as 1 − βt, the share of the old image that survives one step.

Many small steps collapse into one jump. Multiply the α values from step t up to T−1 and call the product ᾱt (read “alpha bar”). Then xt = √ᾱt xT + √(1 − ᾱt) ξ. Try it with two steps of α = 0.8. Then ᾱ = 0.64, so xt = 0.8 xT + 0.6 ξ. The weights 0.8 and 0.6 square to 0.64 and 0.36, which add to 1. The image fades as the noise grows, and the total size never changes.

The reverse film: what the network learns

To run the film backward you need one thing: at each noisy image, which noise was just added? The network εθ(xt, c, t) answers that. Its inputs are the noisy image, the condition c (the text prompt) and the step t. Its output is a tensor with the same shape as the image. We train it with a plain regression: make a noisy image from a real one, and ask the network to guess the noise we used.

loss = ½ ‖ ξ − εθ(√ᾱt xT + √(1−ᾱt) ξ, c, t) ‖2

The paper calls ε the score function. It points along the direction that makes the image look less like noise and more like data. So a good guess of the noise is also a guide toward cleaner images.

Sampling uses that guide one step at a time. Start from pure noise x1. At each step, the model proposes the mean of a bell curve for the next, cleaner image. Then we draw the next image from it:

xt+1
The next, cleaner image. We draw it at random, so two runs give two pictures.
μ
The mean of the bell curve: the model’s best guess for where the next image sits.
β̃t
The spread of the bell curve, βt(1 − ᾱt+1)/(1 − ᾱt). It is fixed by the schedule. It is not learned.
1/√αt
Undoes the shrink from the forward step.
βt/√(1−ᾱt)
How much of the predicted noise to subtract at this step.

This is the object the rest of the lesson reshapes. One step of the reverse film is one transition kernel: a rule that takes the current image and gives a bell curve over the next one. Hold on to that phrase. The paper steers a diffusion model by editing these kernels.

Run the reverse film

Each line is one image, reduced to a single number. The toy data is just two values, +1 and −1. Press Denoise or drag the step.

1

Illustrative toy with 25 steps and a made-up schedule (β falls from 0.35 to 0.02). With data that is exactly +1 or −1, the best noise guess has a closed form, so this is the real sampler with a perfect network, not a trained one. Images in the paper have 4 × 64 × 64 numbers, not one.

Early in the film the lines tangle in the middle. They are noise, and they have not chosen a side. Late in the film each line has locked onto +1 or −1. The model never decides at one moment. A little of the choice happens at every step. That detail is what makes control possible: every step is a place to push.

Guidance, and the code

For a text prompt, the standard trick is classifier-free guidance. The network is trained with the prompt hidden a small share of the time (the paper uses 10%). At sampling time it runs twice, with and without the prompt, and extrapolates: ε̂ = (1 + λ) ε(x, c, t) − λ ε(x, ∅, t). The paper sets λCFG = 7.5. In code, the whole sampler is short.

def sample(eps, c, beta, abar, lam=7.5):
    x = randn(4, 64, 64)                    # x_1: pure noise
    for t in range(1, T):                   # x_T is the clean image
        e = (1 + lam) * eps(x, c, t) - lam * eps(x, None, t)   # guidance
        mu = (x - beta[t] / sqrt(1 - abar[t]) * e) / sqrt(1 - beta[t])
        var = beta[t] * (1 - abar[t + 1]) / (1 - abar[t])
        x = mu + sqrt(var) * randn_like(x)  # draw x_{t+1}
    return x                                # shape (4, 64, 64)

Stable Diffusion also keeps a text encoder and an image autoencoder (the VAE) around the network. The paper freezes both and trains only the network that makes the noise guess.

In the paper’s indexing, what does one reverse step do, and what does the network supply?

Chapter 2

Denoising as Control

Treat each reverse step as a choice, tilt it toward reward, and pay a price for every tilt

Imagine a hiker crossing a foggy hill. Left alone, the hiker follows a habit: a trail worn by years of walking. At each step the hiker has a spread of places to put a foot, and the habit says which are likely. Now you stand beside the hiker. You can lean on the hiker a little, so likely places shift toward the summit. But the harder you lean, the further the hiker strays from the trail that kept them safe.

The pretrained diffusion model is that hiker. Its habit is the transition kernel from Chapter 1. This chapter sets up the leaning and its price. We build it in four small pieces.

Piece one: the state is the image so far

A Markov chain is a process where the next state depends only on the current one. The reverse film is one. The state is the noisy image xt (with the prompt c and the step t riding along). The next state xt+1 is a random draw from the kernel. Nothing earlier matters.

Earlier papers on reinforcement learning for diffusion, such as DDPO and DPOK, call this a standard Markov decision process (MDP): a world where an agent picks actions. They set the action to be the next image xt+1 and the policy to be the kernel. The paper points out the catch. That “action” is the next state itself. The only real freedom is how the kernel is shaped. So why add an action at all?

Piece two: the controller tilts the kernel

The paper uses a smaller framework, the linearly-solvable MDP (LS-MDP) of Todorov (2006). It has no actions. The controller changes the kernel directly, and the pretrained kernel p0 is the passive dynamics: what the world does when you do nothing. The control u tilts the passive kernel with an exponential:

Pu,t
The controlled kernel: the new bell curve over the next image, after control.
p0,t
The pretrained kernel from Chapter 1. The subscript 0 means “no control”.
exp(u)
The tilt. Where u is positive the kernel gains weight, where u is negative it loses weight. The exponential keeps every weight above zero.

The integral on the right is a rule, not a choice. The new kernel must still add up to 1. So you cannot raise every place at once. If you add weight in one place, you take it from another. Any new kernel that gives weight only where the old one did can be written as such a tilt, so this form loses nothing.

A small case shows the shape. Say the next image is one number, the pretrained step is a bell curve with mean μ and variance β̃, and the tilt is a straight line, u(x) = a x. Multiply the bell curve by ea x. You get a bell curve of the same width whose mean moved to μ + aβ̃. A tilt of strength a pushes the mean by aβ̃. Drag it below.

Tilt one step

Top: the pretrained step (blue) and the tilted step (warm). Bottom: net value against tilt a. Pick a cost τ, then drag a to the top of the curve.

0.50

Illustrative toy with made-up numbers: one step with variance β̃ = 0.5, and a future value that grows one-for-one with the next image, V(x) = x. The mean shift aβ̃ and the KL cost a²β̃/2 are exact for a bell curve tilted by a straight line.

The bottom curve is the whole story of the chapter. A tilt earns reward, because the mean moves toward a bigger future value. A tilt also costs something. The net value rises, peaks, and then falls. Where it peaks depends on the price τ.

Piece three: the price is a divergence

The paper writes the price as a divergence: a number that says how far apart two distributions are, zero when they match. The best known one is the KL divergence, DKL(p ‖ q) = ∫ p log(p/q) dx. The paper allows a whole family, the f-divergences, Df(p ‖ q) = ∫ f(p/q) q dx, where f is a convex function with f(1) = 0. Choose f(s) = s log s and you get KL. Each choice of f penalizes drift in its own way.

Piece four: the value to maximize

At the end of the film we score the finished image with the reward r(xT, c). We want the chain of tilts that scores highest, minus the price paid at every step. Write Vu,t for the value we expect from state xt on, if we use control u:

Vu,t
The value: the total we expect from now to the end, reward minus price, under control u.
rt
The reward at step t. In this paper it is zero until the last step, where it is the score of the finished image (Eq. 11).
E[Vu,t+1]
The average value of the next state, drawn from the controlled kernel.
τ Df
The price. τ ≥ 0 sets how dear drift is. τ = 0 means drift is free, and large τ means stay home.

Run the numbers from the toy with τ = 1. The gain is aβ̃ = 0.5a. The price is τ a²β̃/2 = 0.25a². At a = 1 the net is 0.5 − 0.25 = 0.25. At a = 2 the gain is 1.0, the price is 1.0, and the net is 0. The peak sits at a = 1/τ. This is a small preview of the next chapter: the best tilt is the future value divided by τ.

def tilt(p0, u):
    """p0, u: arrays over a grid of next images. Returns the controlled kernel."""
    w = p0 * np.exp(u)              # tilt the passive kernel
    return w / w.sum()              # the constraint: it must add up to 1

def kl(p, q):
    return np.sum(p * np.log(p / q))

One goal remains. We want the best control u*, and then a diffusion model whose finished images follow it. The paper’s plan has two steps. Chapter 3 finds u*. Chapters 4 and 5 learn an ordinary score ε* whose samples land where u* would put them, using the usual regression of Chapter 1 but with images drawn from the controlled target.

In the paper’s framework, what does the controller choose at each step, and what keeps it from simply chasing reward?

Chapter 3

The Best Control, Solved Backward

Work from the finished image back to the first step, and find that the best steered model is the pretrained one times exp(reward/τ)

You plan a road trip by starting at the destination. First you ask which towns are good places to be one hour from the end. Then which towns are good two hours out, because they lead to good places. You never plan from the front, because the front does not know where the road ends.

The best control works the same way. We start from the finished image, where the reward is known, and move backward through the steps. We use the KL price in this chapter, because it gives a clean answer. Chapter 4 returns to other prices.

Step one: how good is it to be here?

At the last step the answer is simple. The score of the finished image is r(xT, c). We put it on an exponential scale and call it the goodness Z:

ZT(xT, c) = exp( r(xT, c) / τ )

Why exponential? The price in Chapter 2 is a KL, and KL involves a logarithm. A logarithm turns sums of reward into products of goodness. Dividing by τ sets the exchange rate between reward and drift.

One step earlier, the goodness of a state is the average goodness of where the passive step takes you. Use the pretrained kernel p0, not the controlled one:

Zt
The goodness of image xt: how rewarding its future looks, on the exponential scale. Zt = exp(V*t/τ), where V* is the best value from Chapter 2.
Ep0,t
An average over where the pretrained step might land. Passive, because we plan with the habit, not with a tilt.
Zt+1
The goodness of each possible next image, already known because we work backward.

This is the paper’s Bellman recursion (Eqs. 54 and 57), simplified. A Bellman recursion defines the value of a state from the value of the states that follow it. The “linearly solvable” in LS-MDP refers to this. The recursion is a plain average, with no maximum inside it. The hard optimization has been solved by the change to Z.

Step two: tilt each step by the goodness of where it lands

Now the best control follows. The best next-step distribution is the passive one, reweighted by the goodness of each landing place. The division by Zt is exactly the factor that makes it add up to 1, because Zt is the average of Zt+1 under p0:

Pu*,t
The optimal controlled kernel (Eq. 59). The star marks the best control u*.
p0,t
The pretrained step. It is the starting point of every tilt.
Zt+1
Boosts landing places with a good future and shrinks those with a bad one.
Zt
The normalizer. It makes the new kernel add up to 1.

Compare with Chapter 2. There the best tilt in the toy was a = 1/τ, the future value over τ. Here the tilt is exp(u*) = Zt+1/Zt = exp(V*t+1/τ)/Zt. It is the same rule, now exact for every step. Try it on a tree small enough to compute by hand.

Solve a tree backward

Start at the left. Each choice has two even passive branches. Leaves show a reward. Thick lines are the best controlled probabilities, thin grey lines are the passive 50/50. Drag τ.

0.50

Illustrative toy with made-up rewards: leaves A1 = 3, A2 = 0, B1 = 1, B2 = 1, and a passive 50/50 choice at each fork. The goodness values and probabilities are computed exactly with the paper’s recursion (Eqs. 56 to 59).

Slide τ down. At τ = 0.5 almost every run goes to branch A and then to the 3-reward leaf. Slide it up and the controlled probabilities fall back to the passive 50/50, so the average reward falls back to 1.25. Small τ means a cheap price for drift, and the controller drifts a lot.

Step three: the whole chain, and the image distribution

Chain the steps. Each controlled kernel carries a factor Zt+1/Zt. Multiply them across the film and every Z cancels except the first and last. What is left is the paper’s Eq. 60:

Pu*(x1:T)
The chance of a whole film, from noise to image, under the best control.
P0(x1:T)
The chance of the same film under the pretrained model.
exp(r/τ)
One weight for the whole film, set only by the final image’s reward.
Z0(c)
A single number that makes everything add up to 1.

Sum over all the middle images and you get the answer the hero showed: the finished images of the best controlled model follow pu*(xT|c) ∝ p0,T(xT|c) exp(r(xT, c)/τ). The pretrained image distribution is reweighted by exp(reward/τ). That is the entire optimum. It explains KL-regularized reward fine-tuning in one line.

def optimal_kernel(p0, reward, tau):
    """p0[t][s] = dict of next state -> prob. Returns Z and the best kernel."""
    Z = {s: np.exp(reward[s] / tau) for s in leaves}          # Z_T
    for t in reversed(range(T)):                              # work backward
        for s in states[t]:
            Z[s] = sum(p * Z[n] for n, p in p0[s].items())    # Z_t = E[Z_{t+1}]
    return Z, {s: {n: p * Z[n] / Z[s] for n, p in p0[s].items()} for s in Z if s in p0}

Why we cannot just sample from it

You might think we are done: sample from P*, and the job is done. We are not. Zt(xt) is an average over every possible future of xt, and for images that is far too many to enumerate. The kernel P* has an energy-based form. To sample one step you would run an inner loop that estimates Zt+1 for each candidate. The paper avoids that. It learns a normal diffusion model whose finished images follow pu*, and then samples it the usual cheap way. That is the job of the next two chapters.

One honesty point. For a price other than KL, the best whole-film distribution is not generally the same as what the step-by-step LS-MDP gives. The paper notes that these differ for general f, and it still derives a useful loss in that case (Chapter 4). For KL the two agree exactly.

With the KL price, what is the distribution of finished images under the best control?

Chapter 4

The Reward-Weighted Loss

Turn the best distribution into a training loss: study the pretrained model’s own pictures, and let the reward decide how much each one counts

A chef wants to cook what the judges love. There is no list of winning dishes to copy. But the chef can cook a hundred dishes, ask the judges to score them, and then study the recipes again. The high scorers get a lot of attention. The low scorers get almost none. After a while the chef’s habits tilt toward what wins.

That is the whole idea of a reward-weighted loss. This chapter shows why the idea is not just a heuristic here. For the paper’s control problem, a particular weight gives exactly the best model of Chapter 3.

What we want to train

Chapter 3 gave a target: finished images xT that follow p*(xT|c). If we had pictures drawn from p*, training would be the plain regression of Chapter 1. Eq. 10 of the paper writes it down: guess the noise that was added to xT ~ p*. But we have no pictures from p*. We only have the pretrained model and a reward model.

Here is the trick. The target is the pretrained distribution times a weight, p*(x) = p0(x) w(x). So the average of anything under p* is the average of w times that thing under p0. A picture from the pretrained model that counts w times is the same as a picture from p* that counts once. This is importance weighting. We can train on pretrained pictures and multiply each one’s loss by its weight.

Which weight?

The paper derives the weight instead of guessing it. Step back from single steps and look at whole films. Let P be any distribution over films and P0 the pretrained one. Ask for the P that maximizes expected final reward minus the price:

maxP
Search over all distributions of whole films. Eq. 18 of the paper.
EP[r]
The average reward of the finished images under P.
τ Df
The price for P differing from the pretrained film distribution.

Write P = w P0, so w is the weight of each film. The weights must be zero or positive, and they must average to 1 under P0, so that P adds up to 1. The paper adds a multiplier b to enforce that average and sets the slope to zero (the standard calculus rules for optimizing under a constraint, called the KKT conditions). The result:

w*
The best weight of a film: how many times to count a pretrained film.
(f′)−1
The inverse of the slope of f. Each divergence has its own. It maps a scaled reward to a weight.
r − b
The reward minus a baseline b that depends on the prompt. The baseline makes the weights average to 1.
τ
The price. A small τ makes the weights spread out, a large τ makes them flat.

The max with 0 is the key change. A weight cannot be negative. So images with a reward far below the baseline get weight exactly zero for some divergences. Plug in the KL case, f(s) = s log s. Then (f′)−1(y) = exp(y − 1), so w = exp(r/τ) up to a constant. That is the Chapter 3 answer. For an α-divergence the weight is polynomial: wα = [ 1 + ((α−1)/τ)(r − b) ]+1/(α−1).

The loss

Put the weight in front of the regression. This is Theorem 1 of the paper:

Lf
The reward-weighted loss. It has the same minimizer as the original loss on p* (for KL, exactly pu*).
wf
The weight from the last equation, computed from the image’s reward.
ξ − ε(·)
The usual noise-guess error from Chapter 1.

Why does a weight not break the regression? The paper uses a lemma: if you weight a score-matching loss by any positive function of the noisy image, the best score is unchanged. The weights change which pictures matter, and the weighted pictures make a new target distribution. The best noise guess for that target is the score of p*. So the weighted loss has p*’s score as its minimizer.

One caution from the paper. For an f other than KL, the whole-film optimum p̃* generally differs from the stepwise LS-MDP optimum. The weighted loss then trains toward p̃*. The authors call it a meaningful surrogate and show it works in experiments.

Feel the weights

Eight images have reward scores near 0.3, which is the size of a typical preference score. Choose a weighting rule and slide τ. Watch how much weight lands on the best image.

Weigh eight images

Bars show each image’s share of the total training weight. Images are sorted by reward, low to high.

0.0100

Illustrative: eight made-up reward scores (0.262 to 0.318) and a baseline b equal to their mean, 0.290. “Reward itself” is the weight used by earlier reward-weighted methods (Lee et al., Fan et al.). The α rule is the paper’s Eq. 21 with α = 1 + τ, as in its RWL runs. Effective sample size is (∑w)²/∑w².

With the reward itself as the weight, every bar is close to 1/8. Nothing steers. With the exponential or the paper’s polynomial weight at τ = 0.01, one or two images carry most of the weight. The training concentrates on the best pictures. That is control, applied through a loss.

The paper’s own setting is stark. It uses τRWL = 5×10−4 with α = 1 + τ. The exponent 1/(α−1) is then 2,000. The baseline b is the mean reward of the first training batch. A weight that powerful is nearly a hard pick of the best image in each batch. Appendix D reports that a τRWL below 0.0005 broke the weight computation with not-a-number errors. That fits an overflow in a power of 2,000 or more, though the paper does not say so.

def rwl_step(net, prompts, reward_model, tau, b, alpha_m1):
    x = sample(net, prompts)                    # online images from the current model
    r = reward_model(x, prompts)                # one scalar per image
    w = (1 + (alpha_m1 / tau) * (r - b)).clamp(min=0) ** (1 / alpha_m1)   # Eq. 21
    t = randint(1, T)
    xi = randn_like(x)
    xt = sqrt(abar[t]) * x + sqrt(1 - abar[t]) * xi
    loss = 0.5 * (w * ((xi - net(xt, prompts, t)) ** 2).sum(dim=(1, 2, 3))).mean()
    loss.backward(); opt.step()
Why can the paper train on the pretrained model’s own images and still reach the best controlled model?

Chapter 5

Policy Gradient and PPO, with a Price

Credit each denoising step for how much better than expected it made the final image, minus what the step drifted

A coach watches the film of a lost game. The score only appears at the final whistle. Which of the fifty moves caused the loss? The coach cannot know. But the coach can ask one question about each move: was it better or worse than a typical move from that position? Moves that beat the typical one get more practice. Moves that did not get less.

A diffusion model faces the same problem. Only the finished image gets a score, yet there are many steps to credit. This is the second training route in the paper. Chapter 4 learned from finished images. This route learns from the steps themselves, as policy gradient methods do.

The policy is the reverse kernel

A policy is a rule that chooses what to do next. Here the policy is the Gaussian reverse step of Chapter 1, now with parameters θ: pθ,t(xt+1|xt, c) = N(μθ(xt, c, t), β̃t I). The mean μθ comes from the noise network εθ in the same way as before. So θ lives inside the noise network, and the spread β̃t stays fixed. Training moves the means.

To weigh drift, write ζt+1 = pθ,t(xt+1|xt, c) / p0,t(xt+1|xt, c). This is the density ratio: how much more likely the trained step is than the pretrained step, at the point it actually went. With the reward only at the end, unfolding the value from Chapter 2 gives the paper’s Eq. 15:

Vθ,t
The value of being at xt if we keep using the policy θ from here.
r(xT, c)
The score of the finished image. Paid once, at the end.
τ ∑
The price of drift, added up over every remaining step.
f(ζ)/ζ
The per-step drift of the chosen divergence. For KL, f(ζ)/ζ = log ζ, the log of the density ratio.

For KL this reads simply: the value is the final reward minus τ times the total log ratio of all the steps that remain. Think of the ratio as a meter that counts drift in nats, the unit of information that uses the natural logarithm. One nat is about 1.44 bits.

The soft advantage

The advantage of a step answers the coach’s question. It is the value you got after the step, minus the value you expected before it. The paper adds the price of that one step. With KL it is:

Aθ,t+1
The soft advantage of the step from xt to xt+1. The word “soft” means the price is inside it. Its average over the step is zero.
Vt+1
How good the new state is.
τ log ζ
What this step drifted from the pretrained step, in reward units.
Vt
How good the old state was. This is the expectation we compare with.

Take three steps with τ = 1. Say the log ratios are 0.10, 0.30 and −0.05, the final reward is 1.2, and a value estimate gives V0 = 0.80, V1 = 0.90, V2 = 1.10 (all made up). The advantages are:

stepV after− τ log ζ− V beforeadvantage
10.90−0.10−0.800.00
21.10−0.30−0.90−0.10
31.20+0.05−1.10+0.15

The three advantages add to 0.05. That equals the whole return, 1.2 − 0.35 = 0.85, minus the starting value 0.80. Step 2 drifted a lot (0.30 nats) and the future did not pay for it, so it earns a negative score. Step 3 moved back toward the pretrained step and gets a bonus. The price is already counted in each advantage.

Proposition 1 and PPO

The paper proves that the gradient of the expected value is the classic policy-gradient formula with this advantage (Proposition 1):

∇θJ
The direction that raises the expected value J.
∇ log p
The direction that makes this exact step more likely. For a Gaussian step it points toward the chosen xt+1.
A
The soft advantage. It decides whether to push the step up or down, and how hard.

Two known methods drop out as special cases. Set τ = 0 and you get the REINFORCE-style gradient of DDPO. DPOK also uses a KL price, but it counts only the current step’s log ratio at step t. The paper’s Eq. 32 counts the sum of log ratios from step t to the end. The gradients differ in that regularization term.

Raw policy gradient can take a step that is too large and wreck the model. PPO (proximal policy optimization) limits the damage. It looks at the ratio ρ between the new and the old policy at the sampled step, and clips it to the band [1 − δ, 1 + δ]. Eq. 17 of the paper maximizes min( ρ A, clip(ρ, 1−δ, 1+δ) A ). Drag the controls to see where it goes flat.

Clip the update

The warm line is the objective. The shaded band is the clip region. Move the advantage and the ratio.

0.50
0.20
1.10

The curve is the exact formula min(ρA, clip(ρ, 1−δ, 1+δ)A) from the paper’s Eq. 17. The advantage values are illustrative. The paper’s PPO run uses τKL = 1e-4 and does not state δ in the main text, so the slider range is ours.

For a positive advantage, the objective rises with ρ until ρ reaches 1 + δ, then goes flat. The gradient is zero there, so the model gets no reason to move that step further. For a negative advantage the same happens below 1 − δ. PPO keeps each update near the policy that collected the data.

def ppo_loss(net, net_old, net_pre, traj, V, tau, delta):
    loss = 0
    for t in range(T - 1):                              # one term per denoising step
        logp     = log_normal(traj.x[t+1], mu(net,     traj, t), var[t])
        logp_old = log_normal(traj.x[t+1], mu(net_old, traj, t), var[t])
        logp_pre = log_normal(traj.x[t+1], mu(net_pre, traj, t), var[t])
        A = V[t+1] - tau * (logp_old - logp_pre) - V[t]  # soft advantage, KL case
        rho = exp(logp - logp_old)
        loss -= torch.min(rho * A, rho.clamp(1 - delta, 1 + delta) * A)
    return loss
In the paper’s policy gradient, how does the price of drift enter?

Chapter 6

The Best Score Is the Pretrained Score Plus a Correction

Learn what the optimum looks like, so you can build a model that only has to learn the difference

A tailor gets a suit that almost fits. The tailor does not cut new cloth. The tailor adds a tuck at the waist and lets out the sleeve. The tailor can do this because the final suit is the old suit plus two small changes. If the best steered model has the same shape, we should build only the changes.

This chapter shows that it does. It is the bridge from the theory to the network in Chapter 7.

What Chapter 3 hands us

The best step is the pretrained step tilted by Zt+1/Zt. A tilted Gaussian is still close to a Gaussian, with its mean moved. Chapter 2 showed this for a straight-line tilt: the mean moves by aβ̃. The noise guess ε sets that mean, so the best noise guess ε* is the pretrained guess ε0 with a change. The paper asks what shape that change has, under the KL price. It assumes the pretrained network is the exact minimizer of its own loss, and that the finished images have every number between −1 and 1.

The answer is Proposition 2. We state its structure and leave the constants to the paper:

ε*
The best noise guess for the controlled model. The model we want.
(1 − z*) ε0
The pretrained guess, kept in proportion to one minus the gate z*. A gate is a number between open and shut. Here z* = 0 keeps all of ε0.
at z* xt
A pull toward the current noisy image, strong where the gate is high. The number at comes from the noise schedule.
bt (1 − z*) h*
A shift h*: a tensor of the same shape as the image that moves the guess. bt also comes from the schedule.
error
Small leftovers. They shrink as the pretrained model gets closer to the true data posterior, and as the number of features M (below) grows.

Read it as a recipe. Everything the control needs to add fits in two objects: the gate z* (one scalar between 0 and 1) and the shift h* (one tensor). When the gate is 0, the control is the pretrained guess plus a shift. When the gate grows, the pretrained guess fades. Eqs. 24 to 26 of the paper have the exact constants.

What the correction depends on

Here is the second finding. The shift h* and the gate z* do not need a free-form network of xt. Both can be written as sums of random Fourier features. These come from a classic idea (Rahimi and Recht, 2007): pick random directions ω, and any smooth function can be built as a sum of cosines and sines along them. The features here are:

φω
One feature pair: a cosine and a sine of one projection of the pretrained mean.
ω
A random direction, drawn from a standard bell curve. M of them are used (Eq. 25 and 26).
μ0
The pretrained reverse mean from Chapter 1. This is where the image enters. Notice that it is not xt.
√β̃t
The step’s spread. It sets the scale at which the pretrained step is blurry.

Then h* = (1/M) ∑i W*(ωi, c, t) φωi plus an error of size O(1/√M), and the logit of z* (the value before it is squeezed into the 0 to 1 range) has the same form with a vector u* in place of W*. The weights W* and u* depend on the prompt c and the step t, but only through those weights. Try the idea in one dimension. A smooth target function is fit by M random frequencies, with the weights solved exactly.

Fit with random features

The warm curve is a smooth target. The teal curve is a sum of cosines and sines at M random frequencies. Add frequencies.

3

Illustrative toy: a made-up target as a function of the pretrained mean, 24 seeded random frequencies (the first M are used), and weights fit by ridge-regularized least squares on 80 points. The paper fixes M only in theory; its network learns the feature directions instead of sampling them.

With one frequency the fit is a rough wave. With three it already follows the main bump. By twelve it is hard to tell apart from the target. The paper’s result says the same thing in general: a modest number of random features is enough, and the error shrinks like 1/√M.

A hint of attention

Look again at where the image goes in. It enters only through μ0. The prompt and the step, (c, t), choose the weights that pick and mix the features. This is the structure of cross-attention, where one stream (the image features) is read by another (the condition) through learned projections. The paper makes the link explicit: it is analogous to cross-attention with μ0 in place of xt. In practice it does not draw random ω at all, because that would make the batch too large. It lets the feature directions be learnable, which cross-attention projections do implicitly.

The design rule that falls out is short. Keep the pretrained score ε0 as the baseline. Give the control a small module with two heads, a gate and a shift. Feed it μ0, which the backbone already computes. Chapter 7 builds exactly that.

def eps_controlled(backbone, side_net, x_t, c, t, lam=1.0):
    e0, mu0 = backbone(x_t, c, t)        # noise guess and implied reverse mean (exposed outputs)
    z, h = side_net(mu0, c, t)           # gate z: 1 channel, shift h: 4 channels
    s = -z * e0 - a[t] * (z * mu0 + b[t] * (1 - z) * h)    # Eq. 28; a[t], b[t] from the schedule
    return e0 + lam * s                  # Eq. 27
What does Proposition 2 let the paper do?

Chapter 7

The Side Network

Follow one latent image through the small network that learns the gate and the shift, and see why it can work on a sealed backbone

Picture a sealed engine in a car. You cannot open it. But it has a gauge on the outside that shows what it is doing at every moment. You bolt a small controller next to it. The controller reads the gauge and adds a gentle push to the output. It never touches the engine.

That is the gray-box idea. The backbone stays frozen and hidden. It only has to expose its outputs at each denoising step: the noise guess ε0 and the implied reverse mean μ0. Everything we train sits beside it.

The parameterization

Chapter 6 told us the shape of the best score. The paper turns it into a model with two equations. A side network sθ outputs the gate and the shift, and the controlled score is the pretrained score plus the side network’s correction:

εθ
The controlled noise guess. The sampler of Chapter 1 uses it unchanged.
ε0
The frozen backbone’s guess. It is exposed, not edited.
λmodel
A guidance strength, at least 1, set by hand. It scales the correction up or down at test time.
sθ(μ0, c, t)
The side network. Its image input is the pretrained mean μ0, not the noisy image xt. The prompt and the step ride along.

Inside sθ the output is split into the gate zθ and the shift hθ, and combined as in Chapter 6 (Eq. 28 of the paper). It has two parts, a gate part and a shift part, exactly as the optimum predicted.

One latent image, stage by stage

The side network is a small UNet, a network that shrinks an image to find big-picture features and then expands it again with shortcuts. The paper builds it from standard blocks: two plain residual down blocks, one middle block that cross-attends to the prompt, and two plain residual up blocks. A residual block adds its input back onto its output, which keeps deep stacks easy to train. Table 3 of the paper gives the channels at each stage. The input is a latent of 4 channels on a 64 × 64 grid. Step through it. Then switch to the Naive variant to see what changes.

Walk the side network

Boxes are tensors: taller means a finer grid, wider means more channels. Drag the stage. Switch to Naive to see the two differences.

0

Channels and resolutions are the paper’s Table 3 (block channels 128 and 256, one layer per block, 64 × 64 latent for Stable Diffusion v1.4). The variants differ as in Table 4: the input, the output channels (5 against 4) and how the output is used. Both have 1.2 × 107 trainable parameters (Table 1).

At stage 7 the DiffCon network writes 5 channels: one for the gate, four for the shift. The extra channel is the only change to the output layer. The Naive network writes 4 channels and adds them straight onto ε0. It has the same body and the same parameter count, so any gap in the results (Chapter 9) comes from the form, not the size.

A little arithmetic shows how small the difference is. The input convolution has 3 × 3 filters from 4 channels to 128, so 4 × 128 × 9 = 4,608 weights and 128 biases, 4,736 numbers in all. The output convolution reads 128 channels. If the gate is one extra 3 × 3 output filter, it costs 128 × 9 + 1 = 1,153 numbers. Against 11.8 million parameters in the whole network, that is about 0.01%. The gate is almost free. The paper’s Table 4 says the two variants differ by one output channel, so this is our estimate of the size of that change.

Why each choice is made

The input is μ0, not xt. The theory says the image enters the optimal correction only through μ0 (Chapter 6). An ablation in the paper (Figure 14) found that feeding μ0 gave better results for the reward-weighted run than feeding xt.

The last layer starts at zero. The paper sets the output layer’s weights to 0. Then sθ = 0, and εθ equals ε0 on the first step of training. The model begins as the pretrained model and moves away only as far as the data pull it. LoRA does the same.

The blocks are cheap. The paper tried four block layouts (Table 11). The one with two plain residual down blocks and two plain residual up blocks, 11.8 million parameters, worked best. Layouts with attention blocks cost 13.4 and 18.5 million and did not win. It also noted that one gate channel and a tensor of shifts keep the correction “small and interpretable”.

λmodel turns the correction up. During training λmodel is 1. At test time the authors tried several values and report the best win rate among them for each checkpoint. That is a tunable dial, and a fair reading of the tables must remember it (Chapter 9).

MethodWhat trainsParamsAccess
DiffConside network sθ1.2 × 107gray-box
DiffCon-Naivesame body, ungated residual1.2 × 107gray-box
LoRA, rank 16low-rank adapters inside the backbone1.7 × 107white-box
DiffCon-JLoRA rank 4 and side network, trained jointly1.6 × 107white-box
DiffCon-SLoRA rank 4 and side network, trained apart, combined at test time1.6 × 107white-box
class SideNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.unet = UNet(in_ch=4, out_ch=5,                # 4 latent channels in, 1 gate + 4 shift out
                         block_out=(128, 256), down=("Down", "Down"), up=("Up", "Up"),
                         mid="CrossAttn")                  # the middle block reads the prompt
        nn.init.zeros_(self.unet.conv_out.weight)          # start as the pretrained model

    def forward(self, mu0, c, t):                          # mu0: (B, 4, 64, 64)
        o = self.unet(mu0, t, c)                           # (B, 5, 64, 64)
        return o[:, :1], o[:, 1:]                          # z: gate channel (B, 1, 64, 64), h: shift (B, 4, 64, 64)

One honest gap. The main text does not say how the side network combines with classifier-free guidance at 7.5. We show the structure and leave that detail to the paper’s code and appendix.

Why does the DiffCon side network start with its last layer set to zero, and what does it read as input?

Chapter 8

Three Recipes, One Template

Follow the data and the loss through supervised tuning, reward-weighted regression and PPO, and see exactly what differs between them

A kitchen has one stove and one set of pans. A cook can learn three ways. Copy a cookbook. Cook, taste and study the best dishes. Or cook, taste and adjust every move with a coach. The pans are the same. What changes is where the food comes from and how the lesson is scored.

The paper tests its side network under three recipes. The network and the sampler are the same each time. Only the data source and the loss change.

The three recipes

SFT is supervised fine-tuning. You have target images. The paper uses the “winner” images and their prompts from the Human Preference Dataset v2 (HPD v2): pairs where people picked one image over another. The loss is the plain noise-guess regression of Chapter 1, with those images as xT. The paper notes this is the same as classifier-free guidance training. It trains with batch size 128 for 1,000 iterations.

RWL is the reward-weighted loss of Chapter 4. There are no target images. The reward model is HPS-v2, a network trained on human preference choices. The weight is the polynomial one of Eq. 21 with τRWL = 5×10−4, α = 1 + τRWL, and a baseline b equal to the mean reward of the first training batch. Every 2 iterations, 64 prompts make 64 images with the current model, and then two gradient steps use that batch. It trains for 2,000 iterations at batch size 64.

PPO is the KL-regularized online PPO of Chapter 5, with the same HPS-v2 reward, τKL = 1×10−4, batch size 64 and 2,400 iterations. The data are online: they come from the current model, not from a fixed set.

All three use Stable Diffusion v1.4 with the text encoder and the image autoencoder frozen. Only the latent noise network is trained. The sampler uses classifier-free guidance at λCFG = 7.5, with the prompt dropped 10% of the time in training, and Adam for the optimizer. DiffCon uses a learning rate of 1e-5 in every recipe. LoRA uses 1e-5 for SFT and 1e-4 for RWL and PPO.

Run one iteration

Pick a recipe, then press Run one iteration. The pulse walks the five stages. Boxes that differ from SFT are outlined in warm.

Hyperparameters are from the paper’s Section 5.1: SFT batch 128 for 1,000 iterations; RWL batch 64 for 2,000 iterations, sampling every 2; PPO batch 64 for 2,400 iterations. The five-box layout is our summary of the loop, not a figure from the paper.

Look at the boxes that light up in warm. SFT never calls a reward model and never samples from itself, so it is cheap. RWL and PPO both need fresh images from the current model, and both need the reward. RWL then trains with one weighted regression. PPO needs the whole path of steps stored, a value estimate for the advantage, and the old policy for the ratio.

There is one subtle point in RWL. In Theorem 1 the images xT come from the pretrained model, because the weight turns them into samples of the target. In practice the paper draws images from the current model every 2 iterations, which it calls online sampling. Its Figure 8 compares both settings, which it names teacher sampling and online sampling, and tests its polynomial weight against the DPOK reward weight in each. Online sampling is a practical choice, and the target the loss chases then moves as the model improves. That is one reason the baseline b and the price τ matter so much.

One template

The loop is the same shape in all three. This code is our own condensed summary, using the formulas from the earlier chapters:

def finetune(recipe, net, pre, iters):
    for it in range(iters):
        if recipe == "sft":
            prompts, x = next(hpd_winners)                      # fixed target images
            loss = noise_regression(net, x, prompts)            # Eq. 10
        elif recipe == "rwl":
            if it % 2 == 0:                                     # fresh images every 2 iterations
                prompts, x = sample_with(net, 64)
                r = hps_v2(x, prompts)
            w = (1 + (r - b)).clamp(min=0) ** (1 / tau)         # Eq. 21 with alpha = 1 + tau
            loss = weighted_noise_regression(net, x, prompts, w)  # Eq. 19
        else:
            traj = sample_trajectories(net, 64)                 # keep every x_t
            loss = ppo_loss(net, net_old, pre, traj, V, tau, delta)   # Eq. 17
        loss.backward(); opt.step(); opt.zero_grad()
    # net is DiffCon: only side-net weights have grads, the backbone is frozen

Because the parameterization only adds a correction to the score, it does not care which loss you use. The paper calls the parameterization orthogonal to the learning algorithm. That is why the same side network can be compared under all three.

How the results are scored

The main metric is the win rate: show the same prompt to two models, score both images with HPS-v2, and count how often the tested model scores higher. 0.5 is a tie. The test set is the HPS-v2 prompt set. As a sanity check against reward hacking, the paper also reports CLIP, Clip-Aesthetics and PickScore (Chapter 10). For PPO it adds a human study with more than 50 raters on 50 prompts, four images each.

One protocol detail will matter later. For every checkpoint the authors tried a few values of the test-time guidance λmodel and report the best HPS-v2 win rate among them. For SFT and RWL the DiffCon sweep covers 1/λmodel from 0.1 to 1.0. For PPO it covers 0.7 to 1.0. LoRA has no such dial.

Which statement about the three recipes is right?

Chapter 9

What the Results Show

Read Table 1 row by row, compare methods with the same budget, and see where the gray-box side network wins and where it loses

A race has a time, a rank and a course. The time alone does not tell you much. You need to know what the others ran and on which road. A results table is the same. This chapter reads the paper’s main table slowly, with that in mind.

How to read a win rate

A win rate of 0.6667 means that in 66.67% of head-to-head comparisons, the tuned model’s image scored higher on HPS-v2 than the pretrained model’s image for the same prompt. A tie is 0.5. Each number comes with a ± spread, which the table reports but the main text does not define in terms of runs, so treat it as a rough error bar.

There are five methods and three recipes. Parameter counts are the number of trainable weights. All use Stable Diffusion v1.4.

Compare five methods

Pick a recipe. Bars show the win rate against the pretrained model, with the paper’s spread as a thin line. The dashed line is 0.5, a tie.

All numbers are from the paper’s Table 1 (HPS-v2 win rate against the pretrained model on the HPS-v2 test prompt set, at the end of training, with the spread the table reports). For the side-network methods the paper reports, for each checkpoint, the best win rate over a few test-time λmodel values. Parameters: DiffCon and Naive 1.2 × 107, LoRA 1.7 × 107, DiffCon-J and DiffCon-S 1.6 × 107.

Four things the table says

One. The form beats the size. DiffCon and DiffCon-Naive have the same body and the same 12 million parameters. Under SFT DiffCon wins 66.67% and Naive wins 56.55%. Under RWL it is 68.15% against 50.60%. Under PPO it is 69.57% against 52.01%. Naive barely beats a coin flip in two of the three. The gate and shift form, with μ0 as input, is what carries the gain.

Two. Gray-box beats white-box in two recipes. The side network, with no access to backbone weights and 12 million parameters, beats LoRA at 17 million under SFT (66.67% against 57.66%) and under RWL (68.15% against 61.09%). That is 9.0 and 7.1 points ahead, with 29% fewer trainable weights.

Three. PPO is the exception. Under PPO LoRA reaches 90.48% and DiffCon only 69.57%, about 20.9 points behind. The paper says it plainly: for PPO, the white-box methods reach above 0.9. One plausible reading, which the paper does not test, is that a frozen backbone leaves less room to move in this recipe.

Four. Adding the side network to LoRA helps. DiffCon-J and DiffCon-S use a smaller LoRA (rank 4) plus the side network, for 16 million parameters. Under PPO they reach 93.53% and 93.15% against LoRA’s 90.48%. Under SFT both reach 69.64% against 57.66%. Under RWL DiffCon-S is best at 70.91% and DiffCon-J reaches 65.55%.

Here is a back-of-envelope check on the efficiency claim. Take the win rate above a tie, per million trainable parameters. Under SFT, DiffCon gets (0.6667 − 0.5)/12 = 1.4 points per million, and LoRA gets (0.5766 − 0.5)/17 = 0.45. Under PPO, DiffCon gets 1.6 and LoRA gets 2.4. This is our crude arithmetic, not a measure from the paper. It shows why the abstract says “trade-off”: the side network is far ahead per parameter in two recipes and behind in the third. Parameters are also not the same as time or memory, which the tables do not report.

Paired duels and people

Figure 3 of the paper puts methods against each other directly instead of against the pretrained model. These are read from the bars in that figure, so treat them as approximate:

PairSFTRWLPPOPPO, human raters
DiffCon vs DiffCon-Naive0.5360.5970.6130.596
DiffCon-J vs LoRA0.5540.5170.5200.536
DiffCon-S vs LoRA0.5680.5070.5270.520

Every value is above 0.5, so every pairing favors the side-network variant. The human study agrees in direction for PPO: raters preferred DiffCon over Naive in about 60% of comparisons. The white-box pairings against LoRA sit between 0.507 and 0.568, close to a coin flip, and the paper reports error bars only for the HPS-v2 numbers.

What to keep in mind

Three limits shape how to read these numbers. First, RWL and PPO train on HPS-v2, and the win rate is measured with HPS-v2. A tuned model that learned the reward model’s taste will do well here by design. Chapter 10 looks at the other scorers. Second, the test-time λmodel is picked for the best win rate among a handful of values, which favors the side-network methods a little, since LoRA has no such dial. Third, there is one backbone, Stable Diffusion v1.4, and one task, text-to-image. The paper itself lists personalization, safety alignment and transfer as future directions.

def win_rate(tuned, pretrained, prompts, reward):
    wins = 0
    for c in prompts:                                   # the HPS-v2 test prompt set
        a = sample(tuned, c)                            # image from the tuned model
        b = sample(pretrained, c)                       # image from the pretrained model
        wins += float(reward(a, c) > reward(b, c))      # 1 if the tuned image scores higher
    return wins / len(prompts)                          # 0.5 is a tie
DiffCon and DiffCon-Naive have the same body and the same 12 million parameters. What does their gap in Table 1 tell you?

Chapter 10

Ablations, Other Scorers and Limits

Check whether a higher win rate means better pictures, see which knobs mattered, and list what the paper leaves open

A student who studies for one exam and aces it has not yet shown they learned the subject. You would give a different exam. The win rates in Chapter 9 come from the same scorer that RWL and PPO trained against. So the paper gives other exams too: CLIP, Clip-Aesthetics and PickScore. This chapter reads those, then the knobs the authors turned, then the limits.

The other exams

CLIP scores how well an image matches its prompt. Clip-Aesthetics scores how pleasing an image looks. PickScore is a second human-preference model, trained on different data than HPS-v2. If tuning only learned the quirks of HPS-v2, these scores would fall while the win rate rises. The pretrained model scores 0.2750 on CLIP, 5.5163 on Clip-Aesthetics and 0.2103 on PickScore. The plot shows each method as a percent change from those values.

Check the other scorers

Choose a recipe and a scorer. Bars to the right beat the pretrained model on that scorer, bars to the left fall below it.

Values are from the paper’s Tables 8 to 10 (means; the tables also give spreads). The bar is the percent change from the pretrained value, (method − pretrained) / pretrained. The paper reports these scores to show quality is “not compromised”; the percent view is ours.

Try PPO with CLIP. LoRA, DiffCon-J and DiffCon-S all reach 90% or higher win rates, and their CLIP scores fall by about 3.3% to 4.2%. Switch to PickScore and the same three methods rise, from 0.2103 to 0.2125, 0.2133 and 0.2142. So an independent preference model agrees with HPS-v2, while the prompt match slips. DiffCon alone, under PPO, loses 1.4% on CLIP and 3.3% on Clip-Aesthetics (5.3370 against 5.5163), the biggest aesthetics dip of any row. Its PickScore also slips, from 0.2103 to 0.2094. The drops are small, but they are not zero. The honest reading is mixed: the preference scorers agree for the three strongest methods, and the other two scorers give up a little.

You can run this kind of check on any tuned model. First, pick scorers that the training never saw. Second, compute the percent change from the untuned model, as the plot does. Third, compare it with a control, such as DiffCon-Naive here, so you can see whether a drop comes from the method or from tuning in general. Under PPO, Naive moves little on every scorer: CLIP 0.2748, aesthetics 5.5186, PickScore 0.2106. It also barely raises its win rate, 0.5201. A model that does not move much cannot hack much. So the drops in the strong methods are the price of their gains, and the paper’s own claim that quality is not compromised is true only up to those small dips.

The knobs that mattered

The appendix turns one knob at a time. Here is what it found.

KnobWhat the paper found
τKL for PPO, values 0, 1e-5, 1e-4, 5e-4, 1e-31e-4 was best. With the regularizer too small, or zero, the reward does not go up (Figure 10).
τRWL, values 0.0005, 0.0025, 0.005Smaller was better, but below 0.0005 the weight computation broke with not-a-number errors. 0.0005 was used (Figure 11).
Weighting function for RWLThe exponential weight with τRWL = 0.0015 also works: DiffCon beats LoRA again (Figure 12). The paper also compares its polynomial weight with the DPOK reward weight (Figure 8).
Learning rateLoRA likes 1e-4 for RWL and PPO. DiffCon likes 1e-5 (Figure 9).
Side-network blocksTwo plain residual down blocks and two up blocks (11.8M parameters) were best. Adding attention blocks cost 13.4M or 18.5M (Table 11, Figure 13).
Side-network inputFeeding μ0 beat feeding xt for RWL (Figure 14).
Test-time λmodelLarger values improved generation quality for SFT and RWL (Figures 4 to 7).

Two of these are worth a second look. The PPO result says the regularizer is not only a safety rope. With no price, the paper’s runs did not gain reward at all, so the KL term shaped learning, not just the result. And the τRWL floor fits a numerical limit more than a theoretical one, as Chapter 4 noted.

Limits and open questions

Scope. All experiments use one backbone (Stable Diffusion v1.4) and one task (text-to-image preference alignment). The conclusion names personalization, safety alignment and transfer learning as directions still to be tried.

Theory. Proposition 2 assumes the pretrained network exactly minimizes its loss, that finished images have every number in [−1, 1], and that the price is KL. For other f-divergences, the weighted loss is a surrogate for the whole-film optimum, which can differ from the step-by-step one. The paper says so. How much the choice of f matters beyond the exponential and polynomial weights is not studied.

Access. Gray-box still needs the backbone’s per-step outputs. A service that returns only finished images cannot be controlled this way.

Efficiency. The abstract speaks of better quality-efficiency trade-offs. The tables measure efficiency as trainable parameters. They do not report wall-clock time, memory or the cost of calling the backbone at each step. That part is our reading of what is missing, not a claim by the authors.

The PPO gap. In the one recipe where reward rises most, the frozen-backbone method trails LoRA by about 21 points. Whether better side networks, a larger λmodel range or other tricks close that gap is open.

Under PPO, LoRA’s HPS-v2 win rate is above 0.90, but its CLIP score falls. What is the fair reading?

Chapter 11

Field Guide

Test your sense of the numbers, then keep the summary, the table, the core code and the links

Here is the whole paper in one paragraph. Reverse diffusion is a chain of kernels. Steering it means tilting each kernel by exp(u) and paying τ times an f-divergence for the tilt. With a reward only at the end, the best controlled model is the pretrained model times a weight of the final reward: exp(r/τ) for KL. That answer gives two ways to train: a reward-weighted regression on the pretrained model’s images, and a policy gradient with a soft advantage that includes the price, with PPO on top. It also gives the shape of the model: the pretrained score plus a gate and a shift that read the pretrained mean. A small side network with that shape, started at zero, steers a frozen Stable Diffusion v1.4 better than the same network without the shape, and in two of three recipes better than LoRA.

Test your sense of the numbers

Pick a method and a recipe, set your guess for its win rate against the pretrained model, then reveal the paper’s number.

Guess, then reveal

Choose a recipe and a method. Slide your guess along the line. Press Reveal.

0.700

Values are the means in Table 1 of the paper: HPS-v2 win rate against the pretrained model on the HPS-v2 test prompt set.

Numbers and settings

WhatValueSource
DiffCon win rate vs pretrained, SFT / RWL / PPO0.6667 / 0.6815 / 0.6957Table 1
DiffCon-Naive, same 1.2 × 107 parameters0.5655 / 0.5060 / 0.5201Table 1
LoRA rank 16, 1.7 × 107 parameters0.5766 / 0.6109 / 0.9048Table 1
DiffCon-J, LoRA rank 4 plus side net, 1.6 × 1070.6964 / 0.6555 / 0.9353Table 1
DiffCon-S, trained apart0.6964 / 0.7091 / 0.9315Table 1
Side network, best layout, trainable parameters11,810,621 (two residual down, two residual up, channels 128 and 256)Table 11
Training: batch and iterations (SFT / RWL / PPO)128 × 1,000 / 64 × 2,000 / 64 × 2,400Sec. 5.1
Prices and weightsτRWL = 5e-4, α = 1 + τRWL; τKL = 1e-4Sec. 5.1
Sampler and training common settingsλCFG = 7.5, prompt dropout 0.1, Adam, DiffCon learning rate 1e-5Sec. 5.1
Human study (PPO)more than 50 raters, 50 prompts, four images eachApp. C

Terms

TermPlain meaning
Passive dynamicsWhat the pretrained model does by itself: its reverse kernels p0,t.
Control, tiltThe factor exp(u) that reweights a kernel. It must keep the kernel adding up to 1.
LS-MDPA control problem where the controller picks the next-state distribution directly. Solved by a plain average, hence “linearly solvable”.
f-divergenceA family of distances between distributions. KL is one member.
Goodness Zexp(V*/τ): how rewarding a state’s future looks, averaged under the pretrained step.
Reward-weighted lossNoise regression on pretrained images, each multiplied by a weight from its reward.
Soft advantageHow much better than expected a step was, with its drift price included.
Gate, shiftThe two outputs of the side network: z fades the pretrained guess, h moves it.
Gray-boxThe backbone is sealed but exposes its per-step outputs.
Win rateThe share of head-to-head prompts where the tuned model’s image scores higher.

The core, as code

# 1. The best controlled image distribution (KL):  p*(x) ~ p0(x) * exp(r(x) / tau)
# 2. Train toward it by weighting the pretrained model's own images (Theorem 1)
def rwl_weight(r, b, tau, alpha_m1):
    return (1 + (alpha_m1 / tau) * (r - b)).clamp(min=0) ** (1 / alpha_m1)

# 3. The model form: frozen score + gated, shifted correction from a side network (Eqs. 27, 28)
def eps_theta(backbone, side, x_t, c, t, lam=1.0):
    e0, mu0 = backbone(x_t, c, t)           # the only things we need from the backbone
    z, h = side(mu0, c, t)                  # the side network reads the pretrained mean
    s = -z * e0 - a[t] * (z * mu0 + b[t] * (1 - z) * h)
    return e0 + lam * s

# 4. Sample as usual: same reverse step, same guidance, new score
x = randn(4, 64, 64)
for t in range(1, T):
    x = reverse_step(x, eps_theta(backbone, side, x, c, t), t)

Where it sits in the field

Earlier reinforcement-learning methods for diffusion, such as DDPO and DPOK, treat the denoising chain as a standard MDP. DDPO is the τ = 0 case of this paper’s policy gradient. DPOK adds a KL price but counts it step by step. DRaFT instead sends gradients through a differentiable reward. DPO-style methods learn from pairs of preferred and rejected images. Tang and Zhou link continuous-time diffusion tuning to entropy and f-divergence control, and the authors build on that line. On the model-form side, LoRA edits the backbone, while ControlNet, T2I-Adapter and IP-Adapter add side modules that act like guidance. The paper’s side network differs in that its form is derived from the control solution and it reads the pretrained mean.

Keep going

Cite and read

Tong Yang, Moonkyung Ryu, Chih-Wei Hsu, Guy Tennenholtz, Yuejie Chi, Craig Boutilier and Bo Dai. Diffusion Controller: Framework, Algorithms and Parameterization. arXiv:2603.06981, March 2026. arxiv.org/abs/2603.06981. The authors are at Carnegie Mellon, Google Research, Yale and Google DeepMind. Every number in this lesson comes from the paper unless it is labelled illustrative. The toy devices use made-up numbers to show how the mechanisms behave.

Treat denoising as control, and the trade becomes exact. The best steered model is the pretrained model reweighted by exp(reward/τ). That one line yields a loss you can train on, a policy gradient with a built-in price, and a model shaped as the pretrained score plus a small correction. The correction can live in a side network that never touches the backbone.
Go back to the hero and slide τ down. Now you can say why the curve moves, what it costs, and which loss from this lesson would train a network to follow it. Then try Present or Teach, and explain the gate and the shift in your own words.
Diffusion Controller
Read the paper · Back to Veanors