Skip to content

Benchmarks

ModifiedDistributions benchmarks each modifier's hot paths so wrapper overhead is visible and regressions are caught on every pull request.

The suite (benchmark/benchmarks.jl) evaluates construction, logpdf, pdf, cdf/ccdf, quantile and rand for every modifier around the same base LogNormal, with the bare base as the shared baseline floor:

  • Baseline: the bare base LogNormal.

  • Affine: the change-of-variables paths through Y = scale * X + shift.

  • Weighted: the logpdf weight paths, scalar and the vectorised Product{Weighted} form.

  • Transformed: thin and cumulative, whose forward ops are transparent to every distribution method, so these rows should sit on the baseline.

  • Modified: the hazard modification on both analytic links; the identity-link quantile and rand exercise the monotone-bisection cdf inversion, the one non-closed-form path.

  • AD gradients: DifferentiationInterface.gradient of every test/ADFixtures scenario across the ForwardDiff, ReverseDiff, Mooncake and Enzyme backends, sharing the fixtures that drive the AD test suite.

Run the suite locally with task benchmark, or compare against main with task benchmark-compare (see benchmark/README.md). On pull requests the benchmark workflow benchmarks head and base in separate jobs and posts a single comparison comment. Pushes to main and tags append to the performance history shown below.

Performance history

Ratio summary

c5ff0062ac07a5...
AD gradients/Affine LogNormal scale+shift logpdf/Enzyme forward8.73 ± 0.12 μs
AD gradients/Affine LogNormal scale+shift logpdf/Enzyme reverse3.04 ± 0.051 μs
AD gradients/Affine LogNormal scale+shift logpdf/ForwardDiff0.743 ± 0.1 μs
AD gradients/Affine LogNormal scale+shift logpdf/Mooncake forward7.03 ± 0.23 μs
AD gradients/Affine LogNormal scale+shift logpdf/Mooncake reverse20 ± 1.1 μs
AD gradients/Affine LogNormal scale+shift logpdf/ReverseDiff (tape)16.4 ± 0.47 μs
AD gradients/Modified LogNormal identity-link logpdf/Enzyme forward8.78 ± 0.077 μs
AD gradients/Modified LogNormal identity-link logpdf/Enzyme reverse3.01 ± 0.076 μs
AD gradients/Modified LogNormal identity-link logpdf/ForwardDiff1.07 ± 0.016 μs
AD gradients/Modified LogNormal identity-link logpdf/Mooncake forward8.7 ± 0.18 μs
AD gradients/Modified LogNormal identity-link logpdf/Mooncake reverse0.036 ± 0.0017 ms
AD gradients/Modified LogNormal identity-link logpdf/ReverseDiff (tape)31.5 ± 0.59 μs
AD gradients/Modified LogNormal log-link logpdf/Enzyme forward8.6 ± 0.09 μs
AD gradients/Modified LogNormal log-link logpdf/Enzyme reverse3.54 ± 0.086 μs
AD gradients/Modified LogNormal log-link logpdf/ForwardDiff0.905 ± 0.094 μs
AD gradients/Modified LogNormal log-link logpdf/Mooncake forward7.6 ± 0.16 μs
AD gradients/Modified LogNormal log-link logpdf/Mooncake reverse0.0477 ± 0.0047 ms
AD gradients/Modified LogNormal log-link logpdf/ReverseDiff (tape)26.2 ± 0.59 μs
AD gradients/Product{Weighted} LogNormal vector logpdf/Enzyme forward8.26 ± 0.14 μs
AD gradients/Product{Weighted} LogNormal vector logpdf/Enzyme reverse1.02 ± 0.22 μs
AD gradients/Product{Weighted} LogNormal vector logpdf/ForwardDiff0.897 ± 0.068 μs
AD gradients/Product{Weighted} LogNormal vector logpdf/Mooncake forward7.18 ± 0.46 μs
AD gradients/Product{Weighted} LogNormal vector logpdf/Mooncake reverse0.037 ± 0.003 ms
AD gradients/Product{Weighted} LogNormal vector logpdf/ReverseDiff (tape)16.4 ± 0.44 μs
AD gradients/Transformed cumulative LogNormal logpdf/Enzyme forward8.03 ± 0.068 μs
AD gradients/Transformed cumulative LogNormal logpdf/Enzyme reverse1.97 ± 0.061 μs
AD gradients/Transformed cumulative LogNormal logpdf/ForwardDiff0.541 ± 0.083 μs
AD gradients/Transformed cumulative LogNormal logpdf/Mooncake forward6.4 ± 0.61 μs
AD gradients/Transformed cumulative LogNormal logpdf/Mooncake reverse30.8 ± 8.1 μs
AD gradients/Transformed cumulative LogNormal logpdf/ReverseDiff (tape)14.8 ± 0.43 μs
AD gradients/Transformed thin LogNormal logpdf/Enzyme forward8.09 ± 0.084 μs
AD gradients/Transformed thin LogNormal logpdf/Enzyme reverse1.97 ± 0.066 μs
AD gradients/Transformed thin LogNormal logpdf/ForwardDiff0.545 ± 0.081 μs
AD gradients/Transformed thin LogNormal logpdf/Mooncake forward7.7 ± 0.21 μs
AD gradients/Transformed thin LogNormal logpdf/Mooncake reverse30 ± 7.7 μs
AD gradients/Transformed thin LogNormal logpdf/ReverseDiff (tape)14.7 ± 0.4 μs
AD gradients/Weighted Affine LogNormal nested logpdf/Enzyme forward8.55 ± 0.1 μs
AD gradients/Weighted Affine LogNormal nested logpdf/Enzyme reverse0.954 ± 0.072 μs
AD gradients/Weighted Affine LogNormal nested logpdf/ForwardDiff0.861 ± 0.14 μs
AD gradients/Weighted Affine LogNormal nested logpdf/Mooncake forward7.37 ± 0.21 μs
AD gradients/Weighted Affine LogNormal nested logpdf/Mooncake reverse20.5 ± 1.2 μs
AD gradients/Weighted Affine LogNormal nested logpdf/ReverseDiff (tape)18.3 ± 0.49 μs
AD gradients/Weighted LogNormal observation-time weight logpdf/Enzyme forward8.05 ± 0.075 μs
AD gradients/Weighted LogNormal observation-time weight logpdf/Enzyme reverse1.3 ± 0.32 μs
AD gradients/Weighted LogNormal observation-time weight logpdf/ForwardDiff0.591 ± 0.096 μs
AD gradients/Weighted LogNormal observation-time weight logpdf/Mooncake forward6.19 ± 0.76 μs
AD gradients/Weighted LogNormal observation-time weight logpdf/Mooncake reverse0.0369 ± 0.0033 ms
AD gradients/Weighted LogNormal observation-time weight logpdf/ReverseDiff (tape)16.8 ± 0.45 μs
AD gradients/Weighted LogNormal scalar logpdf/Enzyme forward8.04 ± 0.07 μs
AD gradients/Weighted LogNormal scalar logpdf/Enzyme reverse1.25 ± 0.34 μs
AD gradients/Weighted LogNormal scalar logpdf/ForwardDiff0.597 ± 0.091 μs
AD gradients/Weighted LogNormal scalar logpdf/Mooncake forward6.01 ± 0.7 μs
AD gradients/Weighted LogNormal scalar logpdf/Mooncake reverse0.0446 ± 0.0036 ms
AD gradients/Weighted LogNormal scalar logpdf/ReverseDiff (tape)16.9 ± 0.47 μs
AD gradients/Weighted Sequential observed-total logpdf/Enzyme forward0.155 ± 0.0041 ms
AD gradients/Weighted Sequential observed-total logpdf/Enzyme reverse0.492 ± 0.033 ms
AD gradients/Weighted Sequential observed-total logpdf/ForwardDiff0.126 ± 0.0013 ms
AD gradients/Weighted Sequential observed-total logpdf/Mooncake forward0.588 ± 0.014 ms
AD gradients/Weighted Sequential observed-total logpdf/Mooncake reverse1.52 ± 0.035 ms
AD gradients/Weighted Sequential observed-total logpdf/ReverseDiff (tape)4.24 ± 0.51 ms
Affine/LogNormal/ccdf3.27 ± 0.38 μs
Affine/LogNormal/cdf3.36 ± 0.37 μs
Affine/LogNormal/construction3.1 ± 0.01 ns
Affine/LogNormal/logpdf2.63 ± 0.35 μs
Affine/LogNormal/pdf3.78 ± 0.2 μs
Affine/LogNormal/quantile0.488 ± 0.017 μs
Affine/LogNormal/rand1.27 ± 0.073 μs
Baseline/LogNormal/ccdf2.66 ± 0.34 μs
Baseline/LogNormal/cdf2.65 ± 0.34 μs
Baseline/LogNormal/construction1.55 ± 0.009 ns
Baseline/LogNormal/logpdf1.67 ± 0.31 μs
Baseline/LogNormal/pdf2.96 ± 0.32 μs
Baseline/LogNormal/quantile0.467 ± 0.017 μs
Baseline/LogNormal/rand1.03 ± 0.03 μs
Modified/IdentityLink/ccdf7.5 ± 0.018 μs
Modified/IdentityLink/cdf7.13 ± 0.02 μs
Modified/IdentityLink/construction3.1 ± 0.01 ns
Modified/IdentityLink/logpdf10.5 ± 0.051 μs
Modified/IdentityLink/pdf12.8 ± 0.05 μs
Modified/IdentityLink/quantile0.107 ± 0.00018 ms
Modified/IdentityLink/rand0.559 ± 0.015 ms
Modified/LogLink/ccdf5.76 ± 0.043 μs
Modified/LogLink/cdf6.11 ± 0.026 μs
Modified/LogLink/construction2.79 ± 0.01 ns
Modified/LogLink/logpdf7.99 ± 0.025 μs
Modified/LogLink/pdf9.29 ± 0.04 μs
Modified/LogLink/quantile0.922 ± 0.07 μs
Modified/LogLink/rand5.13 ± 0.14 μs
Transformed/cumulative/cdf2.64 ± 0.32 μs
Transformed/cumulative/construction4.02 ± 0.011 ns
Transformed/cumulative/logpdf1.66 ± 0.31 μs
Transformed/cumulative/rand1.04 ± 0.032 μs
Transformed/thin/cdf2.65 ± 0.34 μs
Transformed/thin/construction4.02 ± 0.01 ns
Transformed/thin/logpdf1.66 ± 0.31 μs
Transformed/thin/rand1.04 ± 0.039 μs
Weighted/Product/construction0.305 ± 0.14 μs
Weighted/Product/logpdf2.92 ± 0.21 μs
Weighted/scalar/construction3.41 ± 0.001 ns
Weighted/scalar/logpdf1.73 ± 0.3 μs
time_to_load0.594 ± 0.0037 s
c5ff0062ac07a5...
AD gradients/Affine LogNormal scale+shift logpdf/Enzyme forward0.044 k allocs: 1.52 kB
AD gradients/Affine LogNormal scale+shift logpdf/Enzyme reverse24 allocs: 0.969 kB
AD gradients/Affine LogNormal scale+shift logpdf/ForwardDiff7 allocs: 0.484 kB
AD gradients/Affine LogNormal scale+shift logpdf/Mooncake forward0.07 k allocs: 3.33 kB
AD gradients/Affine LogNormal scale+shift logpdf/Mooncake reverse0.292 k allocs: 13.5 kB
AD gradients/Affine LogNormal scale+shift logpdf/ReverseDiff (tape)0.248 k allocs: 10.6 kB
AD gradients/Modified LogNormal identity-link logpdf/Enzyme forward0.04 k allocs: 1.25 kB
AD gradients/Modified LogNormal identity-link logpdf/Enzyme reverse14 allocs: 0.609 kB
AD gradients/Modified LogNormal identity-link logpdf/ForwardDiff7 allocs: 0.359 kB
AD gradients/Modified LogNormal identity-link logpdf/Mooncake forward0.064 k allocs: 3.06 kB
AD gradients/Modified LogNormal identity-link logpdf/Mooncake reverse0.455 k allocs: 21.3 kB
AD gradients/Modified LogNormal identity-link logpdf/ReverseDiff (tape)0.465 k allocs: 17.8 kB
AD gradients/Modified LogNormal log-link logpdf/Enzyme forward0.04 k allocs: 1.25 kB
AD gradients/Modified LogNormal log-link logpdf/Enzyme reverse24 allocs: 0.969 kB
AD gradients/Modified LogNormal log-link logpdf/ForwardDiff7 allocs: 0.359 kB
AD gradients/Modified LogNormal log-link logpdf/Mooncake forward0.064 k allocs: 3.06 kB
AD gradients/Modified LogNormal log-link logpdf/Mooncake reverse0.439 k allocs: 0.039 MB
AD gradients/Modified LogNormal log-link logpdf/ReverseDiff (tape)0.377 k allocs: 14.9 kB
AD gradients/Product{Weighted} LogNormal vector logpdf/Enzyme forward0.053 k allocs: 2.31 kB
AD gradients/Product{Weighted} LogNormal vector logpdf/Enzyme reverse16 allocs: 0.922 kB
AD gradients/Product{Weighted} LogNormal vector logpdf/ForwardDiff15 allocs: 1.06 kB
AD gradients/Product{Weighted} LogNormal vector logpdf/Mooncake forward0.116 k allocs: 6.31 kB
AD gradients/Product{Weighted} LogNormal vector logpdf/Mooncake reverse0.372 k allocs: 23.5 kB
AD gradients/Product{Weighted} LogNormal vector logpdf/ReverseDiff (tape)0.239 k allocs: 10 kB
AD gradients/Transformed cumulative LogNormal logpdf/Enzyme forward0.036 k allocs: 1.11 kB
AD gradients/Transformed cumulative LogNormal logpdf/Enzyme reverse14 allocs: 0.609 kB
AD gradients/Transformed cumulative LogNormal logpdf/ForwardDiff7 allocs: 0.266 kB
AD gradients/Transformed cumulative LogNormal logpdf/Mooncake forward0.058 k allocs: 2.91 kB
AD gradients/Transformed cumulative LogNormal logpdf/Mooncake reverse0.274 k allocs: 25.6 kB
AD gradients/Transformed cumulative LogNormal logpdf/ReverseDiff (tape)0.213 k allocs: 9.06 kB
AD gradients/Transformed thin LogNormal logpdf/Enzyme forward0.036 k allocs: 1.11 kB
AD gradients/Transformed thin LogNormal logpdf/Enzyme reverse14 allocs: 0.609 kB
AD gradients/Transformed thin LogNormal logpdf/ForwardDiff7 allocs: 0.266 kB
AD gradients/Transformed thin LogNormal logpdf/Mooncake forward0.058 k allocs: 2.91 kB
AD gradients/Transformed thin LogNormal logpdf/Mooncake reverse0.274 k allocs: 25.6 kB
AD gradients/Transformed thin LogNormal logpdf/ReverseDiff (tape)0.213 k allocs: 9.06 kB
AD gradients/Weighted Affine LogNormal nested logpdf/Enzyme forward0.036 k allocs: 1.38 kB
AD gradients/Weighted Affine LogNormal nested logpdf/Enzyme reverse6 allocs: 0.484 kB
AD gradients/Weighted Affine LogNormal nested logpdf/ForwardDiff7 allocs: 0.516 kB
AD gradients/Weighted Affine LogNormal nested logpdf/Mooncake forward0.08 k allocs: 4.02 kB
AD gradients/Weighted Affine LogNormal nested logpdf/Mooncake reverse0.329 k allocs: 15.6 kB
AD gradients/Weighted Affine LogNormal nested logpdf/ReverseDiff (tape)0.269 k allocs: 11.3 kB
AD gradients/Weighted LogNormal observation-time weight logpdf/Enzyme forward0.032 k allocs: 1.05 kB
AD gradients/Weighted LogNormal observation-time weight logpdf/Enzyme reverse10 allocs: 1.14 kB
AD gradients/Weighted LogNormal observation-time weight logpdf/ForwardDiff7 allocs: 0.297 kB
AD gradients/Weighted LogNormal observation-time weight logpdf/Mooncake forward0.068 k allocs: 3.59 kB
AD gradients/Weighted LogNormal observation-time weight logpdf/Mooncake reverse0.32 k allocs: 0.0353 MB
AD gradients/Weighted LogNormal observation-time weight logpdf/ReverseDiff (tape)0.239 k allocs: 9.97 kB
AD gradients/Weighted LogNormal scalar logpdf/Enzyme forward0.032 k allocs: 1.05 kB
AD gradients/Weighted LogNormal scalar logpdf/Enzyme reverse10 allocs: 1.14 kB
AD gradients/Weighted LogNormal scalar logpdf/ForwardDiff7 allocs: 0.297 kB
AD gradients/Weighted LogNormal scalar logpdf/Mooncake forward0.068 k allocs: 3.59 kB
AD gradients/Weighted LogNormal scalar logpdf/Mooncake reverse0.348 k allocs: 0.0453 MB
AD gradients/Weighted LogNormal scalar logpdf/ReverseDiff (tape)0.239 k allocs: 9.97 kB
AD gradients/Weighted Sequential observed-total logpdf/Enzyme forward0.556 k allocs: 21.1 kB
AD gradients/Weighted Sequential observed-total logpdf/Enzyme reverse1.83 k allocs: 0.0805 MB
AD gradients/Weighted Sequential observed-total logpdf/ForwardDiff0.159 k allocs: 8.22 kB
AD gradients/Weighted Sequential observed-total logpdf/Mooncake forward1.37 k allocs: 0.0577 MB
AD gradients/Weighted Sequential observed-total logpdf/Mooncake reverse6.49 k allocs: 1.33 MB
AD gradients/Weighted Sequential observed-total logpdf/ReverseDiff (tape)0.0531 M allocs: 2.06 MB
Affine/LogNormal/ccdf2 allocs: 0.906 kB
Affine/LogNormal/cdf2 allocs: 0.906 kB
Affine/LogNormal/construction0 allocs: 0 B
Affine/LogNormal/logpdf2 allocs: 0.906 kB
Affine/LogNormal/pdf2 allocs: 0.906 kB
Affine/LogNormal/quantile2 allocs: 0.219 kB
Affine/LogNormal/rand2 allocs: 0.906 kB
Baseline/LogNormal/ccdf2 allocs: 0.906 kB
Baseline/LogNormal/cdf2 allocs: 0.906 kB
Baseline/LogNormal/construction0 allocs: 0 B
Baseline/LogNormal/logpdf2 allocs: 0.906 kB
Baseline/LogNormal/pdf2 allocs: 0.906 kB
Baseline/LogNormal/quantile2 allocs: 0.219 kB
Baseline/LogNormal/rand2 allocs: 0.906 kB
Modified/IdentityLink/ccdf2 allocs: 0.906 kB
Modified/IdentityLink/cdf2 allocs: 0.906 kB
Modified/IdentityLink/construction0 allocs: 0 B
Modified/IdentityLink/logpdf2 allocs: 0.906 kB
Modified/IdentityLink/pdf2 allocs: 0.906 kB
Modified/IdentityLink/quantile2 allocs: 0.219 kB
Modified/IdentityLink/rand2 allocs: 0.906 kB
Modified/LogLink/ccdf2 allocs: 0.906 kB
Modified/LogLink/cdf2 allocs: 0.906 kB
Modified/LogLink/construction0 allocs: 0 B
Modified/LogLink/logpdf2 allocs: 0.906 kB
Modified/LogLink/pdf2 allocs: 0.906 kB
Modified/LogLink/quantile2 allocs: 0.219 kB
Modified/LogLink/rand2 allocs: 0.906 kB
Transformed/cumulative/cdf2 allocs: 0.906 kB
Transformed/cumulative/construction0 allocs: 0 B
Transformed/cumulative/logpdf2 allocs: 0.906 kB
Transformed/cumulative/rand2 allocs: 0.906 kB
Transformed/thin/cdf2 allocs: 0.906 kB
Transformed/thin/construction0 allocs: 0 B
Transformed/thin/logpdf2 allocs: 0.906 kB
Transformed/thin/rand2 allocs: 0.906 kB
Weighted/Product/construction3 allocs: 2.45 kB
Weighted/Product/logpdf6 allocs: 2.72 kB
Weighted/scalar/construction0 allocs: 0 B
Weighted/scalar/logpdf2 allocs: 0.906 kB
time_to_load0.149 k allocs: 11.2 kB

Per-benchmark timelines

plot_ModifiedDistributions_1.pngplot_ModifiedDistributions_2.pngplot_ModifiedDistributions_3.pngplot_ModifiedDistributions_4.pngplot_ModifiedDistributions_5.pngplot_ModifiedDistributions_6.png