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

Export LogDensityFunction #820

Merged
merged 2 commits into from
Feb 26, 2025
Merged

Export LogDensityFunction #820

merged 2 commits into from
Feb 26, 2025

Conversation

penelopeysm
Copy link
Member

Closes #816

@penelopeysm penelopeysm changed the base branch from master to release-0.35 February 25, 2025 21:01
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.60%. Comparing base (4bc0d1f) to head (b699b7b).
Report is 1 commits behind head on release-0.35.

Additional details and impacted files
@@              Coverage Diff              @@
##           release-0.35     #820   +/-   ##
=============================================
  Coverage         84.60%   84.60%           
=============================================
  Files                34       34           
  Lines              3832     3832           
=============================================
  Hits               3242     3242           
  Misses              590      590           

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

@coveralls
Copy link

Pull Request Test Coverage Report for Build 13530876693

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-11.4%) to 73.244%

Files with Coverage Reduction New Missed Lines %
src/varinfo.jl 3 82.82%
Totals Coverage Status
Change from base Build 13530836280: -11.4%
Covered Lines: 2795
Relevant Lines: 3816

💛 - Coveralls

1 similar comment
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13530876693

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-11.4%) to 73.244%

Files with Coverage Reduction New Missed Lines %
src/varinfo.jl 3 82.82%
Totals Coverage Status
Change from base Build 13530836280: -11.4%
Covered Lines: 2795
Relevant Lines: 3816

💛 - Coveralls

@coveralls
Copy link

coveralls commented Feb 25, 2025

Pull Request Test Coverage Report for Build 13530876693

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage remained the same at 84.692%

Files with Coverage Reduction New Missed Lines %
src/varinfo.jl 3 82.82%
Totals Coverage Status
Change from base Build 13530836280: 0.0%
Covered Lines: 3242
Relevant Lines: 3828

💛 - Coveralls

@penelopeysm penelopeysm requested a review from mhauru February 26, 2025 12:02
@mhauru
Copy link
Member

mhauru commented Feb 26, 2025

Happy with this, unless we are going to what @yebai proposed and merge DynamicPPL.LogDensityFunction and AbstractMCMC.LogDensityModel, in which case we might be exposing an interface we are just about to change.

@penelopeysm
Copy link
Member Author

They are different: DynamicPPL.LogDensityFunction is something that obeys the LogDensityProblems interface, whereas AbstractMCMC.LogDensityModel is something that wraps something that obeys the LogDensityProblems interface. (Mouthful, I know.)

I think that this in turn is because the LDP interface doesn't use abstract types. Thus, if you have a type T that obeys the LDP interface, you can't do

struct T <: ObeysLDPInterface
    fields...
end

sample(::ObeysLDPInterface,
    ::AbstractSampler,
    ...
)

Instead, if you want to sample from something that obeys it, you have to wrap it in a LogDensityModel and then you can dispatch on it.

I do find all this indirection a bit confusing and I would love to be able to simplify it, but I'm not sure if it's possible, and in any case I don't think it's a matter for this release

@yebai
Copy link
Member

yebai commented Feb 26, 2025

Can we make AbstractMCMC.LogDensityModel obey the LDP interface? This might be breaking, but we could still do it if it simplifies the code.

EDIT: if AbstractMCMC.LogDensityModel obeys the LDP interface, we can use it to replace DynamicPPL.LogDensityFunction.

@penelopeysm
Copy link
Member Author

penelopeysm commented Feb 26, 2025

@yebai How about making LogDensityFunction subtype AbstractModel? I think that might sort it out. But it needs slightly deeper investigation, and I think it's best we leave this for another minor version.

As I understand it, the reason why LogDensityModel doesn't obey LDP is mainly to avoid method ambiguities: TuringLang/AbstractMCMC.jl#110 (comment)

Copy link
Member

@mhauru mhauru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging the two sounds great if it works out. However, on a call Penny also just pointed out that Turing.jl already exports LogDensityFunction. In that case I think it should be exported in DPPL as well, and doing so doesn't cause any more breakage in the future, because any breakage of LDF is breaking for Turing.jl already as is. Hence happy to merge this and release it in v0.35 even if the LDF-LDM merging is going to happen soonish.

@penelopeysm
Copy link
Member Author

I'll merge first, and I'll open another issue to track the possibilities.

@penelopeysm penelopeysm merged commit a765af3 into release-0.35 Feb 26, 2025
16 checks passed
@penelopeysm penelopeysm deleted the py/export-ldf branch February 26, 2025 16:32
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.

LogDensityFunction should be exported
4 participants