Skip to content

Get identical results for parallel and sequential?

4 messages · Libo Sun, Dirk Eddelbuettel, Paul Johnson

#
On 11 February 2012 at 15:27, Libo Sun wrote:
| Hi All,
| 
| I have a question about R parallel computing by using snowfall.
| 
| How can I set the seeds on parallel workers to get the same result as
| sequential mode?
| 
| For example:
| 
| > sfSapply(c(1,1),rnorm)
| [1]  1.823082 -2.222052
| > rnorm(2)
| [1] -0.5179967 -1.0807196
| 
| How to get the identical result?

By making sure the RNG streams are initialised identically on all nodes.

Dirk
2 days later
#
On Sat, Feb 11, 2012 at 4:27 PM, Libo Sun <libosun at rams.colostate.edu> wrote:
As Hana S said, the snowFT package has the ability to assign seeds to
"replications", unlike other methods, which assign seeds to compute
nodes.  By associating seeds to replications, it is thus assured that
each time a step runs, it gets same seed, no matter on which node.

I've been trying to generalize that idea to allow multiple (separate)
streams of random numbers for each replication.  We have several
projects where the replication requires the "exact same random
numbers" from each of several streams. You could try this out and let
me know if it works for your purpose.

http://winstat.quant.ku.edu/svn/hpcexample/trunk/Ex66-ParallelSeedPrototype

If the README doesn't seem clear, email me, I will fix it up.

pj