Skip to content

Support proposals of varying dimensions in vector-of-proposals (#120)#121

Merged
sunxd3 merged 4 commits intomainfrom
sunxd/fix-varying-dim-proposals
Feb 10, 2026
Merged

Support proposals of varying dimensions in vector-of-proposals (#120)#121
sunxd3 merged 4 commits intomainfrom
sunxd/fix-varying-dim-proposals

Conversation

@sunxd3
Copy link
Member

@sunxd3 sunxd3 commented Feb 6, 2026

Fix #120

parameters are split according to each proposal's dimension before stepping, and the resulting draws are repacked into a flat vector afterward

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

AdvancedMH.jl documentation for PR #121 is available at:
https://TuringLang.github.io/AdvancedMH.jl/previews/PR121/

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.88%. Comparing base (e318654) to head (5cf0323).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/proposal.jl 90.32% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
+ Coverage   90.03%   90.88%   +0.85%     
==========================================
  Files           9        9              
  Lines         311      340      +29     
==========================================
+ Hits          280      309      +29     
  Misses         31       31              

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

@coveralls
Copy link

coveralls commented Feb 6, 2026

Pull Request Test Coverage Report for Build 21801718299

Details

  • 25 of 30 (83.33%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.8%) to 91.15%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/proposal.jl 25 30 83.33%
Files with Coverage Reduction New Missed Lines %
src/proposal.jl 3 86.36%
Totals Coverage Status
Change from base Build 19030906276: 0.8%
Covered Lines: 309
Relevant Lines: 339

💛 - Coveralls

@sunxd3 sunxd3 requested a review from penelopeysm February 6, 2026 13:02
mixed-dimension proposal vectors.
"""
proposal_dim(p::Proposal{<:UnivariateDistribution}) = 1
proposal_dim(::Proposal{<:Function}) = 1
Copy link
Member

@penelopeysm penelopeysm Feb 6, 2026

Choose a reason for hiding this comment

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

The code in the PR all looks good, and I know I didn't say this in the original issue, but there are still quite a few more blockers to using this upstream in Turing. For example in this line which handles conditional proposals, are we implicitly assuming that the proposal is necessarily conditional on a single element?

Consider e.g.

@model f() = x ~ product_distribution([uni, uni])

where uni is some univariate distribution, and we want to propose new values of x based on the value at the previous step. Then we would need something like

StaticProposal(slice -> MvNormal(slice, I))

Or even something like a matrix distribution, which we would flatten inside an LDF. I don't immediately know how we can represent this in AdvancedMH where everything has to be flattened. I suppose that we would have to use something like a StaticProposal(vec(matrix_dist)).

Again, I don't think this has to be handled in this PR (if anything I actively think it shouldn't be). To be completely honest, I also don't know how to handle this, short of adding another field to StaticProposal that specifies the length. Just wanted to check that I'm understanding correctly

Copy link
Member

@penelopeysm penelopeysm Feb 6, 2026

Choose a reason for hiding this comment

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

Basically the problem is, if I have a high-level construct like

spl = MH(
    @varname(x) => xprop,
    @varname(y) => yprop,
)

how do we translate that into AdvancedMH. From an LDF we can identify the range of indices that each varname belongs to, so as long as we can translate the individual prop's into AdvancedMH proposals, this PR will let us then stack them together, which is great.

But we still need to be able to translate the props and that can depend quite a bit on what prop is, what x's distribution in the model is, etc. For example if x ~ LKJCholesky() and we want to say 'sample x from the prior', that is quite easy to do in Turing because you have access to the distribution. But in AdvancedMH we would need to translate this into 'sample a vectorised form of x from a vectorised form of LKJCholesky'. Then it gets more complex if you have a conditional distribution etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

these are tricky interface questions, we'll deal with them when they emerge

on the first comment, my cop out thought is that, if the user is serious about using this type of proposal, they can overload proposal_dim. this is not quite nice, but I am going to leave it there. that said, I added an error message

Copy link
Member

Choose a reason for hiding this comment

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

fwiw I'm happy to merge and release this!

@sunxd3 sunxd3 merged commit b5ee244 into main Feb 10, 2026
8 checks passed
@sunxd3 sunxd3 deleted the sunxd/fix-varying-dim-proposals branch February 10, 2026 03:18
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.

Proposals of varying dimensions can't be combined

3 participants