Skip to content

Implement Turing-like model macro #291

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

Merged
merged 19 commits into from
Apr 30, 2025
Merged

Implement Turing-like model macro #291

merged 19 commits into from
Apr 30, 2025

Conversation

sunxd3
Copy link
Member

@sunxd3 sunxd3 commented Apr 7, 2025

Address #281

Edited:
I wrote some documentation in markdown for this PR and design, there is a slight change from last weeks' Monday meeting.

The markdown doc should be concise enough and I don't think I can make it much shorter without losing essential information.

So could the reviews, please, give https://github.com/TuringLang/JuliaBUGS.jl/blob/sunxd/new_model_syntax/docs/src/julia_syntax.md a quick read?

@coveralls
Copy link

coveralls commented Apr 11, 2025

Pull Request Test Coverage Report for Build 14760776262

Details

  • 74 of 87 (85.06%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 83.512%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/JuliaBUGS.jl 10 11 90.91%
src/model_macro.jl 64 76 84.21%
Files with Coverage Reduction New Missed Lines %
src/JuliaBUGS.jl 1 83.72%
Totals Coverage Status
Change from base Build 14757438446: 0.1%
Covered Lines: 2107
Relevant Lines: 2523

💛 - Coveralls

@sunxd3 sunxd3 marked this pull request as ready for review April 14, 2025 10:53
Copy link
Member

@mhauru mhauru left a comment

Choose a reason for hiding this comment

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

I read the Markdown, it's well written. There's a broader conversation about @parameters that concerns DPPL too, as discussed e.g. today, but I assume that's outside the scope of this PR. I didn't actually read the implementation of the macros.

I added a couple of suggested comments to explain the tests, do edit them if I they are wrong.

Copy link
Contributor

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.0166 7.06933
pumps 12 0.8262 0.958345
bones 13 74.0 84.375
oxford 244 10.7705 12.75
epil 303 31.125 35.75
lsat 1006 97.541 133.125
schools 133 224.313 341.25
beetles 2 0.740625 0.803912
air 5 0.817139 0.902269

JuliaBUGS Mooncake results:

Model Parameters Density Time (µs) Density+Gradient Time (µs)
rats 65 1.25191 7.81933
pumps 12 0.512207 1.95836
bones 33 60.375 264.625
oxford 244 21.917 55.584
epil 303 7.472 37.25
lsat 1006 54.875 243.23
schools 133 86.292 704.875
beetles 2 1.15332 4.175
air 5 0.310484 1.28239

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.2158 7.60733
pumps 12 0.952103 1.21487
bones 13 69.95 86.29
oxford 244 13.721 17.733
epil 303 28.934 35.385
lsat 1006 164.315 199.421
schools 133 485.632 720.498
beetles 2 0.850412 1.00428
air 5 0.667591 0.809833

JuliaBUGS Mooncake results:

Model Parameters Density Time (µs) Density+Gradient Time (µs)
rats 65 1.9356 13.8005
pumps 12 0.5939 2.71873
bones 33 47.889 353.426
oxford 244 23.504 72.915
epil 303 10.79 55.072
lsat 1006 89.736 363.58
schools 133 102.766 1085.04
beetles 2 1.09742 4.57183
air 5 0.341453 1.36633

@sunxd3
Copy link
Member Author

sunxd3 commented Apr 30, 2025

@yebai I am merging this. It is not a breaking change because the model macro is not exported and compile's behavior is not changed yet. I want this to be in the main branch to update the interop examples.

We can adjust the public interface later, and bump the version then.

@sunxd3 sunxd3 merged commit d034d65 into main Apr 30, 2025
11 of 14 checks passed
@sunxd3 sunxd3 deleted the sunxd/new_model_syntax branch April 30, 2025 21:50
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.

4 participants