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

Use LogDensityProblemsAD with ADTypes #198

Merged
merged 6 commits into from
Jul 3, 2024
Merged

Use LogDensityProblemsAD with ADTypes #198

merged 6 commits into from
Jul 3, 2024

Conversation

sethaxen
Copy link
Member

@sethaxen sethaxen commented Jul 3, 2024

LogDensityProblemsAD has ADTypes integration for defining gradients and hessians of the log-density. DynamicPPL.jl then customizes this integration for DynamicPPL.LogDensityFunction (see e.g. https://github.com/TuringLang/DynamicPPL.jl/blob/master/ext/DynamicPPLForwardDiffExt.jl).

Switching to use LogDensityProblemsAD gradient and hessian functions instead of Optimization's ensures that when such customizations are made to improve performance or work around some issue unique to that LogDensityProblem, we then do the right thing. A potential downside is that Optimization.jl may support more ADs than LogDensityProblemsAD.jl, and we would not support these extra ADs. However, a simple workaround is that a user could pass Base.Fix1(LogDensityProblems.log_density, prob) to pathfinder or multipathfinder, which would not be identifiable as a LogDensityProblem and would then result in Optimization's ADTypes integration being used.

Edit: relates #93

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.83%. Comparing base (3b29881) to head (b9ee54a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #198      +/-   ##
==========================================
+ Coverage   80.61%   80.83%   +0.21%     
==========================================
  Files          13       13              
  Lines         614      621       +7     
==========================================
+ Hits          495      502       +7     
  Misses        119      119              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sethaxen sethaxen merged commit c2f04ad into main Jul 3, 2024
17 checks passed
@sethaxen sethaxen deleted the ldpad branch July 3, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant