TuringLang / DynamicPPL.jl

Implementation of domain-specific language (DSL) for dynamic probabilistic programming
https://turinglang.org/DynamicPPL.jl/
MIT License
157 stars 27 forks source link

Add `acclogp_assume!!` and `acclogp_observe!!` #565

Closed torfjelde closed 9 months ago

torfjelde commented 10 months ago

This PR adds two new methods:

The idea is to provide slightly more control over the acclogp!! process, beyond (#563).

The main motivation for this, is to fix the bug where particle samplers in Turing.jl currently do not respect the contextual tilde-pipeline since we accumulate the logp in the "leaf" of the tilde-pipeline, e.g. observe and assume:

This means that any context which alters the value of logp, e.g. MiniBatchContext, will have no effect.

After this PR, particle samplers can overload acclogp_observe!! to run Libtask.produce(logpdf(dist, value)), which occurs at the very end of the tilde-pipeline, hence allowing these samplers to also respect the context behaviors.

github-actions[bot] commented 10 months ago

Pull Request Test Coverage Report for Build 6977964954


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/context_implementations.jl 8 9 88.89%
<!-- Total: 8 9 88.89% -->
Totals Coverage Status
Change from base Build 6952497716: 0.02%
Covered Lines: 2572
Relevant Lines: 3153

💛 - Coveralls
codecov[bot] commented 10 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (b52e4c2) 81.00% compared to head (3561ab2) 81.03%.

Files Patch % Lines
src/context_implementations.jl 88.88% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #565 +/- ## ========================================== + Coverage 81.00% 81.03% +0.02% ========================================== Files 26 26 Lines 3170 3174 +4 ========================================== + Hits 2568 2572 +4 Misses 602 602 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

devmotion commented 10 months ago

Related to https://github.com/TuringLang/DynamicPPL.jl/issues/390?