config
Pydantic configuration models for Jim's samplers.
Integer counts require Python integers; booleans, floats and strings are rejected.
Each sampler has its own *Config class discriminated by a type literal;
SamplerConfig is the discriminated-union annotation a caller passes to
Jim(..., sampler_config=...).
Attributes:
| Name | Type | Description |
|---|---|---|
FlowMCLocalKernelConfig |
Discriminated union of every flowMC local-kernel config, by its own |
|
SMCKernelConfig |
Discriminated union of the BlackJAX SMC mutation kernels, by their own |
|
SamplerConfig |
Discriminated union of every concrete sampler config. |
FlowMCLocalKernelConfig = Annotated[Union[FlowMCMALAConfig, FlowMCHMCConfig, FlowMCGRWConfig], Discriminator('kernel')]
module-attribute
¤
Discriminated union of every flowMC local-kernel config, by its own
kernel field -- the same pattern SamplerConfig itself uses (there via
type), so the active kernel's settings live in exactly one place with no
separate selector field to fall out of sync with it.
SMCKernelConfig = Annotated[Union[SMCTPCNConfig, SMCGRWConfig], Discriminator('kernel')]
module-attribute
¤
Discriminated union of the BlackJAX SMC mutation kernels, by their own
kernel field, as FlowMCLocalKernelConfig is for flowMC.
SamplerConfig = Annotated[Union[FlowMCConfig, BlackJAXNSAWConfig, BlackJAXNSSConfig, BlackJAXSwiGConfig, BlackJAXSMCConfig], Discriminator('type')]
module-attribute
¤
Discriminated union of every concrete sampler config.
BaseSamplerConfig
¤
Bases: BaseModel
Fields shared by all sampler configs.
BlackJAXNSAWConfig
¤
Bases: BaseSamplerConfig[Literal['blackjax-ns-aw']], _CheckpointMixin, _LiveSetConfigMixin
Configuration for the BlackJAX acceptance-walk nested sampler.
Note
This sampler requires the sampling space to be the unit hypercube
[0, 1]^n_dims. When using Jim, this means all
sample_transforms must map the prior support onto the unit cube.
Note
Periodic parameters are not configured here. Pass a
periodic argument to Jim instead.
For NS AW, bounds are implicit as [0, 1]; just list the
parameter names.
BlackJAXNSSConfig
¤
Bases: BaseSamplerConfig[Literal['blackjax-nss']], _CheckpointMixin, _LiveSetConfigMixin, _ShardingMixin
Configuration for the BlackJAX nested slice sampler.
Note
Periodic parameters are not configured here. Pass a periodic
argument to Jim instead.
BlackJAXSMCConfig
¤
Bases: BaseSamplerConfig[Literal['blackjax-smc']], _CheckpointMixin
Configuration for the BlackJAX SMC sampler.
mcmc_kernel selects the kernel that moves the particles at each
temperature: an SMCTPCNConfig (default) or an SMCGRWConfig, an
equivalent dict with a "kernel" key, or the bare kernel name for
its defaults (mcmc_kernel="GRW"). flow moves the particles in the
latent space of a normalizing flow, with either kernel: an
SMCFlowConfig (default), a dict of its fields, True for the
defaults, or False/None for no flow.
Without target_ess or target_ess_fraction, the ESS target is
3.0 * n_particles with persistent sampling and 0.9 * n_particles
without.
Parameters¤
batch_size : int, optional
Number of particles to process per sequential batch during the MCMC
update step. When batch_size > 0, the sampler uses jax.lax.map
instead of jax.vmap, which reduces peak GPU memory at the cost
of sequential execution. 0 (default) uses the original full
jax.vmap behaviour.
Note
Periodic parameters are not configured here. Pass a periodic
argument to Jim instead.
BlackJAXSwiGConfig
¤
Bases: BaseSamplerConfig[Literal['blackjax-swig']], _CheckpointMixin, _LiveSetConfigMixin, _ShardingMixin
Configuration for Nested Slice within Gibbs (SwiG) sampling.
blocks are expressed in sampling-space parameter names.
A supported likelihood validates that they form an exact partition and
identifies which blocks refresh its cache.
FlowMCConfig
¤
Bases: BaseSamplerConfig[Literal['flowmc']], _CheckpointMixin
Configuration for FlowMCSampler.
The local_kernel field selects the MCMC kernel used for local
proposals -- pass a FlowMCMALAConfig (default), FlowMCHMCConfig, or
FlowMCGRWConfig instance (or an equivalent dict with a "kernel" key,
or just the bare kernel name as a string for its defaults, e.g.
local_kernel="HMC"):
FlowMCMALAConfig— Metropolis-Adjusted Langevin; default.FlowMCHMCConfig— Hamiltonian Monte Carlo.FlowMCGRWConfig— Gaussian random walk.
Parallel tempering is off by default. To enable, pass a
FlowMCParallelTemperingConfig,
a dict of its fields, or simply True (uses all defaults).
False disables it.
Note
Periodic parameters are not configured here. Pass a periodic
argument to Jim instead; Jim resolves
parameter names to dimension indices and passes them to the sampler.
FlowMCGRWConfig
¤
Bases: BaseModel
Gaussian random-walk local-kernel settings for the flowMC backend.
step_size may be a scalar float (applied uniformly to all
dimensions) or a 1-D np.ndarray of length n_dims for
per-dimension step sizes.
FlowMCHMCConfig
¤
Bases: BaseModel
HMC local-kernel settings for the flowMC backend.
step_size may be a scalar float (applied uniformly) or a 1-D
np.ndarray of length n_dims for per-dimension sizes.
condition_matrix may also be a scalar or 1-D array and is used
as the mass matrix / preconditioning for HMC leapfrog steps.
FlowMCMALAConfig
¤
Bases: BaseModel
MALA local-kernel settings for the flowMC backend.
step_size may be a scalar float (applied uniformly to all
dimensions) or a 1-D np.ndarray of length n_dims for
per-dimension step sizes.
FlowMCParallelTemperingConfig
¤
Bases: BaseModel
Parallel-tempering settings for the flowMC backend.
Construct directly or pass a plain dict to FlowMCConfig.parallel_tempering.
Use True to enable with all defaults, False / None to disable.
SMCFlowConfig
¤
Bases: BaseModel
Normalizing-flow settings for the BlackJAX SMC backend.
At every mutation a newly initialised masked-coupling rational-quadratic
spline flow trains on the particles for n_epochs, and the kernel moves
the particles in the flow's latent space.
SMCGRWConfig
¤
Bases: BaseModel
Gaussian random-walk kernel settings for the BlackJAX SMC backend.
Each mutation runs n_mcmc_steps_per_dim * n_dims steps with proposal
covariance s * Cov(particles). After it, s is multiplied by
exp(scale_adaptation_gain * (acceptance - target_acceptance_rate));
initial_cov_scale is the first s.
SMCTPCNConfig
¤
Bases: BaseModel
t-pCN kernel settings for the BlackJAX SMC backend.
A mutation stops once the particles' mean log posterior has not improved
for n_patience_per_dim * n_dims steps, a count that grows as the step
size shrinks, or after n_max_per_dim * n_dims steps. The step size
adapts towards target_acceptance_rate.