WorksMathematics
Semi-Amortized Bayesian Inference with Reusable Local Posteriors
Abstract
Amortized Bayesian inference uses simulations to perform Bayesian estimation when likelihoods are expensive or analytically unavailable. However, learning the full joint posterior is challenging in high-dimensional models with complex dependencies. We introduce a semi-amortized method that divides parameters into smaller blocks, and uses conditional independence to identify the information needed to infer each block. We train neural estimators for blocks whose posterior updates are computationally expensive or frequently repeated. Each estimator learns from simulations of the relevant model components to approximate the block's full conditional posterior, given the relevant observations and the values of the variables on which it depends. A Markov chain then alternates direct draws from these estimators with conventional updates of the remaining variables. Each neural update uses the current conditioning values and requires neither likelihood evaluation nor an acceptance-rejection step. Where the same conditional structure recurs, one estimator can be reused across blocks and datasets, with an output dimension determined by the block rather than the full model. We illustrate the approach in high-dimensional and computationally expensive hierarchical and spatiotemporal models.
INTRODUCTION
Neural simulation-based inference (SBI) can learn intractable probability distributions from simulations when likelihoods are expensive or analytically unavailable [9]. In amortized neural posterior estimation (NPE), a conditional density estimator is trained on simulated parameter–data pairs to approximate the posterior . Once trained, it can obtain samples for any new observation without retraining, amortizing the cost of repeated inference.
However, amortizing the full posterior becomes challenging as the number of inferred parameters grows and their dependencies become more complex. For example, hierarchical models connect group-specific parameters through population distributions [11], state-space models link latent states over time [10], and spatial models describe dependence across locations [32]. Such models can strain amortized methods, as the posterior dimension grows with the number of groups, time points, or locations, while dependencies between parameters must still be represented jointly.
The joint posterior of such models can often be decomposed into inverse factors involving subsets of variables [35, 40, 15]. This decomposition exposes smaller inference problems in which one block of variables is inferred conditional on the others. In a hierarchical model, for example, each group’s parameters can be inferred from its observations conditional on the population parameters. Classical Gibbs sampling exploits this structure by iteratively drawing each parameter block from its full conditional distribution.
Amortized Bayesian inference on structured models also relies on clever factorization. Existing methods assign neural estimators to individual inverse factors so that samples from the joint posterior can be generated by ancestral sampling [40, 18, 16, 15, 5]. While effective for moderately sized models, full amortization can become extremely costly when the posterior contains thousands or even hundreds of thousands of factors due to simulation and memory costs. Compositional modeling mitigates this problem by combining exchangeable factors at inference [4]. However, its accuracy can deteriorate as the number of composed factors grows.
Building on likelihood-free approximate Gibbs sampling [27], we instead develop a semi-amortized Bayesian inference (SABI) method that combines neural conditional updates with conventional MCMC steps (Figure 1). Similar to Arruda et al. [4], our method does not simulate the full graphical model; it requires only identifying which inverse factors are difficult to sample and which admit efficient conventional updates—a distinction that is typically clear from the model structure. In hierarchical models, for example, the challenging step is often sampling group-specific posteriors, whereas the hyperposterior is well identified and easier to sample.
Figure 1. Comparison of sampling methods for the same graphical model, where shared parameters and govern interconnected local parameters , each generating observations . (a) Conventional MCMC updates all parameter blocks in repeated sweeps. (b) Amortized neural posterior estimation (NPE) tries to approximate the full joint posterior directly through a suitable inverse factorization (see text) without resorting to MCMC. (c) Semi-amortized inference (ours) combines conventional MCMC updates of with draws from amortized conditional posteriors for the remaining . Estimator A is shared across the blocks, while estimator B updates . During each sweep, a conditional update uses the current values of the other blocks.
We demonstrate SABI across three realistic applications with complex dependencies and tens of thousands of parameters, where comparisons with reference samplers show close agreement in posterior summaries. In a simulation-based application, SABI outperforms alternative SBI methods; further, it enables reuse of the same trained estimator across different hierarchical structures at scale. Additionally, we provide an initial analysis of the sampler’s stationary accuracy.
SEMI-AMORTIZED INFERENCE
Let collect the parameter blocks selected for learned updates, the remaining parameter blocks, the observations, and the fixed model inputs. The full conditional of each block depends on the other model variables only through its Markov blanket [20]. We denote the observations in this blanket by , collect the blanket parameter values in , and write for the relevant fixed inputs. For example, in a hierarchical two-level model, contains the population parameters, while contains the group’s design matrix. In a spatial model, may contain neighboring states and shared parameters. We write the full conditional as:
where denotes the remaining learned blocks.
Training the Neural Updates
We train a neural estimator to approximate this conditional using existing SBI infrastructure:
where denotes the learnable neural network parameters. The estimator must learn how a block’s posterior changes with its conditioning parameters and observation design. We therefore generate training pairs of conditioning parameters and fixed inputs from a chosen training distribution . For each combination, we draw the block’s parameters from the model’s conditional prior and simulate its observations:
For simulated training set . The conditional prior and observation model determine the posterior target, while controls training coverage. Varying population means, scales, covariates, and observation counts supports reuse across groups and datasets. Preliminary inference or conditional diagnostics can guide refinement of to improve approximation accuracy of see Appendix § 9.
Large or variable-sized inputs of , , and can be represented by a learned summary network with network parameters . We train the estimator and any learned summary by minimizing the expected negative log-likelihood over simulated training examples [26]:
Training can use transformed parameter coordinates, with the corresponding density transformation and equivalent objective described in Appendix § 8. We use normalizing flows as implemented in BayesFlow [21]. We chose normalizing flows due to their fast single-step sampling, but any modern free-form architecture is compatible with our method (e.g., diffusion or flow matching [3]).
Semi-Amortized Inference
After training, inference proceeds through an MCMC sampler on all model parameters . Starting from initial values, the sampler repeatedly updates each block conditional on the current values of the others. A complete pass through the learned blocks and the conventional blocks is one sweep. We write for the trained estimator assigned to block ; multiple blocks may share the same estimator. The network parameters , observations , and fixed inputs remain unchanged throughout sampling.
For a learned update, we first compute from the latest values of the other parameters, including any values updated earlier in the sweep. The observations , conditions , and fixed inputs enter the trained estimator through the input map in (4). We then sample a draw from to update block .
Each conventional block is updated using a Gibbs draw from its full conditional or an MCMC transition preserving that distribution, such as Metropolis–Hastings or slice sampling. Here denotes the other conventional blocks.
Algorithm 1 outlines the resulting sampler. It discards warm-up sweeps and retains the following states. Each update immediately replaces the corresponding current value.
Algorithm 1 Semi-amortized block sampling
Require: Observations y, fixed model inputs x,
trained estimators q_1, \ldots, q_N, initial parameters
(\theta^{(0)}, \vartheta^{(0)}), W warm-up sweeps, and T retained
sweeps.
1: for t = 1,\ldots,W+T do
2: (\theta^{(t)}, \vartheta^{(t)}) \leftarrow (\theta^{(t-1)}, \vartheta^{(t-1)}).
3: for i = 1,\ldots,N do
4: Form c_i^{(t)} from \theta^{(t)} and \vartheta^{(t)}.
5: Draw \theta_i^{(t)} \sim q_i(\theta_i \mid y_i,c_i^{(t)},x_i).
6: end for
7: for j = 1,\ldots,M do
8: Draw \vartheta_j^{(t)} \sim p(\vartheta_j \mid \theta^{(t)},\vartheta_{-j}^{(t)},y,x) via Gibbs or
MCMC transition.
9: end for
10: if t > W then
11: Store S_{t-W} = (\theta^{(t)},\vartheta^{(t)}).
12: end if
13: end for
14: Return S_1,\ldots,S_T.
ACCURACY OF THE PROPOSED SAMPLER
Approximation in the learned conditionals can affect posterior accuracy. We first establish posterior invariance when the learned conditionals are exact, then bound posterior error over a finite number of sweeps in terms of conditional approximation error. We also show that small posterior-averaged conditional error does not guarantee stationary accuracy. Proofs and supplementary derivations are in Appendix § 10.
Posterior Invariance
For fixed observations and model inputs , let denote the joint posterior of . Let be the transition kernel for one sweep of Algorithm 1, and the same kernel with each learned update replaced by an exact full-conditional draw. The exact sampler preserves the posterior, . Thus, when every learned conditional is exact, SABI preserves the intended joint posterior, including dependencies between blocks (Appendix § 10.§ 1). Next we examine how approximation error can affect posterior accuracy.
Finite-Sweep Error
For learned block , define its conditional KL error at parameter state and the total error averaged over the posterior:
Here denotes the conditioning inputs computed from . sums the errors across learned blocks, averaging over the exact posterior for the observed data . To isolate the error introduced by learned updates, we compare them with exact conditional draws. Starting from , the exact sampler preserves , whereas the approximate sampler has distribution after sweeps. This lets us bound the finite-sweep error.
Proposition 1 (Finite-sweep error). Suppose . For every integer ,
Since every exact block update preserves , the expected conditional KL errors accumulate to over sweeps, giving (6) (Appendix C.2). Equation (7) shows the a bound on posterior probability errors, where the approximate probability differs from the intended probability by at most . Here denotes total variation distance.
Training minimizes the KL averaged over simulated datasets and conditioning inputs, whereas the bound depends on observed dataset through . Its posterior may concentrate on conditioning values where the learned updates are less accurate, despite small average error across training simulations. Small training error therefore need not imply small , and the following proposition shows that small itself need not imply stationary accuracy.
Proposition 2 (Conditional error and stationary accuracy). For every , there is a posterior over two parameter blocks and an approximate sampler alternating learned updates of with an exact updates of , whose stationary distribution satisfies
Both the approximate sampler and its exact counterpart converge to unique stationary distributions.
Thus, arbitrarily small conditional error averaged under does not guarantee an accurate stationary distribution. The learned update is inaccurate at conditioning values that are rare under and contribute little to (C.3). The approximate updates make these values difficult to leave, so the chain spends most of its time there. Errors that receive little weight in can thus dominate the approximate sampler’s behavior.
Errors can also propagate through the conditioning inputs supplied to subsequent updates, as illustrated for Gaussian conditionals in Appendix C.4.
More generally, the effect of conditional errors on individual posterior expectations depends on their persistence and cancellation across updates (Appendix C.5). Our results on real data at scale show that such errors are less concerning in practice and can be reduced with longer training runs.
RELATED WORK
The literature on graphical model estimation is vast. The paragraphs below focus exclusively on amortized approaches explicitly situated in or adjacent to SBI.
Structured posterior approximations. Graph-structured inference methods use the generative model to construct posterior approximations. Faithful inversion derives inference-network factorizations that avoid spurious conditional independencies [40, 15]. In contrast, Ambrogioni et al. [1] and Rouillard and Wassermann [30] adopt simpler variational factorizations that need not preserve all posterior dependencies, retaining the prior dependency structure and imposing mean-field independence across latent blocks, respectively. Importantly, these approaches target full amortization rather than selected conditional transitions.
Hierarchical neural posterior estimation. Relatedly, hierarchical neural posterior estimators exploit posterior factorizations, sharing networks across groups and respecting exchangeability [28, 18, 29, 16, 15]. Fully amortized variants learn population- and group-level posterior factors, but require complete hierarchical datasets for training. Arruda et al. [5] instead amortize group-level posteriors and fit population-level parameters with a maximum likelihood estimator. More recently, Arruda et al. [4] avoid complete hierarchical simulations by composing scores of exchangeable factors at the cost of error accumulation, while still pursuing fully amortized inference.
Amortized Monte Carlo proposals. Another line of work learns neural proposals while retaining Monte Carlo correction. Inference compilation and its extensions use neural proposals in sequential importance sampling (Le et al., 2017; Baydin et al., 2019; Harvey et al., 2022). Meta-learned block proposals and lightweight inference compilation instead retain Metropolis–Hastings correction (Wang et al., 2018; Liang et al., [23]), while amortized population Gibbs sampling uses importance weighting and resampling (Wu et al., 2020). These corrections require computable ratios involving model and proposal densities, including the relevant prior and likelihood contributions, potentially evaluated on an augmented simulator trace. We instead use learned full-conditional approximations directly as sampling updates, without acceptance tests or importance weights.
Likelihood-free approximate Gibbs. The closest work is the likelihood-free approximate Gibbs sampler of Rodrigues et al. [27], which replaces intractable full conditionals with neural regression. We extend this backbone with modern SBI machinery (i.e., flexible neural estimators and learned summaries), and analyze sampler correctness and the propagation of approximation errors. Further, we provide benchmarks against gold-standard samplers and demonstrate scalability to large hierarchical and spatiotemporal models, including a simulation-based model with over 30,000 parameters and a spatiotemporal model with nearly two million observations.
EXPERIMENTS
TIMSS: Three-level hierarchical model
Our first application evaluates the accuracy and scalability of SABI in a large 21,757 parameter three-level hierarchical model of the TIMSS dataset, with 256,416 students nested in 10,820 schools across 54 countries [19]. We model fourth-grade mathematics achievement as a function of home resources. The response is the first of five plausible values, generated through item response theory [7]. We train neural estimators for conditional updates for both school and country coefficients. The model’s analytic full conditionals allow direct comparison with a Gibbs sampler, providing an oracle reference for posterior accuracy and computational efficiency. Data preparation, priors, and sampling details are given in the supplementary material.
We use a three-level Gaussian linear model with students nested within schools and countries. School intercepts and home-resources slopes vary around country coefficients, which in turn vary around population means (Appendix § 11.§ 1). The model estimates intercept-slope correlations at both the school and country levels. Figure 2 shows a graphical representation of the model.

