File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -31,18 +31,17 @@ getmetric(state::HMCState) = state.metric
31
31
getintegrator (state:: HMCState ) = state. κ. τ. integrator
32
32
33
33
function AbstractMCMC. getparams (state:: HMCState )
34
- # TODO (sunxd): should we return a copy?
35
34
return state. transition. z. θ
36
35
end
37
36
37
+ # Using @set to update state.transition.z.θ can lead to inconsistencies:
38
+ # - It retains cached log-joint and gradient computations that become invalid
39
+ # - This can cause incorrect evaluations in subsequent steps (e.g. MH)
40
+ #
41
+ # TODO : adopt https://github.com/TuringLang/MCMCTempering.jl/blob/deb96684496f3fbd011b9f70f28c49a161def23f/ext/MCMCTemperingAdvancedHMCExt.jl#L10-L17
42
+ # if in the future the interface provides access to the log density function
38
43
function AbstractMCMC. setparams!! (state:: HMCState , params)
39
- hamiltonian = AdvancedHMC. Hamiltonian (state. metric, model)
40
- return Setfield. @set state. transition. z = AdvancedHMC. phasepoint (
41
- hamiltonian,
42
- params,
43
- state. transition. z. r;
44
- ℓκ = state. transition. z. ℓκ,
45
- )
44
+ return @set state. transition. z. θ = θ
46
45
end
47
46
48
47
"""
429
428
430
429
function make_kernel (spl:: HMCSampler , integrator:: AbstractIntegrator )
431
430
return spl. κ
432
- end
431
+ end
You can’t perform that action at this time.
0 commit comments