Score-based Generative Modeling Secretly Minimizes the Wasserstein Distance

Dohyun Kwon, Ying Fan, Kangwook Lee

Score-based generative models—the mathematical engines powering modern diffusion models like Stable Diffusion—are typically trained to match the "score" (the gradient of the log-density) of a data distribution. While previous research linked this training objective to the minimization of Kullback–Leibler (KL) divergence, this NeurIPS 2022 paper proves these models are simultaneously optimizing for the Wasserstein distance. By bridging score matching and optimal transport theory, the authors provide a new theoretical guarantee for the convergence and robustness of diffusion models.

The Problem with KL Divergence

Generative modeling aims to create a model distribution ($q_0$) that perfectly mimics a real data distribution ($p_0$). Score-based models achieve this by gradually adding noise to data (the forward process) and learning to reverse that noise (the reverse process) using a learned score function.

Until recently, our theoretical understanding of why this works was tied to KL divergence. However, KL divergence has a major mathematical weakness: if the model and data distributions do not overlap perfectly (i.e., they have disjoint supports), the KL divergence can become infinite or undefined.

The Wasserstein distance (often called the "Earth Mover's Distance") is much better behaved in these scenarios because it measures the geometric cost of transporting probability mass from one distribution to another. The authors set out to answer a fundamental question: Do score-based models minimize the Wasserstein distance, even though they aren't explicitly trained to do so?

Bridging Score Matching and Optimal Transport

To answer this, the authors utilize the machinery of Optimal Transport and Partial Differential Equations (PDEs) to analyze how these distributions evolve.

  1. Continuity Equations: They represent the forward and reverse diffusion processes as "velocity fields" moving probability mass over time.
  2. Upper Bounding the Distance: They derive a mathematical proof showing that the 2-Wasserstein distance ($W_2$) is upper-bounded by the square root of the score-matching loss ($J_{SM}$), plus a small constant offset related to the prior noise distribution.
  3. Practical Loss Functions: Because the true score matching loss ($J_{SM}$) is often intractable, they extend their proof to Denoising Score Matching ($J_{DSM}$), the standard loss function used in practice (e.g., in Denoising Diffusion Probabilistic Models).
  4. One-Sided Lipschitz Condition: To ensure the math holds, they assume the learned score function satisfies a "one-sided Lipschitz condition," which limits how wildly the score function can change across the data space.

Empirical Verification

Because the paper focuses on fundamental theory, the authors validated their bounds using synthetic 1D and 2D datasets where the ground truth is known and the exact Wasserstein distance can be calculated. These included simple single Gaussian clusters and multi-modal mixtures.

Training curves showing the correlation between Wasserstein distance, KL divergence, and DSM loss across different synthetic datasets.

The key empirical results strongly support the theoretical claims:

  • The Square Root Relationship: Both theory and experiments confirm that $W_2 \propto \sqrt{Loss}$. In log-log plots of training curves, the relationship between the Wasserstein distance and the loss function shows a consistent slope of 0.5.
  • Correlated Convergence: On all tested datasets, as the training objective ($J_{DSM}$) decreased, the Wasserstein distance decreased alongside it. The model naturally aligns with the $W_2$ metric without explicit knowledge of it.
  • Time Horizon ($T$): The authors showed that as the diffusion time $T$ increases, the "offset" term in their theoretical bound decays exponentially. This means longer diffusion processes lead to better alignment with the true data distribution.

Implications and Limitations

This "secret" connection reveals that score matching isn't just a local trick to learn density gradients; it has global geometric implications. Minimizing the mean squared error of the score function automatically forces the model distribution closer to the data distribution in a Wasserstein sense.

Furthermore, the "tightness" of this theoretical bound depends on the Lipschitz constant of the neural network. The authors note that regularization techniques like spectral normalization or weight clipping can make the theoretical bound tighter, though this introduces a trade-off with raw training performance.

While the theory holds for any dimension, calculating the one-sided Lipschitz constant for a deep neural network is NP-hard. This makes it difficult to calculate the exact value of the upper bound for complex, high-dimensional models like ImageNet generators. Future work will likely focus on finding ways to tighten these bounding constants to provide more precise guarantees for real-world diffusion models.

Summary updated

BibTeX
@inproceedings{kwon2022score,
  author = {Dohyun Kwon and Ying Fan and Kangwook Lee},
  title = {{Score-based Generative Modeling Secretly Minimizes the Wasserstein Distance}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=Btnq5ZTEZi},
}
Figure