Skip to content

Diffusion beyond pictures: DiffDock and Diffusion Policy

Diffusion models can generate a molecule's pose or a robot's next moves. DiffDock diffuses over position, orientation and bond angles, where angles wrap around. Diffusion Policy denoises a chunk of actions and runs only its start.

Advanced ~15 min9 steps

What runs in CodeSplash

You will be able to

  • Describe DiffDock's pose space and why angles need periodic differences
  • Compute a wrapped angle difference
  • Explain Diffusion Policy's action chunks and receding-horizon execution
  • Say what a docking confidence score and a cloned policy do not establish

Read first

01

Diffusion on other spaces

Read

A denoising diffusionDenoising diffusionAdds noise to data in many small steps and trains a network to undo one step; sampling starts from noise and denoises step by step. model learns to remove noise step by step, so it can turn random noise into a sample. The training loss is the same wherever it is used: predict the noise that was added,

L=E ∥ϵ−ϵθ(xk,k,c)∥2,\mathcal{L} = \mathbb{E}\,\lVert \epsilon - \epsilon_\theta(x_k, k, c) \rVert^2 ,

where xkx_k is the noised sample at level kk and cc is what the sample is conditioned on. Here xx is no longer an image: it is a molecule's pose, or a short sequence of robot actions.

How a diffusion sampler turns noise into samples, step by step.

DExplorable · Diffusion: noise schedule, sampler steps, guidance

How does a diffusion model turn noise back into data, and what do the schedule, the steps and guidance change?

With this sampler and number of steps, will the samples match the data?

How sure?

β schedule

250

The forward process at this step: how much signal is left.

Sampler

DDPM adds fresh noise every step; DDIM is deterministic.

50
0.0

0 = unconditional, 1 = plain conditional, above 1 = guided.

Class to guide toward

400
  • Noised samples
  • Exact q(xₜ)
  • Samples
  • Data

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

02

DiffDock: where does the ligand sit?

Read

Docking asks how a small molecule (the ligand) sits in a protein pocket. DiffDockDiffDockA docking model that samples a ligand's pose by diffusion over its position, orientation and bond angles, then ranks the samples. samples poses by diffusion over the pose's real degrees of freedom: a translation in R3\mathbb{R}^3, a rotation in SO(3)SO(3), and mm torsion anglesTorsion angleThe twist around a rotatable bond. It is periodic, so 179° and −179° are 2° apart, not 358°. on a torus Tm\mathbb{T}^m. Each part gets its own noise and score, suited to its space.

A separate confidence model ranks the sampled poses. Its score orders candidates; it is not a calibrated probability of binding, and a good pose is not a measured affinity or a biological effect.

Reference · SEQ013 · Explained hereDiffDockA generative docking method sampling ligand poses relative to a protein using diffusion over translation, rotation, and rotatable-bond torsions. A separate confidence model ranks candidate poses.
03

Angles wrap around

Explore

A torsion angle of 179° and one of −179° are 2° apart, not 358°. The reference computes both: the naive difference is −358° and the wrapped one 2°. Noise, scores and errors on angles must use the wrapped version, or the model learns to move the long way round.

Python
import numpy as np
a, b = np.deg2rad(179.), np.deg2rad(-179.)
print(np.rad2deg(b - a), np.rad2deg(np.arctan2(np.sin(b - a), np.cos(b - a))))   # naive, wrapped
R
a <- 179 * pi / 180; b <- -179 * pi / 180
print(c((b - a) * 180 / pi, atan2(sin(b - a), cos(b - a)) * 180 / pi))           # naive, wrapped

The same wrap breaks ordinary averages of directions. Put the true direction near the 0° seam and compare the two means:

AExplorable · The mean of an angle

What is the average of 350° and 10°?

What does the ordinary arithmetic mean of these angles come to?

180
How sure?
350
25
30
0°90°180°270°

