Skip to content

Advanced usage: Nested Samplers and Multi threading

Néstor Espinoza edited this page Dec 19, 2018 · 3 revisions

Nested samplers within juliet

Currently, juliet allows the user to perform Nested Sampling via classical Nested Sampling (either using MultiNest via PyMultiNest or via simple or multiple ellipsoids via dynesty), via Importance Nested Sampling (via PyMultiNest) or via Dynamic Nested Sampling (via dynesty).

All the above defined algorithms need as input the so-called live-points, which are the ones that explore the prior volume to compute the evidences and used to gather (unweighted) posterior samples (which are internally weighted to perform the final posterior samples which are saved by juliet). Within juliet the number of live points is set by default to 1000, but this can be changed via the -nlive flag, e.g.,

python juliet.py ... -nlive 500

will set the number of live points to 500.

By default, juliet uses Importance Nested Sampling via PyMultiNest. However, this algorithm starts to be inefficient for dimensions larger than around 20, where Dynamic Nested Sampling starts to excel. To activate dynesty within juliet, simply add the --use_dynesty flag in a juliet run, i.e.,

python juliet.py ... --use_dynesty

By default, this will perform a juliet run using dynesty's multi-ellipsoid Nested Sampling (i.e., similar to MultiNest). Dynamic Nested Sampling is activated via the --dynamic flag, i.e.,

python juliet.py ... --use_dynesty --dynamic

For typical problems in exoplanetary science, multiple-ellipsoids might be overkill as there is usually one global maximum. If this is believed to be the case, one can turn off the multiple ellipsoids by setting the -dynesty_bound flag to single, i.e.,

python juliet.py ... --use_dynesty --dynamic -dynesty_bound single

This latter option usually involves a significant speed-up in computation time. Although this might be sufficient for most usages, further options for dynesty can be defined; we refer the user to check the possible juliet flags that allows to do this.

Multi-threading with juliet

One of the nice features of juliet (thanks to the usage of MultiNest and dynesty for Nested Sampling) is its ability to perform multi-threading to speed up the runs. Depending on the number of cores this can dramatically decrease the computing time, which will be dependant on the number of dimensions of the problem at hand.

Depending on the algorithm used to perform Nested Sampling, turning multi-threading on will be different. Below we detail how to do this within juliet.

Multi-threading with MultiNest

MultiNest (used in juliet via PyMultiNest) provides direct OpenMPI support (which needs to be installed in your machine) for multi-threading. As such, activating multi-threading via MultiNest is done externally. In order to activate it, instead of starting a juliet run using python juliet ..., one would start a juliet run by doing:

mpirun -np X python juliet.py ...

where X is the number of threads to be used. This will thus start a juliet run with X threads.

Multi-threading with dynesty

If a juliet run is performed using dynesty instead of MultiNest (the latter being juliet's the default sampler), multi-threading is performed internally via python parallelization. This has already been coded inside juliet, and thus using this is extremely simple. To use it, simply add the flag -dynesty_nthreads X, where X is the number of threads to use, i.e.:

python juliet.py ... -dynesty_nthreads X

Activating this flag means by default the user wants to perform multi-threading.