-
Couldn't load subscription status.
- Fork 230
Support DPPL 0.37 #2550
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
Support DPPL 0.37 #2550
Conversation
|
That is tempting, to not waste time fixing code that's on its way out. I worry though that removing the samplers will take a while still, and in the meanwhile all the accumulator stuff, and other DPPL changes that build on it, would be held back from Turing.jl. For instance, introducing ValuesAsInModelAccumulator would cut our inference time in #2542 by half. |
|
IMO, it goes both ways. Reducing sampler complexity would make this PR easier. On the other hand, merging this PR would also make it easier to remove the duplicate samplers. (To be precise, DPPL 0.37 would make it easier.) I think DPPL 0.37 has taken a long time and we should prioritise this, rather than trying to squeeze in the changes to samplers. I'm going to fix the merge conflicts and add a Note that 1.10 CI will always fail as |
test/mcmc/hmc.jl
Outdated
| # TODO(mhauru) Do we give up being able to sample from only prior/likelihood like this, | ||
| # or do we implement some way to pass `whichlogprob=:LogPrior` through `sample`? |
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.
sample(::LogDensityFunction) would solve that, since we could set getlogprior in the LDF, but I guess that'll be the next release.
| # TODO(penelopeysm): Can we just use leafcontext(model.context)? Do we | ||
| # need to pass in the sampler? (In fact LogDensityFunction defaults to | ||
| # using leafcontext(model.context) so could we just remove the argument | ||
| # entirely?) | ||
| DynamicPPL.SamplingContext(rng, spl, DynamicPPL.leafcontext(model.context)); | ||
| adtype=spl.alg.adtype, |
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.
As established in (e.g.) TuringLang/DynamicPPL.jl#955 (comment) SamplingContext for Hamiltonians was never overloaded so it is equivalent to just use DefaultContext in the LDF.
|
Because Turing re-exports some things that were changed in DPPL 0.37 (for example, |
4ee5649 to
4d03c07
Compare
|
Turing.jl documentation for PR #2550 is available at: |
* Use new `getlogjoint` for optimisation * Change getlogjoint -> getlogjoint_internal where needed * Enforce re-evaluation when constructing `Transition` * fix tests * Remove extra evaluations from SGLD and SGHMC * Remove dead `transitions_from_chain` method (used to be part of `predict`) * metadata -> getstats_with_lp * Clean up some stray getlogp
| # TODO(DPPL0.37/penelopeysm): decide what to do with these tests | ||
| @testset "Coalescing multiple observations into one" begin | ||
| # Instead of observing x[1] and x[2] separately, we lump them into a | ||
| # single distribution. | ||
| @model function dynamic_bernoulli() | ||
| b ~ Bernoulli() | ||
| if b | ||
| dists = [Normal(1.0)] | ||
| else | ||
| dists = [Normal(1.0), Normal(2.0)] | ||
| end | ||
| return x ~ product_distribution(dists) | ||
| end | ||
| model = dynamic_bernoulli() |
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.
To be discussed @ 4 Aug meeting
* Allow Prior to skip model re-evaluation * remove unneeded `default_chain_type` method * add a test * add a likelihood term too * why not test correctness while we're at it
8af36e1 to
806c82d
Compare
|
Apologies for force push, I did it on the wrong branch. I undid it (force pushed back to the old commit) so it shouldn't affect any local git history. CI is now failing because DynamicPPL's breaking branch doesn't exist... hmmmm |
|
I'd be happy to merge TuringLang/DynamicPPL.jl#1005, release DPPL, then remove the |
|
I agree on that plan. |
* Remove calls to resetlogp!! * Add a changelog for 0.40 * Update HISTORY.md Co-authored-by: Markus Hauru <markus@mhauru.org> --------- Co-authored-by: Markus Hauru <markus@mhauru.org>
* Unify `Transition` methods * Add tests * Add same test for SGLD/SGHMC * Refactor so that it's nice and organised * Fix failing test on 1.10 * just increase the atol * Make addlogprob test more robust * Remove stray `@show` Co-authored-by: Markus Hauru <markus@mhauru.org> --------- Co-authored-by: Markus Hauru <markus@mhauru.org>
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.
I'm very pleased with where we are on this, would be happy to merge into breaking and then main. Was there anything else you wanted to add to 0.40?
|
Thanks, very happy with that. I'm good to merge and release once tests pass. You wanna do it? |
|
Okay 😄 |
|
I'll merge into breaking then let CI run on that branch. |
* [no ci] Bump to v0.40.0 * Uncomment tests that should be there * Support DPPL 0.37 (#2550) * First efforts towards DPPL 0.37 compat, WIP * More DPPL 0.37 compat work, WIP * Add [sources] for DynamicPPL@0.37 * Remove context argument from `LogDensityFunction` * Fix MH * Remove spurious logging * Remove residual OptimizationContext * Delete files that were removed in previous releases * Fix typo * Simplify ESS * Fix LDF * Fix Prior(), fix a couple more imports * fixes * actually fix prior * Remove extra return value from tilde_assume * fix ldf * actually fix prior * fix HMC log-density * fix ldf * fix make_evaluate_... * more fixes for evaluate!! * fix hmc * fix run_ad * even more fixes (oh goodness when will this end) * more fixes * fix * more fix fix fix * fix return values of tilde pipeline * even more fixes * Fix missing import * More MH fixes * Fix conversion * don't think it really needs those type params * implement copy for LogPriorWithoutJacAcc * Even more fixes * More fixes; I think the remaining failures are pMCMC related * Fix merge * DPPL 0.37 compat for particle MCMC (#2625) * Progress in DPPL 0.37 compat for particle MCMC * WIP PMCMC work * Gibbs fixes for DPPL 0.37 (plus tiny bugfixes for ESS + HMC) (#2628) * Obviously this single commit will make Gibbs work * Fixes for ESS * Fix HMC call * improve some comments * Fixes to ProduceLogLikelihoodAccumulator * Use LogProbAccumulator for ProduceLogLikelihoodAccumulator * use get_conditioned_gibbs --------- Co-authored-by: Penelope Yong <penelopeysm@gmail.com> * "Fixes" for PG-in-Gibbs (#2629) * WIP PMCMC work * Fixes to ProduceLogLikelihoodAccumulator * inline definition of `set_retained_vns_del!` * Fix ProduceLogLikelihoodAcc * Remove all uses of `set_retained_vns_del!` * Use nice functions * Remove PG tests with dynamic number of Gibbs-conditioned-observations * Fix essential/container tests * Update pMCMC implementation as per discussion * remove extra printing statements * revert unneeded changes * Add back (some kind of) dynamic model test * fix rebase * Add a todo comment for dynamic model tests --------- Co-authored-by: Markus Hauru <mhauru@turing.ac.uk> * Use accumulators to fix all logp calculations when sampling (#2630) * Use new `getlogjoint` for optimisation * Change getlogjoint -> getlogjoint_internal where needed * Enforce re-evaluation when constructing `Transition` * fix tests * Remove extra evaluations from SGLD and SGHMC * Remove dead `transitions_from_chain` method (used to be part of `predict`) * metadata -> getstats_with_lp * Clean up some stray getlogp * InitContext isn't for 0.37, update comments * Fix merge * Do not re-evaluate model for Prior (#2644) * Allow Prior to skip model re-evaluation * remove unneeded `default_chain_type` method * add a test * add a likelihood term too * why not test correctness while we're at it * No need to test AD for SamplingContext{<:HMC} (#2645) * change breaking -> main * Remove calls to resetlogp!! & add changelog (#2650) * Remove calls to resetlogp!! * Add a changelog for 0.40 * Update HISTORY.md Co-authored-by: Markus Hauru <markus@mhauru.org> --------- Co-authored-by: Markus Hauru <markus@mhauru.org> * Remove `[sources]` * Unify Turing `Transition`s, fix some tests (#2651) * Unify `Transition` methods * Add tests * Add same test for SGLD/SGHMC * Refactor so that it's nice and organised * Fix failing test on 1.10 * just increase the atol * Make addlogprob test more robust * Remove stray `@show` Co-authored-by: Markus Hauru <markus@mhauru.org> --------- Co-authored-by: Markus Hauru <markus@mhauru.org> * Update changelog for PG in Gibbs --------- Co-authored-by: Penelope Yong <penelopeysm@gmail.com> --------- Co-authored-by: Markus Hauru <markus@mhauru.org>
Currently in a very unfinished state.