Simulation-Based Inference for Precision Cosmology
Every Pixel Counts!



Justine Zeghal
Mila, Université de Montréal
PIML workshop 2026, Heraklion, Crete, GreeceWhy do we need SBI in cosmology?
Why do we need SBI in cosmology?
Goal: Get the value of the cosmological parameters

with the uncertainty!

Bayes theorem:
Why do we need SBI in cosmology?


Why do we need SBI in cosmology?


The power spectrum is near gaussian so we have an approximation of the likelihood
Why do we need SBI in cosmology?
The power spectrum is near gaussian so we have an approximation of the likelihood

DES Y3 WL Results (with SBI).
The power spectrum is not a sufficient statistics for non gaussian field
Why do we need SBI in cosmology?






Stage III
Stage IV
Portion of the Virgo cluster, zoom on RSCG 55
Portion of the Virgo cluster, zoom on RSCG 55
Access to new non gaussian small scales. We don't want to lose this new information!
What is SBI?
What is SBI?
What is SBI?
Simulator

Initial conditions
Large Scale Structure

Prediction
Inference
Explicit inference
Needs an explicit simulator to sample the joint posterior through MCMC:
Implicit inference
We use simulations to
learn
Instead of relying on an analytical model to describe the phenomenon, we can simulate it.
Two ways of performing inference from simulations:
What is SBI?
Explicit inference
Needs an explicit simulator to sample the joint posterior through MCMC:
Implicit inference
We use simulations to
learn
Instead of relying on an analytical model to describe the phenomenon, we can simulate it.
Two ways of performing inference from simulations:
Because we work at the map level, considering all cosmological information, we call this inference:
Field-level inference / Pixel-level inference / Full-field inference
Most precise inference!


How implicit inference works?
How implicit inference works?
From the dataset we can learn:
- the marginal likelihood
- the posterior
- the likelihood to evidence ratio
We use generative models
Most of the time: Normalizing Flows



How implicit inference works?



How implicit inference works?



How implicit inference works?



How implicit inference works?



How implicit inference works?



How implicit inference works?



How implicit inference works?



Change of Variable Formula:
Should be easy to compute
We need to learn the mapping to approximate the complex distribution
How implicit inference works?
Credit: François Lanusse
We need a tool to compare distributions:
the Kullback-Leiber Divergence
How implicit inference works?
How implicit inference works?
We want to minimize the Kullback-Leiber Divergence wrt
How implicit inference works?
We want to minimize the Kullback-Leiber Divergence wrt
How implicit inference works?
We want to minimize the Kullback-Leiber Divergence wrt
How implicit inference works?
Simulations only!
Change of variable formula
We want to minimize the Kullback-Leiber Divergence wrt
How implicit inference works?
How implicit inference works?
Likelihood approximation (e.g. Papamakarios et al., 2019)
How implicit inference works?
Likelihood approximation (e.g. Papamakarios et al., 2019)
Posterior approximation (e.g. Papamakarios et al., 2016)
Both methods require a lot of costly simulations!
Implicit inference with few simulations
Implicit inference with few simulations
Brehmer et al. (2018), Zeghal et al. (2022)
For instance for NPE:
Neural-based SBI
?
❌
✅





We also want to use the simulator's gradients information:
and we want to learn the marginal posterior but
Minimized by
Implicit inference with few simulations
Neural-based SBI
Lack expressivity!



Brehmer et al. (2018), Zeghal et al. (2022)
Implicit inference with few simulations
Neural-based SBI














Without gradients
With gradients
Some results

Without gradients
With gradients
Brehmer et al. (2018), Zeghal et al. (2022)
Implicit inference with few simulations
Neural-based SBI
Application to Weak Lensing Cosmology
Zeghal et al. (2024)
Implicit inference with few simulations
Neural-based SBI
Application to Weak Lensing Cosmology
Zeghal et al. (2024)
No improvements when using the gradients.



We are using the joint gradients:


Need to check your gradients before. And maybe use variance reduction techniques.
Implicit inference with few simulations
For instance for NPE:



Neural-based SBI
?
❌
✅





Lack expressivity!
Brehmer et al. (2018), Zeghal et al. (2022)
Building more simulations at low cost
Building more simulations at low cost
Building more simulations at low cost
→ e.g. log-normal, LPT, PM
| O(ms) runtime | ✅ |
| differentiable | ✅ |
| realistic | ❌ |
Fast simulations

→ e.g. full nbody, hydro

Costly simulations
| O(ms) runtime | ❌ |
| differentiable | ❌ |
| realistic | ✅ |
We can learn the mapping between a cheap and a realistic simulation
Easier to learn a small correction & requires fewer simulations
One way to do:
minimized by
which is fine if, for instance , is a dirac
Building more simulations at low cost



We can learn the mapping between a cheap and a realistic simulation
Easier to learn a small correction & requires fewer simulations
One way to do:
minimized by
which is fine if, for instance , is a dirac
Building more simulations at low cost


Building more simulations at low cost
We can learn the mapping between a cheap and a realistic simulation
Easier to learn a small correction & requires fewer simulations
One way to do:
minimized by
which is fine if, for instance , is a dirac



when is not a dirac we should use generative models to get probable samples
Building more simulations at low cost
For instance, in Zeghal et al. (2025) we aim to approximate
from unpaired simulations
- is not a dirac
- how to benefit from the approximate simulations?



Dataset 2



