-
Notifications
You must be signed in to change notification settings - Fork 230
Do not take an initial step before starting the chain in HMC #2674
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
Conversation
|
Turing.jl documentation for PR #2674 is available at: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2674 +/- ##
==========================================
- Coverage 85.86% 85.79% -0.07%
==========================================
Files 22 22
Lines 1429 1422 -7
==========================================
- Hits 1227 1220 -7
Misses 202 202 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Pull Request Test Coverage Report for Build 17642662193Details
💛 - Coveralls |
sunxd3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, no objection. The failed tests also look unrelated, so good.
On versioning, do you think this constitute a breaking change? Not saying I do, but worth second thought.
|
I think generally for random results we shouldn't guarantee the exact numerical results as being part of the API, but we should guarantee some statistical properties. Since this doesn't change convergence properties for MCMC I think it's fine to put as a bugfix. I guess this isn't an official policy though so maybe worth checking if we all agree? |
|
My concern is the behavior of initialization. Before this PR, the initialization wasn't returned in the chain. |
|
There is actually a subtle change that I just realised with this: when the initial state is included, then there are no sampler stats for the first entry in the chain (because the sampler hasn't run). That means they all get a value of Because MCMCChains requires a consistent eltype for all parameters + stats, this means that all the parameters are stored as julia> using Turing; @model f() = x ~ Normal(); c = sample(f(), HMC(0.1, 5), 100)
Sampling 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████| Time: 0:00:00
Chains MCMC chain (100×13×1 reshape(::Matrix{Union{Missing, Float64}}, 100, 13, 1) with eltype Union{Missing, Float64}):
Iterations = 1:1:100
Number of chains = 1
Samples per chain = 100
Wall duration = 0.26 seconds
Compute duration = 0.26 seconds
parameters = x
internals = hamiltonian_energy, n_steps, numerical_error, loglikelihood, hamiltonian_energy_error, is_accept, logprior, log_density, step_size, acceptance_rate, lp, nom_step_size
Use `describe(chains)` for summary statistics and quantiles.
julia> eltype(c[:x])
Union{Missing, Float64}On main, This to me is not actually a Turing problem. It's an MCMCChains problem. But I wonder if that would factor into the decision. |
|
i'll change the base to |
97ce752 to
3ebd958
Compare
* Bump minor version * Do not take an initial step before starting the chain in HMC (#2674) * Do not take an initial step before starting the chain in HMC * Fix some tests * update changelog * Compatibility with DynamicPPL 0.38 + InitContext (#2676) * Import `varname_leaves` etc from AbstractPPL instead * initial updates for InitContext * More fixes * Fix pMCMC * Fix Gibbs * More fixes, reexport InitFrom * Fix a bunch of tests; I'll let CI tell me what's still broken... * Remove comment * Fix more tests * More test fixes * Fix more tests * fix GeneralizedExtremeValue numerical test * fix sample method * fix ESS reproducibility * Fix externalsampler test correctly * Fix everything (I _think_) * Add changelog * Fix remaining tests (for real this time) * Specify default chain type in Turing * fix DPPL revision * Fix changelog to mention unwrapped NT / Dict for initial_params * Remove references to islinked, set_flag, unset_flag * use `setleafcontext(::Model, ::AbstractContext)` * Fix for upstream removal of default_chain_type * Add clarifying comment for IS test * Revert ESS test (and add some numerical accuracy checks) * istrans -> is_transformed * Remove `loadstate` and `resume_from` * Remove a Sampler test * Paper over one crack * fix `resume_from` * remove a `Sampler` test * Update HISTORY.md Co-authored-by: Markus Hauru <[email protected]> * Remove `Sampler`, remove `InferenceAlgorithm`, transfer `initialstep`, `init_strategy`, and other functions from DynamicPPL to Turing (#2689) * Remove `Sampler` and move its interface to Turing * Test fixes (this is admittedly quite tiring) * Fix a couple of Gibbs tests (no doubt there are more) * actually fix the Gibbs ones * actually fix it this time * fix typo * point to breaking * Improve loadstate implementation * Re-add tests that were removed from DynamicPPL * Fix qualifier in src/mcmc/external_sampler.jl Co-authored-by: Xianda Sun <[email protected]> * Remove the default argument for initial_params * Remove DynamicPPL sources --------- Co-authored-by: Xianda Sun <[email protected]> * Fix a word in changelog * Improve changelog * Add PNTDist to changelog --------- Co-authored-by: Markus Hauru <[email protected]> Co-authored-by: Xianda Sun <[email protected]> * Fix all docs warnings --------- Co-authored-by: Markus Hauru <[email protected]> Co-authored-by: Markus Hauru <[email protected]> Co-authored-by: Xianda Sun <[email protected]>
Closes #2673