Skip to content
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

Remove selector/space stuff #2458

Merged
merged 22 commits into from
Feb 14, 2025
Merged

Remove selector/space stuff #2458

merged 22 commits into from
Feb 14, 2025

Conversation

mhauru
Copy link
Member

@mhauru mhauru commented Jan 8, 2025

This PR aims to remove all use of the Selector/Gibbs ID/space mechanisms that the old Gibbs sampler relied on. Methods for functions like getspace will still be defined for compatibility with the current DPPL version, but will not do anything. The goal is that after this has been merged a new release of DPPL could be made that removes the same mechanisms from VarInfo without anything breaking on the Turing.jl side.

@coveralls
Copy link

coveralls commented Jan 8, 2025

Pull Request Test Coverage Report for Build 12714062015

Details

  • 47 of 58 (81.03%) changed or added relevant lines in 9 files are covered.
  • 121 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-7.8%) to 77.2%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/mcmc/mh.jl 13 15 86.67%
src/mcmc/hmc.jl 0 9 0.0%
Files with Coverage Reduction New Missed Lines %
src/mcmc/Inference.jl 1 86.5%
src/mcmc/repeat_sampler.jl 1 83.33%
src/mcmc/mh.jl 3 84.8%
src/mcmc/hmc.jl 116 0.0%
Totals Coverage Status
Change from base Build 12675082674: -7.8%
Covered Lines: 1158
Relevant Lines: 1500

💛 - Coveralls

Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 96.55172% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (breaking@b97334b). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/mcmc/mh.jl 86.66% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             breaking    #2458   +/-   ##
===========================================
  Coverage            ?   85.01%           
===========================================
  Files               ?       21           
  Lines               ?     1495           
  Branches            ?        0           
===========================================
  Hits                ?     1271           
  Misses              ?      224           
  Partials            ?        0           

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

@mhauru mhauru marked this pull request as ready for review January 9, 2025 17:05
@mhauru mhauru requested a review from penelopeysm January 9, 2025 17:06
@penelopeysm
Copy link
Member

I feel like intuitively I'd have removed it from DPPL first, is there a particular reason you started here?

@mhauru
Copy link
Member Author

mhauru commented Jan 10, 2025

I feel like intuitively I'd have removed it from DPPL first, is there a particular reason you started here?

My thinking was to first stop using a feature of a dependency, then remove that feature. It doesn't make much of a difference, but I thought it might help make incremental changes. For instance, when making changes to DPPL, I should be able to test that Turing.jl tests pass with the new DPPL, without modifying Turing.jl code.

Copy link
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

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

I suppose that the selector features in DPPL are almost purely motivated by this, so from that perspective it does make sense to me to remove this first. It's just a bit awkward with the testing machinery because you'd have to manually run the Turing testsuite with a dev'd version of DPPL..(?) Also, CI won't run the Turing integration tests.

Anyway, just some tiny tidyup suggestions below.

unset_flag!(vi, vn, "del") # Reference particle parent
r = rand(trng, dist)
vi[vn] = DynamicPPL.tovec(r)
DynamicPPL.setgid!(vi, spl.selector, vn)
Copy link
Member

@penelopeysm penelopeysm Jan 10, 2025

Choose a reason for hiding this comment

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

Is this line needed? (Specifically the setgid one)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, nice catch. I hope not. It shouldn't? I tried removing it, and a bunch of other calls to setgid! and updategid!, let's see what the test suite says.

Comment on lines +120 to +127
elseif length(proposals) == 1
# If we hit this block, check to see if it's
# a run-of-the-mill proposal or covariance
# matrix.
prop = proposal(s)

# Return early, we got a covariance matrix.
return new{typeof(prop)}(prop)
Copy link
Member

Choose a reason for hiding this comment

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

This feels confusing to me, it could probably be handled better with a new method, but maybe a case for another time too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it the early return that confuses you? It confuses me. It's been there for at least ~5 years though, and I just left it be for now.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that and the call to proposal(), which is a bit opaque. But it's definitely out of scope for this PR.

Copy link
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

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

Happy to merge!

@mhauru
Copy link
Member Author

mhauru commented Jan 13, 2025

Thanks @penelopeysm! Let's hold off for a while, since 0.36 hasn't even been released yet.

@mhauru mhauru mentioned this pull request Jan 21, 2025
@mhauru mhauru changed the base branch from master to breaking February 14, 2025 17:20
@mhauru
Copy link
Member Author

mhauru commented Feb 14, 2025

Changed the base branch to breaking to collect multiple breaking changes into a single branch/PR.

