TuringLang / AdvancedHMC.jl

Robust, modular and efficient implementation of advanced Hamiltonian Monte Carlo algorithms
https://turinglang.org/AdvancedHMC.jl/
MIT License
228 stars 39 forks source link

Improve Hamiltonian constructors #307

Closed devmotion closed 1 year ago

devmotion commented 1 year ago

This PR proposes some changes of the Hamiltonian constructors:

torfjelde commented 1 year ago

Sorry, but isn't this a breaking change? Prior to this PR, you didn't have to implement the LogDensityProblems-interface; you could still just provide a callable that represented the logdensity. It seems like this is no longer possible?

devmotion commented 1 year ago

No, I don't think so. Already prior to this PR in AdvancedHMC 0.4, Hamiltonian(metric, lp) required that lp supported LogDensityProblems.logdensity. Arbitrary callables were only supported in the Hamiltonian(metric, lp, lp_and_grad) constructor which is not affected by this PR.

The main changes in this PR were:

In principle, in a follow-up PR we could re-add support for callables which was removed in AdvancedHMC 0.4: If LogDensityProblems.capabilities(logdensity) === nothing, we could assume the provided logdensity is a function.