Notes

robot learning · diffusion policies · 6 min read

Residual Denoising vs. Action-Space Residuals in Diffusion Policies

Intro

Picture two robots cleaning a table. One moves a tray out of the way and the other wipes underneath it. They each know their own job. But if the first one puts the tray back too early, the second one can't finish.

One option is to keep the pretrained policies frozen and learn a correction on top [5]. The obvious way is to add it to the final action. Residual denoising puts it inside the sampling process instead, at every step. I wanted to see how moving the correction changes the actions we end up with.

Action-space residuals

Let \(o\) be the robot's local observation and \(x\in\mathbb R^{Hd}\) a chunk of \(H\) actions, each with \(d\) coordinates [1]. We sample a chunk from the base policy \(p_B\) and then add a correction.

\[ x_B\sim p_B(\cdot\mid o),\qquad x_A=x_B+r_\phi(o,x_B). \]

This is the idea from residual RL. The controller already does something useful, so we just learn what to add to it [2]. You could also learn the correction from demonstrations.

First, say the residual only gets \(o\). Once the observation is fixed, every sampled chunk gets the same correction.

\[ p_A(x\mid o)=p_B(x-r_\phi(o)\mid o),\qquad \operatorname{Cov}(x_A\mid o)=\operatorname{Cov}(x_B\mid o). \]

The distribution moves over but keeps its shape. Say the base samples \(-1\) or \(+1\) equally often. Adding a constant can't send both to \(+1\). The two outputs are still two units apart.

Now let the residual see the sample. If we pick \(r(x_B)=1-x_B\), both outputs go to \(+1\). So an action-space residual can change the shape of the distribution. We just have to be careful about which version we're comparing.


From a denoiser to a sampling direction

Add Gaussian noise to a clean chunk to get \(y=x+\sigma\epsilon\), where \(\epsilon\sim\mathcal N(0,I)\). The noise level \(\sigma>0\) controls how much noise we add. A denoiser \(D(y,\sigma,o)\) tries to get \(x\) back. With squared-error training, its best answer is the posterior mean, which is the average of the clean chunks that could have made \(y\), weighted by probability [3].

Call the noisy density \(p_\sigma\). If we differentiate its Gaussian convolution, we get

\[ \begin{aligned} s_\sigma(y\mid o) &=\nabla_y\log p_\sigma(y\mid o)\\ &=\mathbb E\!\left[\frac{x-y}{\sigma^2}\,\middle|\,y,o\right] =\frac{D^*(y,\sigma,o)-y}{\sigma^2}. \end{aligned} \]

The gradient on the left is the score. It points toward noisy chunks that are more likely. A learned \(D\) gives us an estimate of it, and we can plug that into the probability-flow ODE [3], [4].

\[ \frac{dy}{d\sigma}=-\sigma s_\sigma(y\mid o) =\frac{y-D(y,\sigma,o)}{\sigma}. \]

We follow this equation from high noise down toward zero. The observation stays fixed the whole time, and different starting noise gives different chunks. All of this happens before the robot does anything.

Putting the residual inside the sampler

Keep the base denoiser \(D_B\) frozen and learn \(D_R=D_B+\Delta_\phi\). The residual gets the noisy chunk, the noise level, and the local observation [5]. Plug this into the score and ODE equations.

\[ s_R=s_B+\frac{\Delta_\phi}{\sigma^2},\qquad \frac{dy_R}{d\sigma} =\frac{y_R-D_B(y_R,\sigma,o)}{\sigma} -\frac{\Delta_\phi(y_R,\sigma,o)}{\sigma}. \]

So we're changing the direction the sampler follows while it builds the chunk. This algebra works for the score estimates even if the networks aren't perfect.

The minus sign is easier to see in a discrete step. For decreasing noise levels \(\sigma_k\), let \(c_k=(\sigma_k-\sigma_{k+1})/\sigma_k\). An Euler step gives

\[ y_{k+1}=(1-c_k)y_k+c_kD_B(y_k,\sigma_k,o) +c_k\Delta_\phi(y_k,\sigma_k,o). \]

The correction shows up as \(c_k\Delta_\phi\). It has a plus sign here because the step goes toward lower noise. I used Euler to keep the math short, but a higher-order solver would work too [3]. These equations use clean-action predictions. With the same corruption rule, noise prediction gives \(D=y-\sigma\hat\epsilon\), so \(\Delta_D=-\sigma\Delta_\epsilon\).

Why the final correction isn't just a sum

After one correction, the next denoising step gets a different input. To see how this builds up, multiply the residual by \(\eta\) and start both samplers from the same noise. At \(\eta=0\) we just have the base sampler. Let \(v_k=\left.\partial y_k^\eta/\partial\eta\right|_{\eta=0}\), which tells us how the chunk starts to change when we turn the residual on. Differentiating gives

\[ \begin{aligned} v_{k+1}&=J_kv_k+c_k\Delta_k,\\ J_k&=(1-c_k)I+c_k\nabla_yD_B(y_k^B,\sigma_k,o), \end{aligned} \]

Both \(\Delta_k\) and \(J_k\) are evaluated on the base path. The matrix \(J_k\) tells us how a change in the input passes through the next base step. Since \(v_0=0\), two steps give \(v_2=J_1c_0\Delta_0+c_1\Delta_1\). So the first correction goes through another step before it reaches the output, and that step can make it bigger, smaller, or rotate it. For small \(\eta\), the change after \(K\) steps is about \(\eta v_K\).

This means "small residual" needs some care. If we bound \(\|r\|\leq\varepsilon\), that directly bounds the output change before clipping. For a denoiser residual we also need to know how the later steps respond. And a small change in the action doesn't guarantee the robot moves safely.


What is the residual learning?

For training, we take collaborative demonstrations \((x,o)\sim\mathcal D_C\), add noise to the chunks, and only update the adapter.

\[ \mathcal L_C=\mathbb E_{\mathcal D_C,\sigma,\epsilon} \left[w(\sigma)\left\|D_B(y,\sigma,o)+\Delta_\phi(y,\sigma,o)-x\right\|^2\right], \quad y=x+\sigma\epsilon. \]

If \(w(\sigma)>0\) and the model is big enough, the best residual is \(\Delta^*=\mathbb E_C[x\mid y,\sigma,o]-D_B\). If the base is also an ideal denoiser, we can subtract their score identities.

\[ \Delta^*(y,\sigma,o)=\sigma^2\nabla_y \log\frac{p_{C,\sigma}(y\mid o)}{p_{B,\sigma}(y\mid o)}. \]

I like this equation because it shows the ideal residual fixing the difference between the collaborative score and the base score. That difference can change which action modes the sampler prefers. Also, predicting a mean during training doesn't make every final sample the same. The mean depends on the noisy input, and that's different for each sample.

The adapter can still wreck an old skill even though the base weights never changed. One way to discourage that is to penalize \(\|\Delta_\phi\|^2\) on replay inputs from the original tasks [5]. If the residual were zero along every source sampling path, we'd get the base back exactly. But a small penalty on training examples doesn't guarantee a zero residual on every path.

Which would I use?

If the plan is already good and the gripper just needs a small position fix, I'd start with an action-space residual. It adds one correction pass and could use a fresh observation after sampling. If coordination changes the whole action chunk, I'd try residual denoising. We can train it on noisy expert chunks with the denoising loss, but we pay for the adapter on every denoiser call.

I wouldn't say denoising is better just from this math. A strong output residual that sees the sample can change the distribution too. I'd want to compare them with the same base policy, data, and compute before deciding.

Both still rely on the robot's observations. Putting the correction inside the sampler won't tell a robot what its teammate is doing behind a box.

Summary

Action-space residuals edit a chunk after it's finished. Residual denoising changes the score by \(\Delta_\phi/\sigma^2\) while the chunk is being sampled, so the later steps affect how the correction reaches the output. Both can change the action distribution, and which one is better depends on the task and the compute budget.


References

  1. Cheng Chi et al. Diffusion Policy (Visuomotor Policy Learning via Action Diffusion). RSS, 2023.
  2. Tobias Johannink et al. Residual Reinforcement Learning for Robot Control. ICRA, 2019.
  3. Tero Karras, Miika Aittala, Timo Aila, and Samuli Laine. Elucidating the Design Space of Diffusion-Based Generative Models. NeurIPS, 2022.
  4. Yang Song et al. Score-Based Generative Modeling through Stochastic Differential Equations. ICLR, 2021.
  5. Dayi Dong, Maulik Bhatt, Aayushi Shrivastava, Lasse Peters, and Negar Mehr. Residual Denoising Enables Sample-Efficient Multi-Agent Coordination on Demand. 2026.