Simple Algorithm
Reinforcement Learning · Fixed Point · 26 min

Expressive Policies: Diffusion Policy & Action Chunking

Multimodal demonstrations, and the policy classes that can represent them.

Half the demonstrators pass an obstacle on the left and half on the right. A policy trained by squared error learns to drive straight into it. This lesson shows why mean regression fails on multimodal demonstrations, and works through the policy classes that can represent several ways of acting: mixtures, discretized and tokenized actions, energy-based models, diffusion and flow policies, and policies that predict whole chunks of actions.

What you’ll learn

  • Show that squared-error cloning learns the conditional mean, and explain why that action can be one no demonstrator would take.
  • Compare mixture, discretized (BeT), energy-based (implicit BC), diffusion and flow-matching policies by what they can represent, how they are trained and what inference costs.
  • Explain Diffusion Policy's design (denoising action sequences, receding-horizon execution, observation conditioning) and why it trains more stably than an energy-based policy.
  • Explain action chunking with temporal ensembling (ACT), what it does to the effective horizon and what it costs, and place the generalist robot policies of the mid-2020s in this picture.

The mean of two good answers can be a bad one

Cloning with squared error, which is maximum likelihood for a Gaussian policy with a fixed variance, fits the conditional mean of the expert's action. When demonstrations are multimodal, with several distinct good actions in the same state, the mean can fall between them.

DerivationSquared error picks the average
  1. E[(A−f(s))2 ∣ S=s]=Var⁡(A∣S=s)+(m(s)−f(s))2\E\big[(A - f(s))^2\,\big|\,S = s\big] = \Var(A\mid S = s) + \big(m(s) - f(s)\big)^2

    For any prediction f(s)f(s), add and subtract the conditional mean m(s)=E[A∣S=s]m(s) = \E[A\mid S = s]; the cross term has zero mean:

  2. So a rich enough regressor learns f=mf = m. In front of an obstacle where half the demonstrators steer a=−1a = -1 (left) and half a=+1a = +1 (right), it learns f(s)=0f(s) = 0: straight ahead, into the obstacle. A single Gaussian fitted by maximum likelihood makes the same choice, because its fitted mean is the average whatever its variance.

Predict before you look

In that example, predicting the mean a=0a = 0 has expected squared error 1. What is the expected squared error of always predicting a=+1a = +1, a perfectly good action?

Show the answer

2

Half the time the error is 0, and half the time it is (1−(−1))2=4(1 - (-1))^2 = 4, so the expected squared error is 2. Squared error therefore prefers the harmful average to either good action: the loss, not the network, is what fails.

A second, subtler failure concerns time. A policy that does represent both modes but samples each step independently can choose left at one step and right at the next, jittering between two plans that are each fine on their own. Predicting a sequence of actions from one sample avoids it, and comes back in the last two steps.

The oldest remedy is a mixture density network (Bishop, 1994): the network outputs the weights, means and variances of KK Gaussians and is trained by maximum likelihood. It works for a few modes, but KK must be chosen, training can collapse onto one component, and the mixture becomes hard to fit when actions are high-dimensional.

Discretize, or learn an energy

Discretize. A categorical distribution over bins represents any number of modes, and cross-entropy training is as stable as classification. Behavior Transformers (BeT; Shafiullah, Cui, Altanzaya & Pinto, 2022) cluster the dataset's continuous actions with kk-means, let a transformer over the recent observation history predict the cluster, and add a predicted continuous offset within the cluster, an idea borrowed from object detection. Transformer robot policies such as RT-1, and RT-2, which reuses a vision–language model, turn actions into tokens in the same spirit. The costs: precision is limited by the bins, and a joint grid of bins grows exponentially with the action dimension, so tokenized policies usually discretize each dimension separately and emit one token per dimension.

Learn an energy. Implicit behavioral cloning (Florence et al., 2021) learns a scalar energy Eθ(o,a)E_{\boldsymbol\theta}(o, a) and acts by minimizing it, a^=arg min⁡aEθ(o,a)\hat a = \argmin_a E_{\boldsymbol\theta}(o,a). It is trained as a conditional energy-based model, with negative counter-examples a~1,…,a~M\tilde a_1,\dots,\tilde a_M sampled from the action space for each demonstrated pair:

