build_adapt_step¶
- jaxrens.sampling.adaptation.manager.build_adapt_step(move_descriptors, per_move_fns, batcher, adjust_n_samples, adjust_factor, adjust_max_rounds, adjust_interval, trial_batch_size=None)[source]¶
Build the per-iteration adapt step.
Returns
Nonewhen adaptation is inactive — whenper_move_fnsormove_descriptorsis empty, oradjust_interval <= 0. Callers detect inactivity viaif adapt_step is None.Otherwise returns
adapt_step(ns_state, emax, rng_key)which:Extracts current step sizes from
ns_state.population.Iterates over moves: per-move bisection on a fresh trial sample, with early exit per-replica once every replica has converged.
Writes the new step sizes back into the population and returns the full
(new_ns_state, diag, new_rng_key)tuple.
rng_keyMUST already matchbatcher.shape_prefix: scalar forSingleRun,(R,)forVmapRuns(R),(G, P)forPmapVmapRuns(G, P), and(n_gpu,)(broadcast — same key on every shard, required forlax.psumbisection coherence) forShardedSingleRun. Callers that carry a scalar key (e.g. burn-in) must promote it themselves before calling.- Parameters:
move_descriptors (Sequence[MoveKernel]) – One
MoveKernelper move type.per_move_fns (Sequence[Callable] | None) – One step function per move type.
None/ empty → inactive.batcher (SingleRun | VmapRuns | PmapVmapRuns | ShardedSingleRun) –
BatchDescriptor(SingleRun/VmapRuns/PmapVmapRuns/ShardedSingleRun).adjust_n_samples (int) – Walkers per bisection trial round (static).
adjust_factor (float) – Multiplicative step-size factor (static).
adjust_max_rounds (int) – Max bisection rounds (static).
adjust_interval (int) – Iterations between fires.
<= 0→ inactive.trial_batch_size (int | None) – Optional chunk for the per-round trial vmap (
jax.lax.map(batch_size=...)). Bounds peak memory attrial_batch_size * per-walker tape.None→ full vmap.
- Returns:
adapt_stepclosure (signature above), orNonewhen inactive.- Return type:
Callable[[Any, Float[jaxlib._jax.Array, ’*B’], Key[jaxlib._jax.Array, ’*B’]], tuple[Any, dict, Key[jaxlib._jax.Array, ’*B’]]] | None
The
diagdict it returns has keysrate/counts/n_rounds/converged/cap_hits/floor_hits/bracket_detected/trial_n_evaluations/trial_n_grad_evaluations. Stacked over moves along the axis right after the batch prefix: shape(n_moves, ...)for SingleRun,(n_runs, n_moves, ...)for VmapRuns,(G, P, n_moves, ...)for PmapVmapRuns.