Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 0.40.3

Fix a method ambiguity caused by a bugfix in DynamicPPL 0.37.2.

This patch means that if you are using `RepeatSampler()` to sample from a model, and you want to obtain `MCMCChains.Chains` from it, you need to specify `sample(...; chain_type=MCMCChains.Chains)`.
This only applies if the sampler itself is a `RepeatSampler`; it doesn't apply if you are using `RepeatSampler` _within_ another sampler like Gibbs.

# 0.40.2

`sample(model, NUTS(), N; verbose=false)` now suppresses the 'initial step size' message.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Turing"
uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
version = "0.40.2"
version = "0.40.3"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
24 changes: 0 additions & 24 deletions src/mcmc/abstractmcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,3 @@ function AbstractMCMC.sample(
check_model && _check_model(model, alg)
return AbstractMCMC.sample(rng, model, Sampler(alg), ensemble, N, n_chains; kwargs...)
end

function AbstractMCMC.sample(
rng::AbstractRNG,
model::AbstractModel,
sampler::Union{Sampler{<:InferenceAlgorithm},RepeatSampler},
ensemble::AbstractMCMC.AbstractMCMCEnsemble,
N::Integer,
n_chains::Integer;
chain_type=MCMCChains.Chains,
progress=PROGRESS[],
kwargs...,
)
return AbstractMCMC.mcmcsample(
rng,
model,
sampler,
ensemble,
N,
n_chains;
chain_type=chain_type,
progress=progress,
kwargs...,
)
end
5 changes: 0 additions & 5 deletions src/mcmc/repeat_sampler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ function RepeatSampler(alg::InferenceAlgorithm, num_repeat::Int)
return RepeatSampler(Sampler(alg), num_repeat)
end

getADType(spl::RepeatSampler) = getADType(spl.sampler)
DynamicPPL.default_chain_type(sampler::RepeatSampler) = default_chain_type(sampler.sampler)
# TODO(mhauru) Remove the below once DynamicPPL has removed all its Selector stuff.
DynamicPPL.inspace(vn::VarName, spl::RepeatSampler) = inspace(vn, spl.sampler)

function setparams_varinfo!!(model::DynamicPPL.Model, sampler::RepeatSampler, state, params)
return setparams_varinfo!!(model, sampler.sampler, state, params)
end
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Combinatorics = "1"
Distributions = "0.25"
DistributionsAD = "0.6.3"
DynamicHMC = "2.1.6, 3.0"
DynamicPPL = "0.37"
DynamicPPL = "0.37.2"
FiniteDifferences = "0.10.8, 0.11, 0.12"
ForwardDiff = "0.10.12 - 0.10.32, 0.10, 1"
HypothesisTests = "0.11"
Expand Down
9 changes: 8 additions & 1 deletion test/mcmc/repeat_sampler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module RepeatSamplerTests

using ..Models: gdemo_default
using DynamicPPL: Sampler
using MCMCChains: Chains
using StableRNGs: StableRNG
using Test: @test, @testset
using Turing
Expand All @@ -26,7 +27,13 @@ using Turing
)
repeat_sampler = RepeatSampler(sampler, num_repeats)
chn2 = sample(
copy(rng), gdemo_default, repeat_sampler, MCMCThreads(), num_samples, num_chains
copy(rng),
gdemo_default,
repeat_sampler,
MCMCThreads(),
num_samples,
num_chains;
chain_type=Chains,
)
@test chn1.value == chn2.value
end
Expand Down