TuringLang / TuringLang/AbstractMCMC.jl
Improving interaction between different implementations of the interface
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 108
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
How do you feel about adding something like:
"""
state_from_transiton(state, transition_prev[, state_prev])
Return new instance of `state` using information from `transition_prev` and, optionally, `state_prev`.
Defaults to `setparameters!!(state, parameters(transition_prev))`.
"""
function state_from_transition(state, transition_prev, state_prev)
return state_from_transition(state, transition_prev)
end
function state_from_transition(state, transition)
return setparameters!!(state, parameters(transition))
end
"""
setparameters!!(state, parameters)
Return new instance of `state` with parameters set to `parameters`.
"""
setparameters!!
"""
parameters(transition)
Return parameters in `transition`.
"""
parameters
to make it easier for samplers to interact across packages? Then you just need to implement state_from_transition for the different types to get cross-package compat.
Another issue is also the model argument which often is specific to a particular sampler implementation. We've previous spoken about generalizing this so that we don't have a bunch of these lying around, e.g. AdvancedMH.DensityModel and AdvancedHMC.DifferentiableDensityModel, but we should also maybe add a function getmodel(model, sampler, state) or something too, which is identity by default but allows one to provide a model-type which encodes a bunch of different models for specific samplers, e.g. in the case of a MixtureSampler you might have a MixtureState which, among other things, holds the current sampler-index, and a ManyModels which simply wraps a collection of models corresponding to each of the components/samplers in the MixtureSampler:
getmodel(model::ManyModels, sampler::MixtureSampler, state::MixtureState) = model[state.current_index]
I've been running into quite a few scenarios recently where I'd love to have something like this, e.g. wanting to implement MixtureSampler and CompositionSampler.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposed state_from_transition, setparameters!!, parameters, and getmodel interface functions in the issue. Determine whether a concrete cross-package interface and model-dispatch design can be agreed on; done would require a settled scope rather than the current collection of suggestions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100