replica_exchange_step¶
- jaxrens.sampling.moves.replica_exchange.replica_exchange_step(rng_key, walkers, emax, run_params, kernel, backend=None, n_swap_cycles=1)[source]¶
Run inter-replica swaps across R parallel runs.
Each cycle attempts the even pairs (0,1), (2,3), … and then the odd pairs (1,2), (3,4), …. For each pair one walker is drawn uniformly from each run,
kernel.proposebuilds the walkers that would enter the two runs, and the swap is accepted iff each incoming walker’s energy is below the receiving run’s Emax.- Parameters:
rng_key (Key[jaxlib._jax.Array, '']) – JAX PRNG key.
walkers (SwapWalker) – Population with leaves shaped
(R, K, ...); energies in each run’s own frame.emax (Float[jaxlib._jax.Array, 'R']) –
(R,)NS contour of each run.run_params (dict[str, Array]) – Per-run ensemble params, each leaf shaped
(R, ...)(e.g.{"pressure": (R,), "chemical_potentials": (R, S)}).kernel (SwapKernel) – Swap flavor.
backend (Any) – Energy backend, passed to
kernel.propose.n_swap_cycles (int) – Number of even+odd cycles.
- Returns:
(new_walkers, swap_info);swap_infohasn_accepted,n_attempted,n_energy_evals, and per-pairn_accepted_per_pair/n_attempted_per_pairof shape(R - 1,)indexed bymin(i, j).- Return type:
tuple[SwapWalker, dict[str, Array]]