Flow Matching for Posterior Inference with Simulator Feedback

Benjamin J. Holzschuh, Nils Thuerey

Abstract

Flow-based generative modeling is a powerful tool for solving inverse problems in physical sciences that can be used for sampling and likelihood evaluation with much lower inference times than traditional methods. We propose to refine flows with additional control signals based on a simulator. Control signals can include gradients and a problem-specific cost function if the simulator is differentiable, or they can be fully learned from the simulator output. In our proposed method, we pretrain the flow network and include feedback from the simulator exclusively for finetuning, therefore requiring only a small amount of additional parameters and compute. We motivate our design choices on several benchmark problems for simulation-based inference and evaluate flow matching with simulator feedback against classical MCMC methods for modeling strong gravitational lens systems, a challenging inverse problem in astronomy. We demonstrate that including feedback from the simulator improves the accuracy by $53\%$, making it competitive with traditional techniques while being up to $67$x faster for inference.

Introduction

In many scientific fields, Simulation-Based Inference (SBI) is the primary tool for identifying parameters ($\theta$) that explain complex observations ($x_o$). While traditional Markov Chain Monte Carlo (MCMC) methods are highly accurate, they are computationally expensive, often requiring thousands of simulator calls for a single observation.

Modern machine learning has introduced "amortized" alternatives like Normalizing Flows, which are significantly faster at inference. However, these models typically operate in an "open-loop" fashion—once trained, they do not verify their predictions against the physical simulator. This can lead to a "simulation gap," where the model's samples fail to capture the physical reality defined by the simulator, particularly in high-dimensional problems like gravitational lensing.

Methodology: Closing the Loop with Controlled Flow

This work introduces a method to integrate real-time simulator feedback into Flow Matching (FM) models. The core innovation is the Controlled Flow mechanism, which allows the model to "check its work" during the sampling process.

Overview of the Controlled Flow Matching framework, illustrating the feedback loop between the neural network and the simulator.

The process follows three main steps:

  1. 1-Step Prediction: During sampling, the model makes a "look-ahead" estimate ($\hat{\theta}_1$) of the final parameter values.
  2. Simulator Feedback: This estimate is passed to the simulator. If the simulator is differentiable, the model receives a gradient from a task-specific cost function. For "black-box" simulators, a small encoder network learns to extract useful feedback from the output.
  3. Controlled Refinement: An auxiliary control network (comprising roughly 10% of total parameters) uses this feedback to nudge the flow trajectory toward a more accurate posterior.

Key Results and Insights

The researchers evaluated this approach on standard SBI benchmarks (e.g., Lotka-Volterra, SIR) and a high-stakes astronomical problem: strong gravitational lensing involving 23 parameters.

Quantitative comparison of loss metrics for velocity and x-prediction, showing the impact of simulator feedback.
  • Accuracy and Speed: In gravitational lensing tasks, the method improved accuracy by 53% compared to standard flow matching. It achieved a lower average $\chi^2$ (1.48) than traditional MCMC methods like NUTS (1.83) while being 67x faster for inference.
  • Feedback vs. Scale: Adding simulator feedback proved more effective than simply increasing training data. In the Lotka-Volterra task, a model with feedback outperformed vanilla models trained on $100\times$ more data.
  • Statistical Trustworthiness: Simulation-Based Calibration (SBC) plots confirmed that feedback-enabled models produced more reliable and less biased posteriors.

Limitations and Future Work

While significantly faster than MCMC, this method introduces some inference overhead compared to vanilla flow matching due to the required simulator calls during sampling. Additionally, using non-differentiable control signals prevents the use of exact likelihood computation via the instantaneous change of variables formula. Future research will explore more complex control theory mechanisms to further optimize the interaction between neural networks and physical simulators.

Summary updated

Abstract

Flow-based generative modeling is a powerful tool for solving inverse problems in physical sciences that can be used for sampling and likelihood evaluation with much lower inference times than traditional methods. We propose to refine flows with additional control signals based on a simulator. Control signals can include gradients and a problem-specific cost function if the simulator is differentiable, or they can be fully learned from the simulator output. In our proposed method, we pretrain the flow network and include feedback from the simulator exclusively for finetuning, therefore requiring only a small amount of additional parameters and compute. We motivate our design choices on several benchmark problems for simulation-based inference and evaluate flow matching with simulator feedback against classical MCMC methods for modeling strong gravitational lens systems, a challenging inverse problem in astronomy. We demonstrate that including feedback from the simulator improves the accuracy by $53\%$, making it competitive with traditional techniques while being up to $67$x faster for inference.
BibTeX
@misc{holzschuh2024flow,
  author = {Benjamin J. Holzschuh and Nils Thuerey},
  title = {{Flow Matching for Posterior Inference with Simulator Feedback}},
  year = {2024},
  eprint = {2410.22573},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.22573},
}
Figure