Closed OGdodge closed 2 years ago
Hi,
Thanks for the report. I can reproduce the issue with this script (it first has to be run with resume=False, interrupted then resumed):
import numpy as np
import dynesty
import time
class CL:
def __init__(self):
pass
def __call__(self, x):
time.sleep(.01)
return -0.5 * np.sum((x - .5)**2)
def pt(self, x):
return x
if __name__ == '__main__':
C = CL()
resume = True
if not resume:
with dynesty.pool.Pool(4, C, C.pt) as pool:
dns = dynesty.DynamicNestedSampler(pool.loglike,
pool.prior_transform,
4,
pool=pool)
dns.run_nested(checkpoint_file='xx.pkl', checkpoint_every=10)
else:
with dynesty.pool.Pool(4, C, C.pt) as pool:
dns = dynesty.DynamicNestedSampler.restore('xx.pkl', pool=pool)
dns.run_nested(resume=True)
I haven't previously tested the dynesty.pool with the resume.
If you use the standard multiprocessing pool it will certainly work without issues.
But with the dynesty.pool, I need to think about it. it may be not trivial (to be honest it may even be impossible)
I think I've fixed this issue with https://github.com/joshspeagle/dynesty/commit/3411eecfab468130d290b07a6db4b6091c91890c please check if it works for you. The fix is somewhat tentative.
Works perfectly, thanks for the fix much appreciated! :)
Dynesty version Specify the exact version, and how you installed it (pip/git) 1.2.2 thru git clone Describe the bug [A clear and concise description of what the bug is.] Resuming a dynamic nested sampler in a dynesty pool does not correctly recognise the provided prior transform function, leading to an error on resumption. I think I've got the setup pretty much as described in the dynamic sampler tutorial on read the docs. Setup I am runningthe following dynesty setup:
Dynesty output
Bug I find the prior transform function is not found by the resumed sampler which gives the following error: Traceback (most recent call last):
The behaviour I expected was a simple resumption of the nested sampling. My setup works without a pool. Apologies if this isn't at all helpful, my first bug report and tbh I'm not even sure it's a bug, I could be doing something stupid wrong! Just figured I'd submit it as a bug as the question section said if you're not sure to submit it as a bug :) Thanks for dynesty, it's a wonderfully simple sampler overall and has made my life a lot easier!