Repository navigation
sbi 0.28 brings the Simformer, typed per-model configs for every network, save() and load() for trainers and posteriors, parallel simulation with simulate_from_theta, and the bind() API for potentials. Most of the release is a large correctness sweep: about 100 bug-fix PRs across training, sampling, diagnostics and plotting, many of them found and fixed by 25 new contributors. It also removes the aliases deprecated in v0.27.0 (SNPE, SNLE, SNRE and friends) and the deprecations due in this release, and requires Python 3.11, torch 2.5 and zuko 1.3. Please read the breaking changes before you upgrade: several fixes change numbers you may have saved, e.g. z-scoring, the default zuko networks, the TARP p-value and multi-round NPE-A.
Thanks to everyone who contributed to this release: @AndreIsraelAO, @Abhinav3499, @aniketpandey05, @AryanRG, @Ashwini8686, @BHARATH0153, @bmalezieux, @CaptainAni187, @clarkf19, @dgedon, @dhruvb2028, @G26karthik, @janfb, @Jocho-Smith, @JoeyTan21, @mayuriphad, @mmporong, @Mohit-Ak, @nMaax, @patelshivani2283-lab, @pawank925, @Rohan-Dedhia, @SahilKumar75, @satwiksps, @shivansh023023, @ShreyanshGoyal, @soujasK, @studentarijitpaul, @tanmayBeginsJourney, @ThomasGesseyJonesPX, @varunikarai, @vitorbborges and @YashDoesCode.
✨ Highlights
- Simformer: sample any conditional of a joint model (#1621 by @nMaax)
- Typed per-model configs for every network (#1986, #1975, #1996, #1997, #1957, #1921 by @satwiksps, docs in #1987)
- Save and load trainers and posteriors (#2007 by @BHARATH0153)
simulate_from_thetaruns any simulator on given parameters, in parallel (#1738 by @bmalezieux)- Potentials get
bind(x_o)(#1989, ported from the GSoC 2026 work of @Jocho-Smith) - NaN-padded observations with every posterior (#1988 by @janfb, #1828 by @patelshivani2283-lab)
kl_divergence_mcestimates the KL divergence between two posteriors (#1993 by @vitorbborges): for posteriors with a normalizedlog_prob().
⚠️ Breaking Changes
Requirements
- sbi requires Python 3.11 or newer (#2068 by @janfb)
- sbi requires torch 2.5 or newer (#2245 by @janfb):
LRUEmbedding(mode="scan")needs torch 2.8; usemode="loop"below. - sbi requires zuko 1.3 or newer (#2289 by @janfb)
- sbi requires joblib 1.3 or newer (#1738 by @bmalezieux)
Removed names and arguments
- The aliases deprecated in v0.27.0 are removed (#2164 by @dgedon): use
NPE,NLE,NRE,MCABC,SMCABCand their variants. VectorFieldPosterior.sample()no longer takessample_with(#2164 by @dgedon): pass it tobuild_posterior().mixed_likelihood_estimator_based_potentialandMixedLikelihoodBasedPotentialare removed (#2249 by @janfb): uselikelihood_estimator_based_potential.- Trainers no longer take
summary_writer(#2249 by @janfb): passtracker=TensorBoardTracker(summary_writer). FMPEandNPSEno longer takedensity_estimator, andNPSEno longer takesscore_estimator(#2249 by @janfb): pass the estimator asvf_estimator.- The flat vector field builders and their config classes are removed (#1996 by @satwiksps): use
FlowMatchingConfigor the score configs fromsbi.neural_nets. ConditionalFlowConfig,ClassifierConfigand themodel_buildersdictionaries are removed (#1997 by @satwiksps): use the per-model configs fromsbi.neural_nets.build_zuko_cnfand the"CNF"option ofbuild_zuko_floware removed (#2162 by @dgedon): use flow matching (FMPE) for a continuous flow.FlowMatchingEstimatorno longer takesnum_freqsor other unknown keyword arguments (#2249 by @janfb): unknown arguments raise aTypeError.plot_summaryno longer takesinferenceordisable_tensorboard_prompt(#2249 by @janfb): usetrainer, andverbose=False.LC2STandLC2ST_NFno longer takethetas, and theirget_scores()andget_statistics_under_null_hypothesis()no longer takereturn_probs(#2249 by @janfb): useprior_samplesand the returnedLC2STScores.- Posteriors no longer take
x_shape(#2249 by @janfb) potential.x_o = ...no longer works (#1989): usepotential = potential.bind(x_o).- NPE-A no longer accepts an arbitrary object with
get_mog_params()as a proposal (#2103 by @janfb): use anNPE_A_Posterior, a one-componentMoGor aMultivariateNormal.
Changed results and behaviour
DirectPosterior.sample()returns the requestedsample_shape(#2019 by @janfb):sample()now returns(D,)instead of(1, D).- Posteriors check the shape of
x, and those that support iid data combine several observations as trials (#2140 by @janfb) - Posteriors check the width of theta (#2194 by @Ashwini8686)
- Amortized VI
sample()andlog_prob()take one observation (#2193 by @BHARATH0153): usesample_batched()andlog_prob_batched(). - Amortized VI raises for objectives other than
"rKL"(#2074 by @BHARATH0153) - Multi-round NPE-A trains one Gaussian per round and needs
train(final_round=...)(#2110 by @janfb) - The conditioned MNLE potential includes the prior (#2084 by @janfb)
- Guided and iid sampling of vector field posteriors gives different samples (#2111 by @janfb)
sample()raises for ODE sampling with iid data or guidance (#2111 by @janfb): build the posterior withsample_with="sde".simulate_for_sbiruns onsimulate_from_theta(#1738 by @bmalezieux): withnum_workers > 1, simulators receive CPU tensors.- A prior that returns numpy arrays passes numpy arrays to the simulator (#2224 by @BHARATH0153)
sample_batched()andlog_prob_batched()raise for NaN or Inf inx(#1988 by @janfb): NaN padding passes when the embedding net accepts it.- The
log_prob()normalizer of NPE always stops, and FMPE and NPSE get one (#2239 by @janfb, #2015 by @janfb, #2216 by @BHARATH0153) RestrictedPrioruses the device of its prior, and itsdeviceargument is deprecated (#2234 by @janfb): use.to(device);devicegoes in v0.29.0.RestrictedPrior.log_prob()follows the caller's grad mode (#2298 by @dgedon)NPE_PFN.build_posteriorpicks the posterior from a typedposterior_parameters(#2249 by @janfb):DirectPosteriorParameters()now builds aDirectPosterior; useFilteredDirectPosteriorParameters()to keep filtering.- Potentials follow the caller's grad mode (#2127 by @janfb): pass
track_gradients=Truewhere you need gradients insidetorch.no_grad().
Changed networks
These changes alter networks built with this version. Networks saved with save() or pickled whole keep their old layers unless noted.
- Zuko flows get two hidden layers for an int
hidden_features(#2115 by @janfb) - Unconditional zuko flows z-score their input before the flow transforms (#2105 by @aniketpandey05)
- Marginal NSF and NCSF flows use the
num_binsyou set (#1975 by @satwiksps): the default is now 10 bins instead of 8. - Embedding nets end in a linear layer (#2118 by @janfb)
PermutationInvariantEmbeddingpasses log(1 + N) instead of the trial count N (#2113 by @janfb): this also changes networks saved with older sbi; retrain them.- Structured z-scoring uses the std over all values (#2240 by @janfb, #2171 by @G26karthik)
- z-scoring leaves constant features unscaled (#2240 by @janfb)
- z-scoring keeps float32 precision for data with a large mean and a small spread (#2246 by @janfb)
- The NPSE loss averages over parameter dimensions (#2083 by @BHARATH0153)
Changed diagnostics and metrics
check_tarpreturns a p-value that tests calibration, and needsnum_tarp_samplesfor it (#2156 by @janfb): passnum_tarp_samples.wasserstein_2_squaredand ABC'sDistance("wasserstein")scale the regularization with the mean cost and warn when they do not converge, andepsilonbecomesrelative_epsilon(#2078 by @G26karthik):relative_epsilonis relative to the mean cost (default1e-2), so choose a new value.sbi.utils.metrics.l1is the sum of absolute differences (#1998 by @SahilKumar75): scale ABC'sepsby the number of features for the old behaviour.c2stsubsamples unequal sample counts and accepts integer samples (#2263 by @janfb)
⚠️ Deprecations
set_x()and passingx_oto a potential warn, and go in v0.29.0 (#1989, #2248 by @janfb): usepotential = potential.bind(x_o).- The old
build_posteriorarguments warn whenever they are passed, and go in v0.29.0 (#2249 by @janfb): passposterior_parametersinstead. MCMCPosterior.log_prob()andRejectionPosterior.log_prob()warn with a FutureWarning and go in v0.29.0 (#2249 by @janfb): use.potential(theta, x).- The trainers'
logging_levelwarns and goes in v0.29.0 (#2249 by @janfb): set the level of thesbilogger instead. ConditionalEstimatorBuilderis renamedConditionalEstimatorBuildFn(#1957, #2249 by @janfb): the old name goes in v0.29.0.- A
ZukoFlowTypeasdensity_estimatorofMarginalTrainergoes in v0.29.0, a string in v0.30.0 (#1975, #2249): use a marginal config, e.g.MarginalNSFConfig(). - Passing a string as
density_estimator,classifierorvf_estimatorgoes in v0.30.0 (#1957, #1921, #2249): use a per-model config, e.g.MAFConfig(). - Old-style
pairplotandmarginal_plotkeyword arguments warn visibly and go in v0.29.0 (#2160 by @dgedon): pass them infig_kwargsor in the*_kwargsthat the warning names, andoffdiagasupper. - The per-call
effective_t_maxargument of the flow matching SDE functions goes in v0.29.0 (#2111 by @janfb): seteffective_t_maxon the estimator instead. unbiased=Trueof alpha VI warns and goes in v0.30.0 (#2207 by @janfb): useunbiased=False.
⭐ New Features
- Heun predictor for diffusion sampling (#2082 by @BHARATH0153)
LabeledSamplescarries plot labels and limits with the samples (#2016 by @BHARATH0153)sbc_rank_plot(plot_type="cdf-diff")(#1951 by @BHARATH0153, #2173 by @janfb)summary["converged"]records whether training converged (#2018 by @CaptainAni187)TQDM_DISABLE=1turns off sbi's progress bars and epoch counter (#2164 by @dgedon)- Sampling progress bars share one description (#2023 by @janfb)
EnsemblePosterior.map()takesforce_update(#2123 by @BHARATH0153)
🐛 Bug Fixes
Inference and posteriors
- Posteriors of NPE, FMPE and NPSE trained without a prior (#2308 by @janfb)
- NPE-A posteriors apply the proposal correction in all methods (#2035, #2045 by @janfb)
- Multi-round NPE-A and NPE-C with an MDN map the prior and proposal into the network's z-scored space (#2103 by @janfb)
- Multi-round NPE-C with an MDN uses the full Gaussian prior (#2081 by @aniketpandey05)
NPE_Bwith chunked appends,proposal=Noneand high-dimensional parameters (#2200 by @aniketpandey05)posterior.to(device)keeps the posterior's state and returns it (#2104 by @janfb)- Posteriors loaded with
torch.load(..., map_location=...)work on the new device (#1972 by @BHARATH0153) - Direct posteriors accept an explicit
xandthetaon another device (#2033 by @janfb, #2057 by @YashDoesCode) - Posteriors use the
max_sampling_batch_sizegiven to their constructor (#2077 by @mayuriphad) set_default_x()resets the saved leakage correction (#2015 by @janfb)ImportanceSamplingPosterior.log_prob()uses the right normalization for each x (#2107 by @aniketpandey05)map()returns the right estimate when no optimization step improves on the best initialization (#2072 by @BHARATH0153)map()lists theinit_methodoptions each posterior supports (#2106 by @SahilKumar75)- 1-D priors with batch shape (1,) give one log prob per sample (#2116 by @janfb)
- Rejection sampling with a
DirectPosteriororVIPosteriorproposal finds the right envelope (#2249 by @janfb) - Clear errors in importance sampling and SIR (#2223 by @patelshivani2283-lab)
sample((0,))returns an empty tensor (#2216 by @BHARATH0153)EnsemblePosterioruses new weights, works on the GPU and returns samples in random order (#2094 by @AryanRG, #2129 by @aniketpandey05)MCMCPosterior.set_mcmc_method()changes the sampler, and serialslice_npthins once (#2158 by @dgedon)- MCMC
sample_batched()withinit_strategy="latest_sample"continues each observation's own chains (#2233 by @aniketpandey05) RestrictedPriorwithsample_with="sir"respects the restriction and the prior (#2101 by @shivansh023023)- NPE-PFN sampling works with tabpfn 9.1 (#2051 by @janfb)
Variational inference
- VI with
vi_method="IW"trains the importance-weighted ELBO (#2067 by @SahilKumar75) - VI quality control retrains once, at your observation and settings (#2149 by @janfb)
- The PSIS check of VI fits the right tail (#2223 by @patelshivani2283-lab)
- Amortized VI works with bounded priors (#2139 by @AndreIsraelAO)
- Importance-weighted and alpha VI train with a
RestrictedPrioror a hard constraint (#2207 by @janfb) - Forward-KL VI and the VI convergence check with particles outside the support (#2172 by @janfb)
Vector field methods
- Guided and iid sampling of vector field posteriors (#2111 by @janfb, #2210 by @Abhinav3499)
- iid sampling with
iid_method="auto_gauss"and mixture priors (#2044 by @BHARATH0153) - iid sampling and guidance with a uniform prior use the right noised prior (#2063 by @YashDoesCode, #2204 by @mayuriphad, #2201 by @studentarijitpaul)
- Gauss-corrected iid sampling no longer fails on a singular precision (#2098 by @janfb)
- Diffusion sampling with
iid_method="fnpe"(#2088 by @janfb) - The Langevin corrector scores at the samples' current time (#2170 by @SahilKumar75)
- Vector field network settings reach the network (#1985 by @janfb)
- Vector field configs build with a BatchNorm embedding net (#2249 by @janfb)
- No more nested progress bars when a sampler draws from a posterior proposal (#1922 by @BHARATH0153)
Networks, priors and simulators
ConditionedMDNandMoG.condition(#2026 by @BHARATH0153, #2039 by @janfb)- MDN
log_probis normalized with structured z-scoring (#2079 by @G26karthik) - z-scoring layers move with
.to(), and networks rebuilt from one row load trained weights (#2155 by @janfb) CNNEmbeddingandCausalCNNEmbeddingcheck the input layout (#1983 by @ShreyanshGoyal)- Network factories accept an embedding net without parameters (#2118 by @janfb)
CategoricalMADErejects values it did not see in training (#2153 by @BHARATH0153)- A list of priors supports any sample shape (#2070 by @janfb)
- Mixture priors work on torch 2.8 and newer (#2071 by @janfb)
- float64 priors (#2064 and #2146 by @ThomasGesseyJonesPX)
- Reversed numpy views in and out of simulators (#2224 by @BHARATH0153)
- Complex simulator outputs raise (#2224 by @BHARATH0153)
ABC
- SMCABC keeps particles and simulations paired, and the linear regression adjustment stays within the prior (#2087 by @janfb)
SMCABCwithdistance_based_decay=Truepicks the epsilon quantile (#2123 by @BHARATH0153)SMCABCstarts fresh on every call (#2128 by @aniketpandey05)- ABC with
distance_batch_sizeno longer accepts uninitialized distances (#2020 by @janfb) get_kde(bandwidth="cv")finds the cross-validated bandwidth (#2061 by @JoeyTan21)
Diagnostics and metrics
- SBC uniformity checks account for the discrete ranks (#2102 by @BHARATH0153)
- 1D ranks in
check_sbcandsbc_rank_plot(#2209 by @patelshivani2283-lab) - SBC and TARP helpers handle a multidimensional
sample_shape(#2012 by @SahilKumar75) - TARP bins coverage values over [0, 1] (#2085 by @varunikarai)
run_tarpwith your ownreferencesand invalid simulations (#2163 by @soujasK)- L-C2ST keeps its false-positive rate (#2098 by @janfb)
- L-C2ST runs on the GPU and with
LC2ST_NFon nflows posteriors (#2206 by @janfb, #2143 by @BHARATH0153) - The MMD misspecification test is valid for many observations, ordered data and GPUs (#2157 by @G26karthik)
- The unbiased MMD of the misspecification test leaves out the kernel diagonal (#2225 by @soujasK)
biased_mmdstays finite for repeated values (#2190 by @clarkf19)c2sttakes custom classifiers, leaves its inputs unchanged and works on the GPU (#2124 by @shivansh023023)- The sample metrics read 1D samples as one feature (#2212 by @patelshivani2283-lab)
wasserstein_2_squaredandwasserstein_distancefor points far from the origin (#2205 by @mayuriphad)conditional_corrcoeffwith an unsortedsubset(#2196 by @aniketpandey05)samples_true_posterior_gaussian_mixture_uniform_priorreturns the right posterior (#2100 by @janfb, #2284 by @clarkf19)
Plotting
marginal_plotdraws each panel from its own dimension (#2219 by @dgedon)pairplotdraws the lower triangle with the column dimension on x, andsbc_rank_plotbins ranks over [0, N] (#2119 by @dgedon)- Legends and the uniformity band of
sbc_rank_plotwith several rank sets (#2173 by @janfb) - Plotting functions accept GPU tensors, tensors that require gradients and numpy limits (#2055 by @YashDoesCode, #2000 by @dhruvb2028)
pairplotwarns about unknown keys indiag_kwargs,upper_kwargsandlower_kwargs(#2006 by @BHARATH0153)pp_plotandpp_plot_lc2sttake arrays (#2215 by @Rohan-Dedhia)pairplotwithfig_kwargs=dict(legend=True)and an empty lower triangle no longer draws a stray x-label under the legend (#2160 by @dgedon).sbi.analysisimports with python-dateutil 4 (#2154 by @Mohit-Ak)
Messages
- NPE leakage is explained where it shows up (#2217 by @janfb)
- The low-acceptance warning of rejection sampling no longer fires after sampling has finished (#2164 by @dgedon)
🚀 Performance
- The batched NPE normalizer draws at most
rejection_sampling_batch_sizesamples at once over all observations (#2239 by @janfb) - MDN precision indices are device buffers (#2048 by @YashDoesCode)
📖 Documentation
- New how-to guides on estimator configs (#1987 by @satwiksps) and on running simulations in parallel (#1738 by @bmalezieux), a Simformer tutorial (#1621 by @nMaax), and a section on truncated proposals in the multi-round guide (#2217 by @janfb).
- The L-C2ST how-to guide is a short task guide, and the tutorial explains the method without true posterior samples (#2206 by @janfb).
- The leakage FAQ quotes the current warning and the current MCMC API, and no longer recommends an MDN to avoid leakage (#2192 by @aniketpandey05, #2217 by @janfb).
- The API reference has an Estimators page, working links, and class pages that list only sbi's own members (#1990 by @pawank925, #1991 by @janfb).
- Docstring and tutorial fixes: #1973 by @vitorbborges, #2009 by @tanmayBeginsJourney, #2112 by @mmporong, #2120 by @Ashwini8686, #2144, #2145, #2147 and #2174 by @aniketpandey05.
- The ArviZ how-to guide works with ArviZ 1, which PyMC 6 installs, and shows the samples of every MCMC sampler in parameter space; the PyMC and Pyro examples showed them in the unconstrained space of the prior. The estimator configs guide runs again.
- Enhancement proposals EP-02 (a standalone training loop) and EP-03 (training on datasets larger than memory), and EP-01 marked as completed (#2286, #2287 by @janfb).
🛠️ Maintenance
- Removed the GitHub Codespaces setup, which could not start outside the sbi-dev organization (#2022 by @janfb).
- Issue templates are forms with required version and device fields, and the contributing guide states the PR and review policy (#1974, #1977 by @janfb). A workflow tells outside contributors the expected review time (#2288, #2294 by @janfb).
- mini-sbibm selects estimators, has a mixed-data task and an MNLE mode, and compares runs over seeds (#2024, #2034 by @SahilKumar75, #2036 by @janfb).
- Internal refactors and type fixes: the
Proposalprotocol (#2013 by @vitorbborges), method overrides that match their base classes (#1984 by @pawank925), the VI link as a module (#2188 by @janfb), one helper for the SBC CDF plots (#2161 by @dgedon). - Tests: parallel test workers use one thread each (#2191 by @janfb), and test fixes (#1992, #2050 by @janfb).
- Dependency and lockfile updates by @dependabot and @github-actions (#2001, #2002, #2003, #2027, #2028, #2029, #2030, #2031, #2032, #2089, #2090, #2096, #2097, #2099, #2131, #2133, #2134, #2175, #2181, #2268, #2279, #2280).
🎉 New Contributors
- @vitorbborges made their first contribution in #1973
- @ShreyanshGoyal made their first contribution in #1983
- @pawank925 made their first contribution in #1990
- @dhruvb2028 made their first contribution in #2000
- @SahilKumar75 made their first contribution in #2012
- @tanmayBeginsJourney made their first contribution in #2009
- @CaptainAni187 made their first contribution in #2018
- @YashDoesCode made their first contribution in #2048
- @G26karthik made their first contribution in #2079
- @JoeyTan21 made their first contribution in #2061
- @mayuriphad made their first contribution in #2077
- @varunikarai made their first contribution in #2085
- @AryanRG made their first contribution in #2094
- @aniketpandey05 made their first contribution in #2081
- @shivansh023023 made their first contribution in #2101
- @mmporong made their first contribution in #2112
- @Ashwini8686 made their first contribution in #2120
- @AndreIsraelAO made their first contribution in #2139
- @Mohit-Ak made their first contribution in #2154
- @soujasK made their first contribution in #2163
- @clarkf19 made their first contribution in #2190
- @studentarijitpaul made their first contribution in #2201
- @bmalezieux made their first contribution in #1738
- @Rohan-Dedhia made their first contribution in #2215
- @Abhinav3499 made their first contribution in #2210
Full Changelog: v0.27.0...v0.28.0