JohannesBuchner / UltraNest

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

MPI fails with likelihoods that have plateaus #107

Closed gregorydavidmartinez closed 10 months ago

gregorydavidmartinez commented 10 months 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 10 months ago

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

JohannesBuchner commented 10 months ago

A PR would be great!

JohannesBuchner commented 10 months ago

Fixed via #110

JohannesBuchner commented 10 months ago

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