Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor divergence check to each sampler #579

Merged
merged 2 commits into from
Oct 29, 2023

Conversation

junpenglao
Copy link
Member

Fix #391.

The change end up quite small that it do away divergence check in proposal.py, and compute divergence only when needed (in hmc.py and trajectory.py). The functions in proposal.py is more general than just HMC that we see pattern like:

new_proposal, _ = generate_proposal(state, end_state)

So removing the check would keeps the functions in proposal.py simpler and more focus.

However, we cannot push the check the top most level (ie., it need to remain in trajectory.py), as the information is used during the trajactory building and it is not easy to refactor it away.

@codecov
Copy link

codecov bot commented Oct 29, 2023

Codecov Report

Merging #579 (48acc23) into main (df935cf) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #579   +/-   ##
=======================================
  Coverage   99.14%   99.14%           
=======================================
  Files          49       49           
  Lines        2099     2100    +1     
=======================================
+ Hits         2081     2082    +1     
  Misses         18       18           
Files Coverage Δ
blackjax/mcmc/hmc.py 100.00% <100.00%> (ø)
blackjax/mcmc/mala.py 100.00% <100.00%> (ø)
blackjax/mcmc/proposal.py 100.00% <100.00%> (ø)
blackjax/mcmc/random_walk.py 100.00% <100.00%> (ø)
blackjax/mcmc/trajectory.py 95.90% <100.00%> (+0.06%) ⬆️

@junpenglao junpenglao enabled auto-merge (squash) October 29, 2023 12:43
Copy link
Member

@albcab albcab left a comment

Choose a reason for hiding this comment

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

Looks good, makes proposal.py cleaner!

@junpenglao junpenglao merged commit 29dc2eb into blackjax-devs:main Oct 29, 2023
7 checks passed
@junpenglao junpenglao deleted the refactor_proposal branch October 29, 2023 16:07
junpenglao added a commit that referenced this pull request Mar 12, 2024
* partially fix #391

* fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move divergence_threshold to postprocessing in the higher-level kernel
2 participants