Figure 2. TIMSS hierarchy fit in Experiment 1. Students nested within schools and countries/systems. Separate neural estimators update school coefficients (green) and country coefficients (purple). Population means , covariance matrices and , and residual variance receive Gibbs updates. Gray nodes denote the achievement scores (), and the home-resources scores ().
Inference combines neural draws for school and country coefficients with conjugate Gibbs updates for the remaining parameters. The school network conditions
on each school’s data, the country coefficients, and the residual variance. The country network conditions on the school coefficients, the global parameters, and the residual variance.
We compare SABI to a full-Gibbs sampler that replaces the two neural updates with draws from their analytic Gaussian conditionals. Full-Gibbs was 10.4 times faster than SABI. Figure 3 compares the nine global marginals and the school and country parameter medians for the full dataset, showing close marginal agreement between the two samplers. Global agreement was further corroborated by a classifier two-sample test (C2ST; Lopez-Paz and Oquab, [24]), showing an accuracy score of 0.508 across the joint global parameter distribution, indicating indiscriminate draws, although there was still mismatch in the full joint including all locals (accuracy: 0.764).
Figure 3. TIMMS posterior comparison in Experiment 1. Top: global posterior medians (dots) and 95% credible intervals (bars), using Gibbs (blue) or SABI (red); and denote country and school levels. Bottom: paired posterior medians for every school and country intercept and slope, with Gibbs estimates on the x axis and SABI estimates on the y axis. We observe high agreement across all parameters.
Citi Bike: Spatial and Temporal Dependence
Our second application evaluates SABI in a large spatiotemporal model with an expensive observation likelihood. We model hourly Citi Bike departures at 1,427 stations over eight weeks, comprising 11,416 station-weeks and 1,917,888 observations [8].
We use a Poisson–lognormal distribution, with an expected weekly departures and overdispersion parameter for every station in every week. A Gaussian graph prior links nearby stations and consecutive weeks (Figure 4). An hourly profile is shared across stations and weeks that captures the distribution of hourly departures across the week (see Appendix § 11.§ 2). The observation model introduces a latent rate for each count; critically, SABI avoids the need to numerically integrate out or explicitly sample these rates during inference.

