Skip to content

Link varinfo by default in AD testing utilities; make test suite run on linked varinfos #890

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

Merged
merged 9 commits into from
Apr 16, 2025

Conversation

penelopeysm
Copy link
Member

@penelopeysm penelopeysm commented Apr 15, 2025

This is a followup from yesterday's meeting.

I think this is a breaking change, so merging into minor release...

@penelopeysm penelopeysm changed the base branch from main to breaking April 15, 2025 13:38
@penelopeysm penelopeysm requested a review from sunxd3 April 15, 2025 13:40
Copy link
Contributor

github-actions bot commented Apr 15, 2025

Benchmark Report for Commit 976885c

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 |                  9.5 |                 1.6 |
|           Smorgasbord |       201 | forwarddiff |             typed |  false |                756.4 |                34.2 |
|           Smorgasbord |       201 | forwarddiff | simple_namedtuple |   true |                319.8 |                65.0 |
|           Smorgasbord |       201 | forwarddiff |           untyped |   true |               1221.8 |                27.3 |
|           Smorgasbord |       201 | forwarddiff |       simple_dict |   true |               3264.9 |                23.8 |
|           Smorgasbord |       201 | reversediff |             typed |   true |               1439.4 |                29.9 |
|           Smorgasbord |       201 |    mooncake |             typed |   true |                935.5 |                 5.3 |
|    Loop univariate 1k |      1000 |    mooncake |             typed |   true |               5428.5 |                 4.1 |
|       Multivariate 1k |      1000 |    mooncake |             typed |   true |               1004.6 |                 8.9 |
|   Loop univariate 10k |     10000 |    mooncake |             typed |   true |              61134.8 |                 3.7 |
|      Multivariate 10k |     10000 |    mooncake |             typed |   true |               8897.3 |                 9.7 |
|               Dynamic |        10 |    mooncake |             typed |   true |                135.6 |                12.2 |
|              Submodel |         1 |    mooncake |             typed |   true |                 27.2 |                 6.9 |
|                   LDA |        12 | reversediff |             typed |   true |                482.1 |                 5.8 |

Copy link

codecov bot commented Apr 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.76%. Comparing base (5ba3530) to head (976885c).
Report is 1 commits behind head on breaking.

Additional details and impacted files
@@            Coverage Diff            @@
##           breaking     #890   +/-   ##
=========================================
  Coverage     84.75%   84.76%           
=========================================
  Files            35       35           
  Lines          3877     3879    +2     
=========================================
+ Hits           3286     3288    +2     
  Misses          591      591           

☔ 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

@sunxd3 sunxd3 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
Copy link
Member Author

I've actually been thinking about the interface a bit again, I thought that just using @test would be fine, but it's very hard to (1) capture the result if the test throws an error (this is useful for e.g. checking how wrong something was or whether it contained NaN results) and also (2) determine what kind of error was thrown...

@penelopeysm penelopeysm force-pushed the py/link-adtest branch 2 times, most recently from 77faa53 to e37e6bb Compare April 15, 2025 23:16
@penelopeysm penelopeysm changed the title Link varinfo by default in AD testing utilities Link varinfo by default in AD testing utilities; make test suite run on linked varinfos Apr 15, 2025
@penelopeysm penelopeysm force-pushed the py/link-adtest branch 2 times, most recently from 1f4ec6f to dc04166 Compare April 15, 2025 23:24
@penelopeysm
Copy link
Member Author

penelopeysm commented Apr 16, 2025

@sunxd3 Sorry to mess with you! Decided to change a few more things in the PR. It's mostly motivated by ADTests, because over there I need to run the AD and then catch the error to tell what went wrong (e.g. is it NaN or just outright wrong). The DPPL tests now use linked varinfo too. I think it's all looking better now.

Copy link
Member

@sunxd3 sunxd3 left a comment

Choose a reason for hiding this comment

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

In general, all make sense.

It will also perform _linking_, that is, the parameters in the VarInfo will
be transformed to unconstrained Euclidean space if they aren't already in
that space. Note that the act of linking may change the length of the
parameters. To disable linking, set `linked=false`.
Copy link
Member

Choose a reason for hiding this comment

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

I think this paragraph should be removed from this version?
And instead say something like "by default, we'll use linked (explaining what "link" means) varinfo..."

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, this is my bad. I messed with the interface a few times and forgot to update this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed now!

Comment on lines 175 to 176
value_atol::Real=1e-6,
grad_atol::Real=1e-6,
Copy link
Member

Choose a reason for hiding this comment

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

might as well be Float(even Float64)? my opinion is not strong here, just a mention.
Also could value_atol and grad_atol have different types?

Copy link
Member Author

@penelopeysm penelopeysm Apr 16, 2025

Choose a reason for hiding this comment

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

Actually, yes, I think some of these Reals should be AbstractFloats? I think f64 might be a bit too restrictive, I guess it's pretty much always going to be f64 in regular usage, but since this is an exported interface I figured it should be generic.

@penelopeysm penelopeysm requested a review from sunxd3 April 16, 2025 12:10
Copy link
Member

@sunxd3 sunxd3 left a comment

Choose a reason for hiding this comment

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

Thanks!

@penelopeysm penelopeysm merged commit be27636 into breaking Apr 16, 2025
17 of 18 checks passed
@penelopeysm penelopeysm deleted the py/link-adtest branch April 16, 2025 12:28
github-merge-queue bot pushed a commit that referenced this pull request Apr 24, 2025
* Release 0.36

* AbstractPPL 0.11 + change prefixing behaviour (#830)

* AbstractPPL 0.11; change prefixing behaviour

* Use DynamicPPL.prefix rather than overloading

* Remove VarInfo(VarInfo, params) (#870)

* Unify `{untyped,typed}_{vector_,}varinfo` constructor functions (#879)

* Unify {Untyped,Typed}{Vector,}VarInfo constructors

* Update invocations

* NTVarInfo

* Fix tests

* More fixes

* Fixes

* Fixes

* Fixes

* Use lowercase functions, don't deprecate VarInfo

* Rewrite VarInfo docstring

* Fix methods

* Fix methods (really)

* Link varinfo by default in AD testing utilities; make test suite run on linked varinfos (#890)

* Link VarInfo by default

* Tweak interface

* Fix tests

* Fix interface so that callers can inspect results

* Document

* Fix tests

* Fix changelog

* Test linked varinfos

Closes #891

* Fix docstring + use AbstractFloat

* Fix `condition` and `fix` in submodels (#892)

* Fix conditioning in submodels

* Simplify contextual_isassumption

* Add documentation

* Fix some tests

* Add tests; fix a bunch of nested submodel issues

* Fix fix as well

* Fix doctests

* Add unit tests for new functions

* Add changelog entry

* Update changelog

Co-authored-by: Hong Ge <[email protected]>

* Finish docs

* Add a test for conditioning submodel via arguments

* Clean new tests up a bit

* Fix for VarNames with non-identity lenses

* Apply suggestions from code review

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

* Apply suggestions from code review

* Make PrefixContext contain a varname rather than symbol (#896)

---------

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

---------

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

2 participants