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

Fix non-reproducible step sizes #1924

Merged
merged 2 commits into from
Dec 24, 2022
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
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.23.1"
version = "0.23.2"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
4 changes: 2 additions & 2 deletions src/inference/hmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function DynamicPPL.initialstep(

# Find good eps if not provided one
if iszero(spl.alg.ϵ)
ϵ = AHMC.find_good_stepsize(hamiltonian, theta)
ϵ = AHMC.find_good_stepsize(rng, hamiltonian, theta)
@info "Found initial step size" ϵ
else
ϵ = spl.alg.ϵ
Expand Down Expand Up @@ -550,7 +550,7 @@ function HMCState(

# Find good eps if not provided one
if iszero(spl.alg.ϵ)
ϵ = AHMC.find_good_stepsize(h, θ_init)
ϵ = AHMC.find_good_stepsize(rng, h, θ_init)
@info "Found initial step size" ϵ
else
ϵ = spl.alg.ϵ
Expand Down
9 changes: 9 additions & 0 deletions test/inference/hmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,13 @@
end
@test sample(rng, mwe3(), HMC(0.2, 4), 1_000) isa Chains
end

# issue #1923
@turing_testset "reproducibility" begin
alg = NUTS(1000, 0.8)
res1 = sample(StableRNG(123), gdemo_default, alg, 1000)
res2 = sample(StableRNG(123), gdemo_default, alg, 1000)
res3 = sample(StableRNG(123), gdemo_default, alg, 1000)
@test Array(res1) == Array(res2) == Array(res3)
end
end