diff --git a/joss.05776/10.21105.joss.05776.jats b/joss.05776/10.21105.joss.05776.jats new file mode 100644 index 0000000000..0b36d9fa77 --- /dev/null +++ b/joss.05776/10.21105.joss.05776.jats @@ -0,0 +1,756 @@ + + +
+ + + + +Journal of Open Source Software +JOSS + +2475-9066 + +Open Journals + + + +5776 +10.21105/joss.05776 + +BlackBIRDS: Black-Box Inference foR Differentiable +Simulators + + + +https://orcid.org/0000-0001-5055-9863 + +Quera-Bofarull +Arnau + + + +* + + +https://orcid.org/0000-0002-8304-8450 + +Dyer +Joel + + + +* + + +https://orcid.org/0000-0003-2082-734X + +Calinescu +Anisoara + + + + +https://orcid.org/0000-0001-7871-073X + +Farmer +J. Doyne + + + + + + +https://orcid.org/0000-0002-9329-8410 + +Wooldridge +Michael + + + + + +Department of Computer Science, University of Oxford, +UK + + + + +Institute for New Economic Thinking, University of Oxford, +UK + + + + +Mathematical Institute, University of Oxford, +UK + + + + +Santa Fe Institute, USA + + + + +* E-mail: +* E-mail: + + +14 +7 +2023 + +8 +89 +5776 + +Authors of papers retain copyright and release the +work under a Creative Commons Attribution 4.0 International License (CC +BY 4.0) +2022 +The article authors + +Authors of papers retain copyright and release the work under +a Creative Commons Attribution 4.0 International License (CC BY +4.0) + + + +Python +Bayesian inference +differentiable simulators +variational inference +Markov chain Monte Carlo + + + + + + Summary +

BlackBIRDS is a Python package consisting of + generically applicable, black-box inference methods for differentiable + simulation models. It facilitates both (a) the differentiable + implementation of simulation models by providing a common + object-oriented framework for their implementation in + PyTorch + (Paszke + et al., 2019), and (b) the use of a variety of + gradient-assisted inference procedures for these simulation models, + allowing researchers to easily exploit the differentiable nature of + their simulator in parameter estimation tasks. The package consists of + both Bayesian and non-Bayesian inference methods, and relies on + well-supported software libraries (e.g., + normflows, + Stimper + et al., 2023) to provide this broad functionality.

+
+ + Statement of need +

Across scientific disciplines and application domains, simulation + is used extensively as a means to studying complex mathematical models + of real-world systems. A simulation-based approach to modelling such + systems provides the modeller with significant benefits, permitting + them to specify their model in the way that they believe most + faithfully represents the true data-generating process and relieving + them from concerns regarding the mathematical tractability of the + resulting model. However, this additional flexibility comes at a + price: the resulting model can be too complex to easily perform + optimisation and inference tasks on the corresponding simulator, which + in many cases necessitates the use of approximate, simulation-based + inference and optimisation methods to perform these tasks + inexactly.

+

The complicated and black-box nature of many simulation models can + present a significant barrier to the successful deployment of these + simulation-based inference and optimisation techniques. Consequently, + there has been increasing interest within various scientific + communities in constructing differentiable simulation + models (see e.g., + Baydin + et al., 2020; + Chopra + et al., 2023): simulation models for which the gradient of the + model output with respect to the model’s input parameters can be + easily obtained. The primary motivation for this is that access to + this additional information, which captures the sensitivity of the + output of the simulator to changes in the input, can enable the use of + more efficient simulation-based optimisation and inference procedures, + helping to reduce the total runtime of such algorithms, their overall + consumption of valuable computational resources, and their concomitant + financial and environmental costs.

+

To this end, BlackBIRDS was designed to + provide researchers with easy access to a set of parameter inference + methods that exploit the gradient information provided by + differentiable simulators. The package provides support for a variety + of approaches to gradient-assisted parameter inference, including:

+ + +

Simulated Minimum Distance + (Franke, + 2009; SMD, see e.g., + Gourieroux + et al., 1993), in which parameter point estimates + + + 𝛉̂ + are obtained as

+

+ + 𝛉̂=argmin𝛉𝚯(𝛉,𝐲), + where + + 𝛉 + are the simulator’s parameters, which take values in some set + + + 𝚯, + and + + + is a loss function capturing the compatibility between the + observed data + + 𝐲 + and the simulator’s behaviour at parameter vector + + + 𝛉;

+
+ +

Markov chain Monte Carlo (MCMC), in which samples from a + parameter posterior

+

+ + π(𝛉𝐲)e(𝛉,𝐲)π(𝛉),

+

corresponding to a choice of loss function + + + + and a prior density + + π + over + + 𝚯 + are generated by executing a Markov chain on + + + 𝚯. + Currently, support is provided for Metropolis-adjusted Langevin + Dynamics + (Roberts + & Tweedie, 1996), although nothing prevents the + inclusion of additional gradient-assisted MCMC algorithms such as + Hamiltonian Monte Carlo + (Duane + et al., 1987);

