-
Notifications
You must be signed in to change notification settings - Fork 37
Description
The problem
Currently, DynamicPPL.jl supports implementation of Gibbs sampling through usages of Selectors and gids, which are effectively ways for each instance of Sampler to define it's unique "Gibbs ID" and then subsequently which sampler that particular realization present in VarInfo came from.
All of this machinery is complicated and means that samplers outside of DynamicPPL are not compatible without an annoying amount of code needed.
In TuringLang/Turing.jl#2099 we're introducing an alternative approach to a Gibbs sampler which makes use of the condition functionality to define a sequence of conditioned Models, whose random variables are then restricted to only those that a particular sampler needs.
This has the following benefits:
- Any sampler which wants to be compatible with
Gibbson aModel, simply needs to be able to sample from aModel(which, thanks toDynamicPPL.LogDensityFunctionis quite easy in most cases). - There is no need for all the code relating to
Selectorandgidssince all the variables present in aVarInfois supposed to be sampled. - Moreover, once we remove this "some variables in
VarInfoare not supposed to be sampled and some are"-convention, we can also remove some of the more unfortunate tilde-implementations, e.g.DynamicPPL.get_and_set_val, and instead fully adopt the convention that: if we're using aSamplingContext, things might get resampled, and if we're not using aSamplingContext, then things are not to be sampled. This will then also remove the need fordelfalgs, etc.
Currently the sampler introduced in TuringLang/Turing.jl#2099 does still depend on a small part of this Selector-business, but it does so only to stay comaptible with the current DynamicPPL. Once we remove this from DynamicPPL, we can remove the old Gibbs sampler in Turing.jl, and finally move completely away from this stuff.
Things we need to do
Here's some rough things we need to get done (this will be probably change):
- Try out
Turing.Experimental.Gibbson a diverse set of problems to make sure it works as expected. - Determine if particle samplers will still be functional if we indeed remove this selector business completely.
- Remove
Selectorandgids. - Stop using
Samplerto as an indexing object, etc.