Check only for negative divergences #574
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, a divergence error is triggered both when the energy increases and decreases excessively. However a large
delta_energy
can also occur in complex models, when initial points are widely outside the typical set. Then proposal steps typically vastly improve the likelihood and have large energy differences, but these are currently rejected. Changing the current behavior to only trigger whendelta_energy
is excessively negative fixes this behavior.This is in line with the implementation in Stan: https://github.com/stan-dev/stan/blob/88cffcf6271da06b0474dd6ce90d69a54127a5e6/src/stan/mcmc/hmc/nuts/base_nuts.hpp#L262C11-L262C19 and Numpyro: https://github.com/pyro-ppl/numpyro/blob/065aa4352dbc9ebeb1132b15b51d8b3149848640/numpyro/infer/hmc.py#L382C13-L382C13
I only modified the documentation of the local function, otherwise left that
divergence_threshold
is the "max value allowed for the difference in energies to be considered a divergence". I think it would lead to more confusion than be helpful if replaced by "an increase". Also, effectively, when the chain converged to the typical set, it shouldn't change anything.main
commit;pre-commit
is installed and configured on your machine, and you ran it before opening the PR;