@mhauru mhauru merged commit 08e4c08 into breaking Feb 14, 2025
55 of 57 checks passed
@mhauru mhauru deleted the mhauru/selector-clean-up branch February 14, 2025 17:23
mhauru added a commit that referenced this pull request Mar 19, 2025
* Bump minor version to v0.37

* Remove selector/space stuff (#2458)

* Remove selector stuff from ESS

* Remove selector stuff from MH

* Remove selector stuff from HMC

* Remove selector stuff from Emcee

* Remove selector stuff from IS

* Add missing getspace methods

* Remove selector stuff for particle methods

* Fix an HMC selector bug

* Code style

* Fix Emcee selector bug

* Fix typo in ESS tests

* Fix some constructor overwrites

* Remove unnecessary tests

* Remove selector stuff from SGHMC

* Remove drop_space and other non-longer-necessary deprecation measures

* Bump minor version 0.37. Add a HISTORY.md entry

* Apply suggestions from code review

Co-authored-by: Penelope Yong <[email protected]>

* Remove unnecessary type parameters

Co-authored-by: Penelope Yong <[email protected]>

* Simplify constructors in particle_mcmc.jl

* Remove calls to setgid and updategid

---------

Co-authored-by: Penelope Yong <[email protected]>

* Bump Mooncake compat to 0.4.95

* Support for DynamicPPL v0.35 (#2488)

* Progress towards compat with DPPL v0.35

* More fixing of DPPL v0.35 stuff

* Fix LogDensityFunction argument order

* More minor bugfixes

* [TEMP] Commit Manifest pointing to DynamicPPL#release-0.35

* remove LogDensityProblemsAD (#2490)

* Remove LogDensityProblemsAD, part 1

* update Optimisation code to not use LogDensityProblemsAD

* Fix field name change

* Don't put chunksize=0

* Remove LogDensityProblemsAD dep

* Improve OptimLogDensity docstring

* Remove unneeded model argument to _optimize

* Fix more tests

* Remove essential/ad from the list of CI groups

* Fix HMC function

* more test fixes (#2491)

* Remove LogDensityProblemsAD, part 1

* update Optimisation code to not use LogDensityProblemsAD

* Fix field name change

* Don't put chunksize=0

* Remove LogDensityProblemsAD dep

* Improve OptimLogDensity docstring

* Remove unneeded model argument to _optimize

* Fix more tests

* Remove essential/ad from the list of CI groups

* Fix HMC function

* More test fixes

* Remove Manifest

* More fixes for DynamicPPL 0.35 (#2494)

* Remove test/dynamicppl/compiler.jl

* Remove old regression tests

* Remove vdemo2

* Fix last test

* Add HISTORY.md entry about DPPL 0.35

* Allow ESS to sample variables with different symbols

* Update a TODO note

---------

Co-authored-by: Penelope Yong <[email protected]>

* Fix call to DynamicPPL.initialize_parameters!!

* Remove `Zygote` (#2505)

* Remove `Zygote`; fix #2504

* Update test/test_utils/ad_utils.jl

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Add HISTORY.md entry about removing support for Zygote

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Markus Hauru <[email protected]>
Co-authored-by: Penelope Yong <[email protected]>
Co-authored-by: Markus Hauru <[email protected]>

* Fix a Gibbs test

* Clean up exports (#2474)

* Regroup exports by package

* Export DynamicPPL.returned and DynamicPPL.prefix

* Stop exporting  @logprob_str and @prob_str

* Remove DynamicPPL module export

* Remove DynamicPPL.LogDensityFunction re-export

* Remove BernoulliLogit, drop support for Distributions < 0.25.77

* Stop blanket re-exporting Libtask and Bijectors

* Manually specify AbstractMCMC exports

* Format

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Remove Bijectors.ordered export

* Re-export LinearAlgebra.I

* Replace Turing.Model -> DynamicPPL.Model

* Format

* Keep exporting LogDensityFunction

* Add note in docs

* Align Turing exports with docs API page

* Fix things like `predict` on docs API page

* Fix a Gibbs test

* Format

* Fix missing Bijectors import

* Update docs/src/api.md

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

* Update docs/src/api.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Clean up broken docs links, remove unneeded deps

* Format

* Add changelog entry for exports

* Clean up exports in essential/Essential

* Apply suggestions from code review

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

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Markus Hauru <[email protected]>
Co-authored-by: Markus Hauru <[email protected]>

---------

Co-authored-by: Penelope Yong <[email protected]>
Co-authored-by: Hong Ge <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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