autofit.DynestyStatic#

class DynestyStatic[source]#

Bases: AbstractDynesty

A Dynesty NonLinearSearch using a static number of live points.

For a full description of Dynesty, checkout its GitHub and readthedocs webpages:

https://github.com/joshspeagle/dynesty https://dynesty.readthedocs.io/en/latest/index.html

Parameters:
  • name (Optional[str]) – The name of the search, controlling the last folder results are output.

  • path_prefix (Union[str, Path, None]) – The path of folders prefixing the name folder where results are output.

  • unique_tag (Optional[str]) – The name of a unique tag for this model-fit, which will be given a unique entry in the sqlite database and also acts as the folder after the path prefix and before the search name.

  • nlive (int) – Number of live points used for sampling.

  • dlogz (Optional[float]) – Stopping criterion: iteration stops when the estimated contribution of the remaining prior volume to the total evidence falls below this threshold.

  • maxiter (Optional[int]) – Maximum number of iterations.

  • logl_max (float) – Maximum log-likelihood value allowed.

  • iterations_per_full_update (int) – The number of iterations performed between update (e.g. output latest model to hard-disk, visualization).

  • number_of_cores (int) – The number of cores sampling is performed using a Python multiprocessing Pool instance.

  • session (Optional[Session]) – An SQLalchemy session instance so the results of the model-fit are written to an SQLite database.

Methods

apply_test_mode

Reduce the search's budget for test mode: the generic reduction sets each attribute of the declared test_mode_budget (apply_test_mode of this module).

check_model

check_pool

chunk_is_finished

Whether a run_nested chunk stopped on dynesty's own termination criterion rather than on its budget, given the budget (iterations) and the total calls before and after the chunk.

chunk_kwargs

Extra run_nested keyword arguments for a chunk, given the number of likelihood calls made before it.

copy_with_paths

exact_fit

execution_settings

How this search executes its objective on analysis, resolved once: batching, eager or jitted execution, gradient use and the resolved gradient mode, plus the Fitness keyword arguments the backend builds its Fitness with (autofit.non_linear.search.preflight.ExecutionSettings).

finalize_result

The one ending of a fit that ran (or was bypassed in test mode): build the Result, run the analysis' save_results hooks, unfreeze the model and complete the fit (archive, then .completed).

finalize_search_internal

Archive search_internal (output_search_internal) when the search retains its internal state, otherwise remove the search_internal folder.

fit

Fit a model, M with some function f that takes instances of the class represented by model M and gives a score for their fitness: the search produces instances of the model by picking points in its N dimensional space.

fitness_overrides

A JAX analysis is jitted lazily by the scalar objective __call__ dispatches to; the deprecated use_jax_jit=False keeps its old meaning (eager JAX) for one release.

info_from

The samples_info entries of a run(ctx) search's internal state, the info its raw_samples_from puts on the RawSamples (autofit.non_linear.samples.adapter).

iterations_from

Returns the next number of iterations that a dynesty call will use and the total number of iterations that have been performed so far.

live_points_init_from

By default, dynesty live points are generated via the sampler's in-built initialization.

load_search_internal

The archive (search_internal.dill, written when the fit completed) or, for a run that has not completed, the sampler restored from its resume state (savestate.save).

make_fitness

The Fitness this search evaluates its likelihood through, the one construction site every search shares.

maxcall_from

The maxcall handed to run_nested for a chunk of iterations likelihood calls, given that total_iterations calls have already been made.

optimise

Optimise one expectation-propagation factor with this search (autofit.graphical.expectation_propagation.SearchFactorOptimiser).

output_search_internal

Archive search_internal through the search's checkpointer and, once a fit has completed, discard its resume state (there is nothing left to resume).

perform_update

Perform an update of the non-linear search's model-fitting results.

perform_visualization

Perform visualization of the non-linear search's model-fitting results.

plot_latent_results

