Skip to content

v0.10 #305

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

v0.10 #305

wants to merge 10 commits into from

Conversation

sunxd3
Copy link
Member

@sunxd3 sunxd3 commented May 28, 2025

This is to address #296. The changes required from current main branch will be substantial.

The current approach is that I'll gradually merge PR into v0.10 branch. And eventually make a non-squash merge.

I am not entirely clear about the code change that are required, so I might flip-flop on ideas and design, but I'll make the motivation and changes clear.

I will likely to move fast and not request a lot of reviews, and sometimes code changes will break some tests, but their corresponding test will pass. And before merging , all tests will pass.

sunxd3 and others added 2 commits May 28, 2025 15:52
Introduce improved functions and tests.

This PR is purely additive, no old code is removed - this will be done
later.

---------

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

JuliaBUGS.jl documentation for PR #305 is available at:
https://TuringLang.github.io/JuliaBUGS.jl/previews/PR305/

@coveralls
Copy link

coveralls commented May 28, 2025

Pull Request Test Coverage Report for Build 15303545232

Details

  • 59 of 64 (92.19%) changed or added relevant lines in 1 file are covered.
  • 363 unchanged lines in 9 files lost coverage.
  • Overall coverage decreased (-13.8%) to 69.706%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/graphs.jl 59 64 92.19%
Files with Coverage Reduction New Missed Lines %
ext/JuliaBUGSAdvancedMHExt.jl 2 0.0%
src/logdensityproblems.jl 2 84.62%
ext/JuliaBUGSAdvancedHMCExt.jl 9 0.0%
src/graphs.jl 16 75.0%
ext/JuliaBUGSMCMCChainsExt.jl 26 0.0%
src/gibbs.jl 30 0.0%
src/experimental/ProbabilisticGraphicalModels/conditioning.jl 31 0.0%
src/experimental/ProbabilisticGraphicalModels/functions.jl 70 0.0%
src/experimental/ProbabilisticGraphicalModels/bayesian_network.jl 177 0.0%
Totals Coverage Status
Change from base Build 15281006647: -13.8%
Covered Lines: 1804
Relevant Lines: 2588

💛 - Coveralls

sunxd3 and others added 2 commits May 29, 2025 09:00
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
The scope of `interface.jl` is unclear—it contains a set of
miscellaneous functions defined for models, but it's hard to see why
they differ from `condition` and `evaluation`.


Update: merged `interface.jl` into `model.jl` to balance code per file
and keep related code together.

---------

Co-authored-by: Xianda Sun <[email protected]>
Co-authored-by: Xianda Sun <[email protected]>
@yebai
Copy link
Member

yebai commented May 30, 2025

I forgot in #307: src/logdensityprogram.jl can also be moved to src/model/logdensityproblem.jl.

sunxd3 and others added 6 commits June 2, 2025 11:23
1. `FlattenedGraphNodeData` is renamed to `GraphEvaluationData`. 
2. `parameter` field of `BUGSModel` is moved inside
`GraphEvaluationData` and named `sorted_parameters` for better
understanding.

(1) is purely for ease of understanding. 
(2) is motivated by eliminating an implicit invariant where `parameters`
are assumed to be order-consistent with `sorted_nodes` field of
`FlattenedGraphNodeData`, not explicit by construction.
Address #252

The old `condition` does two things at once: it creates a `BUGSModel`
that contains a subset of the original variables and also mark variables
to be conditioned on as `observed`. This was partially motivated by
trying to make BUGS' `Gibbs` algorithm looks like Turing.jl's while make
use the advantage of the graph.

But this is ultimately a badly thought-out interface. This PR implements
`condition` and `decondition` to be like DynamicPPL's, i.e., it only
sets variables from model parameters to observations.

I also took the chance to properly refactored the code to better handle
more types of arguments and added some docstrings.
This fix some issues following the file restructuring.

It's debatable `source_generation.jl` file should be moved to `model`
folder. I left it as is.

There is an error message removed. It is tricky - I think expose the raw
error to user is probably a better idea, and we can improve the error
message if it's required.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
make `/test` mimic `/src` structure-wise.

one redundant test is removed, others was just moved around, some files
are renamed.

CI are split into parallel runs.

`experimental` and some hmc tests are failing and I am going to ignore
them for now.

---------

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

github-actions bot commented Jun 5, 2025

Benchmark results on macOS (aarch64)

BridgeStan not found at location specified by $BRIDGESTAN environment variable, downloading version 2.6.2 to /Users/runner/.bridgestan/bridgestan-2.6.2
Done!

Stan results:

Model Parameters Density Time (µs) Density+Gradient Time (µs)
rats 65 5.2666 7.708
pumps 12 0.842611 1.04666
bones 13 80.292 93.375
oxford 244 11.479 14.166
epil 303 33.917 38.208
lsat 1006 104.042 145.875
schools 133 244.625 382.584
beetles 2 0.790528 0.881462
air 5 0.819444 0.954034

JuliaBUGS Mooncake results:

Model Parameters Density Time (µs) Density+Gradient Time (µs)
rats 65 1.29165 8.08333
pumps 12 0.474873 1.99167
bones 33 55.459 288.625
oxford 244 23.25 56.875
epil 303 8.06933 38.25
lsat 1006 55.5 244.334
schools 133 89.083 732.146
beetles 2 1.105 4.0668
air 5 0.308424 1.2627

Benchmark results on Ubuntu (x64)

BridgeStan not found at location specified by $BRIDGESTAN environment variable, downloading version 2.6.2 to /home/runner/.bridgestan/bridgestan-2.6.2
Done!

Stan results:

Model Parameters Density Time (µs) Density+Gradient Time (µs)
rats 65 5.2076 7.65767
pumps 12 0.961133 1.20069
bones 13 72.416 89.688
oxford 244 13.9515 17.974
epil 303 27.021 33.814
lsat 1006 161.052 201.257
schools 133 533.153 776.644
beetles 2 0.844429 0.980833
air 5 0.661023 0.832429

JuliaBUGS Mooncake results:

Model Parameters Density Time (µs) Density+Gradient Time (µs)
rats 65 1.92567 13.916
pumps 12 0.5929 2.41375
bones 33 47.749 359.013
oxford 244 23.694 74.309
epil 303 10.7805 55.705
lsat 1006 90.089 369.202
schools 133 102.402 1122.9
beetles 2 1.10246 4.652
air 5 0.340632 1.4031

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