Optimal and Diffusion Transports in Machine Learning

Gabriel PeyréarXiv 2025 · DOI

Abstract

Modern machine learning is increasingly characterized by the transformation of high-dimensional probability distributions. This paper synthesizes a unifying mathematical framework that bridges generative modeling, neural network optimization, and transformer dynamics. By viewing these processes through the lens of Optimal Transport (OT) and Diffusion, we can describe the evolution of data and parameters as "flows" governed by the continuity equation. This survey explores the Eulerian and Lagrangian perspectives of these flows, the scalability of Flow Matching, and the emerging interpretation of Transformers as continuous fluid systems.

Introduction

At its core, much of machine learning is a study of transformation. Whether we are mapping noise to a realistic image in generative AI, adjusting network weights to minimize a loss function during training, or processing sequences of tokens in a Transformer, we are essentially moving from one state to another in a high-dimensional space.

Historically, these domains were treated as distinct: generative models relied on stochastic processes, optimization was viewed through the lens of discrete calculus, and Transformers were analyzed as black-box architectural innovations. This paper addresses the need for a unified language to describe these phenomena. By treating data points and parameters as probability measures, we can apply the tools of fluid dynamics and differential geometry to understand how information flows through artificial intelligence systems.

The Mathematical Foundation: Flows and Continuity

The unifying principle of this framework is the continuity equation, a partial differential equation (PDE) that describes how a density evolves over time under the influence of a vector field. The paper distinguishes between two primary ways to analyze these moving distributions:

  1. The Eulerian Perspective: This view tracks how the overall density changes at fixed points in space, akin to observing the flow of a river from a stationary bridge.
  2. The Lagrangian Perspective: This view follows individual "particles" or data points as they move through space, similar to riding a leaf down a stream.

By switching between these perspectives, researchers can choose the mathematical tools best suited for the problem—whether it is analyzing the global convergence of a model or the specific trajectory of a single data sample.

Generative Modeling: From Optimal Transport to Flow Matching

Generative AI has seen a shift from traditional Optimal Transport (OT) toward more scalable techniques like Flow Matching. While OT seeks the "least-effort" path to move one distribution to another, it is often computationally prohibitive for high-dimensional data.

Flow Matching simplifies this by solving an unconstrained least-squares problem to learn the vector field that pushes a simple distribution (e.g., a Gaussian) toward a complex data distribution. The paper notes a "structural gap" between these methods: while OT moves particles along the straightest possible lines, Diffusion and Flow Matching effectively "blur" the data via convolution to create a path. These methods only coincide when the data's covariance matrices commute, such as when starting from a standard isotropic Gaussian.

Optimization as Wasserstein Gradient Flow

A significant insight of this survey is the treatment of neural network training as a Wasserstein Gradient Flow. In this view, training a network is not just a series of discrete weight updates but a "steepest descent" in the space of probability measures.

This theoretical shift allows for rigorous proofs of global convergence. For instance, the paper highlights that for shallow (two-layer) networks, training will always converge to a global optimum provided the initial weights are sufficiently "spread out" (possessing a density relative to the Lebesgue measure). This provides a mathematical explanation for why over-parameterized models often find high-quality solutions.

Transformers and Mean-Field Dynamics

One of the most striking applications of this framework is the modeling of deep Transformers as a "Transformer PDE." By applying mean-field theory, the billions of tokens in a large language model are treated as a continuous fluid rather than discrete points.

This perspective reveals that the self-attention mechanism acts as a force causing tokens to cluster together, explaining how these models focus on relevant context. Furthermore, the paper notes that deep Transformers are "universal in-context learners," meaning they are mathematically capable of approximating any continuous mapping between sets of tokens, providing a theoretical backbone for the versatility of Large Language Models (LLMs).

Key Results and Simplifications

  • Gaussian Simplification: In cases where data or neurons follow Gaussian distributions, the complex PDEs of these systems collapse into solvable Riccati-type Ordinary Differential Equations (ODEs).
  • Global Convergence: The Wasserstein flow perspective confirms that shallow MLPs can reach global minimizers under specific initialization conditions.
  • The Structural Gap: The paper quantifies the divergence between Flow Matching and OT, highlighting that the geometric properties of diffusion fields remain a fertile ground for future research.

Limitations and Future Directions

Despite the elegance of this unified view, several challenges remain. While the theory for shallow networks is robust, extending global convergence guarantees to truly deep architectures is an outstanding problem. Additionally, most current theory assumes continuous time and infinite data; understanding how discretization errors propagate in real-world, finite-sample scenarios is critical. Finally, while the forward pass of a Transformer is well-modeled as a PDE, the training of those Transformer parameters remains largely unexplored in this framework.

Summary updated

BibTeX
@misc{peyre2025optimal,
  author = {Gabriel Peyré},
  title = {{Optimal and Diffusion Transports in Machine Learning}},
  year = {2025},
  eprint = {2512.06797},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.06797},
}
Figure