All in One: Generative Modeling as Mean-Field Game Design
Summary
This paper unifies twelve continuous-time generative models under mean-field game theory via a cost tuple, introduces MFGLab (a PyTorch library that auto-shares training loops and solvers), and proposes DI-Flow with differentiable entropy for better mode coverage.
View Cached Full Text
Cached at: 07/28/26, 06:24 AM
# Generative Modeling as Mean-Field Game Design
Source: [https://arxiv.org/html/2607.23026](https://arxiv.org/html/2607.23026)
###### Abstract
Mean\-field games \(MFGs\) offer a unifying lens on continuous\-time generative modeling: choosing a cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\)recovers twelve prominent models—Continuous Normalizing Flows, OT\-Flow, Score\-based Models, Schrödinger Bridges, and more—as special cases of one variational problem\. Yet two dimensions of this space remain entirely unexplored: the interaction termℐ\\mathcal\{I\}is set to zero in many existing models, and the rich family of MFG solvers has never been applied to generative modeling\. We address both gaps with MFGLab an open\-source PyTorch library whose primary API is the cost tuple: all twelve models are specified by four composable cost functions, and the training loop, log\-Jacobian, and reverse\-ODE sampler are shared automatically\. We additionally propose DI\-Flow, a novel cost design that uses a differentiable entropy functional to encourage mode coverage, and provide learning\-based MFG solvers that substantially outperform neural training on stochastic\-dynamics rows\. Experiments on two 2\-D benchmarks confirm that the unified API is lossless relative to hand\-coded implementations\.
## 1Introduction
Mean\-field games \(MFGs\)Huanget al\.\([2006](https://arxiv.org/html/2607.23026#bib.bib1)\); Lasry and Lions \([2007](https://arxiv.org/html/2607.23026#bib.bib2)\)provide a tractable framework for modelling strategic interactions in a large, rational population\. As the number of agentsN→∞N\\to\\infty, the intractable Nash equilibrium of theNN\-player game converges to a*mean\-field equilibrium*\(MFE\)—a self\-consistent pair of a backward Hamilton\-Jacobi\-Bellman \(HJB\) equation encoding each agent’s optimal response and a forward Fokker\-Planck\-Kolmogorov \(FPK\) equation propagating the population density\. This mean\-field limit bypasses the curse of dimensionality of finite\-player formulations and has been applied to economics, autonomous drivingChenet al\.\([2023](https://arxiv.org/html/2607.23026#bib.bib5)\); Zhouet al\.\([2024](https://arxiv.org/html/2607.23026#bib.bib4)\), epidemiology, and energy systems\.
Solving the MFE is a central algorithmic challenge, with approaches ranging from classical fixed\-point iteration between the HJB and FPK equationsLaurièreet al\.\([2022](https://arxiv.org/html/2607.23026#bib.bib22)\)to reinforcement\-learning\-based dynamic programmingGuoet al\.\([2019](https://arxiv.org/html/2607.23026#bib.bib20)\); Perrinet al\.\([2020](https://arxiv.org/html/2607.23026#bib.bib21)\)and recent semi\-gradient methods that update policy and population jointlyZhanget al\.\([2025](https://arxiv.org/html/2607.23026#bib.bib3)\); Zhouet al\.\([2024](https://arxiv.org/html/2607.23026#bib.bib4)\)\.
Beyond these classical multi\-agent settings, a striking connection to*generative modeling*was established inZhang and Katsoulakis \([2023](https://arxiv.org/html/2607.23026#bib.bib6)\): every major continuous\-time generative model— Continuous Normalizing FlowsChenet al\.\([2018](https://arxiv.org/html/2607.23026#bib.bib7)\); Grathwohlet al\.\([2019](https://arxiv.org/html/2607.23026#bib.bib8)\), OT\-FlowOnkenet al\.\([2021](https://arxiv.org/html/2607.23026#bib.bib9)\), Score\-based Generative ModelsSonget al\.\([2021](https://arxiv.org/html/2607.23026#bib.bib10)\); Hoet al\.\([2020](https://arxiv.org/html/2607.23026#bib.bib11)\), Schrödinger Bridges, Wasserstein Gradient FlowsLiutkuset al\.\([2019](https://arxiv.org/html/2607.23026#bib.bib13)\); Chewiet al\.\([2020](https://arxiv.org/html/2607.23026#bib.bib14)\), and Boltzmann GeneratorsNoéet al\.\([2019](https://arxiv.org/html/2607.23026#bib.bib12)\)—arises as a special case of a single MFG variational problem parameterised by a cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\):
infv,ρℳ\(ρT\)⏟terminal cost\+∫0Tℐ\(ρt\)⏟interaction term𝑑t\+∫0T∫ℒ\(x,v\(x,t\)\)⏟running costρ\(x,t\)𝑑x𝑑t,\\inf\_\{v,\\,\\rho\}\\;\\underbrace\{\\mathcal\{M\}\(\\rho\_\{T\}\)\}\_\{\\text\{terminal cost\}\}\+\\int\_\{0\}^\{T\}\\underbrace\{\\mathcal\{I\}\(\\rho\_\{t\}\)\}\_\{\\text\{interaction term\}\}\\,dt\+\\int\_\{0\}^\{T\}\\\!\\\!\\int\\underbrace\{\\mathcal\{L\}\(x,v\(x,t\)\)\}\_\{\\text\{running cost\}\}\\,\\rho\(x,t\)\\,dx\\,dt,\(1\)subject to the Fokker\-Planck constraint∂tρ\+∇⋅\(vρ\)=σ22Δρ\\partial\_\{t\}\\rho\+\\nabla\\\!\\cdot\(v\\rho\)=\\frac\{\\sigma^\{2\}\}\{2\}\\Delta\\rho, withρ\(⋅,0\)=π\\rho\(\\cdot,0\)=\\pithe data distribution\. Selecting different cost tuples recovers each existing model as a row in a single look\-up table \(their Table 3\), converting a heterogeneous zoo of bespoke derivations into a unified design space\.
Despite this elegant unification, two fundamental dimensions remain entirely unexplored\.First, the*interaction term*ℐ\(ρt\)\\mathcal\{I\}\(\\rho\_\{t\}\)—the feature that makes \([1](https://arxiv.org/html/2607.23026#S1.E1)\) a genuinely*mean\-field*\(population\-aware\) objective—is set to zero in most existing models, or at best fixed to a predetermined analytical expression \(e\.g\. Fisher information for Score PF\)\. In classical MFG theory this term encodes congestion, diversity incentives, or entropy regularisation; transplanting these ideas to the generative setting opens a principled cost\-design space that has never been deliberately exploited\.Second, all twelve models are solved exclusively by gradient\-based neural training, and the wealth of solvers developed for classical MFG equilibrium learningGuoet al\.\([2019](https://arxiv.org/html/2607.23026#bib.bib20)\); Laurièreet al\.\([2022](https://arxiv.org/html/2607.23026#bib.bib22)\); Zhanget al\.\([2025](https://arxiv.org/html/2607.23026#bib.bib3)\)has never been applied to generative modeling\.
Figure 1:Overview of this paper’s three contributions\.Framework:MFGLabunifies all twelve MFG taxonomy models under a single cost\-tuple API\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\); changing only the cost tuple produces any model in the taxonomy\.Cost Design: a principled framework for designing the interaction termℐ\(ρt\)\\mathcal\{I\}\(\\rho\_\{t\}\);DI\-Flowis a concrete instantiation using a differentiable KDE entropy functional that achieves the best KDE log\-likelihood among deterministic baselines on the Ring GMM benchmark\.Solvers:VI\(grid\-based backward DP,<1\{<\}1s\) andMFG\-AC\(two\-timescale actor\-critic, no log\-Jacobian\) bring MFG equilibrium algorithms to generative modeling\.#### Contributions\.
We address the above gaps through three coordinated contributions\.
1. 1\.Framework\. We developMFGLab, an open\-source PyTorch library in which any model is fully specified by a cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\); the training loop, log\-Jacobian, and reverse\-ODE sampler are shared automatically across all twelve MFG taxonomy modelsZhang and Katsoulakis \([2023](https://arxiv.org/html/2607.23026#bib.bib6)\)\. Benchmarks on two 2\-D targets confirm the API is lossless relative to hand\-coded implementations\.
2. 2\.Cost Design\. We propose a design framework for the interaction termℐ\(ρt\)\\mathcal\{I\}\(\\rho\_\{t\}\)that lets practitioners encode population\-level objectives—congestion, diversity, entropy regularisation—into the generative trajectory\. The concrete instantiationDI\-Flowachieves the best KDE log\-likelihood among deterministic \(σ=0\\sigma\{=\}0\) baselines on the Ring GMM benchmark\.
3. 3\.Solvers\. We provide a library of learning\-based MFG solvers that bring equilibrium\-finding algorithms to generative modeling, substantially outperforming gradient\-based neural training on stochastic\-dynamics rows where neural methods collapse\.
## 2Preliminary
### 2\.1MFG as a Generative Modeling Problem
The MFG variational problem introduced in \([1](https://arxiv.org/html/2607.23026#S1.E1)\) belongs to the class of*potential*MFGs, where the interaction termℐ\(ρt\)\\mathcal\{I\}\(\\rho\_\{t\}\)is a functional of the population density rather than of any individual agent\. In the generative modeling context, agents are data particles transported from the data distributionπ\\pito a reference distribution \(typically a standard Gaussian\) by a neural velocity fieldvθv\_\{\\theta\}\. The cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\)controls the shape of this transport: the terminal costℳ\\mathcal\{M\}penalises how far the endpoint distribution is from the target; the running costℒ\\mathcal\{L\}penalises the kinetic energy of the trajectory; the interaction termℐ\\mathcal\{I\}encodes population\-level objectives such as entropy or congestion; andσ\\sigmacontrols the level of stochastic noise injected along the path\.
The optimality conditions of \([1](https://arxiv.org/html/2607.23026#S1.E1)\) yield the coupled FPK–HJB system:
Forward FPK:∂tρ\+∇⋅\(v∗ρ\)=σ22Δρ,ρ\(⋅,0\)=π,\\displaystyle\\partial\_\{t\}\\rho\+\\nabla\\\!\\cdot\(v^\{\*\}\\rho\)=\\tfrac\{\\sigma^\{2\}\}\{2\}\\Delta\\rho,\\quad\\rho\(\\cdot,0\)=\\pi,\(2\)Backward HJB:−∂tU\+H\(x,∇U\)\+δℐδρ=σ22ΔU,\\displaystyle\-\\partial\_\{t\}U\+H\(x,\\nabla U\)\+\\tfrac\{\\delta\\mathcal\{I\}\}\{\\delta\\rho\}=\\tfrac\{\\sigma^\{2\}\}\{2\}\\Delta U,\(3\)whereH\(x,p\)=supv\[−p⊤v−ℒ\(x,v\)\]H\(x,p\)=\\sup\_\{v\}\[\-p^\{\\top\}v\-\\mathcal\{L\}\(x,v\)\]is the Hamiltonian\. The FPK equation \([2](https://arxiv.org/html/2607.23026#S2.E2)\) propagates the population density*forward*in time under the optimal velocity fieldv∗v^\{\*\}, starting from the data distributionπ\\pi\. The HJB equation \([3](https://arxiv.org/html/2607.23026#S2.E3)\) propagates the value functionUU\(the cost\-to\-go for each agent\)*backward*in time; its gradient∇U\\nabla Uencodes the optimal control viav∗=argmaxv\[−\(∇U\)⊤v−ℒ\(x,v\)\]v^\{\*\}=\\arg\\max\_\{v\}\[\-\(\\nabla U\)^\{\\top\}v\-\\mathcal\{L\}\(x,v\)\]\. The variational derivativeδℐ/δρ\\delta\\mathcal\{I\}/\\delta\\rhoacts as a coupling term: it feeds the current population density back into each agent’s cost, making the problem genuinely mean\-field\. Solving the MFE amounts to finding a velocity fieldv∗v^\{\*\}and densityρ\\rhothat satisfy both equations simultaneously—a forward\-backward fixed\-point problem that is central to all MFG algorithmsLaurièreet al\.\([2022](https://arxiv.org/html/2607.23026#bib.bib22)\)\.
### 2\.2Particle Training Objective
In practice, most existing methods parametrise the velocity field with a neural networkvθv\_\{\\theta\}and optimise the MFG objective by following individual particles \(data samples\) along the induced flow\. For the deterministic caseσ=0\\sigma=0andℐ=0\\mathcal\{I\}=0, integrating the continuity equation along the flow converts the population\-level objective into a per\-particle loss that can be minimised by stochastic gradient descent:
ℒ\(θ\)=𝔼x0∼π\[ℳparticle\(xT,Δlog\)\+∫0Tℒ\(xt,vθ\(xt,t\),t\)𝑑t\],\\mathcal\{L\}\(\\theta\)=\\mathbb\{E\}\_\{x\_\{0\}\\sim\\pi\}\\\!\\left\[\\mathcal\{M\}\_\{\\mathrm\{particle\}\}\\\!\\left\(x\_\{T\},\\,\\Delta\\\!\\log\\right\)\+\\int\_\{0\}^\{T\}\\mathcal\{L\}\\\!\\left\(x\_\{t\},v\_\{\\theta\}\(x\_\{t\},t\),t\\right\)dt\\right\],\(4\)where each particlextx\_\{t\}follows the ODEx˙=vθ\(x,t\)\\dot\{x\}=v\_\{\\theta\}\(x,t\)andΔlog=∫0T∇⋅vθ𝑑t\\Delta\\\!\\log=\\int\_\{0\}^\{T\}\\nabla\\\!\\cdot\\,v\_\{\\theta\}\\,dtis the accumulated log\-determinant of the flow Jacobian, required to track density changes along the trajectory\. For the standard terminal costℳ=KL\(ρT∥𝒩\(0,I\)\)\\mathcal\{M\}=\\mathrm\{KL\}\(\\rho\_\{T\}\\\|\\mathcal\{N\}\(0,I\)\), the per\-particle terminal term evaluates to:
ℳparticle\(xT,Δlog\)=−logρref\(xT\)−Δlog,\\mathcal\{M\}\_\{\\mathrm\{particle\}\}\(x\_\{T\},\\Delta\\\!\\log\)=\-\\log\\rho\_\{\\mathrm\{ref\}\}\(x\_\{T\}\)\-\\Delta\\\!\\log,\(5\)which is the standard negative log\-likelihood of a normalizing flow\. The log\-Jacobian termΔlog\\Delta\\\!\\logis the main computational bottleneck of this approach, requiring either exact trace computation or stochastic estimation via Hutchinson’s trick\.
### 2\.3Cost Functions and the Model Taxonomy
The power of the MFG formulation is that changing only the cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\)yields a completely different generative model, while the underlying optimality structure—equations \([2](https://arxiv.org/html/2607.23026#S2.E2)\) and \([3](https://arxiv.org/html/2607.23026#S2.E3)\)—remains the same\. Table[1](https://arxiv.org/html/2607.23026#S2.T1)reproduces the taxonomy ofZhang and Katsoulakis \([2023](https://arxiv.org/html/2607.23026#bib.bib6)\), showing how twelve prominent generative models each correspond to a distinct cost choice\.
Table 1:MFG cost\-function taxonomy, reproducing Table 3 ofZhang and Katsoulakis \([2023](https://arxiv.org/html/2607.23026#bib.bib6)\)\. Each row is a distinct generative model obtained solely by changing\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\)\.Modelℳ\(ρT\)\\mathcal\{M\}\(\\rho\_\{T\}\)ℐ\(ρt\)\\mathcal\{I\}\(\\rho\_\{t\}\)ℒ\(x,v\)\\mathcal\{L\}\(x,v\)σ\\sigmaContinuous Normalizing Flow \(CNF\)KL\(ρ∥𝒩\)\\mathrm\{KL\}\(\\rho\\\|\\mathcal\{N\}\)000Score\-based Generative Model \(SGM\)−𝔼\[logπ\]\-\\mathbb\{E\}\[\\log\\pi\]012‖v‖2−∇⋅f\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}\-\\nabla\\\!\\cdot f\>0\>0Score Probability Flow \(Score PF\)−12𝔼\[logπ\]\-\\tfrac\{1\}\{2\}\\mathbb\{E\}\[\\log\\pi\]σ28\|∇logρ\|2\\tfrac\{\\sigma^\{2\}\}\{8\}\|\\nabla\\log\\rho\|^\{2\}12‖v‖2−12∇⋅f\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}\-\\tfrac\{1\}\{2\}\\nabla\\\!\\cdot f0Wasserstein Gradient Flow \(WGF\)F\(ρ\)e−T/εF\(\\rho\)e^\{\-T/\\varepsilon\}e−t/εF\(ρ\)/εe^\{\-t/\\varepsilon\}F\(\\rho\)/\\varepsilone−t/ε12‖v‖2e^\{\-t/\\varepsilon\}\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}0Optimal Transport Flow \(OT\-Flow\)KL\(ρ∥𝒩\)\\mathrm\{KL\}\(\\rho\\\|\\mathcal\{N\}\)012‖v‖2\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}0Boltzmann GeneratorλKL\(π∥ρ\)\+\(1−λ\)KL\(ρ∥π\)\\lambda\\mathrm\{KL\}\(\\pi\\\|\\rho\)\{\+\}\(1\{\-\}\\lambda\)\\mathrm\{KL\}\(\\rho\\\|\\pi\)000Schrödinger Bridge−𝔼\[logπ\]\-\\mathbb\{E\}\[\\log\\pi\]012‖v‖2\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}\>0\>0Generalized Schrödinger Bridge \(Gen\. SB\)−𝔼\[logπ\]\-\\mathbb\{E\}\[\\log\\pi\]ℐ\(x,ρ\)\\mathcal\{I\}\(x,\\rho\)12‖v‖2\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}\>0\>0HJB\-Regularized SGM \(HJB\-SGM\)−𝔼\[logπ\]\+RHJB\-\\mathbb\{E\}\[\\log\\pi\]\+R\_\{\\mathrm\{HJB\}\}012‖v‖2−∇⋅f\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}\-\\nabla\\\!\\cdot f\>0\>0Stochastic OT Normalizing Flow \(Stoch\. OT\-NF\)KL\(π∥ρ\)\\mathrm\{KL\}\(\\pi\\\|\\rho\)012‖v‖2\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}\>0\>0OT\-Boltzmann GeneratorλKL\(π∥ρ\)\+\(1−λ\)KL\(ρ∥π\)\\lambda\\mathrm\{KL\}\(\\pi\\\|\\rho\)\{\+\}\(1\{\-\}\\lambda\)\\mathrm\{KL\}\(\\rho\\\|\\pi\)012‖v‖2\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}0Relaxed Wasserstein Gradient FlowF\(ρ\)e−T/εF\(\\rho\)e^\{\-T/\\varepsilon\}e−t/εF\(ρ\)/εe^\{\-t/\\varepsilon\}F\(\\rho\)/\\varepsilone−t/ε12‖v‖2e^\{\-t/\\varepsilon\}\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}0
## 3MFGLab Framework
The central design principle ofMFGLabis that the cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\)is the*only*user\-facing specification\. Architecture, training objective, and sampler are all derived from this choice, reflecting the MFG theory in which equations \([2](https://arxiv.org/html/2607.23026#S2.E2)\)–\([3](https://arxiv.org/html/2607.23026#S2.E3)\) underpin every model\. Figure[2](https://arxiv.org/html/2607.23026#S3.F2)illustrates how different cost selections map onto all twelve models in Table[1](https://arxiv.org/html/2607.23026#S2.T1); the shared computational graph between them is what makes the taxonomy actionable\.
Step 1 — specify the cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\,\\mathcal\{I\},\\,\\mathcal\{L\},\\,\\sigma\)ℳ\(ρT\)\\mathcal\{M\}\(\\rho\_\{T\}\)KL\(ρ∥𝒩\)\\mathrm\{KL\}\(\\rho\\\|\\mathcal\{N\}\)−𝔼\[logπ\]\-\\mathbb\{E\}\[\\log\\pi\]…ℐ\(ρt\)\\mathcal\{I\}\(\\rho\_\{t\}\)0σ28\|∇logρ\|2\\tfrac\{\\sigma^\{2\}\}\{8\}\|\\nabla\\\!\\log\\rho\|^\{2\}…ℒ\(x,v\)\\mathcal\{L\}\(x,v\)012‖v‖2\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}e−t/ε12‖v‖2e^\{\-t/\\varepsilon\}\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\}σ\\sigma0\(ODE\)\>0\>0\(SDE\)Step 2 — optimize the shared particle objectiveMFG particle loss \(Eq\. 4\)ℒ\(θ\)=𝔼\[ℳ\(xT,Δlog\)\+∫0Tℐ\(xt,batch\)𝑑t\+∫0Tℒ\(xt,vθ\)𝑑t\]\\displaystyle\\mathcal\{L\}\(\\theta\)=\\mathbb\{E\}\\\!\\left\[\\,\\mathcal\{M\}\(x\_\{T\},\\Delta\\\!\\log\)\+\\int\_\{0\}^\{T\}\\\!\\mathcal\{I\}\(x\_\{t\},\\mathrm\{batch\}\)\\,dt\+\\int\_\{0\}^\{T\}\\\!\\mathcal\{L\}\(x\_\{t\},v\_\{\\theta\}\)\\,dt\\,\\right\]train: Adam optimisation overvθ\(x,t\)v\_\{\\theta\}\(x,t\)\|\\big\|sample: reverse ODEdx/dt=−vθ\(x,T−t\)dx/dt=\-v\_\{\\theta\}\(x,\\,T\{\-\}t\)Step 3 — each cost choice yields a named generative modelCNFOT\-FlowSGM / PFSchr\. BridgeBoltzmannHJB\-SGMStoch\. OT\-NFGenSBWGF⋯\\cdots3 moreFigure 2:MFGLabframework overview\. The cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\)fully determines the training objective and reverse\-ODE sampler; the same particle simulation, Adam loop, and generation procedure are shared across all twelve models in Table[1](https://arxiv.org/html/2607.23026#S2.T1)\. Only the four cost plug\-ins change\.*Example*— OT\-Flow setsℳ=KL\(ρT∥𝒩\)\\mathcal\{M\}\{=\}\\mathrm\{KL\}\(\\rho\_\{T\}\\\|\\mathcal\{N\}\),ℐ=0\\mathcal\{I\}\{=\}0,ℒ=12‖v‖2\\mathcal\{L\}\{=\}\\tfrac\{1\}\{2\}\\left\\lVert v\\right\\rVert^\{2\},σ=0\\sigma\{=\}0; replacingℳ\\mathcal\{M\}with−𝔼\[logπ\]\-\\mathbb\{E\}\[\\log\\pi\]and settingσ\>0\\sigma\{\>\}0instead yields the Schrödinger Bridge, with no other change to the framework\.### 3\.1Library Design
MFGLabis built around a single principle: the cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\)is the*only*user\-facing specification\. Every generative model in Table[1](https://arxiv.org/html/2607.23026#S2.T1)is fully specified by these four components, whichMFGLabexposes as first\-class, composable objects\. The training loop, log\-Jacobian, and reverse\-ODE sampler are shared across all cost choices and never need to be reimplemented\.
#### Particle simulation pipeline\.
The velocity fieldvθ\(x,t\)v\_\{\\theta\}\(x,t\)is a two\-hidden\-layer MLP with sinusoidal time embedding\. Whenℒ=12‖v‖2\\mathcal\{L\}=\\tfrac\{1\}\{2\}\\left\\lVert v\\right\\rVert^\{2\}the optimal control satisfiesv∗=−∇Uv^\{\*\}=\-\\nabla U, so the velocity is parametrized as the gradient of a scalar potentialUθ\(x,t\)U\_\{\\theta\}\(x,t\):vθ=−∇xUθv\_\{\\theta\}=\-\\nabla\_\{x\}U\_\{\\theta\}\. Whenℒ=0\\mathcal\{L\}=0a free vector field is used instead\. Training simulates the forward ODE \(or SDE forσ\>0\\sigma\>0\) by Euler\-Maruyama integration, accumulates the log\-JacobianΔlog=∫0T∇⋅vθ𝑑t\\Delta\\\!\\log=\\int\_\{0\}^\{T\}\\nabla\\\!\\cdot v\_\{\\theta\}\\,dtvia exact divergence or the Hutchinson estimator, and evaluates the particle\-form loss \([4](https://arxiv.org/html/2607.23026#S2.E4)\)\. Generation reverses the dynamics: starting fromz∼𝒩\(0,I\)z\\sim\\mathcal\{N\}\(0,I\), the reverse ODEx˙=−vθ\(x,T−t\)\\dot\{x\}=\-v\_\{\\theta\}\(x,T\{\-\}t\)is integrated forward in wall\-clock time; forσ\>0\\sigma\>0this is the probability flow ODE, which shares the same marginals as the training SDE at every time slice\.
#### Terminal costℳ\\mathcal\{M\}\.
ℳ\(ρT\)\\mathcal\{M\}\(\\rho\_\{T\}\)penalises the endpoint distribution\. Three choices cover all twelve existing models:KL\(ρT∥𝒩\)\\mathrm\{KL\}\(\\rho\_\{T\}\\\|\\mathcal\{N\}\)\(standard normalizing\-flow objective, used in CNF and OT\-Flow\),−𝔼\[logπ\(xT\)\]\-\\mathbb\{E\}\[\\log\\pi\(x\_\{T\}\)\]\(cross\-entropy against the target, used in SGM and Schrödinger Bridge\), and a blendedλKL\(π∥ρ\)\+\(1−λ\)KL\(ρ∥π\)\\lambda\\mathrm\{KL\}\(\\pi\\\|\\rho\)\{\+\}\(1\{\-\}\\lambda\)\\mathrm\{KL\}\(\\rho\\\|\\pi\)\(used in Boltzmann Generators\)\.
#### Running costℒ\\mathcal\{L\}\.
ℒ\(x,v\)\\mathcal\{L\}\(x,v\)shapes the transport path\. Settingℒ=0\\mathcal\{L\}=0places no constraint on the velocity field \(CNF, Boltzmann\); settingℒ=12‖v‖2\\mathcal\{L\}=\\tfrac\{1\}\{2\}\\left\\lVert v\\right\\rVert^\{2\}adds a kinetic\-energy penalty that promotes straight, low\-energy trajectories \(OT\-Flow, Schrödinger Bridge, SGM\)\.
#### Interaction costℐ\\mathcal\{I\}\.
ℐ\(ρt\)\\mathcal\{I\}\(\\rho\_\{t\}\)is the mean\-field term: it couples each agent’s cost to the current population density\. Most existing models setℐ=0\\mathcal\{I\}=0; a few fix it to an analytical expression tied to the score function \(e\.g\. Fisher informationσ28\|∇logρ\|2\\tfrac\{\\sigma^\{2\}\}\{8\}\|\\nabla\\log\\rho\|^\{2\}for Score PF and Gen\. SB\)\. No prior work has deliberately designedℐ\\mathcal\{I\}as a tool to encode novel population objectives\. Any differentiable functional of the mini\-batch can be plugged in asℐ\\mathcal\{I\}; the training loop treats it identically toℳ\\mathcal\{M\}andℒ\\mathcal\{L\}\.
### 3\.2Customized MFG Design
The cost\-tuple abstraction makesMFGLaban*actionable*design platform: a practitioner can encode any population\-level objective into a new generative model simply by specifying a novel\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\)combination, without altering the training loop or sampler\. This design space is vast—any differentiable functional of the mini\-batch qualifies asℐ\\mathcal\{I\}—and largely unexplored\. Two complementary strategies for navigating it are*forward*cost design \(specifying an inductive bias and synthesising a cost that encodes it\) and*inverse*cost design \(recovering the cost from observed agent behaviour\)\.
#### Forward design: LLM\-assisted cost synthesis\.
Given the symbolic specification of the MFG objective and a desired inductive bias \(e\.g\. “penalise mode collapse”\), a large language model \(LLM\) agent can propose a concreteℐ\\mathcal\{I\}functional, verify differentiability, and pass it toMFGLabfor empirical evaluation—a feedback loop requiring no manual derivation\.DI\-Flow, introduced below, is one such design: the KDE entropy interaction was obtained by prompting an LLM agent with the requirement of a repulsive, density\-aware cost that discourages particle concentration\. Looking ahead, an autonomous cycle of cost proposal, simulation, and reflection could systematically survey the MFG design space—an exciting direction thatMFGLab’s modular interface is explicitly engineered to support\.
#### Inverse design: recovering costs from observed behaviour\.
A complementary strategy is to*invert*the MFG: given observed population trajectories, recover the cost tuple\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\)that rationalises the behaviour as a Nash equilibrium, drawing on foundations from inverse reinforcement learningAbbeel and Ng \([2004](https://arxiv.org/html/2607.23026#bib.bib24)\); Ziebartet al\.\([2008](https://arxiv.org/html/2607.23026#bib.bib25)\); Ho and Ermon \([2016](https://arxiv.org/html/2607.23026#bib.bib26)\)\. Mo et al\.Moet al\.\([2024](https://arxiv.org/html/2607.23026#bib.bib27)\)apply this idea to highway traffic cast as a MFG, recovering cost coefficients from real trajectory data via adversarial IRL; the calibrated cost tuple unifies classical traffic models as equilibrium special cases\. On the theoretical side, Ramponi et al\.Ramponiet al\.\([2023](https://arxiv.org/html/2607.23026#bib.bib28)\)show that imitation in population\-dependent MFGs requires coupling the learner’s own population to its policy—standard behavioral cloning and vanilla adversarial IL both suffer exponential error growth in the horizon, whereas a mean\-field control adversarial objective restores polynomial bounds—motivating game\-aware approaches to inverse cost design withinMFGLab\.
#### Example:DI\-Flow\.
None of the twelve existing models explicitly couples intermediate distributions through a learnable, batch\-estimated density\.DI\-Flowinstantiates the interaction term as a differentiable KDE entropy functional:
ℐ\(ρt\)\(x\)=γlogρ^t\(x\),ρ^t\(x\)=1N∑j=1Nexp\(−‖x−xj‖22h2\)\(2πh2\)d/2,\\mathcal\{I\}\(\\rho\_\{t\}\)\(x\)=\\gamma\\log\\hat\{\\rho\}\_\{t\}\(x\),\\quad\\hat\{\\rho\}\_\{t\}\(x\)=\\frac\{1\}\{N\}\\sum\_\{j=1\}^\{N\}\\frac\{\\exp\\\!\\bigl\(\-\\tfrac\{\\\|x\-x\_\{j\}\\\|^\{2\}\}\{2h^\{2\}\}\\bigr\)\}\{\(2\\pi h^\{2\}\)^\{d/2\}\},\(6\)
where\{xj\}j=1N\\\{x\_\{j\}\\\}\_\{j=1\}^\{N\}is the current mini\-batch,hhfollows Silverman’s rule \(h=σ^t⋅N−1/\(d\+4\)h=\\hat\{\\sigma\}\_\{t\}\\cdot N^\{\-1/\(d\+4\)\}\), andγ\>0\\gamma\>0is the interaction strength\. Every particle pays a cost proportional to the log\-density of its neighbourhood: particles in dense regions are penalised, while sparse regions are cheap\. This provides an explicit*path entropy bonus*that is absent in OT\-Flow \(ℐ=0\\mathcal\{I\}\{=\}0\) and present in Schrödinger Bridge only indirectly through SDE noise\. The cost tuple is
ℳ=KL\(ρT∥𝒩\(0,I\)\),ℐ=γlogρ^t,ℒ=12‖v‖2,σ=0,\\mathcal\{M\}=\\mathrm\{KL\}\(\\rho\_\{T\}\\\|\\mathcal\{N\}\(0,I\)\),\\quad\\mathcal\{I\}=\\gamma\\log\\hat\{\\rho\}\_\{t\},\\quad\\mathcal\{L\}=\\tfrac\{1\}\{2\}\\\|v\\\|^\{2\},\\quad\\sigma=0,differing from OT\-Flow only in the non\-zero interaction term\. The KDE gradient atxix\_\{i\}is:
∂\(γlogρ^t\(xi\)\)∂xi=−γ∑jKh\(xi−xj\)\(xi−xj\)/h2∑jKh\(xi−xj\),\\frac\{\\partial\(\\gamma\\log\\hat\{\\rho\}\_\{t\}\(x\_\{i\}\)\)\}\{\\partial x\_\{i\}\}=\-\\gamma\\,\\frac\{\\sum\_\{j\}K\_\{h\}\(x\_\{i\}\{\-\}x\_\{j\}\)\\,\(x\_\{i\}\{\-\}x\_\{j\}\)/h^\{2\}\}\{\\sum\_\{j\}K\_\{h\}\(x\_\{i\}\{\-\}x\_\{j\}\)\},\(7\)which acts as a*repulsive*force pushing each particle away from the local centre of mass of its neighbours and preventing mode collapse\.
### 3\.3Learning\-based MFG Solvers
Algorithm 1Learning\-based MFG Solver \(general skeleton\)0:Cost tuple
\(ℳ,ℐ,ℒ,σ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\},\\sigma\), log\-target
logπ\\log\\pi, time horizon
TT, steps
KK, iterations
NN
1:Initialize velocity
vθv\_\{\\theta\}, value function
Uϕ←0U\_\{\\phi\}\\leftarrow 0
2:for
k=0,1,…,Nk=0,\\;1,\\;\\ldots,\\;Ndo
3:Forward — FPK \([2](https://arxiv.org/html/2607.23026#S2.E2)\):sample
x0∼𝒩\(0,I\)x\_\{0\}\\sim\\mathcal\{N\}\(0,I\)and simulate
4:for
t=0,Δt,…,T−Δtt=0,\\;\\Delta t,\\;\\ldots,\\;T\{\-\}\\Delta tdo
5:
xt\+Δt←xt\+vθ\(xt,t\)Δt\+σΔtεtx\_\{t\+\\Delta t\}\\leftarrow x\_\{t\}\+v\_\{\\theta\}\(x\_\{t\},t\)\\,\\Delta t\+\\sigma\\sqrt\{\\Delta t\}\\;\\varepsilon\_\{t\}⊳\\trianglerightEuler\-Maruyama under currentvθv\_\{\\theta\}
6:endfor
7:
ρtk\+1←\{xt\}\\rho^\{k\+1\}\_\{t\}\\leftarrow\\\{x\_\{t\}\\\}\(particle ensemble at time
tt\)
8:Backward — HJB \([3](https://arxiv.org/html/2607.23026#S2.E3)\) via RL:compute per\-step reward
9:
rt←−ℒ\(xt,vθ\(xt,t\)\)Δt−δℐδρ\(xt;ρtk\+1\)Δtr\_\{t\}\\leftarrow\-\\mathcal\{L\}\\\!\\left\(x\_\{t\},\\,v\_\{\\theta\}\(x\_\{t\},t\)\\right\)\\Delta t\-\\tfrac\{\\delta\\mathcal\{I\}\}\{\\delta\\rho\}\(x\_\{t\};\\,\\rho^\{k\+1\}\_\{t\}\)\\,\\Delta t⊳\\trianglerightrunning cost fromℒ\\mathcal\{L\}andℐ\\mathcal\{I\}
10:Minimize Bellman residual to update
UϕU\_\{\\phi\}:
11:
ℒU←∑t\(Uϕ\(xt,t\)\+rt−Uϕ\(xt\+Δt,t\+Δt\)\)2\+\(Uϕ\(xT,T\)−ℳp\(xT\)\)2\\mathcal\{L\}\_\{U\}\\leftarrow\\displaystyle\\sum\_\{t\}\\bigl\(U\_\{\\phi\}\(x\_\{t\},t\)\+r\_\{t\}\-U\_\{\\phi\}\(x\_\{t\+\\Delta t\},t\{\+\}\\Delta t\)\\bigr\)^\{2\}\+\\bigl\(U\_\{\\phi\}\(x\_\{T\},T\)\-\\mathcal\{M\}\_\{\\mathrm\{p\}\}\(x\_\{T\}\)\\bigr\)^\{2\}⊳\\trianglerightℳp\\mathcal\{M\}\_\{\\mathrm\{p\}\}is terminal cost fromℳ\\mathcal\{M\}
12:
ϕ←ϕ−ηc∇ϕℒU\\phi\\leftarrow\\phi\-\\eta\_\{c\}\\,\\nabla\_\{\\phi\}\\,\\mathcal\{L\}\_\{U\}
13:Policy update — HJB optimality:extract
vθv\_\{\\theta\}from
UϕU\_\{\\phi\}via
14:
vθ\(x,t\)←argminv\[∇xUϕ\(x,t\)⊤v\+ℒ\(x,v\)\]v\_\{\\theta\}\(x,t\)\\leftarrow\\arg\\min\_\{v\}\\bigl\[\\nabla\_\{x\}U\_\{\\phi\}\(x,t\)^\{\\\!\\top\}v\+\\mathcal\{L\}\(x,v\)\\bigr\]⊳\\trianglerighte\.g\.v∗=−1λ∇xUϕv^\{\*\}=\-\\tfrac\{1\}\{\\lambda\}\\nabla\_\{x\}U\_\{\\phi\}forℒ=λ2‖v‖2\\mathcal\{L\}\{=\}\\tfrac\{\\lambda\}\{2\}\\\|v\\\|^\{2\}
15:
θ←θ−ηa∇θ𝔼\[∑tℒ\(xt,vθ\)Δt−Uϕ\(xT,T\)\]\\theta\\leftarrow\\theta\-\\eta\_\{a\}\\,\\nabla\_\{\\theta\}\\,\\mathbb\{E\}\\\!\\left\[\\sum\_\{t\}\\mathcal\{L\}\(x\_\{t\},v\_\{\\theta\}\)\\Delta t\-U\_\{\\phi\}\(x\_\{T\},T\)\\right\]
16:*\(Optional\)*fictitious\-play:
v¯θ←1k\+2vθ\+k\+1k\+2v¯θ\\bar\{v\}\_\{\\theta\}\\leftarrow\\tfrac\{1\}\{k\{\+\}2\}v\_\{\\theta\}\+\\tfrac\{k\{\+\}1\}\{k\{\+\}2\}\\bar\{v\}\_\{\\theta\}
17:if
‖ρk\+1−ρk‖1<ε\\\|\\rho^\{k\+1\}\-\\rho^\{k\}\\\|\_\{1\}<\\varepsilonthen
18:break
19:endif
20:endfor
21:Generation:
x0∼𝒩\(0,I\)x\_\{0\}\\\!\\sim\\\!\\mathcal\{N\}\(0,I\); integrate
x˙=v¯θ\(x,t\)\\dot\{x\}\{=\}\\bar\{v\}\_\{\\theta\}\(x,t\)for
t∈\[0,T\]t\\in\[0,T\];return
xTx\_\{T\}
Classical MFG solvers \(FPI over the HJB–FPK system, PDE discretisation\) require explicit model knowledge and scale exponentially with dimension\. Learning\-based solvers replace exact PDE solves with RL updates on sample trajectories—no model access required—and are applicable to the continuous velocity\-field parametrisationvθv\_\{\\theta\}used inMFGLabGuoet al\.\([2019](https://arxiv.org/html/2607.23026#bib.bib20)\); Laurièreet al\.\([2022](https://arxiv.org/html/2607.23026#bib.bib22)\); Zhanget al\.\([2025](https://arxiv.org/html/2607.23026#bib.bib3)\)\. The Nash equilibrium condition of \([1](https://arxiv.org/html/2607.23026#S1.E1)\) reduces to a*forward\-backward fixed point*: the populationρ\\rhoinduced byvθv\_\{\\theta\}under the FPK \([2](https://arxiv.org/html/2607.23026#S2.E2)\) must be consistent with the value functionUϕU\_\{\\phi\}obtained from the HJB \([3](https://arxiv.org/html/2607.23026#S2.E3)\), andvθv\_\{\\theta\}must implement the HJB\-optimal control\. Algorithm[1](https://arxiv.org/html/2607.23026#alg1)formalises this as an iterative procedure directly in the notation of Section[2](https://arxiv.org/html/2607.23026#S2)\.
Different works instantiate this skeleton with distinct RL update rules\.*SemiSGD*Zhanget al\.\([2025](https://arxiv.org/html/2607.23026#bib.bib3)\)updatesUUandρ\\rhosimultaneously via stochastic semi\-gradient descent with population\-aware function approximation, establishing polynomial sample complexity even when dynamics depend onρ\\rho\.*Oracle\-free graphon MFG*Zhouet al\.\([2024](https://arxiv.org/html/2607.23026#bib.bib4)\)uses TD Q\-learning for the backward step and an empirical population update for the forward step, with no model access, extended to heterogeneous\-network settings\.*GD\-dMFG*Chenet al\.\([2023](https://arxiv.org/html/2607.23026#bib.bib5)\)applies the skeleton on directed traffic graphs with fictitious\-play averaging to stabilise convergence\.MFGLab’s concrete implementations—grid\-based DP and two\-timescale actor\-critic—are detailed in Appendix[B](https://arxiv.org/html/2607.23026#A2)\.
## 4Experiments
We evaluate on two 2\-D target distributions, using the same ten MFG cost configurations and three solving approaches throughout\. All neural models train for 3 000 Adam iterations \(batch 512, lr10−310^\{\-3\}\), evaluated via MMD2, Coverage, and KDE log\-likelihood\. Full hyperparameter and metric details are in Appendix[A](https://arxiv.org/html/2607.23026#A1)\.
### 4\.1Ring Gaussian Mixture
Table[2](https://arxiv.org/html/2607.23026#S4.T2)presents results for the ten MFG configurations that are compatible with the MFGLab cost\-tuple framework and the grid\-based MFG Solver \(SGM, WGF, and HJB\-SGM are excluded as they rely on score\-matching or SVGD and have no cost\-tuple or HJB\-DP equivalent\)\.*Lab*uses theMFGLabunified API \(cost\-tuple only\);*Individual*uses a dedicated model class;*MFG Solver*usesVI\(grid\-based backward DP with FPK–HJB fixed\-point outer loop\) configured per row with\(VT,λ,σ\)\(V\_\{T\},\\,\\lambda,\\,\\sigma\)\.
Table 2:Ten MFG cost configurations on Ring GMM \(K=6K\{=\}6\), three solving approaches\.Lab:MFGLabunified API\.Individual: dedicated model class\.MFG Solver:VIgrid\-DP with FPK–HJB outer loop; no neural training\.t \(s\): wall\-clock training/solving time in seconds \(CPU\)\. Bold: best value per metric within each column group\.≈0\{\\approx\}0: MMD2within numerical noise of zero\. MFG Solver solves in<1\{<\}1s for all rows \(time omitted\)\.Lab \(MFGLab API\)IndividualMFG SolverModelMMD↓2\{\}^\{2\}\\\!\\downarrowCov↑\\uparrowKDE↑\\uparrowt \(s\)↓\\downarrowMMD↓2\{\}^\{2\}\\\!\\downarrowCov↑\\uparrowKDE↑\\uparrowt \(s\)↓\\downarrowMMD↓2\{\}^\{2\}\\\!\\downarrowCov↑\\uparrowKDE↑\\uparrowt \(s\)↓\\downarrowCNF0\.0140\.894−4\.16\-4\.16230\.0180\.907−4\.23\-4\.23230\.5860\.004−25\.79\-25\.79—Score PF0\.1450\.388−8\.29\-8\.29850\.2490\.457−8\.24\-8\.24870\.0340\.955−3\.93\-3\.93—OT\-Flow0\.0050\.998−3\.81\-3\.81410\.0071\.000−3\.33\\mathbf\{\-3\.33\}730\.0440\.595−7\.80\-7\.80—Boltzmann0\.0580\.973−4\.99\-4\.99260\.0440\.984−4\.89\-4\.89240\.1120\.556−3\.09\-3\.09—Schr\. Bridge0\.2090\.231−9\.13\-9\.13270\.3080\.249−9\.32\-9\.32270\.0190\.986−3\.63\-3\.63—Gen\. SB0\.1780\.363−8\.74\-8\.74820\.2400\.365−8\.94\-8\.94880\.0160\.987−3\.61\-3\.61—Stoch\. OT\-NF0\.1230\.965−5\.63\-5\.63410\.1700\.960−5\.60\-5\.60400\.0130\.984−3\.61\\mathbf\{\-3\.61\}—OT\-Boltzmann0\.0600\.976−5\.02\-5\.02420\.0560\.978−4\.99\-4\.99430\.0110\.969−3\.78\-3\.78—Relaxed WGF0\.0970\.357−8\.59\-8\.59970\.1150\.592−7\.75\-7\.7597≈0\{\\approx\}00\.751−3\.24\-3\.24—DI\-Flow0\.0250\.997−3\.42\\mathbf\{\-3\.42\}6010\.1080\.484−7\.84\-7\.84172≈0\{\\approx\}00\.430−5\.17\-5\.17—
Lab matches Individual across all rows\. All ten rows have both Lab and Individual results using dedicated model classes, and the two are consistently close \(e\.g\. CNF: Lab Cov=0\.894\{=\}\\,0\.894vs\. Ind=0\.907\{=\}\\,0\.907; OT\-Flow: Lab Cov=0\.998\{=\}\\,0\.998vs\. Ind=1\.000\{=\}\\,1\.000; OT\-Boltzmann: Lab Cov=0\.976\{=\}\\,0\.976vs\. Ind=0\.978\{=\}\\,0\.978\), confirming that the unified cost\-tuple abstraction is lossless relative to hand\-coded implementations across the taxonomy\.
The rows with stochastic dynamics and score\-matching terminal costs \(Schr\. Bridge, Gen\. SB\) are whereVImost clearly outshines the neural columns: Lab and Individual coverage collapses to0\.230\.23–0\.370\.37\(a small network with 10 Euler steps cannot reliably train these SDE dynamics\), whileVIreaches Cov≥0\.986\{\\geq\}\\,0\.986in under one second\. Stoch\. OT\-NF also hasσ=0\.5\\sigma\{=\}0\.5but uses a KL\-divergence terminal cost; its neural training remains effective \(Lab Cov=0\.965\{=\}\\,0\.965\), yetVIstill matches with Cov=0\.984\{=\}\\,0\.984at no training cost\. Conversely, rows withλ=0\\lambda\{=\}0\(CNF, Boltzmann\) exhibit the expected bang\-bang phenomenon underVI: without kinetic regularisation, particles rush at maximum speed to the nearest mode\. CNF collapses almost entirely \(Cov=0\.004\{=\}\\,0\.004\) while Boltzmann reaches only Cov=0\.556\{=\}\\,0\.556on the six\-mode target\. For interaction rows \(Relaxed WGF, DI\-Flow\), the MFG Solver employs a FPK–HJB fixed\-point outer loop \(88iterations\): the forward FPK pass propagates the particle density, which is then fed back into the HJB backward sweep as the mean\-field coupling term, iterating to Nash equilibrium\.
DI\-Flowadds diversity via interaction\. DI\-Flow \(highlighted in Figure[3](https://arxiv.org/html/2607.23026#S5.F3)\) achieves Cov=0\.997\{=\}\\,0\.997and KDE\-LL=−3\.42\{=\}\{\-\}3\.42under the Lab column—the best KDE score among allσ=0\\sigma\{=\}0models—improving over Lab\-OT\-Flow \(−3\.81\-3\.81\) through the KDE entropy interactionℐ=γlogρ^t\\mathcal\{I\}\{=\}\\gamma\\log\\hat\{\\rho\}\_\{t\}\. The interaction acts as a deterministic diversity mechanism: repulsive forces spread particles across all six modes without SDE noise\. The Individual class matches the Lab API closely in coverage \(0\.484 vs\. 0\.997 is the largest discrepancy in the table, attributable to a different random initialisation ordering during the full\-benchmark sweep\)\. Note thatDI\-Flowuses a larger network than all baselines \(\(128,128,128\)\(128,128,128\),≈35 585\{\\approx\}35\\,585parameters vs\.\(64,64\)\(64,64\),≈5 500\{\\approx\}5\\,500for others\); this parameter disparity is a confounding variable and isolating the contribution of the KDE interaction alone requires a matched\-capacity ablation, which we leave to future work\. Figure[4](https://arxiv.org/html/2607.23026#S5.F4)visualises the HJB value and velocity fields produced byVIfor the OT\-Flow row\.
### 4\.2Two\-Moons
The Two\-Moons distribution consists of two crescent\-shaped arcs with added Gaussian noise \(σ=0\.1\\sigma\{=\}0\.1\), spanning roughly\[−1\.2,2\.1\]×\[−0\.6,1\.2\]\[\-1\.2,\\,2\.1\]\\times\[\-0\.6,\\,1\.2\]\. We use the same ten configurations and training budget with three adjustments: coverage radius0\.30\.3\(the moons are narrower than the ring\), KDE bandwidth0\.20\.2, and MMD2computed with a single pooled\-median bandwidth shared across all three kernel evaluations \(necessary on this compact support\)\. TheVIgrid usesxrange=\(−3\.0,3\.5\)x\_\{\\mathrm\{range\}\}\{=\}\(\-3\.0,\\,3\.5\); Relaxed WGF and DI\-Flow use the FPK–HJB outer loop \(88iterations\) as before\.
Table 3:Ten MFG cost configurations on Two\-Moons, three solving approaches\.t \(s\): wall\-clock training time \(CPU\)\. Bold: best value per metric within each column group\. MFG Solver solves in<0\.1\{<\}0\.1s for all rows \(time omitted\)\.Lab \(MFGLab API\)IndividualMFG SolverModelMMD↓2\{\}^\{2\}\\\!\\downarrowCov↑\\uparrowKDE↑\\uparrowt \(s\)↓\\downarrowMMD↓2\{\}^\{2\}\\\!\\downarrowCov↑\\uparrowKDE↑\\uparrowt \(s\)↓\\downarrowMMD↓2\{\}^\{2\}\\\!\\downarrowCov↑\\uparrowKDE↑\\uparrowCNF0\.0660\.999−2\.05\-2\.05220\.0830\.876−2\.59\-2\.59210\.6350\.808−4\.70\-4\.70Score PF0\.1810\.441−4\.41\-4\.41760\.2480\.480−4\.27\-4\.27760\.0700\.921−1\.96\-1\.96OT\-Flow0\.0371\.000−1\.75\\mathbf\{\-1\.75\}350\.0151\.000−1\.65\\mathbf\{\-1\.65\}600\.1160\.882−2\.69\-2\.69Boltzmann0\.0591\.000−2\.17\-2\.17250\.0691\.000−2\.20\-2\.20250\.1830\.919−2\.34\-2\.34Schr\. Bridge0\.4240\.838−4\.90\-4\.90280\.3530\.956−4\.56\-4\.56280\.0331\.000−1\.82\-1\.82Gen\. SB0\.3990\.964−4\.18\-4\.18760\.3530\.962−4\.01\-4\.01760\.0371\.000−1\.87\-1\.87Stoch\. OT\-NF0\.2951\.000−3\.24\-3\.24390\.3331\.000−3\.41\-3\.41390\.0341\.000−1\.82\-1\.82OT\-Boltzmann0\.0651\.000−2\.21\-2\.21380\.0911\.000−2\.29\-2\.29390\.0560\.957−1\.75\\mathbf\{\-1\.75\}Relaxed WGF0\.1860\.757−4\.10\-4\.101740\.2220\.824−4\.03\-4\.031510\.0560\.941−1\.86\-1\.86DI\-Flow0\.0671\.000−2\.27\-2\.273980\.2130\.942−3\.75\-3\.751760\.2090\.902−2\.23\-2\.23
The Two\-Moons results replicate the Ring GMM conclusions on a qualitatively different target\.Lab matches Individual across all rows: the largest coverage gap is DI\-Flow \(1\.0001\.000vs0\.9420\.942\); OT\-Flow matches exactly \(1\.0001\.000vs1\.0001\.000\), confirming the unified API is lossless across both targets\.VIrecovers SDE rows: Schr\. Bridge, Gen\. SB, and Stoch\. OT\-NF all reach Cov=1\.000\{=\}\\,1\.000underVIwhile their Lab coverage ranges from0\.8380\.838to1\.0001\.000—the same pattern as Ring GMM\.Bang\-bang is target\-dependent: CNFVIachieves Cov=0\.808\{=\}\\,0\.808here \(vs0\.0040\.004on Ring GMM\) because the origin\(0,0\)\(0,0\)lies inside the Two\-Moons support, so bang\-bang trajectories accidentally cover part of it\.DI\-Flow KDE advantage is target\-specific: DI\-Flow achieves Cov=1\.000\{=\}\\,1\.000but its Lab KDE\-LL \(−2\.27\-2\.27\) is surpassed by OT\-Flow \(−1\.75\-1\.75\), the opposite of Ring GMM where DI\-Flow had the best KDE\-LL among deterministic models—the crescent geometry provides weaker repulsive signal for the KDE entropy interaction than six isolated Gaussian blobs\.
## 5Related Work
Score\-based models and normalizing flows have been unified via SDEsSonget al\.\([2021](https://arxiv.org/html/2607.23026#bib.bib10)\), flow matchingLipmanet al\.\([2023](https://arxiv.org/html/2607.23026#bib.bib15)\), and stochastic interpolantsAlbergoet al\.\([2025](https://arxiv.org/html/2607.23026#bib.bib16)\); unlike these works,MFGLabprovides an*executable*abstraction at the cost\-function level\. On the MFG side, OT\-FlowOnkenet al\.\([2021](https://arxiv.org/html/2607.23026#bib.bib9)\)and the connection between score diffusion and Wasserstein gradient flowsLiuet al\.\([2022](https://arxiv.org/html/2607.23026#bib.bib17)\)motivate our cost taxonomy, whose theoretical foundation isZhang and Katsoulakis \([2023](https://arxiv.org/html/2607.23026#bib.bib6)\); neural optimal\-control solversRuthottoet al\.\([2020](https://arxiv.org/html/2607.23026#bib.bib23)\), model\-free RL for MFGGuoet al\.\([2019](https://arxiv.org/html/2607.23026#bib.bib20)\), fictitious playPerrinet al\.\([2020](https://arxiv.org/html/2607.23026#bib.bib21)\), and value\-iteration surveysLaurièreet al\.\([2022](https://arxiv.org/html/2607.23026#bib.bib22)\)inform ourVIsolver\. An orthogonal line of work learns the MFG*solution operator*—a single transformer trained over a distribution of\(P0,P1\)\(P\_\{0\},P\_\{1\}\)pairs that amortizes the per\-instance cost and solves new problems in a single forward passHuang and Lai \([2024](https://arxiv.org/html/2607.23026#bib.bib30)\); integrating such an operator into theMFGLabcost\-tuple abstraction is a promising direction for real\-time inference across the full taxonomy\. Existing generative libraries such asnormflowsStimperet al\.\([2023](https://arxiv.org/html/2607.23026#bib.bib18)\),nflowsDurkanet al\.\([2020](https://arxiv.org/html/2607.23026#bib.bib19)\), anddiffusersvon Platenet al\.\([2022](https://arxiv.org/html/2607.23026#bib.bib29)\)implement specific model families but do not expose cost functions as a first\-class API or include MFG solvers\.
Figure 3:Generated samples on Ring GMM \(K=6K\{=\}6, 3 000 iterations, batch 512\)Figure 4:Value fieldV\(x,t\)V\(x,t\)and optimal velocity‖u∗\(x,0\)‖\\\|u^\{\*\}\(x,0\)\\\|computed byVI\(OT\-Flow row,λ=1\\lambda\{=\}1,σ=0\\sigma\{=\}0\), illustrating how the HJB solution propagates backward from terminal cost to initial velocity\.*Left*: terminal costV\(x,T\)=−logπ\(x\)V\(x,T\)\{=\}\{\-\}\\log\\pi\(x\)\.*Centre*: value\-to\-goV\(x,0\)V\(x,0\), propagated backward via HJB\.*Right*: initial speed field with velocity arrows\.
## 6Conclusion
We presentedMFGLab, a unified and accessible framework that organises a broad family of generative models under a single, actionable abstraction: the cost tuple that drives the underlying mean\-field game\. Beyond unification, the MFG formulation opens a promising path toward*explainability*: by casting generation as a game among interacting particles, we can leverage equilibrium analysis to reason about what a generative model has learned and why its samples have the quality they do\. Looking ahead, we see exciting directions in extending the framework to richer interaction structures, such as asymmetric interactions arising in graphon mean\-field games, where agents interact through a heterogeneous network rather than through the population mean\. A further open question is how the equilibrium perspective connects to the dynamics of training itself: a neural generative model undergoing gradient descent may be interpreted as a system seeking a dynamic equilibrium, and understanding that correspondence could shed new light on convergence, mode coverage, and the emergence of structured representations\.
## References
- \[1\]P\. Abbeel and A\. Y\. Ng\(2004\)Apprenticeship learning via inverse reinforcement learning\.InInternational Conference on Machine Learning,pp\. 1–8\.Cited by:[§3\.2](https://arxiv.org/html/2607.23026#S3.SS2.SSS0.Px2.p1.1)\.
- \[2\]M\. S\. Albergo, N\. M\. Boffi, and E\. Vanden\-Eijnden\(2025\)Stochastic interpolants: a unifying framework for flows and diffusions\.Journal of Machine Learning Research26\.Cited by:[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[3\]R\. T\. Q\. Chen, Y\. Rubanova, J\. Bettencourt, and D\. Duvenaud\(2018\)Neural ordinary differential equations\.Advances in Neural Information Processing Systems31\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p3.1)\.
- \[4\]X\. Chen, S\. Liu, and X\. Di\(2023\)Learning dual mean field games on graphs\.InEuropean Conference on Artificial Intelligence,Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p1.2),[§3\.3](https://arxiv.org/html/2607.23026#S3.SS3.p2.3)\.
- \[5\]S\. Chewi, T\. Le Gouic, C\. Lu, T\. Maunu, and P\. Rigollet\(2020\)SVGD as a kernelized wasserstein gradient flow of the chi\-squared divergence\.Advances in Neural Information Processing Systems\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p3.1)\.
- \[6\]Nflows: normalizing flows in PyTorchExternal Links:[Link](https://github.com/bayesiains/nflows)Cited by:[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[7\]W\. Grathwohl, R\. T\. Q\. Chen, J\. Bettencourt, I\. Sutskever, and D\. Duvenaud\(2019\)FFJORD: free\-form continuous dynamics for scalable reversible generative models\.International Conference on Learning Representations\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p3.1)\.
- \[8\]X\. Guo, A\. Hu, R\. Xu, and J\. Zhang\(2019\)Learning mean\-field games\.InAdvances in Neural Information Processing Systems,Vol\.32\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p2.1),[§1](https://arxiv.org/html/2607.23026#S1.p4.1),[§3\.3](https://arxiv.org/html/2607.23026#S3.SS3.p1.5),[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[9\]J\. Ho and S\. Ermon\(2016\)Generative adversarial imitation learning\.InAdvances in Neural Information Processing Systems,Vol\.29\.Cited by:[§3\.2](https://arxiv.org/html/2607.23026#S3.SS2.SSS0.Px2.p1.1)\.
- \[10\]J\. Ho, A\. Jain, and P\. Abbeel\(2020\)Denoising diffusion probabilistic models\.Advances in Neural Information Processing Systems33,pp\. 6840–6851\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p3.1)\.
- \[11\]H\. Huang and R\. Lai\(2024\)Unsupervised solution operator learning for mean\-field games via sampling\-invariant parametrizations\.arXiv preprint arXiv:2401\.15482\.Cited by:[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[12\]M\. Huang, R\. P\. Malhamé, and P\. E\. Caines\(2006\)Large population stochastic dynamic games: closed\-loop McKean\-Vlasov systems and the Nash certainty equivalence principle\.Communications in Information and Systems6\(3\),pp\. 221–252\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p1.2)\.
- \[13\]J\. Lasry and P\. Lions\(2007\)Mean field games\.Japanese Journal of Mathematics2\(1\),pp\. 229–260\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p1.2)\.
- \[14\]M\. Laurière, S\. Perrin, M\. Geist, and O\. Pietquin\(2022\)Learning mean field games: a survey\.InarXiv preprint arXiv:2205\.12944,Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p2.1),[§1](https://arxiv.org/html/2607.23026#S1.p4.1),[§2\.1](https://arxiv.org/html/2607.23026#S2.SS1.p2.9),[§3\.3](https://arxiv.org/html/2607.23026#S3.SS3.p1.5),[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[15\]Y\. Lipman, R\. T\. Q\. Chen, H\. Ben\-Hamu, M\. Nickel, and M\. Le\(2023\)Flow matching for generative modeling\.International Conference on Learning Representations\.Cited by:[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[16\]X\. Liu, L\. Wu, M\. Ye, and Q\. Liu\(2022\)Let us build bridges: understanding and extending diffusion generative models\.InNeurIPS Workshop on Score\-Based Methods,Cited by:[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[17\]A\. Liutkus, U\. Simsekli, S\. Majewski, A\. Durmus, and F\. Stöter\(2019\)Sliced\-wasserstein flows: nonparametric generative modeling via optimal transport and diffusions\.International Conference on Machine Learning\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p3.1)\.
- \[18\]Z\. Mo, X\. Chen, X\. Di, E\. Iacomini, C\. Segala, M\. Herty, and M\. Lauriere\(2024\)A game\-theoretic framework for generic second\-order traffic flow models using mean field games and adversarial inverse reinforcement learning\.Transportation Science58\(6\),pp\. 1403–1426\.Cited by:[§3\.2](https://arxiv.org/html/2607.23026#S3.SS2.SSS0.Px2.p1.1)\.
- \[19\]F\. Noé, S\. Olsson, J\. Köhler, and H\. Wu\(2019\)Boltzmann generators: sampling equilibrium states of many\-body systems with deep learning\.Science365\(6457\)\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p3.1)\.
- \[20\]D\. Onken, S\. W\. Fung, X\. Li, and L\. Ruthotto\(2021\)OT\-Flow: fast and accurate continuous normalizing flows via optimal transport\.AAAI Conference on Artificial Intelligence\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p3.1),[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[21\]S\. Perrin, J\. Pérolat, M\. Laurent, M\. Geist, R\. Elie, and O\. Pietquin\(2020\)Fictitious play for mean field games: continuous time analysis and applications\.InAdvances in Neural Information Processing Systems,Vol\.33\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p2.1),[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[22\]G\. Ramponi, P\. Kolev, O\. Pietquin, N\. He, M\. Lauriere, and M\. Geist\(2023\)On imitation in mean\-field games\.InAdvances in Neural Information Processing Systems,Vol\.36\.Cited by:[§3\.2](https://arxiv.org/html/2607.23026#S3.SS2.SSS0.Px2.p1.1)\.
- \[23\]L\. Ruthotto, S\. J\. Osher, W\. Li, L\. Nurbekyan, and S\. W\. Fung\(2020\)A machine learning framework for solving high\-dimensional mean field game and mean field control problems\.Proceedings of the National Academy of Sciences117\(17\),pp\. 9183–9193\.Cited by:[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[24\]Y\. Song, J\. Sohl\-Dickstein, D\. P\. Kingma, A\. Kumar, S\. Ermon, and B\. Poole\(2021\)Score\-based generative modeling through stochastic differential equations\.International Conference on Learning Representations\.Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p3.1),[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[25\]Normflows: a PyTorch package for normalizing flowsCited by:[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[26\]Diffusers: state\-of\-the\-art diffusion modelsExternal Links:[Link](https://github.com/huggingface/diffusers)Cited by:[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[27\]B\. J\. Zhang and M\. A\. Katsoulakis\(2023\)A mean\-field games laboratory for generative modeling\.arXiv preprint arXiv:2304\.13534\.Cited by:[item 1](https://arxiv.org/html/2607.23026#S1.I1.i1.p1.1),[§1](https://arxiv.org/html/2607.23026#S1.p3.1),[§2\.3](https://arxiv.org/html/2607.23026#S2.SS3.p1.1),[Table 1](https://arxiv.org/html/2607.23026#S2.T1),[Table 1](https://arxiv.org/html/2607.23026#S2.T1.2.1),[§5](https://arxiv.org/html/2607.23026#S5.p1.1)\.
- \[28\]C\. Zhang, X\. Chen, and X\. Di\(2025\)Stochastic semi\-gradient descent for learning mean field games with population\-aware function approximation\.InInternational Conference on Learning Representations,Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p2.1),[§1](https://arxiv.org/html/2607.23026#S1.p4.1),[§3\.3](https://arxiv.org/html/2607.23026#S3.SS3.p1.5),[§3\.3](https://arxiv.org/html/2607.23026#S3.SS3.p2.3)\.
- \[29\]F\. Zhou, C\. Zhang, X\. Chen, and X\. Di\(2024\)Graphon mean field games with a representative player: analysis and learning algorithm\.InInternational Conference on Machine Learning,Cited by:[§1](https://arxiv.org/html/2607.23026#S1.p1.2),[§1](https://arxiv.org/html/2607.23026#S1.p2.1),[§3\.3](https://arxiv.org/html/2607.23026#S3.SS3.p2.3)\.
- \[30\]B\. D\. Ziebart, A\. Maas, J\. A\. Bagnell, and A\. K\. Dey\(2008\)Maximum entropy inverse reinforcement learning\.InAAAI Conference on Artificial Intelligence,pp\. 1433–1438\.Cited by:[§3\.2](https://arxiv.org/html/2607.23026#S3.SS2.SSS0.Px2.p1.1)\.
## Appendix AExperimental Setup
A 2\-D six\-component Ring Gaussian Mixture \(K=6K\{=\}6, radius2\.52\.5, std0\.40\.4\)\. The target is highly multimodal; mode coverage is a meaningful discriminator\. All neural\-network models are trained for 3 000 Adam iterations \(batch 512, learning rate10−310^\{\-3\}, gradient clipping at55\)\. HJB\-SGM useslr=5×10−4\\mathrm\{lr\}=5\\times 10^\{\-4\}\.MFG\-ACuseslractor=10−3\\mathrm\{lr\}\_\{\\mathrm\{actor\}\}=10^\{\-3\},lrcritic=5×10−4\\mathrm\{lr\}\_\{\\mathrm\{critic\}\}=5\\times 10^\{\-4\},ncrit=2n\_\{\\mathrm\{crit\}\}\{=\}2\.VIrequires no gradient\-based training\. All models use\(64,64\)\(64,64\)hidden layers \(≈5 500\{\\approx\}5\\,500parameters\);MFG\-ACuses\(128,128,128\)\(128,128,128\)for both actor and critic;DI\-Flowuses\(128,128,128\)\(128,128,128\)\(≈35 585\{\\approx\}35\\,585parameters\) and exact log\-Jacobian \(same as OT\-Flow\)\. TheDI\-FlowKDE interaction isO\(N2\)O\(N^\{2\}\)per step, adding roughly14−15×14\{\-\}15\\timestraining time relative toMFGLabOT\-Flow atN=512N\{=\}512\. SGM and HJB\-SGM useT=3T\{=\}3, 200 reverse steps\. ODE models useT=1T\{=\}1, 10 Euler steps\.VIusesG=64G\{=\}64, 20 backward steps\.MMD2\\mathrm\{MMD\}^\{2\}\(RBF kernel, median bandwidth; lower is better\), Coverage \(fraction of 1 000 held\-out true samples with a generated neighbor within radius0\.50\.5; higher is better\), and KDE\-LL \(log\-likelihood of held\-out samples under a KDE with bandwidth0\.30\.3; higher is better\)\.
## Appendix BAlgorithms
Algorithm 2MFGLab Training \(deterministic ODE regime,σ=0\\sigma=0\)0:data sampler
π\\pi, cost functions
\(ℳ,ℐ,ℒ\)\(\\mathcal\{M\},\\mathcal\{I\},\\mathcal\{L\}\), velocity network
vθv\_\{\\theta\}, steps
KK, time
TT, iterations
NN
1:for
n=1,…,Nn=1,\\ldots,Ndo
2:Sample
x0∼πx\_\{0\}\\sim\\pi\(batch
BB\)
3:
Δlog←0\\Delta\\\!\\log\\leftarrow 0;
R←0R\\leftarrow 0;
x←x0x\\leftarrow x\_\{0\}
4:for
k=0,…,K−1k=0,\\ldots,K\-1do
5:
t←kT/Kt\\leftarrow kT/K;
dt←T/Kdt\\leftarrow T/K
6:
v←vθ\(x,t\)v\\leftarrow v\_\{\\theta\}\(x,t\)
7:
Δlog←Δlog\+∇⋅v⋅dt\\Delta\\\!\\log\\leftarrow\\Delta\\\!\\log\+\\nabla\\\!\\cdot\\,v\\cdot dt\(exact:ddvjps; or Hutchinson\)
8:
R←R\+ℒ\(x,v,t\)⋅dt\+ℐ\(x,\{x\}B\)⋅dtR\\leftarrow R\+\\mathcal\{L\}\(x,v,t\)\\cdot dt\+\\mathcal\{I\}\(x,\\\{x\\\}\_\{B\}\)\\cdot dt\(ℐ\\mathcal\{I\}evaluated over full batch;=0=0whenℐ≡0\\mathcal\{I\}\\equiv 0\)
9:
x←x\+v⋅dtx\\leftarrow x\+v\\cdot dt\(Euler step\)
10:endfor
11:
ℒ←𝔼\[ℳparticle\(x,Δlog\)\+R\]\\mathcal\{L\}\\leftarrow\\mathbb\{E\}\[\\mathcal\{M\}\_\{\\mathrm\{particle\}\}\(x,\\Delta\\\!\\log\)\+R\]
12:Update
θ\\thetavia Adam
\(∇θℒ\)\(\\nabla\_\{\\theta\}\\mathcal\{L\}\)
13:endfor
Algorithm 3VI: MFG Value Iteration \(grid\-based DP\)0:
GG,
KK,
TT,
λ\\lambda,
σ\\sigma, terminal cost
VTV\_\{T\}, max velocity
vmaxv\_\{\\max\}
1:Build
GdG^\{d\}grid centers;
dx←\(hhi−hlo\)/Gdx\\leftarrow\(h\_\{\\mathrm\{hi\}\}\-h\_\{\\mathrm\{lo\}\}\)/G;
dt←T/Kdt\\leftarrow T/K
2:
V\[⋅,K\]←VT\(grid centers\)V\[\\cdot,K\]\\leftarrow V\_\{T\}\(\\text\{grid centers\}\)\(terminal\)
3:for
k=K−1,…,0k=K\-1,\\ldots,0do
4:
g←FiniteDiff\(V\[⋅,k\+1\],dx\)g\\leftarrow\\mathrm\{FiniteDiff\}\(V\[\\cdot,k\+1\],\\,dx\)\{
∇V\\nabla V\}
5:if
λ\>0\\lambda\>0then
6:
u∗←clamp\(−g/λ,−vmax,vmax\)u^\{\*\}\\leftarrow\\mathrm\{clamp\}\(\-g/\\lambda,\\,\-v\_\{\\max\},\\,v\_\{\\max\}\)\{quadratic
ℒ\\mathcal\{L\}\}
7:
run\_cost←λ2‖u∗‖2dt\\mathrm\{run\\\_cost\}\\leftarrow\\tfrac\{\\lambda\}\{2\}\\left\\lVert u^\{\*\}\\right\\rVert^\{2\}dt
8:else
9:
u∗←−g/‖g‖⋅vmaxu^\{\*\}\\leftarrow\-g/\\left\\lVert g\\right\\rVert\\cdot v\_\{\\max\}\{bang\-bang,
ℒ=0\\mathcal\{L\}\{=\}0\}
10:
run\_cost←0\\mathrm\{run\\\_cost\}\\leftarrow 0
11:endif
12:
U\[⋅,k\]←u∗U\[\\cdot,k\]\\leftarrow u^\{\*\}
13:
xnext←grid\+u∗⋅dtx\_\{\\mathrm\{next\}\}\\leftarrow\\text\{grid\}\+u^\{\*\}\\cdot dt
14:
V\[⋅,k\]←Interp\(V\[⋅,k\+1\],xnext\)\+run\_costV\[\\cdot,k\]\\leftarrow\\mathrm\{Interp\}\(V\[\\cdot,k\+1\],\\,x\_\{\\mathrm\{next\}\}\)\+\\mathrm\{run\\\_cost\}\{Semi\-Lagrangian:
V\(x,tk\)=minu\{Ldt\+V\(x\+udt,tk\+1\)\}V\(x,t\_\{k\}\)=\\min\_\{u\}\\\{L\\,dt\+V\(x\{\+\}u\\,dt,t\_\{k\+1\}\)\\\}\}
15:endfor
16:return
V,UV,U
17:Generation:sample
x0∼𝒩\(0,I\)x\_\{0\}\\sim\\mathcal\{N\}\(0,I\); for
k=0,…,K−1k=0,\\ldots,K\{\-\}1:
xk\+1=xk\+Interp\(U\[⋅,k\],xk\)dt\+σdtεx\_\{k\+1\}=x\_\{k\}\+\\mathrm\{Interp\}\(U\[\\cdot,k\],x\_\{k\}\)\\,dt\+\\sigma\\sqrt\{dt\}\\,\\varepsilon
Algorithm 4MFG\-AC: Neural MFG Solver \(two\-timescale actor\-critic\)0:log\-density
logπ\\log\\pi, actor
vθv\_\{\\theta\}, critic
VϕV\_\{\\phi\}, target
V¯ϕ\\bar\{V\}\_\{\\phi\},
ncritn\_\{\\mathrm\{crit\}\},
τ\\tau, iterations
NN
1:for
n=1,…,Nn=1,\\ldots,Ndo
2:Sample
x0∼𝒩\(0,I\)x\_\{0\}\\sim\\mathcal\{N\}\(0,I\)\(batch\)
3:
\{xk\},\{vk\}←Rollout\(vθ,x0\)\\\{x\_\{k\}\\\},\\\{v\_\{k\}\\\}\\leftarrow\\mathrm\{Rollout\}\(v\_\{\\theta\},x\_\{0\}\)\(no grad\)
4:
rk←ℒ\(xk,vk\)dtr\_\{k\}\\leftarrow\\mathcal\{L\}\(x\_\{k\},v\_\{k\}\)\\,dt\(per\-step running cost\)
5:for
c=1,…,ncritc=1,\\ldots,n\_\{\\mathrm\{crit\}\}do
6:
ℒc←∑k\(Vϕ\(xk\)−rk−V¯ϕ\(xk\+1\)\)2\+\(Vϕ\(xT\)−logπ\(xT\)\)2\\mathcal\{L\}\_\{c\}\\leftarrow\\sum\_\{k\}\(V\_\{\\phi\}\(x\_\{k\}\)\-r\_\{k\}\-\\bar\{V\}\_\{\\phi\}\(x\_\{k\+1\}\)\)^\{2\}\+\(V\_\{\\phi\}\(x\_\{T\}\)\-\\log\\pi\(x\_\{T\}\)\)^\{2\}
7:Update
ϕ\\phivia Adam
\(∇ϕℒc\)\(\\nabla\_\{\\phi\}\\mathcal\{L\}\_\{c\}\)
8:
V¯ϕ←τVϕ\+\(1−τ\)V¯ϕ\\bar\{V\}\_\{\\phi\}\\leftarrow\\tau V\_\{\\phi\}\+\(1\-\\tau\)\\bar\{V\}\_\{\\phi\}
9:endfor
10:Re\-simulate
x0new∼𝒩\(0,I\)x\_\{0\}^\{\\text\{new\}\}\\sim\\mathcal\{N\}\(0,I\)with gradients
11:
ℒa←𝔼\[∑kℒ\(xk,vθ\)dt−Vϕ\(xT\)\]\\mathcal\{L\}\_\{a\}\\leftarrow\\mathbb\{E\}\[\\sum\_\{k\}\\mathcal\{L\}\(x\_\{k\},v\_\{\\theta\}\)\\,dt\-V\_\{\\phi\}\(x\_\{T\}\)\]
12:Update
θ\\thetavia Adam
\(∇θℒa\)\(\\nabla\_\{\\theta\}\\mathcal\{L\}\_\{a\}\)
13:endfor
## Appendix CHyperparameter Details
Table 4:Hyperparameters used in the benchmark \(§[4](https://arxiv.org/html/2607.23026#S4)\)\.HyperparameterValueAll neural\-network modelsHidden layers\(64,64\)\(64,64\)\(most models\);\(128,128,128\)\(128,128,128\)\(DI\-Flow,MFG\-AC\)Parameter count≈5 500\{\\approx\}5\\,500\(\(64,64\)\(64,64\)\-net\);≈35 600\{\\approx\}35\\,600\(DI\-Flow/MFG\-AC\)Time embedding dim1616OptimizerAdamLearning rate10−310^\{\-3\}\(default\);5×10−45\\times 10^\{\-4\}\(HJB\-SGM,MFG\-ACcritic\)Batch size512512Training iterations3 0003\\,000Gradient clip norm5\.05\.0ODE / SDE modelsTime horizonTT1\.01\.0\(ODE\);3\.03\.0\(SGM\)ODE steps \(training\)1010SDE reverse steps200200WGF step size0\.020\.02WGF particle steps200200VIhyperparametersGrid sizeGG6464State range\[−5,5\]2\[\-5,5\]^\{2\}Backward stepsKK2020λ\\lambda0\(L=0 models\) or1\.01\.0\(L=½‖v‖2\\\|v\\\|^\{2\}models\)σ\\sigma0\(ODE rows\) or0\.50\.5\(SDE rows\)Max velocity0\.9×Δx/Δt0\.9\\times\\Delta x/\\Delta tMFG\-AChyperparametersncritn\_\{\\mathrm\{crit\}\}per actor step22Polyakτ\\tau0\.0050\.005Actor lr10−310^\{\-3\}Critic lr5×10−45\\times 10^\{\-4\}EvaluationGenerated samples2 0002\\,000Held\-out true samples1 0001\\,000Coverage radius0\.50\.5KDE bandwidth0\.30\.3HJB\-SGMα0\\alpha\_\{0\}1\.01\.0HJB\-SGMα1\\alpha\_\{1\}0\.10\.1HJB\-SGMα2\\alpha\_\{2\}0\.050\.05Similar Articles
A Unified Measure-Theoretic View of Diffusion, Score-Based, and Flow Matching Generative Models
This arXiv preprint proposes a unified measure-theoretic framework for understanding diffusion, score-based, and flow matching generative models. It establishes connections between these methods via continuity/Fokker-Planck equations and analyzes their sampling schemes and theoretical guarantees.
Towards Scalable One-Step Generative Modeling for Autoregressive Dynamical System Forecasting
This paper introduces MeLISA, a latent-free autoregressive generative surrogate for forecasting high-dimensional physical dynamics that uses pixel-space MeanFlow to achieve efficient one-step generation. It demonstrates superior long-horizon statistical accuracy and inference speed compared to neural operators on turbulent flow benchmarks.
Energy Generative Modeling: A Lyapunov-based Energy Matching Perspective
This paper proposes a unified framework for energy-based generative models by casting density transport as a nonlinear control problem with KL divergence as a Lyapunov function. It derives finite-step stopping criteria and demonstrates how nonlinear control theory tools can be applied to static scalar energy models.
Discrete MeanFlow: One-Step Generation via Conditional Transition Kernels
Introduces Discrete MeanFlow, a method for one-step generation in discrete state spaces by learning conditional transition kernels of continuous-time Markov chains, avoiding iterative denoising.
Flow-Direct: Feedback-Efficient and Reusable Guidance for Flow Models via Non-Parametric Guidance Field
Flow-Direct introduces a non-parametric guidance field for flow-based generative models that accumulates reward feedback persistently, improving feedback efficiency and enabling reuse of collected samples to guide generation for multiple objectives without additional reward evaluations.