Dataset 1
unlearning dataset 1 would requires more simulations than starting from gaussian noise
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)
Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)
Building more simulations at low cost
We need to learn a continuous transformation solution of the ODE
velocity field
More flexible!
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)
Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)
Building more simulations at low cost
Credit: Gagneux et al. 2025
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)
Building more simulations at low cost
Lipman et al. (2023)
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)
Building more simulations at low cost
Lipman et al. (2023)
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)
Building more simulations at low cost
Lipman et al. (2023)
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)
with:

Tong et al. 2023
Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)
with:

Tong et al. 2023
- Continuous transformation + simulation-free training: high dimension ✅
- Interpolants framework: arbitrary source distribution ✅
Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)

- Continuous transformation + simulation-free training: high dimension ✅
- Interpolants framework: arbitrary source distribution ✅
Unlearning dataset 1 would requires more simulations than starting from gaussian noise
OT to find the minimal effort mapping
Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)

- Continuous transformation + simulation-free training: high dimension ✅
- Interpolants framework: arbitrary source distribution ✅
Unlearning dataset 1 would requires more simulations than starting from gaussian noise
OT to find the minimal effort mapping
Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)

- Continuous transformation + simulation-free training: high dimension ✅
- Interpolants framework: arbitrary source distribution ✅
Unlearning dataset 1 would requires more simulations than starting from gaussian noise
OT to find the minimal effort mapping
Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)

- Continuous transformation + simulation-free training: high dimension ✅
- Interpolants framework: arbitrary source distribution ✅
Unlearning dataset 1 would requires more simulations than starting from gaussian noise
OT to find the minimal effort mapping
Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)


❌
Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)



OT will find the "closest" map!

Building more simulations at low cost
Conditional Optimal Transport Flow Macthing (Kerrigan et al. 2024)

✅

Building more simulations at low cost


Zeghal et al. (2025)
Building more simulations at low cost


LogNormal
Emulated

Challenge simulation
VS
🥳

Zeghal et al. (2025)

Implicit inference with high dimensional data
Implicit inference with high dimensional data
Implicit inference with high dimensional observations is hard
- NLE needs to learn
- NLE needs to learn
- NPE needs to learn
NF are not good in high dimensions
Goal: to build sufficient statistics as a first step, and then run the NPE or NLE method.

The NF needs to learn the distribution for each AND the complex relation between and

Sufficient Statistic:
Mutual information
Implicit inference with high dimensional data
Sufficient Statistic:
Mutual information

Only a matter of the loss function we use!

Lanzieri & Zeghal et al. (2025)
Implicit inference with high dimensional data
Regression Losses
Information-based Losses
→ Build sufficient statistics by definition.
Mean Squared Error (MSE) loss:
→ Approximate the mean of the posterior.
Sufficient Statistic:
Implicit inference with high dimensional data



Lanzieri & Zeghal et al. (2025)
Implicit inference with high dimensional data
How to validate the inference?
How to validate the inference?
Biased
Overconfident
Underconfident
Sharief & Zeghal et al. (2026)
How to validate the inference?
.
Theorem:
Two distributions are equal if their probability measures are the same over all measurable sets.
6 pink samples
5 blue samples
✅
6 pink samples
5 blue samples
✅
Sharief & Zeghal et al. (2026)
How to validate the inference?
.
Theorem:
Two distributions are equal if their probability measures are the same over all measurable sets.
6 pink samples
5 blue samples
✅
6 pink samples
5 blue samples
✅
6 pink samples
✅
6 pink samples
7 blue samples
✅
Sharief & Zeghal et al. (2026)
How to validate the inference?
.
Theorem:
Two distributions are equal if their probability measures are the same over all measurable sets.
6 pink samples
5 blue samples
✅
6 pink samples
5 blue samples
✅
6 pink samples
✅
6 pink samples
7 blue samples
✅
✅
8 pink samples
7 blue samples
✅
Sharief & Zeghal et al. (2026)
How to validate the inference?
Theorem:
Two distributions are equal if their probability measures are the same over all measurable sets.
6 pink samples
5 blue samples
✅
6 pink samples
5 blue samples
✅
6 pink samples
✅
6 pink samples
7 blue samples
✅
✅
8 pink samples
7 blue samples
✅
.
Sharief & Zeghal et al. (2026)
How to validate the inference?
.
Bayesian approach: what is the probability that the true sample lies inside or outside the region given than n samples from the proposed one are inside?
Theorem:
Lemma:
Sharief & Zeghal et al. (2026)
How to validate the inference?

Is it working?
Check the paper for other examples!
Sharief & Zeghal et al. (2026)
How to validate the inference?
Benefits
- Sample-based
- Can work with few samples
- Works in high dimension
- Does not rely on training a model
- Detect miscalibration even when other scores fail
- It is a scalar value


Which posterior is the best?
Sharief & Zeghal et al. (2026)
Best validation method: Comparing Explicit and Implicit
Comparing Explicit and Implicit
Omori & Zeghal et al. (2026)
Explicit inference becomes more challenging as the realism (i.e. the complexity) of the simulator increase
In WL: we infer 3D ICs from a 2D field
Before us in WL: only LPT simulators have been used but never validated against implicit

LPT sampling works fine

We pushed the comparison to PM Nbody simulators
PM sampling works fine but it is very challenging
We need better sampling methods
We need explicit inference methods that can perform with fewer simulations
Zeghal et al. (2024)


Thank you for your attention!
PIML2026
By Justine Zgh
PIML2026
- 14