Skip to content

Remove 3-argument {_,}evaluate!!; clean up submodel code #960

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

Open
wants to merge 5 commits into
base: breaking
Choose a base branch
from

Conversation

penelopeysm
Copy link
Member

@penelopeysm penelopeysm commented Jun 25, 2025

This PR:

  • removes the one last usage of evaluate!!(model, varinfo, context) in the DynamicPPL codebase
  • removes _evaluate!!(model, varinfo, context) as this method was only being used for submodels

In return, it introduces:

  • _evaluate!!(submodel, varinfo, context, left). Yes, yes, I basically moved the implementation from one place to the other; but the whole point is that this was special-case behaviour that was only needed for submodels, so this at least makes it clearer.

It also removes a lot of wrapper code for submodels. I personally don't see the need for more than one layer of indirection for submodels (in terms of the data structure, the only difference between a submodel and a model is that the submodel carries information about whether it should be auto-prefixed). I had mucked around with this in #815 and I didn't find any real problems with removing the wrappers there (in fact in that PR I went one step further and removed all wrappers, but that would have made it impossible to opt-out of prefixing and that's Bad(TM)).

I didn't add any new tests, but test/submodel.jl already contains quite extensive tests to make sure that everything behaves and it passes these tests so I'm quite happy.

#959 needs to be merged first. Done.

Follow-up from #952

Closes #720 (for good)

@penelopeysm penelopeysm changed the title Remove 3-argument _evaluate!!; clean up submodel code Remove 3-argument {_,}evaluate!!; clean up submodel code Jun 25, 2025
@penelopeysm penelopeysm force-pushed the py/no-context-evaluate-submodel branch from 3dc22f4 to 4bb2526 Compare June 25, 2025 17:01
@penelopeysm penelopeysm changed the base branch from breaking to py/move-submodel June 25, 2025 17:01
Copy link
Contributor

github-actions bot commented Jun 25, 2025

Benchmark Report for Commit bfa48b3

Computer Information

Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × AMD EPYC 7763 64-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

Benchmark Results

|                 Model | Dimension |  AD Backend |      VarInfo Type | Linked | Eval Time / Ref Time | AD Time / Eval Time |
|-----------------------|-----------|-------------|-------------------|--------|----------------------|---------------------|
| Simple assume observe |         1 | forwarddiff |             typed |  false |                  8.5 |                 1.6 |
|           Smorgasbord |       201 | forwarddiff |             typed |  false |                689.0 |                43.2 |
|           Smorgasbord |       201 | forwarddiff | simple_namedtuple |   true |                438.4 |                49.6 |
|           Smorgasbord |       201 | forwarddiff |           untyped |   true |               1181.9 |                30.1 |
|           Smorgasbord |       201 | forwarddiff |       simple_dict |   true |               6524.2 |                25.1 |
|           Smorgasbord |       201 | reversediff |             typed |   true |               1070.6 |                38.8 |
|           Smorgasbord |       201 |    mooncake |             typed |   true |               1043.1 |                 4.3 |
|    Loop univariate 1k |      1000 |    mooncake |             typed |   true |               6080.7 |                 3.9 |
|       Multivariate 1k |      1000 |    mooncake |             typed |   true |               1010.0 |                 9.1 |
|   Loop univariate 10k |     10000 |    mooncake |             typed |   true |              68325.8 |                 3.6 |
|      Multivariate 10k |     10000 |    mooncake |             typed |   true |               9028.8 |                 9.8 |
|               Dynamic |        10 |    mooncake |             typed |   true |                139.5 |                13.8 |
|              Submodel |         1 |    mooncake |             typed |   true |                 13.6 |                 6.1 |
|                   LDA |        12 | reversediff |             typed |   true |               1280.5 |                 2.6 |

@penelopeysm penelopeysm force-pushed the py/no-context-evaluate-submodel branch from 4bb2526 to 55f838f Compare June 25, 2025 17:02
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.76%. Comparing base (7f20709) to head (bfa48b3).

Files with missing lines Patch % Lines
src/context_implementations.jl 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           breaking     #960      +/-   ##
============================================
- Coverage     82.85%   82.76%   -0.09%     
============================================
  Files            38       38              
  Lines          4031     4010      -21     
============================================
- Hits           3340     3319      -21     
  Misses          691      691              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@penelopeysm penelopeysm force-pushed the py/no-context-evaluate-submodel branch 2 times, most recently from dcd5c9d to 31b0caa Compare June 25, 2025 20:41
Copy link
Contributor

DynamicPPL.jl documentation for PR #960 is available at:
https://TuringLang.github.io/DynamicPPL.jl/previews/PR960/

Base automatically changed from py/move-submodel to breaking June 26, 2025 00:57
@penelopeysm penelopeysm force-pushed the py/no-context-evaluate-submodel branch from 31b0caa to 039a523 Compare June 26, 2025 01:02
@penelopeysm penelopeysm marked this pull request as ready for review June 26, 2025 13:35
@penelopeysm penelopeysm requested a review from mhauru June 26, 2025 13:35
@penelopeysm penelopeysm force-pushed the py/no-context-evaluate-submodel branch from 039a523 to bfa48b3 Compare June 26, 2025 14:47
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