LInfoNCE=−log⁡e−Eθ(o,a)e−Eθ(o,a)+∑j=1Me−Eθ(o,a~j)\mathcal L_{\mathrm{InfoNCE}} = -\log\frac{e^{-E_{\boldsymbol\theta}(o,a)}}{e^{-E_{\boldsymbol\theta}(o,a)} + \sum_{j=1}^{M}e^{-E_{\boldsymbol\theta}(o,\tilde a_j)}}
The negatives estimate the normalizing constant Z(o)=∫e−Eθ(o,a) daZ(o) = \int e^{-E_{\boldsymbol\theta}(o,a)}\,da. Acting requires an optimization at every step: derivative-free search (sample, keep the best, resample around them) or gradient-based Langevin dynamics.

An energy can represent discontinuous and set-valued maps, such as "push the block from whichever side is closer", which an explicit regressor smooths into something in between. Its weaknesses are the other side of the same coin: good negatives are hard to sample in high dimensions, training can be unstable, and every action costs an inner optimization.

Policy classSeveral modes?Training signalCost of one actionTypical trouble
Gaussian (squared error)NoRegressionOne forward passAverages the modes
Mixture of KK GaussiansUp to KKLikelihoodOne forward passChoosing KK; collapse onto one component
Discretized or tokenized (BeT, RT-1)YesCross-entropyOne pass, or one per tokenPrecision limited by the bins
Energy-based (implicit BC)Yes, even discontinuousContrastive, with negativesAn optimizationNegative sampling; unstable training
Diffusion or flow (Diffusion Policy, π0)YesRegression on noise or velocitySeveral network passesLatency
Five ways to represent π(a∣o)\pi(a\mid o). The last two rows are the subject of the next step.
Check your understanding

Why does training an energy-based policy need negative examples, while training a diffusion policy does not?

  1. Energy-based policies have more parameters
  2. The energy model's likelihood contains the normalizing constant ∫e−E(o,a) da\int e^{-E(o,a)}\,da, which negatives estimate; a diffusion model is trained by regressing the added noise, a supervised loss with no normalizing constant
  3. Diffusion policies only work for one-dimensional actions
  4. Negatives are needed by both; diffusion simply hides them inside the noise schedule
Show the answer

B. The energy model's likelihood contains the normalizing constant ∫e−E(o,a) da\int e^{-E(o,a)}\,da, which negatives estimate; a diffusion model is trained by regressing the added noise, a supervised loss with no normalizing constant

Maximum likelihood for p(a∣o)∝e−E(o,a)p(a\mid o)\propto e^{-E(o,a)} must push down the energy of everything that is not data, which requires samples of "everything else". Denoising score matching sidesteps the normalizer entirely: corrupt a demonstrated action with known noise and train the network to predict that noise. Chi et al. cite this as the main reason Diffusion Policy trains more stably than implicit BC.

Diffusion and flow policies

A diffusion policy generates actions the way image diffusion models generate pictures. A forward process gradually corrupts a demonstrated action (or action sequence) a0a^0 with Gaussian noise over KK steps, ak=αˉk a0+1−αˉk εa^k = \sqrt{\bar\alpha_k}\,a^0 + \sqrt{1-\bar\alpha_k}\,\varepsilon with ε∼N(0,I)\varepsilon\sim\mathcal N(0, I) and a decreasing schedule αˉk\bar\alpha_k, and a network learns to predict the noise from the corrupted action, the noise level and the observation:

L(θ)=Ek, ε, (o, a0)∼D[∥ε−εθ(αˉk a0+1−αˉk ε, k, o)∥2]\mathcal L(\boldsymbol\theta) = \E_{k,\ \varepsilon,\ (o,\,a^0)\sim\data}\Big[\big\|\varepsilon - \varepsilon_{\boldsymbol\theta}\big(\sqrt{\bar\alpha_k}\,a^0 + \sqrt{1-\bar\alpha_k}\,\varepsilon,\ k,\ o\big)\big\|^2\Big]
The noise predictor is, up to the factor −1−αˉk-\sqrt{1-\bar\alpha_k}, the score ∇alog⁡pk(a∣o)\nabla_{a}\log p_k(a\mid o) of the noised action distribution. Sampling starts from pure noise and applies KK denoising updates, each a small noisy step uphill in log-density, so samples end in one of the modes instead of between them.

