CUQI-DTU / CUQIpy

https://cuqi-dtu.github.io/CUQIpy/
Apache License 2.0
48 stars 9 forks source link

reduce time on zexperimental tests #416

Closed chaozg closed 7 months ago

chaozg commented 7 months ago

fixed #413

Issue: the tests on the new samplers take too much time and make the local pytest and github build very slow. Tests on RegularizedLinearRTO and NUTS are the most expensive ones. Solution: as suggested by Nicolai, we

The below shows the top 15 time-consuming tests in tests/zexperimental/test_mcmc.py before and after the change:

(before) slowest durations ==============================================================================
4.82s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target5]
2.94s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target2]
2.67s call     tests/zexperimental/test_mcmc.py::test_NUTS_regression_warmup[target1]
2.52s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_sample[target5]
2.48s call     tests/zexperimental/test_mcmc.py::test_NUTS_regression_sample[target1]
2.38s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target4]
2.08s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target3]
1.86s call     tests/zexperimental/test_mcmc.py::test_NUTS_regression_warmup[target2]
1.80s call     tests/zexperimental/test_mcmc.py::test_UGLA_regression_warmup[128]
1.67s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_sample[target2]
1.59s call     tests/zexperimental/test_mcmc.py::test_UGLA_regression_warmup[64]
1.54s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target1]
1.47s call     tests/zexperimental/test_mcmc.py::test_CWMH_regression_warmup[target2]
1.29s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target0]
1.29s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_sample[target4]
(after) slowest durations ==============================================================================
1.31s call     tests/zexperimental/test_mcmc.py::test_NUTS_regression_warmup[target1]
0.95s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target3]
0.78s call     tests/zexperimental/test_mcmc.py::test_NUTS_regression_sample_tune_first_step_only[target1]
0.56s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target1]
0.55s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_sample[target3]
0.42s call     tests/zexperimental/test_mcmc.py::test_CWMH_regression_warmup[target1]
0.36s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target2]
0.33s call     tests/zexperimental/test_mcmc.py::test_MH_regression_sample[target0]
0.32s call     tests/zexperimental/test_mcmc.py::test_UGLA_regression_warmup[128]
0.31s call     tests/zexperimental/test_mcmc.py::test_checkpointing[sampler3]
0.28s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_sample[target1]
0.27s call     tests/zexperimental/test_mcmc.py::test_checkpointing[sampler2]
0.27s call     tests/zexperimental/test_mcmc.py::test_state_is_fully_updated_after_warmup_step[sampler6]
0.24s call     tests/zexperimental/test_mcmc.py::test_RegularizedLinearRTO_regression_warmup[target0]
0.24s call     tests/zexperimental/test_mcmc.py::test_NUTS_regression_sample_tune_first_step_only[target0]