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!