The search's plots of the model's latent parameters (the corner plot of a shear's magnitude and angle, say), by its posterior_kind; nothing for a search without one.

plot_results

The search's own plots of its samples, by its declared posterior_kind (autofit.non_linear.search.posterior_kind): the chain, weighted or point plotter.

plot_start_point

Visualize the starting point of the non-linear search, using an instance of the model at the starting point of the maximum likelihood estimator.

post_fit_output

Archives the output folder of a completed non-linear search into its .zip file (always), and then removes the folder so only the .zip is left (for supercomputers with a file-count limit) only when remove_files=True in the general.yaml output section; with remove_files=False both are kept.

pre_fit_output

Outputs attributes of fit before the non-linear search begins: the model composition (files/model.json), the search settings (files/search.json), the info dictionary (files/info.json), the analysis' save_attributes (e.g. files/data.json) and its visualize_before_fit / visualize_before_fit_combined visuals (quantities that do not change during the model-fit, e.g. the data).

progress

The run's progress for the status record (autofit.non_linear.status): the likelihood calls so far, the evidence and, when maxcall bounds the run, the share of it spent (fraction).

raw_samples_from

The dynesty run's samples, log likelihoods and nested-sampling weights (exp(logwt - logz[-1])) as raw samples.

read_uses_pool

If a Dynesty fit does not use a parallel pool, and is then resumed using one, this causes significant slow down.

result_via_completed_fit

Returns the result of the non-linear search of a completed model-fit.

run

Run dynesty (the run(ctx) hook; see docs/design/run_ctx.md) and return the sampler.

run_search_internal

Run the Dynesty sampler, which could be either the static of dynamic sampler.

samples_from

Loads the samples of a non-linear search from its output files.

samples_info_from

samples_via_internal_from

The samples of the search, converted from its internal state.

search_internal_from

Returns an instance of the Dynesty static sampler set up using the input variables of this class.

start_points

The search's n initial points, drawn by its initializer, with the start-point plot made once, here, from the first of them.

start_resume_fit

total_calls_from

The total number of likelihood calls the sampler has made so far, or 0 for a sampler that has not run.

write_uses_pool

If a Dynesty fit does not use a parallel pool, and is then resumed using one, this causes significant slow down.

Attributes

batched

checkpoint_file

The path to the file used for checkpointing.

checkpointer

where the backend's final state is stored when a fit completes, for Result.search_internal and samples_via_internal_from.

citation_keys

gradient

honours_gradient_mode

install_extra

invalid_value

jax_use

logger

Log 'msg % args' with severity 'DEBUG'.

name

number_live_points

objective_target

paths

posterior_kind

produces_evidence

quick_update_message

The one-line quick-update cadence logged at the start of every fit.

requires_fp64

resumable

resume_state

The file an interrupted run resumes from, for searches that genuinely resume (None otherwise).

retains_search_internal

always when the archive declares retain_after_completion (its results cannot be rebuilt without it), otherwise when the output.search_internal config is on.

run_kwargs

Run kwargs specific to each subclass, excluding maxcall.

search_internal

The sampler restored from the resume state (savestate.save) of a run that has not completed.

search_kwargs

Shared search kwargs passed to both Static and Dynamic Dynesty samplers.

should_plot_start_point

status

test_mode_budget

timer

The timer of the search (how long the search took, how much parallelization sped it up), or None when the paths keep no timer (has_timer: NullPaths, DatabasePaths).

upstream_url

warm_start

resume_state: Optional[Checkpointer] = NativeFileCheckpointer('savestate.save', retain_after_completion=False)#

The file an interrupted run resumes from, for searches that genuinely resume (None otherwise). Deleted when the fit completes unless it is the archive’s own file or declares retain_after_completion.

property run_kwargs: Dict#

Run kwargs specific to each subclass, excluding maxcall.

search_internal_from(model, fitness, checkpoint_exists, pool, queue_size)[source]#

Returns an instance of the Dynesty static sampler set up using the input variables of this class.

If no existing dynesty sampler exist on hard-disk (located via a checkpoint_file) a new instance is created with which sampler is performed. If one does exist, the dynesty restore() function is used to create the instance of the sampler.

Dynesty samplers with a multiprocessing pool may be created by inputting a dynesty Pool object, however non pooled instances can also be created by passing pool=None and queue_size=None.

Parameters:
  • model (AbstractPriorModel) – The model which generates instances for different points in parameter space.

  • fitness – An instance of the fitness class used to evaluate the likelihood of each model.

  • pool (Optional) – A dynesty Pool object which performs likelihood evaluations over multiple CPUs.

  • queue_size (Optional[int]) – The number of CPU’s over which multiprocessing is performed, determining how many samples are stored in the dynesty queue for samples.

property number_live_points#