Skip to content

Conversation

@penelopeysm
Copy link
Member

Closes #1140, as discussed in today's meeting.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Benchmark Report

  • this PR's head: 574f0b4bd058fba793ccdab47a5137ccecaa1eff
  • base branch: 993cc5ba5d90cbc5be8cc60e190a5de05ef491b3

Computer Information

Julia Version 1.11.7
Commit f2b3dbda30a (2025-09-08 12:10 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

┌───────────────────────┬───────┬─────────────┬───────────────────┬────────┬─────────────────────────────────┬────────────────────────────┬─────────────────────────────────┐
│                       │       │             │                   │        │        t(eval) / t(ref)         │     t(grad) / t(eval)      │        t(grad) / t(ref)         │
│                       │       │             │                   │        │ ──────────┬───────────┬──────── │ ───────┬─────────┬──────── │ ──────────┬───────────┬──────── │
│                 Model │   Dim │  AD Backend │           VarInfo │ Linked │      base │   this PR │ speedup │   base │ this PR │ speedup │      base │   this PR │ speedup │
├───────────────────────┼───────┼─────────────┼───────────────────┼────────┼───────────┼───────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│               Dynamic │    10 │    mooncake │             typed │   true │    367.18 │    361.60 │    1.02 │  11.01 │   10.99 │    1.00 │   4043.24 │   3973.16 │    1.02 │
│                   LDA │    12 │ reversediff │             typed │   true │   8374.88 │   3445.73 │    2.43 │   2.65 │    5.47 │    0.48 │  22155.88 │  18837.83 │    1.18 │
│   Loop univariate 10k │ 10000 │    mooncake │             typed │   true │ 107570.34 │ 111107.34 │    0.97 │   4.11 │    3.93 │    1.04 │ 441680.69 │ 437158.00 │    1.01 │
├───────────────────────┼───────┼─────────────┼───────────────────┼────────┼───────────┼───────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│    Loop univariate 1k │  1000 │    mooncake │             typed │   true │   8135.68 │   9582.93 │    0.85 │   4.75 │    3.95 │    1.20 │  38680.52 │  37816.00 │    1.02 │
│      Multivariate 10k │ 10000 │    mooncake │             typed │   true │  33106.39 │  79731.98 │    0.42 │  10.05 │    5.55 │    1.81 │ 332869.36 │ 442461.79 │    0.75 │
│       Multivariate 1k │  1000 │    mooncake │             typed │   true │   8352.57 │   3543.77 │    2.36 │   4.15 │    9.56 │    0.43 │  34676.99 │  33872.09 │    1.02 │
├───────────────────────┼───────┼─────────────┼───────────────────┼────────┼───────────┼───────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│ Simple assume observe │     1 │ forwarddiff │             typed │  false │      2.72 │      2.69 │    1.01 │   3.94 │    3.97 │    0.99 │     10.70 │     10.67 │    1.00 │
│           Smorgasbord │   201 │ forwarddiff │             typed │  false │   1218.29 │   1216.10 │    1.00 │ 123.49 │   63.26 │    1.95 │ 150444.87 │  76930.22 │    1.96 │
│           Smorgasbord │   201 │ forwarddiff │       simple_dict │   true │       err │       err │     err │    err │     err │     err │       err │       err │     err │
├───────────────────────┼───────┼─────────────┼───────────────────┼────────┼───────────┼───────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│           Smorgasbord │   201 │ forwarddiff │ simple_namedtuple │   true │       err │       err │     err │    err │     err │     err │       err │       err │     err │
│           Smorgasbord │   201 │      enzyme │             typed │   true │   1706.17 │   1736.31 │    0.98 │   5.61 │    7.14 │    0.79 │   9569.12 │  12392.68 │    0.77 │
│           Smorgasbord │   201 │    mooncake │             typed │   true │   1727.61 │   1677.72 │    1.03 │   5.20 │    5.38 │    0.97 │   8978.72 │   9033.29 │    0.99 │
├───────────────────────┼───────┼─────────────┼───────────────────┼────────┼───────────┼───────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│           Smorgasbord │   201 │ reversediff │             typed │   true │   1894.75 │   1687.21 │    1.12 │  78.62 │   89.35 │    0.88 │ 148955.90 │ 150745.35 │    0.99 │
│           Smorgasbord │   201 │ forwarddiff │      typed_vector │   true │   1691.14 │   1685.63 │    1.00 │  55.37 │   58.06 │    0.95 │  93646.57 │  97872.79 │    0.96 │
│           Smorgasbord │   201 │ forwarddiff │           untyped │   true │   1696.68 │   1688.79 │    1.00 │  56.70 │   57.60 │    0.98 │  96196.81 │  97281.80 │    0.99 │
├───────────────────────┼───────┼─────────────┼───────────────────┼────────┼───────────┼───────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│           Smorgasbord │   201 │ forwarddiff │    untyped_vector │   true │   1673.74 │   1713.30 │    0.98 │  54.81 │   57.09 │    0.96 │  91730.23 │  97806.93 │    0.94 │
│              Submodel │     1 │    mooncake │             typed │   true │      7.43 │      7.39 │    1.01 │   5.04 │    5.53 │    0.91 │     37.44 │     40.87 │    0.92 │
└───────────────────────┴───────┴─────────────┴───────────────────┴────────┴───────────┴───────────┴─────────┴────────┴─────────┴─────────┴───────────┴───────────┴─────────┘

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.99%. Comparing base (993cc5b) to head (574f0b4).
⚠️ Report is 1 commits behind head on breaking.

Additional details and impacted files
@@            Coverage Diff            @@
##           breaking    #1161   +/-   ##
=========================================
  Coverage     79.99%   79.99%           
=========================================
  Files            41       41           
  Lines          3874     3874           
=========================================
  Hits           3099     3099           
  Misses          775      775           

☔ 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.

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.

LGTM

@penelopeysm penelopeysm merged commit 54ae7e3 into breaking Dec 1, 2025
21 checks passed
@penelopeysm penelopeysm deleted the py/lp-or-logjoint branch December 1, 2025 18:58
github-merge-queue bot pushed a commit that referenced this pull request Dec 2, 2025
* v0.39

* Update DPPL compats for benchmarks and docs

* remove merge conflict markers

* Remove `NodeTrait` (#1133)

* Remove NodeTrait

* Changelog

* Fix exports

* docs

* fix a bug

* Fix doctests

* Fix test

* tweak changelog

* FastLDF / InitContext unified (#1132)

* Fast Log Density Function

* Make it work with AD

* Optimise performance for identity VarNames

* Mark `get_range_and_linked` as having zero derivative

* Update comment

* make AD testing / benchmarking use FastLDF

* Fix tests

* Optimise away `make_evaluate_args_and_kwargs`

* const func annotation

* Disable benchmarks on non-typed-Metadata-VarInfo

* Fix `_evaluate!!` correctly to handle submodels

* Actually fix submodel evaluate

* Document thoroughly and organise code

* Support more VarInfos, make it thread-safe (?)

* fix bug in parsing ranges from metadata/VNV

* Fix get_param_eltype for TSVI

* Disable Enzyme benchmark

* Don't override _evaluate!!, that breaks ForwardDiff (sometimes)

* Move FastLDF to experimental for now

* Fix imports, add tests, etc

* More test fixes

* Fix imports / tests

* Remove AbstractFastEvalContext

* Changelog and patch bump

* Add correctness tests, fix imports

* Concretise parameter vector in tests

* Add zero-allocation tests

* Add Chairmarks as test dep

* Disable allocations tests on multi-threaded

* Fast InitContext (#1125)

* Make InitContext work with OnlyAccsVarInfo

* Do not convert NamedTuple to Dict

* remove logging

* Enable InitFromPrior and InitFromUniform too

* Fix `infer_nested_eltype` invocation

* Refactor FastLDF to use InitContext

* note init breaking change

* fix logjac sign

* workaround Mooncake segfault

* fix changelog too

* Fix get_param_eltype for context stacks

* Add a test for threaded observe

* Export init

* Remove dead code

* fix transforms for pathological distributions

* Tidy up loads of things

* fix typed_identity spelling

* fix definition order

* Improve docstrings

* Remove stray comment

* export get_param_eltype (unfortunatley)

* Add more comment

* Update comment

* Remove inlines, fix OAVI docstring

* Improve docstrings

* Simplify InitFromParams constructor

* Replace map(identity, x[:]) with [i for i in x[:]]

* Simplify implementation for InitContext/OAVI

* Add another model to allocation tests

Co-authored-by: Markus Hauru <[email protected]>

* Revert removal of dist argument (oops)

* Format

* Update some outdated bits of FastLDF docstring

* remove underscores

---------

Co-authored-by: Markus Hauru <[email protected]>

* implement `LogDensityProblems.dimension`

* forgot about capabilities...

* use interpolation in run_ad

* Improvements to benchmark outputs (#1146)

* print output

* fix

* reenable

* add more lines to guide the eye

* reorder table

* print tgrad / trel as well

* forgot this type

* Allow generation of `ParamsWithStats` from `FastLDF` plus parameters, and also `bundle_samples` (#1129)

* Implement `ParamsWithStats` for `FastLDF`

* Add comments

* Implement `bundle_samples` for ParamsWithStats -> MCMCChains

* Remove redundant comment

* don't need Statistics?

* Make FastLDF the default (#1139)

* Make FastLDF the default

* Add miscellaneous LogDensityProblems tests

* Use `init!!` instead of `fast_evaluate!!`

* Rename files, rebalance tests

* Implement `predict`, `returned`, `logjoint`, ... with `OnlyAccsVarInfo` (#1130)

* Use OnlyAccsVarInfo for many re-evaluation functions

* drop `fast_` prefix

* Add a changelog

* Improve FastLDF type stability when all parameters are linked or unlinked (#1141)

* Improve type stability when all parameters are linked or unlinked

* fix a merge conflict

* fix enzyme gc crash (locally at least)

* Fixes from review

* Make threadsafe evaluation opt-in (#1151)

* Make threadsafe evaluation opt-in

* Reduce number of type parameters in methods

* Make `warned_warn_about_threads_threads_threads_threads` shorter

* Improve `setthreadsafe` docstring

* warn on bare `@threads` as well

* fix merge

* Fix performance issues

* Use maxthreadid() in TSVI

* Move convert_eltype code to threadsafe eval function

* Point to new Turing docs page

* Add a test for setthreadsafe

* Tidy up check_model

* Apply suggestions from code review

Fix outdated docstrings

Co-authored-by: Markus Hauru <[email protected]>

* Improve warning message

* Export `requires_threadsafe`

* Add an actual docstring for `requires_threadsafe`

---------

Co-authored-by: Markus Hauru <[email protected]>

* Standardise `:lp` -> `:logjoint` (#1161)

* Standardise `:lp` -> `:logjoint`

* changelog

* fix a test

---------

Co-authored-by: Markus Hauru <[email protected]>
Co-authored-by: Markus Hauru <[email protected]>
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.

3 participants