Solid arrow: the circular mean, 344.3°, with length R̄ = 0.89. Dashed red: the arithmetic mean, 236.5°, which can point away from every observation.

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

04

Diffusion Policy: a chunk of actions

Read

Diffusion PolicyDiffusion PolicyA robot policy learned from demonstrations that denoises a short sequence of future actions, conditioned on recent observations. learns robot control from demonstrations, a form of behavior cloningBehavior cloningLearns to copy the logged actions from the states (here a multinomial logistic regression): a baseline every learned policy should beat.. Given recent observations oo, it denoises a whole action chunkAction chunkA block of future actions predicted at once; the controller runs only the first few, then observes and predicts again. AA, a short sequence of future actions:

Ak=αˉk A+1−αˉk ϵ.A_k = \sqrt{\bar\alpha_k}\,A + \sqrt{1 - \bar\alpha_k}\,\epsilon .

The robot executes only the first few actions, observes again and predicts a new chunk. Predicting a chunk keeps motions smooth, and diffusion can represent several valid ways to do a task instead of averaging them into an invalid one.

Reference · SEQ010 · Explained hereDiffusion PolicyA behavior-cloning approach modeling observation-conditioned sequences of robot actions with diffusion. It generates an action chunk and executes a prefix before replanning with new observations.
05

The reference's two pieces

Read

The reference shows two components on a four-step, two-joint chunk. A denoiser that predicts 0.8 times the true noise scores a noise error of 0.00105. With a two-step execution horizon, the robot runs the first two actions, (0.1, 0.0) then (0.2, 0.1), and replans.

A longer executed prefix replans less often, but it acts longer without feedback.

06

What cloning doesn't promise

Predict

Predict first

A cloned policy imitates demonstrations closely on held-out demo frames. What happens when it runs on the robot?

It stays as reliable as on the demonstrationsSmall errors can lead it to states the demonstrations never showed
Reveal

It can drift. Each small error changes the next observation, and the robot can end up in states no demonstration covered, where the policy has no guidance. Evaluate success on the real or simulated task from varied starting states; low denoising loss shows neither safety nor success.

07

What runs here

Read
08

Check: diffusion beyond pictures

Checkpoint

Check yourself

Over which degrees of freedom does DiffDock diffuse a ligand's pose?

Show the answer

Answer: b

The pose lives in R3×SO(3)×Tm\mathbb{R}^3 \times SO(3) \times \mathbb{T}^m, and each part gets noise suited to its space.

Check yourself

How many degrees apart are torsion angles of 179° and −179°, going the short way?

Show the answer

Answer: 1.9999999999999918

Angles wrap at ±180°, so the short way round is 2°, not 358°.

Check yourself

DiffDock's confidence model gives a pose a high score. What does that tell you?

Show the answer

Answer: c

Pose ranking is not affinity, and neither is a biological claim. Related proteins in train and test also inflate random-split scores.

Check yourself

Diffusion Policy predicts eight future actions and executes two. Why not execute all eight?

Show the answer

Answer: a

Receding-horizon execution trades fewer replanning calls against acting longer without feedback.

Check yourself

Demonstrators sometimes go left around an obstacle and sometimes right. Why does a diffusion policy handle this better than a model trained by mean squared error on single actions?

Show the answer

Answer: b

A generative policy represents several modes. Regression to the mean picks the average of the modes.

Check yourself

What evidence shows a cloned policy works?

Show the answer

Answer: b

Imitation error compounds when the policy acts. Only task-level evaluation shows success, and safety needs its own checks.

09

Recap

Recap
  • Diffusion's noise-prediction loss carries over to poses and action sequences.
  • DiffDock diffuses over translation, rotation and torsion angles; angles need wrapped differences.
  • Diffusion Policy denoises action chunks and executes only their start before replanning.
  • Confidence isn't affinity; imitation loss isn't task success. Both are explained here only.

Concepts in this lesson