Skip to content

Commit 8762fa3

Browse files
authored
Fix off-by-one NUTS adaptations (#2751)
Closes #2750. Prior to #2674 the counter `i` would be initialised to `1` after the first adaptation had happened. That PR, first released in v0.41, changed it such that the counter `i` was initialised to `1` before the first adaptation happened. That should, of course, be zero, which this PR fixes. I've checked locally and this change makes it such that results from pre-v0.41 are exactly reproducible now, as long as all else is equal (e.g. initialisation, discard_initial, etc).
1 parent 2b95583 commit 8762fa3

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

HISTORY.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# 0.43.3
1+
# 0.42.4
2+
3+
Fixes a typo that caused NUTS to perform one less adaptation step than in versions prior to 0.41.
4+
5+
# 0.42.3
26

37
Removes some dead code.
48

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Turing"
22
uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
3-
version = "0.42.3"
3+
version = "0.42.4"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/mcmc/hmc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function Turing.Inference.initialstep(
228228
adaptor = AHMCAdaptor(spl, hamiltonian.metric, nadapts; ϵ=ϵ)
229229

230230
transition = DynamicPPL.ParamsWithStats(theta, ldf, NamedTuple())
231-
state = HMCState(vi, 1, kernel, hamiltonian, z, adaptor, ldf)
231+
state = HMCState(vi, 0, kernel, hamiltonian, z, adaptor, ldf)
232232

233233
return transition, state
234234
end

0 commit comments

Comments
 (0)