Diffusion Policy (Chi et al., 2023) made this practical for visuomotor control. At time tt it conditions on the last ToT_o observations, denoises a sequence of TpT_p future actions, executes only the first TaT_a of them and then plans again, a receding horizon. The observation features modulate a 1-D temporal convolutional denoiser (a transformer variant also exists), the actions are positions rather than velocities, and DDIM sampling with 100 training steps but only 10 inference steps gave about 0.1 s of latency on a desktop GPU. Across 12 tasks from 4 benchmarks the authors report large gains over the previous state of the art, and they list stable training, compared with energy-based policies, among its main advantages.

Flow matching (Lipman et al., 2023) replaces the noise schedule with a velocity field. Draw noise a0a^0 and a demonstrated action a1a^1, form aτ=(1−τ) a0+τ a1a_\tau = (1-\tau)\,a^0 + \tau\,a^1 at a random time τ∈[0,1]\tau\in[0,1], and regress a network vθ(aτ,τ,o)v_{\boldsymbol\theta}(a_\tau,\tau,o) onto the straight-line velocity a1−a0a^1 - a^0. Acting integrates the ordinary differential equation da/dτ=vθ(a,τ,o)\mathrm d a/\mathrm d\tau = v_{\boldsymbol\theta}(a,\tau,o) from noise to an action, deterministically and often in few steps. The π0\pi_0 policy (Black et al., 2024) generates actions this way, attached to a pretrained vision–language model.

Action chunking and temporal ensembling

Action chunking attacks compounding from the other side. ACT (Action Chunking with Transformers; Zhao, Kumar, Levine & Finn, 2023) models πθ(at:t+k∣st)\pi_{\boldsymbol\theta}(a_{t:t+k}\mid s_t): from one observation it predicts the next kk actions, and the authors describe this as a kk-fold reduction of the task's effective horizon. It is trained as a conditional variational autoencoder, whose latent "style" variable absorbs the variability of human demonstrations and is set to its mean at test time.

Run naively, a chunked policy looks at the world only every kk steps, and its motion can jerk at chunk boundaries. ACT instead queries the policy at every step, so that several overlapping chunks each propose an action for the current step, and it executes their weighted average with weights wi=e−m iw_i = e^{-m\,i}, where w0w_0 belongs to the oldest prediction and a smaller mm lets newer predictions count relatively more. Unlike ordinary smoothing, which blends in actions meant for neighboring time steps, this temporal ensembling averages only predictions of the same step. Trained on 50 demonstrations for most tasks (10 to 20 minutes of data recorded at 50 Hz) with a bimanual teleoperation rig built for under $20,000, ACT reached 80–90% success on fine tasks such as opening a translucent condiment cup and slotting a battery. Diffusion Policy's choice of executing TaT_a of its TpT_p predicted actions is the same compromise between commitment and reactivity.

Generalist robot policies (as of the mid-2020s)

These policy classes now sit inside large models trained on many tasks and robots, mainly by imitation. A few landmarks, described by how they produce actions:

  • RT-1 (Brohan et al., 2022): a transformer from camera images and a language instruction to discretized action tokens, trained on a large collection of real-robot demonstrations.
  • RT-2 (2023): vision–language models fine-tuned to emit actions as text tokens while still training on web data, the origin of the term vision–language–action model.
  • Octo (2024): an open-source transformer policy with a diffusion action head, trained on about 800,000 trajectories from the Open X-Embodiment collection and designed to be fine-tuned to new robots.
  • π0\pi_0 (Black et al., 2024): a pretrained vision–language model with a flow-matching module that generates continuous actions, trained on data from several robot platforms.

Their failure modes are still the ones of this topic: compounding errors, states the data do not cover, and demonstrations that disagree, now in a much larger space of situations.