+
+ +

Variational Inference (VI), in which a parameteric + approximation + + q* + to the intractable posterior is obtained by solving the following + optimisation problem over a variational family + + + 𝒬 + + + q*=argminq𝒬𝔼q[(𝛉,𝐲)]+𝔼q[logq(𝛉)π(𝛉)], + where + + + is defined as above and + + π + is a prior density over + + 𝚯.

+
+
+

The package is written such that the user is free to specify their + choice of + + + and + + π + (in the case of Bayesian methods), under the constraint that both + choices are differentiable with respect to + + + 𝛉. + This allows the user to target a wide variety of parameter point + estimators, and both classical and generalised (see e.g., + Bissiri + et al., 2016; + Knoblauch + et al., 2022) posteriors. We provide a number of + tutorials + demonstrating (a) how to implement a simulator in a differentiable + framework in PyTorch and (b) how to apply the different parameter + inference methods supported by BlackBIRDS to + these differentiable simulators. Our package provides the user with + flexible posterior density estimators with the use of normalising + flows, and has already been used in scientific research to calibrate + differentiable simulators + (Quera-Bofarull, + Chopra, et al., 2023; + Quera-Bofarull, + Dyer, et al., 2023).

+ + Related software +

BlackBIRDS offers complementary + functionality to a number of existing Python packages. + sbi + (Tejero-Cantero + et al., 2020) is a package offering PyTorch-based + implementations of numerous simulation-based inference algorithms, + including those based on the use of MCMC and neural conditional + density estimators. Our package differs significantly, however: in + contrast to sbi, + BlackBIRDS provides support for both Bayesian + and non-Bayesian inference methods, and permits the researcher to + exploit gradients of the simulator, loss function, and/or posterior + density with respect to parameters + + 𝛉 + during inference tasks. The same comparison applies to the the + BayesFlow package + (Radev + et al., 2023). black-it + (Benedetti + et al., 2022) is a further recent Python package that + collects some recently developed parameter estimation methods from + the agent-based modelling community; the focus of this package is, + however, on non-Bayesian methods, and the package does not currently + support the exploitation of simulator gradients. + PyVBMC + (Huggins + et al., 2023) provides a Python implementation of the + Variational Bayesian Monte Carlo algorithm using Gaussian processes, + but differs from our package in that it does not exploit simulator + gradients and is focused on Bayesian inference alone. Additional + older packages (e.g., + Dutta + et al., 2021; + Schälte + et al., 2022) also focus on approximate Bayesian inference + methods for non-differentiable simulators. Beyond this, we are + unaware of other mature software projects in Python that support + parameter inference in the specific case of differentiable + simulation models.

+
+
+ + Features + + +

User-friendly and flexible API: SMD only requires the loss + function + + + and the optimiser to use, while MCMC (resp. VI) requires only the + loss + + , + the prior density + + π, + and the MCMC method (resp. posterior approximator) to be + specified. However, additional arguments can be provided to + straightforwardly customise hyperparameters of the different + methods.

+
+ +

Multi-GPU parallelisation support with MPI.

+
+ +

Support for both forward-mode and reverse-mode + auto-differentiation.

+
+ +

Continuous integration and unit tests.

+
+
+
+ + Acknowledgements +

This research was supported by a UKRI AI World Leading Researcher + Fellowship awarded to Wooldridge (grant EP/W002949/1). M. Wooldridge + and A. Calinescu acknowledge funding from Trustworthy AI - Integrating + Learning, Optimisation and Reasoning + (TAILOR), + a project funded by European Union Horizon2020 research and innovation + program under Grant Agreement 952215.

