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

Adjust for API changes in AdvancedHMC.jl #470

Merged
merged 2 commits into from
Mar 27, 2025
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
Expand Up @@ -93,7 +93,7 @@ BATUltraNestExt = "UltraNest"
ADTypes = "0.2, 1"
Accessors = "0.1"
Adapt = "3, 4"
AdvancedHMC = "0.5, 0.6"
AdvancedHMC = "0.5, 0.6, 0.7"
AffineMaps = "0.2.3, 0.3"
ArgCheck = "1, 2"
ArraysOfArrays = "0.5, 0.6"
Expand Down
10 changes: 8 additions & 2 deletions ext/ahmc_impl/ahmc_sampler_impl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,14 @@

hamiltonian = proposal.hamiltonian

# Current location in the phase space for Hamiltonian MonteCarlo
z_phase = AdvancedHMC.phasepoint(hamiltonian, vec(z_current[:]), rand(rng, hamiltonian.metric, hamiltonian.kinetic))
@static if isdefined(AdvancedHMC, :rand_momentum) #isdefined(AdvancedHMC.rand_momentum, Tuple{AbstractRNG, AdvancedHMC.AbstractMetric, AdvancedHMC.AbstractKinetic, AbstractVecOrMat})

Check warning on line 118 in ext/ahmc_impl/ahmc_sampler_impl.jl

View check run for this annotation

Codecov / codecov/patch

ext/ahmc_impl/ahmc_sampler_impl.jl#L118

Added line #L118 was not covered by tests
# For AdvnacedHMC.jl v >= 0.7
momentum = rand_momentum(rng, hamiltonian.metric, hamiltonian.kinetic, z_current[:])
else
momentum = rand(rng, hamiltonian.metric, hamiltonian.kinetic)
end

z_phase = AdvancedHMC.phasepoint(hamiltonian, vec(z_current[:]), momentum)
# Note: `RiemannianKinetic` requires an additional position argument, but including this causes issues. So only support the other kinetics.

proposal.transition = AdvancedHMC.transition(rng, τ, hamiltonian, z_phase)
Expand Down
Loading