Key takeaways

  • Squared-error or single-Gaussian cloning learns E[A∣S]\E[A\mid S]; with multimodal demonstrations that can be an action no one took, and sampling each step independently can switch modes mid-motion.
  • Mixtures, discretized or tokenized actions (BeT, RT-1), energy-based policies (implicit BC), and diffusion and flow policies can all represent several modes; they differ in training signal (likelihood, cross-entropy, contrastive, regression on noise or velocity) and in the cost of producing an action.
  • Diffusion Policy denoises whole action sequences conditioned on recent observations and executes them with a receding horizon; denoising regression avoids the negative sampling that destabilizes energy-based training, at the price of several network passes per decision.
  • Action chunking (ACT) divides the number of decisions by the chunk length and averages overlapping chunks for smoothness. The generalist robot policies of the mid-2020s combine tokenized, diffusion or flow action heads with large pretrained backbones, trained mainly by imitation.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

At some state, half the demonstrations steer −1-1 and half steer +1+1. What does a policy trained by squared error output there?

  1. −1-1 or +1+1, whichever appears first in the data
  2. A random choice between −1-1 and +1+1 at each visit
  3. About 00, the average of the two
  4. +1+1, because squared error favors larger actions
Show the answer

C. About 00, the average of the two

Squared error is minimized by the conditional mean, here 0, which may be the one action no demonstrator would take. Representing both modes needs a different policy class, such as a mixture, a categorical over bins, an energy model or a diffusion model.

Question 2

Why does Diffusion Policy denoise a sequence of future actions instead of a single action per step?

  1. One sample then fixes a whole plan, so consecutive actions come from the same mode, and executing several of them before replanning gives smooth, consistent motion
  2. A single action vector is too small for a diffusion model to denoise
  3. Predicting sequences removes the need to observe the environment
  4. It makes training faster than predicting single actions
Show the answer

A. One sample then fixes a whole plan, so consecutive actions come from the same mode, and executing several of them before replanning gives smooth, consistent motion

Sampling each step independently can switch modes mid-motion. Denoising TpT_p actions at once keeps them consistent, and executing TaT_a of them before replanning trades some reactivity for smoothness, the receding-horizon compromise also used by model predictive control.

Question 3

What does a flow-matching policy learn, and how does it produce an action?

  1. A noise predictor, sampled by many stochastic denoising steps
  2. A velocity field, regressed onto straight-line velocities from noise samples to demonstrated actions; it acts by integrating an ordinary differential equation from noise, often in few steps
  3. An energy over actions, minimized at every step
  4. A categorical distribution over bins of the action space
Show the answer

B. A velocity field, regressed onto straight-line velocities from noise samples to demonstrated actions; it acts by integrating an ordinary differential equation from noise, often in few steps

Flow matching regresses vθ(aτ,τ,o)v_{\boldsymbol\theta}(a_\tau,\tau,o) onto a1−a0a^1 - a^0 along the interpolation aτ=(1−τ)a0+τa1a_\tau = (1-\tau)a^0 + \tau a^1. Integration is deterministic, and straight paths can be followed in few steps, which is attractive when a robot needs actions quickly.

Question 4

ACT predicts and executes chunks of kk actions. What does chunking do, and what does it cost?

  1. It multiplies the amount of training data by kk
  2. It lets the policy ignore observations entirely
  3. It removes the multimodality of the demonstrations
  4. It divides the number of decisions per episode by kk, shortening the horizon over which errors compound, at the price of acting open-loop within a chunk; temporal ensembling restores some reactivity
Show the answer

D. It divides the number of decisions per episode by kk, shortening the horizon over which errors compound, at the price of acting open-loop within a chunk; temporal ensembling restores some reactivity

Fewer decisions mean fewer chances for errors to compound, but each chunk is a harder, open-loop prediction. Querying the policy every step and averaging the overlapping chunks keeps the motion smooth while still reacting to new observations.

Further reading

  • C. Chi, S. Feng, Y. Du, Z. Xu, E. Cousineau, B. Burchfiel & S. Song, "Diffusion policy: Visuomotor policy learning via action diffusion," RSS (2023).
  • T. Z. Zhao, V. Kumar, S. Levine & C. Finn, "Learning fine-grained bimanual manipulation with low-cost hardware," RSS (2023).
  • P. Florence et al., "Implicit behavioral cloning," CoRL (2021).
  • N. M. M. Shafiullah, Z. J. Cui, A. Altanzaya & L. Pinto, "Behavior transformers: Cloning kk modes with one stone," NeurIPS (2022).
  • K. Black et al., "π0\pi_0: A vision-language-action flow model for general robot control," arXiv:2410.24164 (2024).