Figure 4. Citi Bike Gaussian field fit in Experiment 2. Departures at station in week and hour . Neural estimators update station–week parameters , controlling activity and overdispersion (green), and the shared hourly profile (purple), that together determine latent activity rates. Population mean , covariance , and spatial and temporal coupling strengths and receive conventional updates.
Inference alternates neural draws from the station–week network, the shared hourly profile network and conventional updates of the global parameters. We assess posterior accuracy and computational efficiency against NUTS as implemented in Stan [34], using subsets of 12, 36, 100, and 200 stations. Figure 6 shows that SABI was more than 3 times more efficient at higher station counts, as measured by effective sample size (ESS) per second.
Figure 6. Citi Bike sampling efficiency in Experiment 2: median bulk ESS/s across shared parameters for SABI relative to NUTS. The dashed line marks equal efficiency; timing includes warmup.
Figure 5 compares global posterior densities and

Figure 5. Citi Bike posterior comparison for 200 stations in Experiment 2. Top: global posterior medians (dots) and 95% credible intervals using Stan (blue) or SABI (red). is divided by two and by 100. Bottom: paired posterior medians of and for all 1,600 station–weeks, with Stan on the x-axis and SABI on the y-axis. We find high agreement across all parameters, with slight overestimation of local inverse dispersion that did not translate to global bias.
station–week parameter medians for the 200 stations analysis. Global posterior means differ from Stan by at most 0.26 Stan posterior standard deviations. Global agreement was again assessed using C2ST, showing only mild discrimination of the joint distribution of global parameters with an accuracy score of 0.62. However, the full joint including all locals was perfectly discriminable (accuracy: 1), likely because of the small but consistent bias in the inverse dispersion parameters.
The full model has 23,006 free parameters after marginalizing the latent log rates. Explicitly sampling these rates increases the parameter count to 1,940,894, exceeding the available memory in our Stan implementation. Numerical marginalization was prohibitively slow in Stan, and we stopped that run after one day. SABI avoids both costs through learned updates, requiring neither explicit sampling nor integration. Four chains, each with 500 burn-in sweeps and 1,250 retained draws, took 157 minutes. The maximum was 1.088; median bulk and tail ESS [38] were 4,005 and 4,491, with minima of 38 and 144. Further posterior predictive checks are included in Appendix § 11.2.3.
DMC: Simulation-Based Inference
Our third application evaluates SABI for an observation model lacking a closed form likelihood and demonstrates reuse of the same network across different hierarchical structures. We study decision-making in conflict tasks, in which irrelevant information can support or oppose the required response, using the Diffusion Model for Conflict Tasks (DMC; Ulrich et al. [37]).
The likelihood function of the DMC is unknown, therefore we cannot compare directly with conventional
MCMC methods. Instead, we compare SABI with two alternative SBI approaches, compositional diffusion (Arruda et al. [4]) and direct amortized posterior estimation (Habermann et al. [16]), using a hierarchical model in which for each of the six participant parameters. Training budget was closely matched across all three methods, using 26,200,000 () participant simulations, see appendix Appendix D.3 for details
We evaluated all three methods on 100 paired datasets of 500 participants. Table 1 reports RMSE and expected calibration error (ECE; Ardizzone et al. [2]) averaged over the six population means and variances, alongside training time and sample efficiency. SABI achieves lower RMSE than both baselines. Direct amortization yields low ECE, but mostly due to poor posterior updating, particularly for variances, leading to just returning the prior (see also panels a and b of Figure 8). Compositional inference has both higher RMSE and higher ECE. Three of 100 datasets had (maximum 1.52) using SABI; excluding these datasets decreased SABI’s RMSE by 20.3% and increased ECE by 2.9% (see also Appendix D.3).
Figure 8. DMC estimation and ACDC inference of Experiment 3. (a,b) Posterior means and 95% credible intervals for the mean and log standard deviation of across 100 paired datasets. The three methods show similar recovery for the means, but SABI vastly outperforms the other two on the variance. (c) Posterior medians and 95% intervals for task- and dataset-level population medians of ; dots are participant posterior medians. denotes the number of participants and the number of trials.
Finally, we fit the DMC to empirical data from the large ACDC dataset (Haaf et al. [14]). We use decision-making trials from the three most popular conflict tasks, resulting in 601,800 trials from 5,015 participants across 34 datasets and ten publications. For each DMC parameter, we specify a random-intercept model with crossed publication and task effects and nested dataset effects, yielding 312 global pa*Nominal sample count from the network; SABI uses median bulk ESS.
| Method | Train (min) | ESS/s | ECE | ECE | RMSE | RMSE |
| SABI (ours) | 179 | 32 | 0.042 | 0.059 | 0.120 | 0.307 |
| Compositional | 292 | 12* | 0.157 | 0.308 | 0.246 | 0.738 |
| Direct amortized | 116 | 3853* | 0.031 | 0.030 | 0.377 | 0.764 |
Table 1. Reference comparisons at (100 paired datasets) for Experiment 3. Expected calibration error (ECE) and RMSE for global means and variances; lower is better. SABI has substantially lower RMSE. Direct amortization also has low ECE, since its posteriors remain close to the prior.
rameters and a total of 30,402 parameters (Figure 7).

