ReactiveBayes / RxInfer.jl

Julia package for automated Bayesian inference on a factor graph with reactive message passing
MIT License
265 stars 23 forks source link

fast path for dists in the PointMass constraint #145

Closed bvdmitri closed 1 year ago

bvdmitri commented 1 year ago

Previously the PointMass form constraint called slow optimization routine for <: Distribution objects, even though it is easier and faster to return the mode of the distribution. This PR fixes that. Found by @bartvanerp

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.09% :tada:

Comparison is base (6ad864e) 81.22% compared to head (287aa85) 81.32%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #145 +/- ## ========================================== + Coverage 81.22% 81.32% +0.09% ========================================== Files 11 11 Lines 1209 1210 +1 ========================================== + Hits 982 984 +2 + Misses 227 226 -1 ``` | [Files Changed](https://app.codecov.io/gh/biaslab/RxInfer.jl/pull/145?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=biaslab) | Coverage Δ | | |---|---|---| | [src/constraints/form/form\_point\_mass.jl](https://app.codecov.io/gh/biaslab/RxInfer.jl/pull/145?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=biaslab#diff-c3JjL2NvbnN0cmFpbnRzL2Zvcm0vZm9ybV9wb2ludF9tYXNzLmps) | `78.37% <100.00%> (+3.37%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

bartvanerp commented 1 year ago

Before:

BenchmarkTools.Trial: 6 samples with 1 evaluation.
 Range (min … max):  929.941 ms …   1.077 s  ┊ GC (min … max):  9.92% … 11.26%
 Time  (median):     957.682 ms              ┊ GC (median):    11.08%
 Time  (mean ± σ):   987.136 ms ± 64.681 ms  ┊ GC (mean ± σ):  11.12% ±  0.82%

  █  █      █ █                                        █     █  
  █▁▁█▁▁▁▁▁▁█▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁█ ▁
  930 ms          Histogram: frequency by time          1.08 s <

 Memory estimate: 528.79 MiB, allocs estimate: 4246814.

After

BenchmarkTools.Trial: 7 samples with 1 evaluation.
 Range (min … max):  668.098 ms … 845.756 ms  ┊ GC (min … max):  9.63% … 12.63%
 Time  (median):     725.226 ms               ┊ GC (median):    11.92%
 Time  (mean ± σ):   739.858 ms ±  55.859 ms  ┊ GC (mean ± σ):  11.65% ±  1.28%

  █             █   ██  █            █                        █  
  █▁▁▁▁▁▁▁▁▁▁▁▁▁█▁▁▁██▁▁█▁▁▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█ ▁
  668 ms           Histogram: frequency by time          846 ms <

 Memory estimate: 485.53 MiB, allocs estimate: 3522721.