Optimize generated quantities replay in chain bundling#448
Open
arnavk23 wants to merge 8 commits into
Open
Conversation
…ter space handling - Export generated_quantities_dependency_closure from main module for CI visibility - Fix transformed parameter handling in MCMCChains extension (HMC samples in transformed space) - Ensure generated_quantities_dependency_closure is properly imported in Model submodule
…tion - Use forward bijector (unconstrained->constrained) when parameters are in transformed space - Previously was using inverse bijector which was backwards - This fixes negative parameter values in HMC generated quantities evaluation
- Remove complex custom parameter reconstruction logic - Delegate to evaluate_with_values!! which already handles bijectors correctly - This function now just calls evaluate_with_values!! and returns the evaluation environment - Ensures proper handling of both transformed (HMC) and untransformed (Gibbs) spaces
- Check if model uses auto-marginalization - Use evaluate_with_marginalization_values!! for marginalized models - Use evaluate_with_values!! for regular models - This fixes BoundsError when accessing parameter vectors for marginalized models
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #448 +/- ##
==========================================
+ Coverage 83.56% 83.59% +0.02%
==========================================
Files 27 27
Lines 3949 3961 +12
==========================================
+ Hits 3300 3311 +11
- Misses 649 650 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
@sunxd3 Tried working on this again. |
…s all nodes The docstring incorrectly stated the function only recomputes generated quantities. In reality, it delegates to evaluate_with_values or evaluate_with_marginalization_values, which evaluate all nodes in the model. Updated the docstring to accurately reflect this.
Contributor
Benchmark ResultsJulia 1.11.9 on AMD EPYC 7763 64-Core Processor (Linux) Ratio = JuliaBUGS/Stan (lower is better for JuliaBUGS)
Note: Stan benchmarks use hand-optimized Stan models, not direct BUGS translations. Comparison is illustrative only. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #94 by avoiding full
evaluate!!re-runs during chain bundling for HMC draws.Changes
BUGSModel.JuliaBUGSMCMCChainsExtto use targeted replay instead of full model evaluation.Impact