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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open

Remove selector/space stuff #2458

wants to merge 21 commits into from

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 12713748848

Details

  • 20 of 45 (44.44%) changed or added relevant lines in 8 files are covered.
  • 814 unchanged lines in 18 files lost coverage.
  • Overall coverage decreased (-54.3%) to 30.738%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/mcmc/emcee.jl 0 1 0.0%
src/mcmc/sghmc.jl 0 2 0.0%
src/mcmc/particle_mcmc.jl 7 11 63.64%
src/mcmc/hmc.jl 0 9 0.0%
src/mcmc/mh.jl 6 15 40.0%
Files with Coverage Reduction New Missed Lines %
src/essential/container.jl 1 87.1%
src/variational/VariationalInference.jl 4 0.0%
src/mcmc/abstractmcmc.jl 8 78.72%
src/mcmc/is.jl 15 0.0%
src/mcmc/repeat_sampler.jl 16 0.0%
src/stdlib/RandomMeasures.jl 22 0.0%
ext/TuringDynamicHMCExt.jl 29 0.0%
src/mcmc/mh.jl 41 52.34%
src/mcmc/emcee.jl 47 0.0%
ext/TuringOptimExt.jl 50 0.0%
Totals Coverage Status
Change from base Build 12675082674: -54.3%
Covered Lines: 458
Relevant Lines: 1490

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

Project coverage is 81.60%. Comparing base (7d6f8ed) to head (d6ba522).

Files with missing lines Patch % Lines
src/mcmc/mh.jl 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2458      +/-   ##
==========================================
- Coverage   84.88%   81.60%   -3.28%     
==========================================
  Files          21       21              
  Lines        1581     1506      -75     
==========================================
- Hits         1342     1229     -113     
- Misses        239      277      +38     

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

src/mcmc/particle_mcmc.jl Outdated Show resolved Hide resolved
src/mcmc/particle_mcmc.jl Outdated Show resolved Hide resolved
src/mcmc/particle_mcmc.jl Outdated Show resolved Hide resolved
src/mcmc/particle_mcmc.jl Outdated Show resolved Hide resolved
src/mcmc/particle_mcmc.jl Outdated Show resolved Hide resolved
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.

src/mcmc/sghmc.jl Outdated Show resolved Hide resolved
src/mcmc/sghmc.jl Outdated Show resolved Hide resolved
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.

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