-
Notifications
You must be signed in to change notification settings - Fork 230
Description
Currently, we have two different ways to resume a sampling process.
@model gdemo(x) = begin
s ~ InverseGamma(2,3)
m ~ Normal(0, sqrt(s))
x[1] ~ Normal(m, sqrt(s))
x[2] ~ Normal(m, sqrt(s))
return s, m
end
chn1 = sample(gdemo([1.5, 2.0]), sampler; save_state=true)
# version 1
resume(chn1, 1000)
# version 2
sample(gdemo([1.5, 2.0]), sampler; resume_from=chn1)where the resume function is basically an alias for the second version.
One drawback of the current approach is that we need to store the model function, sampler and further information inside the Chains type.
Lines 203 to 207 in 27b0933
| save!(c::Chain, spl::Sampler, model::Function, vi) = begin | |
| c.info[:spl] = spl | |
| c.info[:model] = model | |
| c.info[:vi] = deepcopy(vi) | |
| end |
From my point of view, resuming a sampling process should no restrict the user to a particular sampler but rather to a class of samplers. If I understand the HMC code on this correctly, we currently discard the selected HMC algorithm if we resume a sampling.
Lines 109 to 111 in 27b0933
| spl = reuse_spl_n > 0 ? | |
| resume_from.info[:spl] : | |
| Sampler(alg, adapt_conf) |
Question 1: Would it be better to store only the type of the sampler or do we want to keep the sampler as a whole and instead adjust the code base so that we do not discard the user specified algorithm? Keeping the sampler would have the advantage that we can resume with exactly the same parameters.
Question 2: Is there a way that we can drop the VarInfo instance? Many fields can be recovered from the Chains type while others, e.g.
Lines 51 to 53 in 414b3b0
| rvs :: Dict{Union{VarName,Vector{VarName}},Any} | |
| dists :: Vector{Distributions.Distribution} | |
| gids :: Vector{Int} |