JohannesBuchner / UltraNest

Fit and compare complex models reliably and rapidly. Advanced nested sampling.
https://johannesbuchner.github.io/UltraNest/
Other
153 stars 30 forks source link

MPI fails with likelihoods that have plateaus #107

Closed gregorydavidmartinez closed 1 year ago

gregorydavidmartinez commented 1 year ago

UltraNest fails when using MPI with likelihoods with plateaus. Apparently, this is because in lines 1445-1451 in integrator.py,

            if 1 < P < len(Ls) and len(Ls) - P + 1 < nroots:
                # guess the number of points needed: P-1 are useless
                self.logger.debug(
                    'Found plateau of %d/%d initial points at L=%g. '
                    'Avoid this by a continuously increasing loglikelihood towards good regions.',
                    P, nroots_needed, Lmin)
                nroots_needed = min(num_stop, nroots_needed + (P - 1))

,self.logger is called by each process, but it's only defined on rank 0. So, the other ranks throw an Attribute not found error. Changing these lines to

            if 1 < P < len(Ls) and len(Ls) - P + 1 < nroots:
                # guess the number of points needed: P-1 are useless
                if self.log:
                    self.logger.debug(
                        'Found plateau of %d/%d initial points at L=%g. '
                        'Avoid this by a continuously increasing loglikelihood towards good regions.',
                        P, nroots_needed, Lmin)
                nroots_needed = min(num_stop, nroots_needed + (P - 1))

seems to fix this. If you with wish, I can submit a pull request?

JohannesBuchner commented 1 year ago

Yes, that's a bug and the right fix!

JohannesBuchner commented 1 year ago

A PR would be great!

JohannesBuchner commented 1 year ago

Fixed via #110

JohannesBuchner commented 1 year ago

The fix is part of ultranest version 3.6.3, please test and let me know whether the issue is resolved for you.