Skip to content

Commit f4f94ae

Browse files
committed
update queue_size restoration
1 parent 78bf0e4 commit f4f94ae

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

docs/source/quickstart.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ If you used the pool in the sampler and you want to use the pool after restoring
655655
sampler.run_nested(resume=True)
656656

657657
You should be careful when restoring the sampler on machine with different number of CPUs when using a pool.
658-
We will try to update the queue_size based on what is the pool size.
658+
We will still use the original queue_size unless it was 1 before.
659659

660660
The checkpointing may be helpful if you are running dynesty on HPC with a queue system that has a limit on a wall-time that your jobs can run.
661661
There is a however an important reminder that should *NOT* use checkpointing for persistence. I.e. if you want to save the results of the sampling, you should save samples, weights or the results object, rather than the whole nested sampling object (as checkpointing does). The reason for this is that the checkpoint files are not guaranteed to be compatible between dynesty versions (even minor ones).

py/dynesty/utils.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,21 +2146,21 @@ def restore_sampler(fname, pool=None):
21462146
f'The dynesty version in the checkpoint file ({save_ver})'
21472147
f'does not match the current dynesty version'
21482148
f'({DYNESTY_VERSION}). That is *NOT* guaranteed to work')
2149-
if pool is not None:
2150-
queue_size_old = getattr(sampler, 'queue_size', None)
2151-
try:
2152-
# we first try to get the new queue_size
2153-
# that may fail if the pool has no information about the size
2154-
mapper, queue_size_new = _parse_pool_queue(pool, None)
2155-
except ValueError:
2156-
# if first failed we are using the new queue_size
2157-
mapper, queue_size_new = _parse_pool_queue(pool, queue_size_old)
2158-
2159-
if queue_size_new is not None and queue_size_new > queue_size_old:
2160-
warnings.warn(
2161-
f'Restoring the sampler with queue_size {queue_size_old}')
2162-
else:
2163-
mapper = map
2149+
2150+
queue_size_old = getattr(sampler, 'queue_size', None)
2151+
try:
2152+
# we first try to get the new queue_size
2153+
# that may fail if the pool has no information about the size
2154+
mapper, queue_size_new = _parse_pool_queue(pool, None)
2155+
except ValueError:
2156+
# if first failed we are using the old queue_size
2157+
mapper, queue_size_new = _parse_pool_queue(pool, queue_size_old)
2158+
2159+
if queue_size_new != queue_size_old and queue_size_old != 1:
2160+
warnings.warn(
2161+
f'Restoring the sampler with queue_size {queue_size_old}')
2162+
queue_size_new = queue_size_old
2163+
21642164
if hasattr(sampler, 'sampler'):
21652165
# This is the case of the dynamic sampler
21662166
# this is better be written as isinstanceof()
@@ -2179,6 +2179,7 @@ def restore_sampler(fname, pool=None):
21792179
for cursamp in samplers:
21802180
cursamp.mapper = mapper
21812181
cursamp.pool = pool
2182+
cursamp.queue_size = queue_size_new
21822183
return sampler
21832184

21842185

0 commit comments

Comments
 (0)