Skip to content

BUG: ensure infinite ACT estimates are properly handled#39

Merged
mj-will merged 4 commits intobilby-dev:mainfrom
ColmTalbot:dynesty-inf-act-estimates
Oct 29, 2024
Merged

BUG: ensure infinite ACT estimates are properly handled#39
mj-will merged 4 commits intobilby-dev:mainfrom
ColmTalbot:dynesty-inf-act-estimates

Conversation

@ColmTalbot
Copy link
Copy Markdown
Collaborator

@lalit-pathak reported the following error. This happens when no points are accepted during the MCMC while using ACT-walk. This is most likely a sign of some underlying pathology in the likelihood/sampling space, but we should handle the case smoothly.

Traceback (most recent call last):
  File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/site-packages/bilby/core/sampler/dynesty_utils.py", line 198, in __call__
    while self.cache[0][2] < args.loglstar:
  File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/site-packages/bilby/core/sampler/dynesty_utils.py", line 207, in cache
    self.build_cache()
  File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/site-packages/bilby/core/sampler/dynesty_utils.py", line 223, in build_cache
    check_interval = int(np.ceil(self.act))
OverflowError: cannot convert float infinity to integer

I also noticed a second case where an infinity can sneak in that will break things, if there are fewer than ten live points, the acceptance walk method will fail on current master.

Traceback (most recent call last):
  File "/Users/colm/modules/bilby/examples/core_examples/linear_regression.py", line 57, in <module>
    result = bilby.run_sampler(
  File "/Users/colm/modules/bilby/bilby/core/sampler/__init__.py", line 234, in run_sampler
    result = sampler.run_sampler()
  File "/Users/colm/modules/bilby/bilby/core/sampler/base_sampler.py", line 97, in wrapped
    output = method(self, *args, **kwargs)
  File "/Users/colm/modules/bilby/bilby/core/sampler/dynesty.py", line 517, in run_sampler
    out = self._run_external_sampler_with_checkpointing()
  File "/Users/colm/modules/bilby/bilby/core/sampler/dynesty.py", line 637, in _run_external_sampler_with_checkpointing
    self.sampler.run_nested(**sampler_kwargs)
  File "/Users/colm/modules/dynesty/py/dynesty/sampler.py", line 1057, in run_nested
    for it, results in enumerate(
  File "/Users/colm/modules/dynesty/py/dynesty/sampler.py", line 877, in sample
    u, v, logl, nc = self._new_point(loglstar_new)
  File "/Users/colm/modules/dynesty/py/dynesty/sampler.py", line 462, in _new_point
    self.update_proposal(blob, update=self.nqueue <= 0)
  File "/Users/colm/modules/bilby/bilby/core/sampler/dynesty_utils.py", line 56, in update_user
    self.walks = (self.walks * delay + n_target / accept_prob) / (delay + 1)
ZeroDivisionError: float division by zero

I'm opening this as a test of migrating open MRs from gitlab to here. https://git.ligo.org/lscsoft/bilby/-/merge_requests/1383 is the original MR.

@mj-will mj-will added the bug Something isn't working label Oct 4, 2024
@ColmTalbot ColmTalbot force-pushed the dynesty-inf-act-estimates branch from cc6978f to 32f348c Compare October 23, 2024 18:31
Copy link
Copy Markdown
Collaborator

@GregoryAshton GregoryAshton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ColmTalbot this cleans things up nicely. Happy to approve.

@ColmTalbot ColmTalbot force-pushed the dynesty-inf-act-estimates branch from 32f348c to 0cab5a3 Compare October 29, 2024 13:18
@ColmTalbot ColmTalbot added this to the 2.4.0 milestone Oct 29, 2024
@mj-will mj-will merged commit 8b2f6cf into bilby-dev:main Oct 29, 2024
JasperMartins pushed a commit to JasperMartins/bilby that referenced this pull request Nov 1, 2024
* BUG: ensure infinite ACT estimates are properly handled

* REFACTOR: promote debug to warning for poor sampling

* FMT: remove excess empty line

* FMT: remove excess whitespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants