Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactivate test for Turing #165

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion ext/PigeonsDynamicPPLExt/state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ end
function Pigeons.step!(explorer::AutoMALA, replica, shared, vi::DynamicPPL.TypedVarInfo)
log_potential = Pigeons.find_log_potential(replica, shared.tempering, shared)
state = DynamicPPL.getall(vi)
Pigeons._extract_commons_and_run_auto_mala!(explorer, replica, shared, log_potential, state)
Pigeons._extract_commons_and_run!(explorer, replica, shared, log_potential, state)
DynamicPPL.setall!(replica.state, state)
end

Expand Down
28 changes: 21 additions & 7 deletions test/test_turing.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
include("supporting/turing_models.jl")




#=
The reason this test is excluded is described in
ADgradient() in TuringLogPotential.jl
=#
# @testset "Turing-gradient" begin
# target = Pigeons.toy_turing_unid_target()
@testset "Turing-gradient" begin
target = Pigeons.toy_turing_unid_target()

# @show Threads.nthreads()
@show Threads.nthreads()

# logz_mala = Pigeons.stepping_stone_pair(pigeons(; target, explorer = AutoMALA(adapt_pre_conditioning = false)))
# logz_slicer = Pigeons.stepping_stone_pair(pigeons(; target, explorer = SliceSampler()))
logz_mala = Pigeons.stepping_stone_pair(pigeons(; target, explorer = AutoMALA(preconditioner = Pigeons.IdentityPreconditioner())))
logz_slicer = Pigeons.stepping_stone_pair(pigeons(; target, explorer = SliceSampler()))

# @test abs(logz_mala[1] - logz_slicer[1]) < 0.1
# end
@test abs(logz_mala[1] - logz_slicer[1]) < 0.1
end

@testset "Turing-variable-names" begin
pt = pigeons(target = TuringLogPotential(model_with_vectors()), n_rounds = 2);
@test length(variable_names(pt)) == 4
end

@testset "Non-turing-gradient" begin
target = Pigeons.toy_mvn_target(2)

@show Threads.nthreads()

logz_mala = Pigeons.stepping_stone_pair(pigeons(; target, explorer = AutoMALA(preconditioner = Pigeons.IdentityPreconditioner())))
logz_slicer = Pigeons.stepping_stone_pair(pigeons(; target, explorer = SliceSampler()))

@test abs(logz_mala[1] - logz_slicer[1]) < 0.1
end
Loading