+
+ + + + + + + PaszkeAdam + GrossSam + MassaFrancisco + LererAdam + BradburyJames + ChananGregory + KilleenTrevor + LinZeming + GimelsheinNatalia + AntigaLuca + DesmaisonAlban + KöpfAndreas + YangEdward + DeVitoZach + RaisonMartin + TejaniAlykhan + ChilamkurthySasank + SteinerBenoit + FangLu + BaiJunjie + ChintalaSoumith + + PyTorch: An imperative style, high-performance deep learning library + Proceedings of the 33rd international conference on neural information processing systems + Curran Associates Inc. + Red Hook, NY, USA + 2019 + + + + + + StimperVincent + LiuDavid + CampbellAndrew + BerenzVincent + RyllLukas + SchölkopfBernhard + Hernández-LobatoJosé Miguel + + Normflows: A PyTorch package for normalizing flows + Journal of Open Source Software + The Open Journal + 2023 + 8 + 86 + https://doi.org/10.21105/joss.05361 + 10.21105/joss.05361 + 5361 + + + + + + + ChopraAyush + RodríguezAlexander + SubramanianJayakumar + Quera-BofarullArnau + KrishnamurthyBalaji + PrakashB. Aditya + RaskarRamesh + + Differentiable agent-based epidemiology + Proceedings of the 2023 international conference on autonomous agents and multiagent systems + International Foundation for Autonomous Agents and Multiagent Systems + Richland, SC + 2023 + 978-1-4503-9432-1 + 1848 + 1857 + + + + + + BaydinAtılım Günes + NYUKyle Cranmer + FeickertMatthew + GrayLindsey + HeinrichLukas + NYUAlexander Held + NeubauerAndrew Melo Vanderbilt Mark + PearkesJannicke + SimpsonNathan + SmithNick + others + + Differentiable programming in high-energy physics + 2020 + + + + + + GourierouxChristian + MonfortAlain + RenaultEric + + Indirect inference + Journal of applied econometrics + Wiley Online Library + 1993 + 8 + S1 + S85 + S118 + + + + + + FrankeReiner + + Applying the method of simulated moments to estimate a small agent-based asset pricing model + Journal of Empirical Finance + Elsevier + 2009 + 16 + 5 + 10.1016/j.jempfin.2009.06.006 + 804 + 815 + + + + + + RobertsGareth O + TweedieRichard L + + Exponential convergence of Langevin distributions and their discrete approximations + Bernoulli + JSTOR + 1996 + 10.2307/3318418 + 341 + 363 + + + + + + DuaneSimon + KennedyAnthony D + PendletonBrian J + RowethDuncan + + Hybrid Monte Carlo + Physics letters B + Elsevier + 1987 + 195 + 2 + 216 + 222 + + + + + + BissiriPier Giovanni + HolmesChris + WalkerStephen G + + A general framework for updating belief distributions + Journal of the Royal Statistical Society: Series B (Statistical Methodology) + Wiley-Blackwell + 2016 + 78 + 5 + 10.1111/rssb.12158 + 1103 + + + + + + + KnoblauchJeremias + JewsonJack + DamoulasTheodoros + + An optimization-centric view on Bayes’ rule: Reviewing and generalizing variational inference + Journal of Machine Learning Research + 2022 + 23 + 132 + 1 + 109 + + + + + + Quera-BofarullArnau + ChopraAyush + CalinescuAnisoara + WooldridgeMichael + DyerJoel + + Bayesian calibration of differentiable agent-based models + ICLR Workshop on AI for Agent-based Modelling + 2023 + + + + + + Quera-BofarullArnau + DyerJoel + CalinescuAnisoara + WooldridgeMichael + + Some challenges of calibrating differentiable agent-based models + ICML Differentiable Almost Everything Workshop + 2023 + + + + + + Tejero-CanteroAlvaro + BoeltsJan + DeistlerMichael + LueckmannJan-Matthis + DurkanConor + GonçalvesPedro J. + GreenbergDavid S. + MackeJakob H. + + Sbi: A toolkit for simulation-based inference + Journal of Open Source Software + The Open Journal + 2020 + 5 + 52 + https://doi.org/10.21105/joss.02505 + 10.21105/joss.02505 + 2505 + + + + + + + BenedettiMarco + CatapanoGennaro + SclavisFrancesco De + FavoritoMarco + GlielmoAldo + MagnanimiDavide + MuciAntonio + + Black-it: A ready-to-use and easy-to-extend calibration kit for agent-based models + Journal of Open Source Software + The Open Journal + 2022 + 7 + 79 + https://doi.org/10.21105/joss.04622 + 10.21105/joss.04622 + 4622 + + + + + + + HugginsBobby + LiChengkun + TobabenMarlon + AarnosMikko J. + AcerbiLuigi + + PyVBMC: Efficient Bayesian inference in python + Journal of Open Source Software + The Open Journal + 2023 + 8 + 86 + https://doi.org/10.21105/joss.05428 + 10.21105/joss.05428 + 5428 + + + + + + + DuttaRitabrata + SchoengensMarcel + PacchiardiLorenzo + UmmadisinguAvinash + WidmerNicole + KünzliPierre + OnnelaJukka-Pekka + MiraAntonietta + + ABCpy: A high-performance computing perspective to approximate Bayesian computation + Journal of Statistical Software + 2021 + 100 + 7 + https://www.jstatsoft.org/index.php/jss/article/view/v100i07 + 10.18637/jss.v100.i07 + 1 + 38 + + + + + + SchälteYannik + KlingerEmmanuel + AlamoudiEmad + HasenauerJan + + pyABC: Efficient and robust easy-to-use approximate Bayesian computation + Journal of Open Source Software + The Open Journal + 2022 + 7 + 74 + https://doi.org/10.21105/joss.04304 + 10.21105/joss.04304 + 4304 + + + + + + + RadevStefan T. + SchmittMarvin + SchumacherLukas + ElsemüllerLasse + PratzValentin + SchälteYannik + KötheUllrich + BürknerPaul-Christian + + BayesFlow: Amortized Bayesian Workflows With Neural Networks + Journal of Open Source Software + 202309 + 8 + 89 + https://joss.theoj.org/papers/10.21105/joss.05702 + 10.21105/joss.05702 + 5702 + + + + + +