Closed andrjohns closed 1 month ago
Name | Old Result | New Result | Ratio | Performance change( 1 - new / old ) |
---|---|---|---|---|
arma/arma.stan | 0.19 | 0.18 | 1.03 | 2.78% faster |
low_dim_corr_gauss/low_dim_corr_gauss.stan | 0.01 | 0.01 | 0.96 | -4.23% slower |
gp_regr/gen_gp_data.stan | 0.02 | 0.1 | 0.21 | -370.0% slower |
gp_regr/gp_regr.stan | 0.11 | 0.1 | 1.1 | 9.03% faster |
sir/sir.stan | 77.15 | 75.81 | 1.02 | 1.74% faster |
irt_2pl/irt_2pl.stan | 3.89 | 3.95 | 0.99 | -1.4% slower |
eight_schools/eight_schools.stan | 0.05 | 0.05 | 1.0 | 0.25% faster |
pkpd/sim_one_comp_mm_elim_abs.stan | 0.25 | 0.25 | 1.01 | 1.11% faster |
pkpd/one_comp_mm_elim_abs.stan | 17.97 | 17.23 | 1.04 | 4.12% faster |
garch/garch.stan | 0.44 | 0.44 | 1.02 | 1.51% faster |
low_dim_gauss_mix/low_dim_gauss_mix.stan | 2.74 | 2.78 | 0.98 | -1.62% slower |
arK/arK.stan | 1.62 | 1.58 | 1.03 | 2.54% faster |
gp_pois_regr/gp_pois_regr.stan | 2.62 | 2.44 | 1.07 | 6.77% faster |
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan | 9.07 | 8.93 | 1.02 | 1.6% faster |
performance.compilation | 176.3 | 179.0 | 0.98 | -1.53% slower |
Mean result: 0.9639894892491869
Jenkins Console Log Blue Ocean Commit hash: fb02dc7240781e4fe7ea4bc1fb4e06e70079765a
Looks good! Do you have an idea about how much larger the range of values is when using this on the log scale?
@spinkney I found that the additional log
/exp
calls were noticeably slowing down the inv_Phi
function, so I've reduced the changes to only the std_normal_log_qf
function.
I'm not whether the range of values would be much changed, but it should be significantly faster - since it reduces the ~14 log_sum_exp
calls to only 2
Name | Old Result | New Result | Ratio | Performance change( 1 - new / old ) |
---|---|---|---|---|
arma/arma.stan | 0.2 | 0.18 | 1.07 | 6.87% faster |
low_dim_corr_gauss/low_dim_corr_gauss.stan | 0.01 | 0.01 | 1.09 | 8.45% faster |
gp_regr/gen_gp_data.stan | 0.02 | 0.02 | 1.08 | 7.15% faster |
gp_regr/gp_regr.stan | 0.11 | 0.1 | 1.05 | 5.16% faster |
sir/sir.stan | 78.23 | 77.31 | 1.01 | 1.18% faster |
irt_2pl/irt_2pl.stan | 3.85 | 3.99 | 0.96 | -3.66% slower |
eight_schools/eight_schools.stan | 0.05 | 0.05 | 0.99 | -1.5% slower |
pkpd/sim_one_comp_mm_elim_abs.stan | 0.25 | 0.25 | 0.97 | -3.56% slower |
pkpd/one_comp_mm_elim_abs.stan | 18.74 | 18.33 | 1.02 | 2.17% faster |
garch/garch.stan | 0.45 | 0.43 | 1.04 | 3.9% faster |
low_dim_gauss_mix/low_dim_gauss_mix.stan | 2.88 | 2.9 | 0.99 | -0.63% slower |
arK/arK.stan | 1.64 | 1.67 | 0.98 | -2.25% slower |
gp_pois_regr/gp_pois_regr.stan | 2.65 | 2.59 | 1.02 | 2.29% faster |
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan | 9.4 | 10.08 | 0.93 | -7.22% slower |
performance.compilation | 175.5 | 176.83 | 0.99 | -0.76% slower |
Mean result: 1.013860961949111
Jenkins Console Log Blue Ocean Commit hash: 13017193216fe150e9a8fadbc7b3f9cb71f8a58d
Looks good, thanks @andrjohns! Feel free to merge
Summary
This PR updates the calculations within the
inv_Phi
function to be on the log-scale and to use vectorised functions (instead of deeply nested multiply-adds).This also results in an significantly simpler implementation for
std_normal_qf
function.Tests
N/A
Side Effects
N/A
Release notes
Improved speed of
inv_Phi
andstd_normal_qf
functionsChecklist
[x] Copyright holder: Andrew Johnson
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
[x] the basic tests are passing
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)[x] the code is written in idiomatic C++ and changes are documented in the doxygen
[x] the new changes are tested