Defer initEpsilon() to start of next iteration #66
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.
This PR defers the call to
initEpsilon()
and associated resetting of a few warmup-related variables from the end of one iteration to the beginning of the next. This is intended for two reasons, both having to do with the case of other samplers operating on the model. (Hence, it should not be relevant if HMC is the only sampler.) These changes are only for theNUTS_sampler
, not the "classic" version. The two reasons are:initEpsilon()
could leave the model out of state, specifically with logProb values that are not up to date. I seevalues(model, nodes) <-
is used to reset node values, but superficially it looks like logProb values would also need to be put back in state. If that is a non-issue, I might be forgetting why. Leavining logProbs out of state will be no problem if the NUTS sampler is about to run (as in this PR), because it will update all nodes and end by leaving the model in state. But if the NUTS sampler is finishing and another sampler will run, it could cause an incorrect update. This would only happen around 5ish times spread throughout a warmup schedule, so it might not cause catastrophic results.initEpsilon()
will operate after them and just before the NUTS update. It is just a guess that this might be slightly better than havinginitEpsilon()
operate after NUTS and before other samplers, making its determination of an initial epsilon value possibly contingent on old values of other parameters.I am running tests locally and don't remember if we have CI set up for this package. About to find out.