ID-5-02 (TO) · Mathematical Foundations of Diffusion Models · W03 demo

The KL Lab

KL divergence is not symmetric, and the asymmetry is not a technicality. Fit the same single Gaussian to the same bimodal data and the two directions give genuinely different answers: one covers everything, the other picks a mode and ignores the rest.

Act ISame target, same family, two answers

The grey curve is the target p: a mixture of two Gaussians. The model family is deliberately too poor to represent it — a single Gaussian q. There is no fit that is right, so the choice of what "close" means decides everything.

forward: KL(p∥q) = ∫ p log(p/q)      reverse: KL(q∥p) = ∫ q log(q/p)

Both optima, drawn together

reverse KL started from:
fitμσKL(p∥q)KL(q∥p)
target p forward optimum reverse optimum
Read the table across, not down. Each fit is the best possible under its own criterion and looks terrible under the other — and the gap is not small. Notice too that the reverse-KL answer changes with where you start it: the objective has one basin per mode.

Act IIWhere each direction pays its penalty

Drag q yourself and watch the two integrands. Both are integrals of a weighted log-ratio, but the weight differs, and that is the entire story: the forward integrand is weighted by p, the reverse by q.

Pointwise contribution to each integral

p q forward integrand p·log(p/q) reverse integrand q·log(q/p)
Put q on one mode. The forward integrand explodes over the abandoned mode — p is large there and q is nearly zero, so log(p/q) is huge and p weights it fully. The reverse integrand cannot see that region at all, because it is weighted by q, which is zero there. Forward KL is mass-covering; reverse KL is zero-forcing.

Act IIITwo landscapes

Sweep the mean of q across the axis, holding σ at its best value for each μ, and plot both objectives. The shapes are qualitatively different, and that difference is why one optimisation is easy and the other depends on initialisation.

Objective against μ, with σ optimised

Forward KL has a single minimum, sitting between the modes where no data actually lives. Reverse KL has one minimum per mode and a barrier between them — gradient descent finds whichever it started nearest, and never crosses.

Which one you are using is rarely a free choice. Maximum likelihood is forward KL, so likelihood-trained models are mass-covering: they put probability on everything they saw, which is one reason they generate blurry averages. Variational inference and the ELBO minimise reverse KL, so they are zero-forcing: they lock on and underestimate spread. Same data, same family, opposite pathologies — from a single swap of argument order.