build_mwg¶
- jaxrens.sampling.mwg.build_mwg(backend, move_descriptors, constraint_descriptors=())[source]¶
Build a Metropolis-within-Gibbs sampler from move descriptors.
Dynamically builds an MCState class containing only the fields needed by the active moves. Step sizes are stored on the state as a per-move array for independent per-replica adaptation.
- Parameters:
backend (Any) – EnergyBackend instance. Captured in move closures.
move_descriptors (list[MoveKernel]) – List of MoveKernel, each specifying a move type with its build_kernel, kwargs, weight, step_size, and optional extra_state_fields.
constraint_descriptors (tuple[ConstraintDescriptor, ...]) – Configuration constraints to enforce. Each is paired statically with the moves that can violate it (via
MoveKernel.mutatesvsConstraintDescriptor.depends_on); only intersecting moves get a constraint gate, and moves with no relevant constraint keep the unmodified fast path. Empty by default, so existing callers are unaffected.
- Returns:
init_fn(positions, types, energy, cell, step_sizes) -> MCState
step_fn(rng_key, state, likelihood_constraint, move_key) -> (MCState, MoveInfo)
- Return type:
(init_fn, step_fn) where