Has Matlab changed the random number generators used in the parallel toolbox in the latest 2019a distribution?
조회 수: 15 (최근 30일)
이전 댓글 표시
In comparing results obtained from stochastic code it is important to have reproducible results. I have code that always gave reproducible results in previous versions of the parallel toolbox, by means of a distributed reproducible RNG seed. This worked in multiple tests, on multiple computers, with different OS and multiple Matlab versions. Currently, when testing using the 2019a distribution, results have become irreproducible, and different to previous versions.
Does anyone know what has changed here? Is it the RNG that's changed? Is there a way to get reproducible RNs between the different Matlab generations? Or is this a lost cause, and Mathworks is just changing the code randomly, without warning - as seems to be the case?
댓글 수: 1
Edric Ellis
2019년 3월 29일
편집: Edric Ellis
2019년 3월 29일
As @Stephan pointed out, the default random number generator for parallel pools did indeed change for R2019a. Can I ask whether you're seeing non-reproducible results in 19a - i.e. despite your setting of the RNG state, things vary from run to run inside 19a? Do you have any simple code that you can share that would demonstrate the problem? For example, I ran the code from this doc page, and got identical numerical results in 18b and 19a.
채택된 답변
추가 답변 (1개)
Stephan
2019년 3월 28일
편집: Stephan
2019년 3월 28일
Hi,
Default random number generator changed for parallel contexts
Behavior change
Starting in R2019a, the default random number generator for parallel computations is changed to Threefry. This change applies to calculations on parallel workers, GPU arrays, distributed arrays, and tall arrays. This generator offers performance enhancements for parallel calculations over the previous default. In releases up to and including R2018b, the default random number generator for parallel computations is CombRecursive.
With a different default generator, MATLAB generates different random number sequences by default in the context of parallel computations. However, the statistics of these calculations remain unaffected. Therefore, you might want to update any code that relies on the specific random numbers being generated, but most calculations on the random numbers are unaffected.
To set the generator to the settings used by default in R2018b and earlier on parallel workers, GPU arrays, and tall arrays, use the following commands.
Calculations on parallel workers and distributed arrays:
spmd
stream = RandStream.create("CombRecursive", "NumStreams", 2^32,...
"StreamIndices", 2*labindex);
RandStream.setGlobalStream(stream);
end
Calculations on GPU arrays:
gpurng(0,"CombRecursive")
Calculations on tall arrays:
tallrng(0,"CombRecursive")
Best regards
Stephan
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Licensing on Cloud Platforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!