Diffusion and Flow World Models › Conditional Denoising Dynamics
World Models HandbookAll chapters Diffusion and Flow World Models › Conditional Denoising DynamicsOne section · Sections in this chapter2 / 9 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The object we want to model is a conditional distribution , where is the target (a next state, a latent, or an entire trajectory) and is the conditioning signal (the current state and action, plus anything else we choose to observe). In a world-modeling context, and , but we will keep the notation general. The Gaussian construction below applies directly to suitably scaled continuous Euclidean targets, including scalar states, vector encodings, latents, and flattened horizons. Periodic, discrete, manifold-valued, or hard-constrained targets may require a different representation or corruption process.
A standard Gaussian DDPM defines a forward corruption process that progressively corrupts . Let be the scalar noise variance at step , define and , and let be the identity matrix matching the target dimension. With suitable data scaling and a schedule for which is near zero, the terminal marginal is close to a Gaussian base. A network then learns approximate reverse conditionals rather than exactly inverting each realized corruption path. The forward process is Markovian, meaning each step depends only on the immediately preceding state:
The schedule typically starts with small values and grows until is nearly zero. Each step multiplies the preceding state by and adds noise with amplitude , equivalently covariance . For , the marginal signal-to-noise ratio decreases with . Low-noise levels preserve fine detail and are traversed near the end of reverse sampling; sufficiently high cumulative noise makes the terminal marginal close to a simple Gaussian base. A useful bookkeeping identity, derived by composing Gaussians, gives the marginal distribution of directly from :
Equivalently, with . This closed form makes training tractable by jumping directly from to . Without it, producing would require simulating forward transitions, about on average under uniform timestep sampling, which would be prohibitively expensive for the thousand-step schedules used in early DDPM experiments.
The closed-form marginal above lets us visualize the forward corruption process directly. The plot below shows several noisy trajectories along a linear schedule, together with the signal amplitude .
import numpy as np
# Small linear schedule for visualization.
betas_viz = np.linspace(1e-4, 0.05, 200)
alphas_viz = 1.0 - betas_viz
alpha_bars_viz = np.cumprod(alphas_viz)
x0_viz = 1.0
viz_rng = np.random.default_rng(42)
viz_trajectories = []
for _ in range(5):
x_t_viz = x0_viz
path_viz = []
for alpha_t_viz, beta_t_viz in zip(alphas_viz, betas_viz):
x_t_viz = (
np.sqrt(alpha_t_viz) * x_t_viz
+ np.sqrt(beta_t_viz) * viz_rng.normal()
)
path_viz.append(x_t_viz)
viz_trajectories.append(path_viz)
viz_trajectories = np.stack(viz_trajectories, axis=0)
signal_viz = np.sqrt(alpha_bars_viz)
timesteps_viz = np.arange(1, len(betas_viz) + 1)
Many canonical diffusion implementations fix a hand-designed schedule , although learned and optimized schedules also exist. A linear schedule from to was the original DDPM experimental default from Ho, Jain, and Abbeel (2020). Nichol and Dhariwal (2021) found a cosine schedule helpful in their image experiments because it preserved information longer than the linear schedule they tested. For world models, the schedule must be evaluated against the scale and distribution of the target. The terminal cumulative signal should be small enough that the chosen Gaussian base is a good approximation, while early noise levels should still expose fine state differences. There is no scale-only rule saying that values in require a particular terminal schedule.
Training consists of one pleasantly simple objective. Sample a timestep , sample from the data, sample , and ask the network to predict the noise:
Despite its simplicity, this objective is a denoising score matching loss in disguise. The optimal predictor satisfies
At each fixed timestep, the population-optimal score is obtained from the noise predictor as . Across timesteps, the unweighted noise loss corresponds to a timestep-weighted score-matching objective. The connection, developed in denoising score matching and used by DDPMs, avoids asking the network to evaluate or normalize a density explicitly. An exact score still has the integrability structure of a log-density gradient; the practical convenience is that training does not require computing a partition function.
A score field gives a complementary local view of a density: it shows the direction and strength of increasing log density. For the well-separated symmetric mixture below, the score is zero at the midpoint and at the two mixture modes, whose locations are numerically indistinguishable from the component means, and points outward toward the modes between those zeros. The stabilized finite-difference curve preserves these central directions and zero crossings; adding to the density before taking its logarithm attenuates the far-tail score magnitude.
import numpy as np
# Score field for a symmetric two-component Gaussian mixture.
x_grid = np.linspace(-3.0, 3.0, 601)
mu_left, mu_right, sigma_mix = -1.2, 1.2, 0.25
density_left = np.exp(-0.5 * ((x_grid - mu_left) / sigma_mix) ** 2) / (
sigma_mix * np.sqrt(2.0 * np.pi)
)
density_right = np.exp(-0.5 * ((x_grid - mu_right) / sigma_mix) ** 2) / (
sigma_mix * np.sqrt(2.0 * np.pi)
)
density_mix = 0.5 * density_left + 0.5 * density_right
log_density_mix = np.log(density_mix + 1e-12)
score_mix = np.gradient(log_density_mix, x_grid)
At sampling time we start from a new Gaussian draw and apply learned reverse-time transitions; this approximates the time reversal of the forward distributional dynamics rather than undoing a realized noise path. For sufficiently small and a regular noisy marginal density, the local conditional is approximately Gaussian; by contrast, is exactly Gaussian for this forward process. Define . In the common epsilon parameterization, the reverse-model mean is
With the fixed-variance choice used in this chapter's code, sampling iterates with for , then uses the mean at . Other DDPM implementations use the forward-posterior variance or a learned variance. Fresh noise makes ancestral paths stochastic; deterministic samplers instead obtain diversity solely from their initial draw. A useful denoised estimate is
This quantity estimates a clean target compatible with the noisy sample; it does not recover a unique originating example. Samplers can be written using data, score, noise, or velocity predictions. These forms are algebraically convertible when they represent the same exact field under one schedule, but separately trained finite-capacity implementations need not behave identically. Some updates are deterministic, some add noise, and multistage solvers may spend several network evaluations per accepted step. We revisit these choices in the sampling-tradeoff section and implement DDPM and DDIM in the worked example.
To model rather than the marginal next-state distribution, the network must receive the relevant conditioning. The simple formulation here uses the current state and action, but a one-step model may also condition on histories, beliefs, observations, or goals. Implementations concatenate these features or inject them through mechanisms such as cross-attention. When a learned score accurately represents a separated bimodal conditional, its reverse-time dynamics can transport different base samples toward different modes instead of returning only their conditional mean.