Mark all methods with DynamicPPL.Model as produceable#2780
Merged
penelopeysm merged 5 commits intomainfrom Mar 2, 2026
Merged
Conversation
3a21368 to
8795e6b
Compare
8795e6b to
3d14cd9
Compare
Contributor
|
Turing.jl documentation for PR #2780 is available at: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2780 +/- ##
==========================================
- Coverage 87.08% 87.03% -0.06%
==========================================
Files 20 20
Lines 1309 1296 -13
==========================================
- Hits 1140 1128 -12
+ Misses 169 168 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This needs a Libtask release and version bump, which I'll handle once JuliaRegistrator does its things.
This essentially implements the plan described in TuringLang/Libtask.jl#217. A lot of the issues stemming from Libtask not picking up model evaluators either with keyword arguments, or in submodels, can be fixed by simply declaring that every method that dispatches on
DynamicPPL.Modelis produceable. The mechanism for this is implemented in TuringLang/Libtask.jl#218, and this PR makes use of that.For the end-user, this means that we guarantee correctness where models either have submodels or where models have keyword arguments. The user no longer has to mark models with keyword arguments as
@might_produce.I tested performance, and there is no regression — in fact there is a small speedup (although that is probably benchmark noise):
Submodel case
This was the issue #2772 where non-inlined submodels were not correctly picked up.
#2778 fixed this with a strategy that was similar to that in this PR, but was slightly more limited (this PR handles both submodels and keyword arguments together).
Keyword argument case
This was the long-standing issue where models with keyword arguments were originally not picked up by Libtask, and since v0.42.5, could be, but relied on the user themselves manually declaring
Libtask.@might_produce.