Figure 7. ACDC hierarchy of Experiment 3. Overlapping plates represent publications and tasks, with datasets in each combination. Parameter nodes collect six coordinates; gray contains a participant’s response times and choices. Fixed trial congruencies are omitted. Light green indicates updates from the participant network; hierarchy parameters receive conventional updates.
We only use SABI for the model of ACDC, as the competing methods already exhibited substantial recovery errors at much lower dimensionality. A key strength of SABI is that participant-level training is separate from the global hierarchy, allowing different joint models to reuse the network. Here we reuse the participant network in the richer model without retraining.
Three chains each retained 2,500 draws in 10.79 minutes. The maximum was 1.037. Across global parameters, median bulk and tail ESS were 6,540 and 6,699, with minima of 71 and 23. Figure 8c shows automatic amplitude parameter across the 3 tasks, all 34 datasets and 5015 participants. See Appendix § 11.3.3 for posterior predictive checks.
DISCUSSION
In this work, we validated SABI, a semi-amortized Bayesian method for large graphical models. SABI combines the modeling flexibility of MCMC with fast, reusable neural conditional updates, without requiring a learned approximation of the entire joint posterior or post-hoc corrections. Across three experiments at a realistic scale, we obtained close agreement with Gibbs and NUTS reference posteriors, faster inference than NUTS on a model with latent variables, and markedly better calibration than compositional inference under the same simulation budget.
Limitations SABI is not fully amortized per construction. Hence, each new dataset requires iterative sampling, warm-up, and convergence assessment. Computational gains must also offset simulation and training costs, as in all neural inference applications. As our learned updates receive no post hoc correction, their approximation errors can bias the resulting posterior and are not eliminated by longer chains. Thus, accurate inference depends on conditional accuracy across the contexts encountered during sampling. Nonetheless, our results indicate clear improvement over existing amortized methods.
Future Directions One direction is to correct SABI’s neural proposals using Metropolis-Hastings steps based on a reference posterior ([39]), obtained from a separately trained estimator or from a teacher network. One could also learn local marginal likelihoods of the observed data given the conditioning parameters. MCMC would then use these learned factors to update the conditioning parameters without drawing the local parameters (Appendix § 12).
Acknowledgments
N.S. and A.H. were supported by an Australia–US Multi-University Research Initiative grant (DSTG AUSMURIV000003, ONR/DoD N00014-23-1-2792). P.-C.-B. acknowledges support from the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) through projects 508399956 and 528702768 and Collaborative Research Center 391 (Spatio-Temporal Statistics for the Transition of Energy and Transport), project 520388526. S.T.R. was funded by the National Science Foundation under Grant No. 2448380.
PARAMETER TRANSFORMATIONS
A learned block may be trained in coordinates related to the model parameters by a map . The map may depend on but is fixed during training, and the inputs needed to evaluate it are retained in the network input. For each , assume the map is a differentiable bijection with differentiable inverse and nonsingular Jacobian. A density in the transformed coordinates then defines the estimator in model coordinates:
Here denotes the Jacobian. Applying the same change of coordinates to the exact full conditional preserves both KL and total variation distance. With , the expected negative log-likelihood in model coordinates differs from that in transformed coordinates by . This expectation is over training simulations and is independent of and because the map is fixed during training.
For the Gaussian conditional prior (19), the map , with , gives prior-standardized coordinates and Jacobian factor . Draws are mapped back to before subsequent updates.
REFINEMENT DIAGNOSTICS
For selected conditioning values and designs, we draw parameters from the conditional prior and simulate observations. Conditional calibration checks compare the generating parameters with independent neural posterior draws. Under exact inference, their ranks are uniform across simulation replicates [36]. Checking separate conditioning regions and data summaries helps reveal errors that cancel when pooled.
Even simpler, sweep checks initialize simulated datasets at their generating parameter states and apply one or more inference sweeps. Exact posterior updates preserve the joint distribution of parameters and observations [12]. Systematic changes in means, variances or dependencies across independent datasets therefore indicate error. Quantities conditioned on during simulation remain fixed during the check. These diagnostics can guide refinement by targeted simulation coverage in problematic regions.
PROOFS AND SUPPLEMENTARY DERIVATIONS
We use the parameter vector , posterior distribution , and sweep kernels and from § 3. Observations and model inputs remain fixed throughout. Index all blocks in the update order of Algorithm 1, so for and for . Let be the transition kernel for block in the exact sampler and the corresponding kernel in the approximate sampler. Conventional updates have . Then and . For probability distributions and , total variation distance is , where the supremum is over measurable sets .
Posterior invariance
An exact conditional draw replaces block while keeping the remaining blocks fixed. Starting from , the resulting joint density is
A conventional MCMC transition also preserves this joint distribution when it preserves for each fixed . Therefore for every block update in the exact sampler, and composition gives for any fixed update order. Under the standard MCMC conditions of Harris recurrence and aperiodicity for the joint chain with kernel , its distribution converges to in total variation from every initial state.
Proof of Proposition 1
Proof. Since , each exact full conditional for a learned block is absolutely continuous with respect to its approximation for -almost every state. Start both chains from and retain the states after every block update through sweeps. Since the initial distributions agree, the KL chain rule expresses the KL between these path distributions as the sum of the KL divergences between corresponding block transitions, averaged under the exact path distribution.
Conventional transitions are identical in both samplers and contribute zero. For learned block , the exact and approximate transitions from state both leave unchanged, so their KL equals from (5). Every exact block update preserves , so every intermediate state of the exact chain has distribution . Each learned block is updated once per sweep, so the KL between the complete path distributions is
The distributions after sweeps are and . Marginalizing the paths to their final states cannot increase KL, proving (6). Pinsker’s inequality and the upper bound of one on total variation distance give (7).
The bound accounts for errors in the learned update, including those caused by information discarded by the summary network. For a fixed summary network, the optimal unrestricted density estimator targets the posterior conditional on its output under the training distribution. This equals the full conditional only when the summary retains all information relevant to the block’s posterior.
Proof of Proposition 2
Proof. We construct a family indexed by , suppressing this dependence in the notation. Let be the posterior distribution of with probability mass function
A sweep first updates and then draws from its exact full conditional. Write
The remaining full conditional is . In the approximate sampler, replace the update of by a draw from
Let and denote the exact and approximate sweep kernels. Both have strictly positive transition probabilities on the four states, so both chains are irreducible and aperiodic and converge to unique stationary distributions. Write for the approximate sampler’s stationary distribution.
Only the conditioning value contributes to . Its posterior probability is , so, as ,
Under the approximate sweep, is a two-state Markov chain with transition probabilities from 0 to 1 and from 1 to 0 given by
Its stationary probability of is therefore
The difference on this event bounds total variation distance from below. Since that distance is at most one,
The exact sweep does not depend on the initial . Its two transition distributions, indexed by the initial , differ in total variation by : the first draw has success probability or , and the second uses the same full conditional given the updated . Thus, for any initial distributions ,
Taking sufficiently small gives both inequalities in Proposition 2 for any . Thus the counterexample holds even when the exact sampler mixes rapidly.
Gaussian conditional structure
We study how errors in the prior mean supplied to a learned update affect its accuracy.
Consider a learned block with conditional prior
where the current conditioning inputs determine the prior mean and covariance . Errors in preceding updates can change these inputs and hence the prior supplied to the network. We compare the learned update supplied with prior mean to the exact conditional posterior at . Here represents an error in the supplied prior mean, inherited from preceding updates.
Let and denote the learned and exact conditional posterior means. The resulting error, as calculated by the difference between the learned and exact means, separates into the network’s own approximation error and the effect of the error in its supplied prior mean:
The first bracket is the network’s approximation error at the supplied prior mean. The second is the effect of the inherited error , the change in the exact posterior mean caused by the changed input.
The inherited error depends on how strongly the exact conditional posterior mean responds to its prior mean. For a Gaussian prior, this sensitivity is
where is the exact conditional posterior covariance [13]. For a small error in the supplied prior mean, this gives
with the posterior covariance evaluated at the original . For a scalar block, the inherited mean error is approximately multiplied by the posterior-to-prior variance ratio. A ratio below one reduces the error; a ratio above one amplifies it.
Stationary error and the Poisson equation
The Poisson equation relates conditional approximation error to bias in posterior expectations [31]. For a function , write and for its expected value after one exact sweep starting from . Suppose has stationary distribution and there is a function satisfying the exact sampler’s Poisson equation:
Assume all expectations below are finite. Since , stationarity gives
To identify the updates contributing to this bias, expand the difference between the sweep kernels as
where empty products are identity kernels. Conventional transitions satisfy and contribute zero. For learned block , set . The difference between its approximate and exact updates is
where denotes evaluated at with block replaced by . Combining (24) and (25) expresses stationary bias as a sum of signed contributions from conditional approximation errors. The preceding approximate updates determine the states at which each error is evaluated, while the subsequent exact updates determine its effect on .
When the following series converges and can be applied term by term, the solution can be written as
At state , the term indexed by is the expected difference between and its posterior mean after exact sweeps. Slow decay allows conditional approximation errors to persist, while contributions with opposite signs can cancel.
EXPERIMENTAL DETAILS
We evaluated SABI across three applications to real data using high-dimensional models with complex dependencies. All experiments were run on a MacBook Pro with an Apple M4 Pro chip (14 CPU cores, 20 GPU cores) and 24 GB RAM.
TIMSS
Model and priors
We use the first mathematics plausible value and home-resources score from [25]. Excluding duplicate regional extracts and incomplete records leaves 256,416 students in 10,820 schools across 54 countries/systems. Both variables are standardized using their pooled, unweighted means and standard deviations; survey weights are not used.
For student in school and country , the model is
The covariance matrices and describe intercept–slope variation at the school and country levels. The independent global priors are
The inverse-Wishart is parameterized by degrees of freedom and scale; the inverse-gamma by shape and scale.
Training and inference
For all three applications, exact training distributions and optimization settings are provided in the accompanying code.
Separate bivariate affine coupling flows estimate school and country coefficients, standardized by their conditional prior mean and Cholesky factor. The school input consists of , , , , , the country coefficients, and . The country input consists of the log number of schools, mean school coefficients, , and . Each covariance is encoded by two log standard deviations and a correlation, giving 11 inputs per network. Both flows have three affine coupling blocks with swap permutations; conditioner widths are (128, 128, 128) for schools and (64, 64) for countries.
The country network trains for 600 epochs.
Both networks minimize posterior NLL. The school network trains for 8,700 epochs, followed by 200 epochs of refinement based on diagnostics of exploratory sweeps (Appendix § 9).
Inference alternates school, country and conjugate global updates. Figure 3 and the two-sample C2ST use three chains of 30,000 sweeps, discarding 10,000 and retaining every 50th draw, giving 1,200 draws per method.
Citi Bike
Model and priors
The dataset covers 1 April–26 May 2024 and retains 1,427 stations with at least 50 departures in every week.
Let denote departures at station in week and hour . Each station–week has parameters , where is the mean hourly count averaged over the week and is log inverse overdispersion. The shared profile distributes the expected weekly total across hours:
The hourly counts follow
Thus and .
A Gaussian graph prior links a symmetrized four-nearest-neighbor spatial graph and consecutive weeks at each station. For stations and weeks, its precision across station–weeks is
where and are the spatial and temporal graph Laplacians. Stacking station–week vectors within weeks gives mean and covariance . Write . We use independent priors
with . The hourly logits have a Gaussian prior on the sum-zero subspace,
For a station–week, let and count its spatial and temporal neighbors, and and sum their parameter vectors. Its conditional prior is
The mean and covariance contain all graph information needed by the local network.
Training and inference
Both networks minimize conditional NLL on simulations. The station–week network receives the 168 pairs and the conditional-prior means, log standard deviations and correlation. A SetTransformer with two 64-dimensional attention blocks, four heads and eight pooling seeds produces a 32-dimensional summary. Four spline coupling layers, with conditioner widths , estimate the two prior-whitened parameters.
After 300 training epochs, we run a 100-station SABI pilot with four chains of 240 sweeps, discarding the first 80 and retaining every tenth state. The pilot supplies conditioning values and hourly profiles: 48 states from three chains form the training bank, and 16 states from the fourth chain form the validation bank. For a further 100 epochs, training mixes the initial simulation design equally with perturbed pilot conditioning values and profiles. Station–week parameters are freshly drawn from the corresponding conditional priors, and counts are freshly simulated. Both banks use the same observed dataset.
The hourly-profile network estimates at fixed pair mass . Gaussian augmentation of the profile prior permits parallel updates of disjoint pairs. Inputs combine the two hours’ transformed count residuals and station–week parameters with the augmented prior context and moment summaries. A two-block DeepSet of width 64, with four-head, four-seed attention pooling, produces a 64-dimensional summary. Four scalar spline layers use 16 bins and conditioner widths (128, 128).
The station–week network is reused across station counts. A separate hourly-profile network trains for 300 epochs for each station count. Inference alternates both neural updates with conventional updates of the graph parameters.
Posterior predictives
The predictive check uses the full 1,427-station fit with four chains of 1,250 retained draws. From each chain we select 256 states without replacement, generate lognormal rates and Poisson counts, and sum every 24 hours into daily totals. The median and pointwise 95% intervals summarize these 1,024 replications. All eight weeks enter the fit.
Figure 9 shows stations near the 3rd, 50th, 75th and 90th percentiles of observed activity. Their daily interval coverages are 94.6%, 87.5%, 80.4% and 83.9%, respectively: the model understates daily variation at the busier selected stations.
Figure 9. Citi Bike daily departures at four stations, ordered by observed activity. Predictive medians and pointwise 95% intervals include parameter and observation variation. All 56 days are used for fitting.
DMC and ACDC
Model and priors
The DMC combines controlled evidence accumulation with a transient automatic response [37]. Following Schaefer et al. [33], we simulate
where for congruent and for incongruent trials. The first crossing of or determines a correct or incorrect response. Response time adds a positive-truncated nondecision draw to the crossing time. All six participant parameters are positive (Table 2). The starting point is fixed at the midpoint, pulse shape at two and diffusion noise at one. Euler simulation uses 1 ms steps, right-endpoint drift and boundary detection on the same grid.
| Parameter | Meaning | Prior for | Prior for |
| Automatic amplitude | |||
| Automatic peak time | |||
| Controlled drift | |||
| Nondecision location | |||
| Boundary distance | |||
| Nondecision spread |
Table 2. DMC population priors. Normal distributions are parameterized by mean and variance; physical time parameters are measured in seconds.
Let collect the six log parameters. In the calibration model, independently across coordinates. Table 2 gives the population priors. The ACDC model adds publication, dataset and task effects:
Each dataset belongs to one publication and task. The priors for and remain those in Table 2, with independent .
The empirical analysis retains participants with accuracy above 0.75 and median RT below 1.25 s, restricts RTs to [0.2, 3) s, and selects 60 trials per congruency condition. A narrow spike of incorrect Rey-Mermet trials in [1.995, 1.996) s is removed before selection. The resulting data contain 5,015 dataset-specific participant units and 601,800 trials across 34 datasets, ten publications and three tasks.
Training and inference
The participant network receives six conditional-prior means and six log standard deviations. It estimates the six prior-standardized log parameters using eight spline coupling layers with conditioner widths (128, 128). A 64-dimensional trial summary combines a SetTransformer with response- and congruency-specific RT-distribution features. Each simulation draws participant parameters and 120 trials, equally split by congruency.
The participant network minimizes posterior NLL for 600 epochs, followed by 200 epochs of refinement based on sweep checks and simulation-based calibration (Appendix § 9).
The compositional estimator pools five participants’ 600 trials per factor and trains for 640 epochs. A SetTransformer with two 64-dimensional attention blocks, four heads and a 16-dimensional output conditions an EDM diffusion network with five 256-unit layers, using F prediction and noise loss. The direct estimator pools all 60,000 trials of each 500-participant dataset without participant identifiers and trains for 100 epochs. A SetTransformer with 32 inducing points and a 16-dimensional output conditions an eight-layer spline flow with widths (128, 128).
Both baselines use the priors in Table 2 and estimate the 12 analytically prior-standardized population parameters. Training budgets are closely matched: SABI and compositional inference each use 26,214,400 participant simulations, and direct inference uses 26,200,000.
Evaluation uses 100 paired datasets of 500 participants and 120 trials each. SABI runs three chains of 2,000 sweeps, discards 500 and retains every fifth draw, giving 900 draws per dataset. Both baselines retain 801 draws, matching SABI’s median bulk ESS. Compositional sampling uses the adaptive two-step diffusion integrator with score mini-batches and denoised-prediction clipping. The empirical ACDC fit reuses the same participant network with three 6,000-sweep chains, discarding 1,000 and retaining every second draw.
Table 3 shows 95% coverage, RMSE and calibration error for all global parameters. RMSE of posterior means is divided by the analytic prior standard deviation of the corresponding parameter. Calibration error is the median absolute difference between empirical and nominal coverage over 20 equally spaced equal-tailed interval levels from 0.005 to 0.995. Both metrics are then averaged over the six coordinates in each family.
| SABI | Compositional | Direct amortized | |||||||
| Coverage | RMSE | ECE | Coverage | RMSE | ECE | Coverage | RMSE | ECE | |
| 91 | 0.209 | 0.065 | 83 | 0.194 | 0.117 | 97 | 0.216 | 0.057 | |
| 89 | 0.256 | 0.051 | 59 | 0.489 | 0.279 | 96 | 0.519 | 0.015 | |
| 95 | 0.052 | 0.025 | 78 | 0.123 | 0.131 | 97 | 0.236 | 0.041 | |
| 93 | 0.061 | 0.061 | 77 | 0.138 | 0.086 | 99 | 0.232 | 0.039 | |
| 94 | 0.062 | 0.022 | 87 | 0.095 | 0.095 | 97 | 0.148 | 0.017 | |
| 95 | 0.081 | 0.026 | 66 | 0.437 | 0.233 | 94 | 0.911 | 0.019 | |
| 90 | 0.321 | 0.041 | 40 | 0.908 | 0.399 | 96 | 0.958 | 0.036 | |
| 77 | 0.815 | 0.203 | 40 | 1.016 | 0.345 | 96 | 0.996 | 0.020 | |
| 90 | 0.142 | 0.025 | 55 | 0.644 | 0.285 | 97 | 0.699 | 0.022 | |
| 93 | 0.148 | 0.014 | 55 | 0.554 | 0.225 | 94 | 0.596 | 0.019 | |
| 91 | 0.185 | 0.030 | 63 | 0.550 | 0.273 | 95 | 0.502 | 0.044 | |
| 93 | 0.231 | 0.043 | 49 | 0.754 | 0.320 | 95 | 0.833 | 0.036 |
Table 3. DMC recovery: 95% coverage; RMSE in prior-SD units.
Posterior predictives
We select 100 evenly spaced retained states from each ACDC chain. At each state, conditional draws of the fitted participants’ parameters generate 120 trials per participant. Figure 10 summarizes these 300 replications by task. Conditional accuracy uses five equal-count RT bins within each participant and congruency condition. Delta plots subtract congruent from incongruent correct-RT quantiles at probabilities 0.1, 0.3, 0.5, 0.7, 0.9. Both summaries weight participants equally; shaded regions are pointwise 95% predictive intervals.
Figure 10. ACDC posterior predictives by task. Top: accuracy across five within-participant RT bins, separately for congruent and incongruent trials. Bottom: incongruent-minus-congruent correct-RT quantiles against their average RT. Observed summaries are compared with predictive medians and pointwise 95% intervals from 300 replications.
Predictions reproduce the increasing Stroop delta curve, but underestimate the slowest-quantile RT difference in all three tasks. Predicted incongruent Stroop accuracy rises with RT, whereas observed accuracy is nearly flat or decreasing.
LEARNING LOCAL MARGINAL LIKELIHOODS
For local blocks that are conditionally independent given shared parameters , an alternative to SABI’s local posterior updates is to learn the marginal likelihood factors
where contains the conditioning parameters for block .
Training uses the same local simulations as SABI: draw from its conditional prior and simulate . Instead of learning the conditional posterior of , train a conditional density estimator for given . MCMC then targets
evaluating the learned factors at each proposed state without drawing the local parameters. This reduces the sampled parameter space, but requires density estimation over the local data and introduces approximation error through the learned likelihood factors.
References
- [1]Ambrogioni, L., Lin, K., Fertig, E., Vikram, S., Hinne, M., Moore, D., and van Gerven, M. (2021). Automatic structured variational inference. In Proceedings of the 24th International Conference on Artificial Intelligence and Statistics, volume 130 of Proceedings of Machine Learning Research, pages 676–684. PMLR.arxiv.org/abs/2002.00643
- [2]Ardizzone, L., Kruse, J., Wirkert, S., Rahner, D., Pellegrini, E. W., Klessen, R. S., Maier-Hein, L., Rother, C., and Köthe, U. (2019). Analyzing Inverse Problems with Invertible Neural Networks.arxiv.org/abs/1808.04730
- [3]Arruda, J., Bracher, N., Köthe, U., Hasenauer, J., and Radev, S. T. (2025). Diffusion models in simulation-based inference: A tutorial review. arXiv preprint arXiv:2512.20685.arxiv.org/abs/2512.20685
- [4]Arruda, J., Pandey, V., Sherry, C., Barroso, M., Intes, X., Hasenauer, J., and Radev, S. T. (2026). Compositional amortized inference for large-scale hierarchical Bayesian models. In The Fourteenth International Conference on Learning Representations.
- [5]Arruda, J., Schälte, Y., Peiter, C., Teplytska, O., Jaehde, U., and Hasenauer, J. (2024). An amortized approach to non-linear mixed-effects modeling based on neural posterior estimation. In International Conference on Machine Learning, pages 1865–1901. PMLR.
- [7]Bezirhan, U. and von Davier, M. (2024). TIMSS achievement scaling methodology: Item response theory and population models. In von Davier, M., Fishbein, B., and Kennedy, A. M., editors, TIMSS 2023 Technical Report, chapter 11. Boston College, TIMSS & PIRLS International Study Center.DOI
- [8]Citi Bike (2024). System data: Citi Bike trip histories. April and May 2024 trip archives.
- [9]Cranmer, K., Brehmer, J., and Louppe, G. (2020). The frontier of simulation-based inference. Proceedings of the National Academy of Sciences, 117(48):30055–30062.DOI
- [10]Durbin, J. and Koopman, S. J. (2012). Time Series Analysis by State Space Methods. Oxford University Press, 2 edition.DOI
- [11]Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., and Rubin, D. B. (2013). Bayesian Data Analysis. Chapman and Hall/CRC, 3 edition.
- [12]Geweke, J. (2004). Getting it right: Joint distribution tests of posterior simulators. Journal of the American Statistical Association, 99(467):799–804.
- [13]Giordano, R., Broderick, T., and Jordan, M. I. (2018). Covariances, robustness, and variational Bayes. Journal of Machine Learning Research, 19(51):1–49.arxiv.org/abs/1709.02536
- [14]Haaf, J. M., Hoffstadt, M., and Lesche, S. (2025). Attentional control data collection: A resource for efficient data reuse. Behavior Research Methods, 57:208.
- [15]Habermann, D., Bulling, A., Radev, S. T., and Bürkner, P.-C. (2026). Amortized bayesian inference on multilevel models of arbitrary structure. arXiv preprint.
- [16]Habermann, D., Schmitt, M., Küh michel, L., Bulling, A., Radev, S. T., and Bürkner, P.-C. (2025). Amortized Bayesian multilevel models. Bayesian Analysis. Advance publication.DOI
- [18]Heinrich, L., Mishra-Sharma, S., Pollard, C., and Windischhofer, P. (2024). Hierarchical neural simulation-based inference over event ensembles. Transactions on Machine Learning Research.
- [19]IEA and TIMSS & PIRLS International Study Center at Boston College (2024). TIMSS 2023 international database: Trends in international mathematics and science study—grade 4. International Association for the Evaluation of Educational Achievement. Dataset, edition 1.
- [20]Koller, D. and Friedman, N. (2009). Probabilistic Graphical Models: Principles and Techniques. MIT Press.
- [21]Kümmichel, L., Huang, J. M., Pratz, V., Arruda, J., Olischläger, H., Habermann, D., Kucharsky, S., Elsemüller, L., Mishra, A., Bracher, N., et al. (2026). Bayesflow 2: Multi-backend amortized bayesian inference in python. arXiv preprint arXiv:2602.07908.
- [23]Liang, F., Arora, N., Tehrani, N., Li, Y., Tingley, M., and Meijer, E. (2021). Accelerating Metropolis–Hastings with lightweight inference compilation. In Proceedings of the 24th International Conference on Artificial Intelligence and Statistics, volume 130 of Proceedings of Machine Learning Research, pages 181–189. PMLR.arxiv.org/abs/2010.12128
- [24]Lopez-Paz, D. and Oquab, M. (2018). Revisiting Classifier Two-Sample Tests.
- [25]Mullis, I. V. S., Martin, M. O., and von Davier, M., editors (2021). TIMSS 2023 Assessment Frameworks. Boston College, TIMSS & PIRLS International Study Center.
- [26]Radev, S. T., Mertens, U. K., Voss, A., Ardizzone, L., and Köthe, U. (2020). BayesFlow: Learning Complex Stochastic Models With Invertible Neural Networks. IEEE Transactions on Neural Networks and Learning Systems, 33(4):1452–1466.arxiv.org/abs/2003.06281
- [27]Rodrigues, G. S., Nott, D. J., and Sisson, S. A. (2020). Likelihood-free approximate Gibbs sampling. Statistics and Computing, 30(4):1057–1073.arxiv.org/abs/1906.04347
- [28]Rodrigues, P. L. C., Moreau, T., Louppé, G., and Gramfort, A. (2021). HNPE: Leveraging global parameters for neural posterior estimation. In Advances in Neural Information Processing Systems, volume 34, pages 13432–13443. Curran Associates, Inc.
- [29]Rouillard, L., Le Bris, A., Moreau, T., and Wassermann, D. (2023). PAVI: Plate-amortized variational inference. Transactions on Machine Learning Research.
- [30]Rouillard, L. and Wassermann, D. (2022). ADAVI: Automatic dual amortized variational inference applied to pyramidal Bayesian models. In International Conference on Learning Representations.arxiv.org/abs/2106.12248
- [31]Rudolf, D. and Schweizer, N. (2018). Perturbation theory for Markov chains via Wasserstein distance. Bernoulli, 24(4A):2610–2639.arxiv.org/abs/1503.04123
- [32]Rue, H. and Held, L. (2005). Gaussian Markov Random Fields: Theory and Applications. Chapman and Hall/CRC.
- [33]Schaefer, S. B., Radev, S. T., Göttmann, J., and Schubert, A.-L. (2026). Amortized Bayesian workflow for modeling congruency effects using the diffusion model for conflict tasks. Computational Brain & Behavior.
- [34]Stan Development Team (2026). Stan Reference Manual.
- [35]Stuhlmüller, A., Taylor, J., and Goodman, N. (2013). Learning stochastic inverses. In Burges, C., Bottou, L., Welling, M., Ghahramani, Z., and Weinberger, K., editors, Advances in Neural Information Processing Systems, volume 26. Curran Associates, Inc.
- [36]Talts, S., Betancourt, M., Simpson, D., Vehtari, A., and Gelman, A. (2018). Validating Bayesian inference algorithms with simulation-based calibration.arxiv.org/abs/1804.06788
- [37]Ulrich, R., Schröter, H., Leuthold, H., and Birngru-ber, T. (2015). Automatic and controlled stimulus processing in conflict tasks: Superimposed diffusion processes and delta functions. Cognitive Psychology, 78:148–174.DOI
- [38]Vehtari, A., Gelman, A., Simpson, D., Carpenter, B., and Bürkner, P.-C. (2021). Rank-normalization, folding, and localization: An improved R̂ for assessing convergence of MCMC (with discussion). Bayesian Analysis, 16(2):667–718.DOI
- [39]Wang, T., Wu, Y., Moore, D. A., and Russell, S. J. (2018). Meta-learning MCMC proposals. In Advances in Neural Information Processing Systems.arxiv.org/abs/1708.06040
- [40]Webb, S., Golinski, A., Zinkov, R., Siddharth, N., Rainforth, T., Teh, Y. W., and Wood, F. (2018). Faithful inversion of generative models for effective amortized inference. In Bengio, S., Wallach, H., Larochelle, H., Grauman, K., Cesa-Bianchi, N., and Garnett, R., editors, Advances in Neural Information Processing Systems, volume 31. Curran Associates, Inc.arxiv.org/abs/1712.00287





