Skip to content

Better support for AbstractSampler #2011

@torfjelde

Description

@torfjelde

Now that we have DynamicPPL.LogDensityFunction + AbstractMCMC.LogDensityModel, it would be nice to drop the usage of Turing.Inference.InferenceAlgorithm and allow "arbitrary" AbstractMCMC.AbstractSampler to be used with in Turing without much effort on the user side.

This would of course also help alleviate the discrepancy in configuration that is present on the package containing the implementation of the sampler and the corresponding "inference algorithm" in Turing.jl.

The issue with just replacing InferenceAlgorithm with AbstractSampler and AbstractMCMC.AbstractModel with DynamicPPL.Model, as is done in #2008, is that of method-ambiguities. I also assume that method ambiguities were part of the reason why InferenceAlgorithm was kept around.

There are, as I see it, two solutions:

  1. Replace the currently present overloads of AbstractMCMC.sample in Turing.jl by Turing's own sample, i.e. make Turing.sample !== AbstractMCMC.sample. Turing.sample then calls AbstractMCMC.sample under the hood but with some additional niceties.
  2. Keep something equivalent to InferenceAlgorithm or a wrapper type and continue overloading AbstractMCMC.sample.

Personally, I'm very much in favour of option (1). This has several benefits:

  1. Removes the type-piracy.
  2. Maintains the status-quo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions