sequince.steps.mutation.eryn#

Attributes#

Classes#

ErynMutation

Fixed-dimensional mutation step using Eryn.

Module Contents#

sequince.steps.mutation.eryn.logger#
class sequince.steps.mutation.eryn.ErynMutation(log_prob_fn, *, n_steps=1, move=None, run_kwargs=None, transform=None, transform_refit='always', store_chains=False, metrics=(), vectorize=True)[source]#

Bases: sequince.steps.mutation.base.MutationStep

Fixed-dimensional mutation step using Eryn.

Parameters:
  • log_prob_fn (callable or Target) – Function to compute the log-probability of a particle position, or a Target instance.

  • n_steps (int, optional) – Number of mutation steps to perform. Default is 1.

  • move (Eryn move object, optional) – Eryn move to use for the mutation. If not provided, a default StretchMove is used.

  • run_kwargs (dict, optional) – Additional keyword arguments to pass to the Eryn sampler’s sample method. Default is None.

  • transform (ParticleTransform, optional) – Transform to apply to the particles before mutation. Default is None.

  • transform_refit (TransformRefit, optional) – Strategy for refitting the transform. Default is “always”.

  • store_chains (bool, optional) – Whether to store the full chain of mutated particles. Default is False.

  • metrics (list of MutationMetric, optional) – Metrics to compute during mutation. Default is an empty list.

  • vectorize (bool, optional) – Whether to vectorize the log-probability evaluation. Default is True.

apply(state, context, rng)[source]#
Parameters:
Return type:

tuple[sequince.state.ParticleState, sequince.steps.context.StepContext, dict[str, object]]

apply_with_mutation_state(state, context, rng, *, n_steps, mutation_state=None)[source]#

Run transitions within a block without finalizing metrics.

Pass mutation_state=None to initialize a new block; otherwise pass the state returned by the preceding call. The state holds individual metric states and cumulative acceptance bookkeeping. It must belong to the same metric configuration and mutation coordinate space.

Returns (state, context, output, mutation_state). The output’s metrics remain unset, including on the first and zero-step calls. Concrete mutations prepare existing metrics on entry, update state for each transition, and return it explicitly without calling metric.result(). Runtime state must never be stored on the mutation object.

Use apply or apply_with_n_steps for a complete standalone block. RepeatedMutationStep uses this method to continue across rounds and finalizes metrics once after the complete block.

Parameters:
Return type:

tuple[sequince.state.ParticleState, sequince.steps.context.StepContext, dict[str, object], sequince.steps.mutation.metrics.MutationStepState | None]