idaholab / raven

RAVEN is a flexible and multi-purpose probabilistic risk analysis, validation and uncertainty quantification, parameter optimization, model reduction and data knowledge-discovering framework.
https://raven.inl.gov/
Apache License 2.0
217 stars 133 forks source link

Implements a numpy-based RNG that produces output identical to the Crow RNG #2205

Closed j-bryan closed 9 months ago

j-bryan commented 10 months ago

Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)

2204

What are the significant changes in functionality due to this change request?

Allows for the use of the numpy stochastic environment by default instead of relying on Crow. The new numpy RNG produces outputs identical to the Crow RNG, with the added NumpyRNG class providing an equivalent interface as the existing CrowRNG class.

One disadvantage of this approach is that many of the nice functions that the numpy interface provides are not usable while still producing identical output due differences in how the underlying Mersenne Twister RNG engine is used when producing anything but 32-bit integers.


For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

j-bryan commented 9 months ago

Some benchmarks for the numpy RNG code and scipy distributions. This compares the results of the current pull request, the current devel branch (982644d0446c6955b3ca004dbcba4736c5a81b70), and the last commit before the distributions were reimplemented in scipy (177725318819492917e2d8e1904f750cc7f2846b). These will be referred to as "feature", "devel", and "previous" here. The tests were run on my 7-year-old Dell XPS laptop.

Benchmark Times: Test/Function Branch RNG Total Samples Time (s)
randomUtils.random(dim=1, size=1) feature numpy 1000000 54.23
randomUtils.random(dim=1, size=1) feature crow 1000000 23.17
randomUtils.random(dim=1, size=1) devel crow 1000000 31.66
randomUtils.random(dim=1, size=1) previous crow 1000000 23.98
- - - - -
randomUtils.random(dim=1000000, size=1) feature numpy 1000000 0.02
randomUtils.random(dim=1000000, size=1) feature numpy 1000000 0.94
randomUtils.random(dim=1000000, size=1) feature numpy 1000000 1.19
randomUtils.random(dim=1000000, size=1) feature numpy 1000000 1.27
- - - - -
randomUtils.randomNormal(size=1) feature numpy 1000000 92.83
randomUtils.randomNormal(size=1) feature crow 1000000 73.61
randomUtils.randomNormal(size=1) devel crow 1000000 69.30
randomUtils.randomNormal(size=1) previous crow 1000000 65.63
- - - - -
randomUtils.randomNormal(size=1000000) feature numpy 1000000 0.53
randomUtils.randomNormal(size=1000000) feature crow 1000000 1.75
randomUtils.randomNormal(size=1000000) devel crow 1000000 28.08
randomUtils.randomNormal(size=1000000) previous crow 1000000 27.44
- - - - -
Distributions.Normal.rvs() feature numpy 10000 32.33
Distributions.Normal.rvs() feature crow 10000 25.89
Distributions.Normal.rvs() devel crow 10000 28.23
Distributions.Normal.rvs() previous crow 10000 1.59
- - - - -
Distributions.MultivariateNormal.rvs() (dim=5) feature numpy 10000 37.61
Distributions.MultivariateNormal.rvs() (dim=5) feature crow 10000 33.83
Distributions.MultivariateNormal.rvs() (dim=5) devel crow 10000 1.78
Distributions.MultivariateNormal.rvs() (dim=5) previous crow 10000 1.61
- - - - -
tests/framework/MCMC/test_1D.xml feature numpy 80000 1827
tests/framework/MCMC/test_1D.xml devel crow 80000 1821
tests/framework/MCMC/test_1D.xml previous crow 80000 1800
- - - - -
tests/framework/Distributions/test_distributionsGeometric.xml feature numpy 10000 230
tests/framework/Distributions/test_distributionsGeometric.xml devel crow 10000 232
tests/framework/Distributions/test_distributionsGeometric.xml previous crow 10000 231

My observations:

moosebuild commented 9 months ago

Job Test qsubs sawtooth on ed4a2ce : invalidated by @j-bryan

Python environment timeout on sawtooth

moosebuild commented 9 months ago

Job Test Ubuntu 18 PIP on 7d63b28 : invalidated by @joshua-cogliati-inl

restarted civet

moosebuild commented 9 months ago

Job Test qsubs sawtooth on 7d63b28 : invalidated by @j-bryan

sawtooth restart

moosebuild commented 9 months ago

Job Test qsubs sawtooth on 7d63b28 : invalidated by @joshua-cogliati-inl

FAILED: Diff tests/cluster_tests/test_mpiqsub_long

moosebuild commented 9 months ago

Job Test qsubs sawtooth on 7d63b28 : invalidated by @joshua-cogliati-inl

Failed with: DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment.