stan-dev / stan

Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
2.58k stars 368 forks source link

Improved rhat diagnostic #3266

Closed aleksgorica closed 5 months ago

aleksgorica commented 8 months ago

Submission Checklist

Summary

Solving issue #3269 Changes in compute_potential_scale_reduction, based on Vehtari Rhat computattion moved in rhat function Added function rank_transform Changed tests values to match new output

Intended Effect

rank_transform: Computes normalized average ranks for draws. Transforming them to normal scores using inverse normal transformation and a fractional offset.

rhat: computes rhat like before, the computatoinal part is just moved in a new function.

compute_potential_scale_reduction: copies draws in matrix object, then computes bulk rhat and tail rhat and returns the maximum

How to Verify

Compare the results with Arviz rhat function arviz

Side Effects

Documentation

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Aleks Stepančič

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

bob-carpenter commented 8 months ago

Hi, @aleksgorica and welcome to the Stan project.

In terms of process, there should be an issue specifying the feature which this PR addresses. Please add an issue.

I would also suggest not removing the old functionality but instead just adding new functionality for the ranked version. That way, it won't break backward compatibility when it's added.

When it's ready to review for inclusion, please ping me and I can do it.

stan-buildbot commented 7 months ago

Name Old Result New Result Ratio Performance change( 1 - new / old )
arma/arma.stan 0.22 0.2 1.13 11.26% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.01 0.01 0.92 -8.7% slower
gp_regr/gen_gp_data.stan 0.02 0.02 0.97 -2.6% slower
gp_regr/gp_regr.stan 0.11 0.11 0.98 -1.79% slower
sir/sir.stan 80.14 78.73 1.02 1.76% faster
irt_2pl/irt_2pl.stan 4.27 3.94 1.08 7.62% faster
eight_schools/eight_schools.stan 0.06 0.05 1.05 4.36% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.26 0.26 1.01 1.3% faster
pkpd/one_comp_mm_elim_abs.stan 18.89 18.45 1.02 2.3% faster
garch/garch.stan 0.49 0.46 1.07 6.46% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.87 2.83 1.01 1.44% faster
arK/arK.stan 1.67 1.65 1.01 1.07% faster
gp_pois_regr/gp_pois_regr.stan 2.59 2.5 1.03 3.35% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 9.41 9.21 1.02 2.2% faster
performance.compilation 176.71 180.14 0.98 -1.94% slower

Mean result: 1.0212747855344297


Jenkins Console Log Blue Ocean Commit hash: f70fb84db501edcbf822691c02664c43b76287b2


Machine information No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 80 On-line CPU(s) list: 0-79 Thread(s) per core: 2 Core(s) per socket: 20 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz Stepping: 4 CPU MHz: 3351.692 CPU max MHz: 3700.0000 CPU min MHz: 1000.0000 BogoMIPS: 4800.00 Virtualization: VT-x L1d cache: 1.3 MiB L1i cache: 1.3 MiB L2 cache: 40 MiB L3 cache: 55 MiB NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78 NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke md_clear flush_l1d arch_capabilities G++: g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Clang: clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
stan-buildbot commented 6 months ago

Name Old Result New Result Ratio Performance change( 1 - new / old )
arma/arma.stan 0.25 0.23 1.1 9.39% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.01 0.02 0.62 -60.65% slower
gp_regr/gen_gp_data.stan 0.02 0.02 0.98 -1.8% slower
gp_regr/gp_regr.stan 0.12 0.13 0.93 -7.72% slower
sir/sir.stan 87.69 85.71 1.02 2.25% faster
irt_2pl/irt_2pl.stan 4.56 4.42 1.03 3.16% faster
eight_schools/eight_schools.stan 0.06 0.07 0.83 -20.07% slower
pkpd/sim_one_comp_mm_elim_abs.stan 0.28 0.26 1.08 7.16% faster
pkpd/one_comp_mm_elim_abs.stan 20.41 20.05 1.02 1.78% faster
garch/garch.stan 0.59 0.51 1.15 13.25% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.38 2.99 1.13 11.56% faster
arK/arK.stan 1.83 1.75 1.05 4.45% faster
gp_pois_regr/gp_pois_regr.stan 2.82 2.66 1.06 5.78% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 10.38 10.44 0.99 -0.55% slower
performance.compilation 209.61 208.84 1.0 0.37% faster

Mean result: 1.0006665985989671


Jenkins Console Log Blue Ocean Commit hash: 728ec0a53bd4cce07bf159a426e13512de0b0263


Machine information No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 80 On-line CPU(s) list: 0-79 Thread(s) per core: 2 Core(s) per socket: 20 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz Stepping: 4 CPU MHz: 2400.000 CPU max MHz: 3700.0000 CPU min MHz: 1000.0000 BogoMIPS: 4800.00 Virtualization: VT-x L1d cache: 1.3 MiB L1i cache: 1.3 MiB L2 cache: 40 MiB L3 cache: 55 MiB NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78 NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke md_clear flush_l1d arch_capabilities G++: g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Clang: clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
stan-buildbot commented 6 months ago

Name Old Result New Result Ratio Performance change( 1 - new / old )
arma/arma.stan 0.23 0.2 1.18 15.25% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.01 0.01 0.94 -6.03% slower
gp_regr/gen_gp_data.stan 0.02 0.02 1.04 3.99% faster
gp_regr/gp_regr.stan 0.11 0.11 1.02 2.19% faster
sir/sir.stan 80.8 79.38 1.02 1.76% faster
irt_2pl/irt_2pl.stan 3.97 4.19 0.95 -5.65% slower
eight_schools/eight_schools.stan 0.06 0.06 1.0 -0.04% slower
pkpd/sim_one_comp_mm_elim_abs.stan 0.27 0.26 1.05 4.59% faster
pkpd/one_comp_mm_elim_abs.stan 18.7 18.64 1.0 0.36% faster
garch/garch.stan 0.46 0.47 0.97 -3.19% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.87 2.92 0.98 -1.77% slower
arK/arK.stan 1.68 1.69 0.99 -0.68% slower
gp_pois_regr/gp_pois_regr.stan 2.64 2.64 1.0 0.18% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 10.08 9.62 1.05 4.56% faster
performance.compilation 191.68 185.64 1.03 3.15% faster

Mean result: 1.015320661964545


Jenkins Console Log Blue Ocean Commit hash: 14dfa9321f82f4102f9b572c68f1e7440177abf4


Machine information No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 80 On-line CPU(s) list: 0-79 Thread(s) per core: 2 Core(s) per socket: 20 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz Stepping: 4 CPU MHz: 3383.494 CPU max MHz: 3700.0000 CPU min MHz: 1000.0000 BogoMIPS: 4800.00 Virtualization: VT-x L1d cache: 1.3 MiB L1i cache: 1.3 MiB L2 cache: 40 MiB L3 cache: 55 MiB NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78 NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke md_clear flush_l1d arch_capabilities G++: g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Clang: clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
stan-buildbot commented 6 months ago

Name Old Result New Result Ratio Performance change( 1 - new / old )
arma/arma.stan 0.2 0.24 0.86 -16.9% slower
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.01 0.01 1.09 8.21% faster
gp_regr/gen_gp_data.stan 0.02 0.02 1.08 7.31% faster
gp_regr/gp_regr.stan 0.11 0.1 1.06 5.56% faster
sir/sir.stan 77.99 75.3 1.04 3.45% faster
irt_2pl/irt_2pl.stan 3.85 3.74 1.03 2.7% faster
eight_schools/eight_schools.stan 0.05 0.05 1.03 2.73% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.25 0.24 1.01 1.24% faster
pkpd/one_comp_mm_elim_abs.stan 18.27 17.61 1.04 3.62% faster
garch/garch.stan 0.46 0.44 1.04 3.64% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.79 2.75 1.02 1.63% faster
arK/arK.stan 1.63 1.59 1.02 2.16% faster
gp_pois_regr/gp_pois_regr.stan 2.54 2.45 1.04 3.65% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 9.07 8.92 1.02 1.65% faster
performance.compilation 179.41 180.07 1.0 -0.37% slower

Mean result: 1.0234405050935638


Jenkins Console Log Blue Ocean Commit hash: 0fcf10855f923eb24c8e9958f1f19fde97572810


Machine information No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 80 On-line CPU(s) list: 0-79 Thread(s) per core: 2 Core(s) per socket: 20 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz Stepping: 4 CPU MHz: 2400.000 CPU max MHz: 3700.0000 CPU min MHz: 1000.0000 BogoMIPS: 4800.00 Virtualization: VT-x L1d cache: 1.3 MiB L1i cache: 1.3 MiB L2 cache: 40 MiB L3 cache: 55 MiB NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78 NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke md_clear flush_l1d arch_capabilities G++: g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Clang: clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
SteveBronder commented 5 months ago

@aleksgorica this code all looks good! The only thing to fix now is the API. We want to keep all the old code and functions the same for backwards compatibility and have all of this in new functions. For instance compute_potential_scale_reduction() should have the same results as previously.

So the new code you have in compute_potential_scale_reduction_rank etc. is good and you can revert your changes to compute_potential_scale_reduction. New code in the future can use your compute_potential_scale_reduction_rank for the new estimate.

Once that is changed then I think you are good to merge!

aleksgorica commented 5 months ago

@aleksgorica this code all looks good! The only thing to fix now is the API. We want to keep all the old code and functions the same for backwards compatibility and have all of this in new functions. For instance compute_potential_scale_reduction() should have the same results as previously.

So the new code you have in compute_potential_scale_reduction_rank etc. is good and you can revert your changes to compute_potential_scale_reduction. New code in the future can use your compute_potential_scale_reduction_rank for the new estimate.

Once that is changed then I think you are good to merge!

Okay, I hope I have understood correctly, I have just reverted the changes in the original non-rank functions to the previous code. However, I would like to know why that is necessary since I believe the new code yields the same results as the previous code according to the tests, and it is also a bit better written.

stan-buildbot commented 5 months ago

Name Old Result New Result Ratio Performance change( 1 - new / old )
arma/arma.stan 0.26 0.19 1.35 25.96% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.01 0.01 1.08 7.44% faster
gp_regr/gen_gp_data.stan 0.02 0.02 1.04 4.04% faster
gp_regr/gp_regr.stan 0.11 0.1 1.04 3.42% faster
sir/sir.stan 78.12 75.68 1.03 3.12% faster
irt_2pl/irt_2pl.stan 3.87 3.93 0.99 -1.51% slower
eight_schools/eight_schools.stan 0.05 0.05 1.0 0.17% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.25 0.25 0.99 -0.58% slower
pkpd/one_comp_mm_elim_abs.stan 18.03 18.27 0.99 -1.28% slower
garch/garch.stan 0.45 0.46 0.98 -2.51% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.78 2.83 0.98 -1.99% slower
arK/arK.stan 1.64 1.69 0.97 -3.19% slower
gp_pois_regr/gp_pois_regr.stan 2.5 2.61 0.96 -4.57% slower
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 9.11 9.43 0.97 -3.52% slower
performance.compilation 178.35 179.15 1.0 -0.45% slower

Mean result: 1.0234807232212786


Jenkins Console Log Blue Ocean Commit hash: ffae22a76851e3b49ca43f31234eeada692f1d9b


Machine information No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 80 On-line CPU(s) list: 0-79 Thread(s) per core: 2 Core(s) per socket: 20 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz Stepping: 4 CPU MHz: 2400.000 CPU max MHz: 3700.0000 CPU min MHz: 1000.0000 BogoMIPS: 4800.00 Virtualization: VT-x L1d cache: 1.3 MiB L1i cache: 1.3 MiB L2 cache: 40 MiB L3 cache: 55 MiB NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78 NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke md_clear flush_l1d arch_capabilities G++: g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Clang: clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
bob-carpenter commented 5 months ago

Okay, I hope I have understood correctly, I have just reverted the changes in the original non-rank functions to the previous code. However, I would like to know why that is necessary since I believe the new code yields the same results.

There's no need to keep the old code, but we need to keep the old interfaces so we don't break anyone's existing code. The new code should be doing ranked R-hat, right? That won't provide the same answers. If you wrote general enough code to do both, you can have the old interface delegate to the new code. Then we can rewrite the interfaces to use the new code and get rid of the old code. @SteveBronder will know more about the specifics here.

SteveBronder commented 5 months ago

@bob-carpenter I rewrote this to dispatch to the old cold from the previous API

@aleksgorica there's one signature missing for split_potential_scale_reduction_rank so it matches the API of split_potential_scale_reduction. See below. Can you add that signature and have the current split_potential_scale_reduction signature call your new split_potential_scale_reduction_rank returning bulk rhat?

https://github.com/stan-dev/stan/blob/develop/src/stan/mcmc/chains.hpp#L219

stan-buildbot commented 5 months ago

Name Old Result New Result Ratio Performance change( 1 - new / old )
arma/arma.stan 0.22 0.2 1.09 8.35% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.01 0.01 0.95 -5.09% slower
gp_regr/gen_gp_data.stan 0.02 0.02 0.99 -0.75% slower
gp_regr/gp_regr.stan 0.12 0.11 1.06 5.76% faster
sir/sir.stan 81.19 82.66 0.98 -1.81% slower
irt_2pl/irt_2pl.stan 4.15 4.03 1.03 2.92% faster
eight_schools/eight_schools.stan 0.05 0.05 1.01 0.63% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.25 0.25 1.01 0.65% faster
pkpd/one_comp_mm_elim_abs.stan 18.61 18.33 1.01 1.47% faster
garch/garch.stan 0.48 0.47 1.03 2.79% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.91 2.83 1.03 2.6% faster
arK/arK.stan 1.66 1.67 0.99 -0.59% slower
gp_pois_regr/gp_pois_regr.stan 2.6 2.61 1.0 -0.35% slower
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 9.39 9.48 0.99 -0.94% slower
performance.compilation 190.84 190.77 1.0 0.04% faster

Mean result: 1.011567169879977


Jenkins Console Log Blue Ocean Commit hash: d8ac1c67d08c8b579e1b20ed5747abacce87c6fc


Machine information No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 80 On-line CPU(s) list: 0-79 Thread(s) per core: 2 Core(s) per socket: 20 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz Stepping: 4 CPU MHz: 2400.000 CPU max MHz: 3700.0000 CPU min MHz: 1000.0000 BogoMIPS: 4800.00 Virtualization: VT-x L1d cache: 1.3 MiB L1i cache: 1.3 MiB L2 cache: 40 MiB L3 cache: 55 MiB NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78 NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke md_clear flush_l1d arch_capabilities G++: g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Clang: clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
SteveBronder commented 5 months ago

Actually I reverted my old PR. Changing all the old functions to use the new one causes cmdstan tests to fail.

Let's have the _rank versions like you made here. We just need one last signature for

double split_potential_scale_reduction(
      const Eigen::Matrix<Eigen::VectorXd, Dynamic, 1>& samples)

Then we are good! After this is in we can then change cmdstan etc. to use the new ranked version. I think this is better because we need to change the output anyway to report back both the bulk and tail rhat

stan-buildbot commented 5 months ago

Name Old Result New Result Ratio Performance change( 1 - new / old )
arma/arma.stan 0.2 0.19 1.07 6.13% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.01 0.01 1.12 10.43% faster
gp_regr/gen_gp_data.stan 0.02 0.02 1.1 8.7% faster
gp_regr/gp_regr.stan 0.11 0.1 1.06 5.37% faster
sir/sir.stan 77.58 75.31 1.03 2.92% faster
irt_2pl/irt_2pl.stan 3.76 3.75 1.0 0.26% faster
eight_schools/eight_schools.stan 0.05 0.05 1.02 1.8% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.25 0.24 1.04 3.67% faster
pkpd/one_comp_mm_elim_abs.stan 17.97 17.57 1.02 2.27% faster
garch/garch.stan 0.45 0.45 1.0 -0.12% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.77 2.73 1.02 1.55% faster
arK/arK.stan 1.63 1.6 1.02 2.0% faster
gp_pois_regr/gp_pois_regr.stan 2.48 2.5 0.99 -0.79% slower
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 9.05 9.02 1.0 0.4% faster
performance.compilation 173.78 176.46 0.98 -1.54% slower

Mean result: 1.030804841038834


Jenkins Console Log Blue Ocean Commit hash: 934e17704b703a32c4c29f9ab5ae1913c4a58a57


Machine information No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 80 On-line CPU(s) list: 0-79 Thread(s) per core: 2 Core(s) per socket: 20 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz Stepping: 4 CPU MHz: 2400.000 CPU max MHz: 3700.0000 CPU min MHz: 1000.0000 BogoMIPS: 4800.00 Virtualization: VT-x L1d cache: 1.3 MiB L1i cache: 1.3 MiB L2 cache: 40 MiB L3 cache: 55 MiB NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78 NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke md_clear flush_l1d arch_capabilities G++: g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Clang: clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
aleksgorica commented 5 months ago

Actually I reverted my old PR. Changing all the old functions to use the new one causes cmdstan tests to fail.

Let's have the _rank versions like you made here. We just need one last signature for

double split_potential_scale_reduction(
      const Eigen::Matrix<Eigen::VectorXd, Dynamic, 1>& samples)

Then we are good! After this is in we can then change cmdstan etc. to use the new ranked version. I think this is better because we need to change the output anyway to report back both the bulk and tail rhat

Ok, but why should we even keep double split_potential_scale_reduction( const Eigen::Matrix<Eigen::VectorXd, Dynamic, 1>& samples) or add double split_potential_scale_reduction_rank( const Eigen::Matrix<Eigen::VectorXd, Dynamic, 1>& samples), when it is declared private and there are no written tests for the function and no known references? Would we break backward compatibility by removing the function?

SteveBronder commented 5 months ago

Oh, your right I didn't see that it was a private member that is never called. Let's leave it for now but idt you need to write a rank version for that one.

SteveBronder commented 5 months ago

@aleksgorica you should have received an email that adds you to the stan project :) clicking on the link in that email from github should then allow you to press the "merge pull request" button

aleksgorica commented 5 months ago

Thank you all for accepting me to Stan project :). I had really great time working on the pull request. Also thank you @SteveBronder and @bob-carpenter for mentoring.

But github doesn't allow me to merge pull request.

bob-carpenter commented 5 months ago

I just verified that Steve gave you permission to merge. Can you verify that works on your end by merging this?

Thanks, and welcome to the Stan team!

SteveBronder commented 5 months ago

Did you click on the link in the email that was sent to you from github? After you click that and refresh the page you should have permission to merge

aleksgorica commented 5 months ago

Yes, I clicked multiple times, now it always redirects me to https://github.com/stan-dev/stan. But it still does not allow me to merge. If I go to https://github.com/settings/organizations, there is written that I am outside collaborator on 1 repository for Stan.

SteveBronder commented 5 months ago

Sorry you should have just gotten a new email that should give you the right permissions