Skip to content

Gibbs sampling - Use blocks to reduce computation #14

@donhausk

Description

@donhausk

I want to use Turing for the GP-SSM model, which is based on the PGAS algorithm. The implementation is actually straight forward thanks to Turing. However, I have noticed that the Gibbs sampler runs the whole model for every subsampler. For large models this implies that there is a huge computational overhead. One way to solve this issue would be by implementing some "hacky" macros, like:

@condition_on (:x, ;y) = begin
# Do some code here which is only executed when :x or :y appears in the sampling space
end

which would be changed to something like :

if :x in spl.alg.space || :y in spl.alg.space
# Run the code above
end

This makes the model rather difficult to design because it might not be obvious what belongs inside the brackets and what not. @torfjelde had the idea to do something like the following instead :

var = @condition_on (:x, ;y) = begin
# Compute var
end

which would be changed to something like :

if :x in spl.alg.space || :y in spl.alg.space
# Compute var
cache["var"] = var
else
var = cache["var"]
end

I am anyway planning to implement this macro for my own use and I was thinking that this might be interesting for Turing in general. What do you think?

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