Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.41.4

Fixed a bug where the `check_model=false` keyword argument would not be respected when sampling with multiple threads or cores.

# 0.41.3

Fixed NUTS not correctly specifying the number of adaptation steps when calling `AdvancedHMC.initialize!` (this bug led to mass matrix adaptation not actually happening).
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.41.3"
version = "0.41.4"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
1 change: 1 addition & 0 deletions src/mcmc/abstractmcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function AbstractMCMC.sample(
N,
n_chains;
chain_type,
check_model=false, # no need to check again
initial_params=map(_convert_initial_params, initial_params),
kwargs...,
)
Expand Down
17 changes: 17 additions & 0 deletions test/mcmc/abstractmcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ using Random: AbstractRNG
using Test: @test, @testset, @test_throws
using Turing

@testset "Disabling check_model" begin
# Set up a model for which check_model errors.
@model f() = x ~ Normal()
model = f()
Turing.Inference._check_model(::typeof(model)) = error("nope")
# Make sure that default sampling does throw the error.
@test_throws "nope" sample(model, NUTS(), 100)
@test_throws "nope" sample(model, NUTS(), MCMCThreads(), 100, 2)
@test_throws "nope" sample(model, NUTS(), MCMCSerial(), 100, 2)
@test_throws "nope" sample(model, NUTS(), MCMCDistributed(), 100, 2)
# Now disable the check and make sure sampling works.
@test sample(model, NUTS(), 100; check_model=false) isa Any
@test sample(model, NUTS(), MCMCThreads(), 100, 2; check_model=false) isa Any
@test sample(model, NUTS(), MCMCSerial(), 100, 2; check_model=false) isa Any
@test sample(model, NUTS(), MCMCDistributed(), 100, 2; check_model=false) isa Any
end

@testset "Initial parameters" begin
# Dummy algorithm that just returns initial value and does not perform any sampling
abstract type OnlyInit <: AbstractMCMC.AbstractSampler end
Expand Down