Skip to content

Conversation

penelopeysm
Copy link
Member

@penelopeysm penelopeysm commented Jul 27, 2025

MCMCChains.jl doesn't like vector-valued or matrix-valued variables. Consequently, in Turing we use DynamicPPL.varname_and_value_leaves to split things like x up into x[1], x[2], ...

This is in general a lossy operation since x cannot be reconstructed from its individual elements.

This conversion used to be done when constructing a Transition. However, there was no need to do it so early. This PR changes it such that it is only done within the _params_to_array method, which is called inside bundle_samples.

On its own, this refactor is quite meaningless from the Turing point of view. However, what it does mean is that if we create a new chains type that doesn't need to break variables up, we can define an AbstractMCMC.bundle_samples(::Vector{<:Transition}, ..., ::NewChainType) which retains the original data structure in the NewChainType, because now the Transition will have that richer information. This has implications for the rewrite of MCMCChains that I'm currently working on.

Copy link
Contributor

Turing.jl documentation for PR #2632 is available at:
https://TuringLang.github.io/Turing.jl/previews/PR2632/

@penelopeysm penelopeysm force-pushed the py/dont-split-varnames-so-soon branch from c10b636 to 5634122 Compare July 27, 2025 01:30
@coveralls
Copy link

coveralls commented Jul 27, 2025

Pull Request Test Coverage Report for Build 16550602808

Details

  • 18 of 18 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.09%) to 84.997%

Totals Coverage Status
Change from base Build 16444793035: 0.09%
Covered Lines: 1252
Relevant Lines: 1473

💛 - Coveralls

@penelopeysm penelopeysm force-pushed the py/dont-split-varnames-so-soon branch from 5634122 to 7c08115 Compare July 27, 2025 02:46
Copy link

codecov bot commented Jul 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.88%. Comparing base (23b92eb) to head (61de0a7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2632      +/-   ##
==========================================
+ Coverage   84.78%   84.88%   +0.09%     
==========================================
  Files          22       22              
  Lines        1466     1475       +9     
==========================================
+ Hits         1243     1252       +9     
  Misses        223      223              

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

@penelopeysm penelopeysm requested a review from sunxd3 July 27, 2025 12:00
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.

No objection in principle.

Failed tests look unrelated, but may still worth a look?

@penelopeysm
Copy link
Member Author

Yupppp, failures are due to Libtask not working on 1.12 yet. Thanks!

@penelopeysm penelopeysm added this pull request to the merge queue Jul 28, 2025
Merged via the queue into main with commit d0510b1 Jul 28, 2025
30 of 33 checks passed
@penelopeysm penelopeysm deleted the py/dont-split-varnames-so-soon branch July 28, 2025 10:10
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