TuringLang / JuliaBUGS.jl

A domain specific language (DSL) for probabilistic graphical models
https://turinglang.org/JuliaBUGS.jl/
MIT License
21 stars 3 forks source link

More performance improvement to log density evaluation #230

Closed sunxd3 closed 4 days ago

sunxd3 commented 5 days ago

This remove another performance bottleneck: getindex from MetaGraph. This is done by storing the data in arrays.

The size of a BUGSModel is increased by 15%.

And it roughly half the previous time, while not impacting the ReverseDiff time.

coveralls commented 5 days ago

Pull Request Test Coverage Report for Build 11541635140

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/model.jl 46 47 97.87%
<!-- Total: 50 51 98.04% -->
Totals Coverage Status
Change from base Build 11519174461: 0.4%
Covered Lines: 1410
Relevant Lines: 1802

💛 - Coveralls
github-actions[bot] commented 5 days ago
BridgeStan not found at location specified by $BRIDGESTAN environment variable, downloading version 2.5.0 to /home/runner/.bridgestan/bridgestan-2.5.0 Done! Model dogs produces error: ErrorException("log_density() failed with exception: Exception: bernoulli_lpmf: Probability parameter is inf, but must be in the interval [0, 1] (in '/home/runner/work/JuliaBUGS.jl/JuliaBUGS.jl/benchmark/stan/bugs_examples/vol1/dogs/dogs.stan', line 37, column 6 to line 38, column 62)\n") Model Parameter Count Data Count Stan Density Time (µs) Stan Density Gradient Time (µs) JuliaBUGS Density Time with Graph Walk (µs) JuliaBUGS Density Gradient Time with ReverseDiff.jl(compiled tape) (µs)
rats 65 150 5.5624 8.07167 138.207 85.5195
pumps 12 10 0.978833 1.28504 18.825 6.34925
dogs 2 720 NA NA 265.154 150.305
seeds 26 21 2.51291 3.12922 49.1165 21.53
surgical_realistic 14 12 1.26496 1.61911 24.715 8.506
magnesium 108 96 10.3645 11.9825 237.342 73.848
salm 22 18 2.37017 3.10306 39.283 12.383
equiv 15 20 2.50373 3.39375 27.351 17.984
dyes 9 30 1.02618 1.33386 16.716 12.964
stacks 6 21 1.12596 1.68841 52.619 14.647
epil 303 236 32.821 38.231 603.015 239.336
blockers 47 44 3.28944 3.73063 107.992 28.283
oxford 244 240 16.13 18.726 704.884 173.784
lsat 1006 5000 173.574 214.736 4083.15 1187.36
bones 33 422 73.758 91.48 1356.48 190.204
mice 20 65 7.32375 9.451 42.279 37.48
kidney 64 58 10.765 16.261 121.757 76.332
leuk 18 714 20.428 26.9 336.116 205.393
leukfr 40 714 23.804 31.949 371.893 239.897
sunxd3 commented 4 days ago

This is not perfect, but I am merging this now and will optimize memory size later.