AbstractMCMC.jl
AbstractMCMC.jl copied to clipboard
Add some interface functions to support the new Gibbs sampler in Turing
The recent new Gibbs sampler provides a way forward for the Turing inference stack.
A near-to-medium-range goal has been to further reduce the glue code between Turing and inference packages (ref https://github.com/TuringLang/Turing.jl/issues/2281). The new Gibbs implementation laid a great plan to achieve this goal.
This PR is modeled after the interface of @torfjelde's recent PR. And in some aspects, it is a rehash of https://github.com/TuringLang/AbstractMCMC.jl/pull/86.
(the explanation here is outdated, please refer to https://github.com/TuringLang/AbstractMCMC.jl/pull/144#issuecomment-2337681868)
~~The goal of this PR is to determine and implement some necessary interface improvements, so that, when we update the inference packages up to the interface, they will more or less "just work" with the new Gibbs implementation.~~
~~As a first step, we test-flight two new functions recompute_logprob!!(rng, model, sampler, state)
and getparams(state)
:~~
- ~~
recompute_logprob!!(rng, model, sampler, state)
recomputes the logprob given thestate
~~ - ~~
getparams(state)
extract the parameter values~~
~~Some considerations:~~
- ~~This assumes a
state
is implemented withAbstractMCMC
compatible inference packages. And astate
at least stores values of parameters from the current iteration (traditionally, this is in the form of aTransition
) and logprob.~~ - ~~
recompute_logprob!!(rng, model, sampler, state)
~~- ~~do we need
rng
?~~ - ~~should we make
model
intoAbstractMCMC.LogDensityModel
or justLogDensityProblem
(and make inference packages depend onLogDensityProblems
in the latter case)? This should allow inference packages to be independent from DynamicPPL, we can usegetparams
to construct avarinfo
in Turing~~
- ~~do we need
- ~~
getparams(state)
~~- ~~What does this function return? A vector, a
transition
?~~ - ~~Do we need
setparams
?~~
- ~~What does this function return? A vector, a
- ~~Do we also need some interface functions for
state
likegetstats
?~~
~~Tor also says (in a Slack conversation) that the a condition(model, params)
is needed, but better to be implemented by packages that defines the model
, which I agree.~~