You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Loading later causes the RNG state to be updated, e.g.
$R--quiet--vanilla> str(globalenv()$.Random.seed)
NULL> loadNamespace("later")
<environment:namespace:later>> str(globalenv()$.Random.seed)
int [1:626] 104036246070596981535537611...
Why is this a problem? This makes it near impossible to get numerically reproducible results in parallel processing where the persistent workers are used (e.g. parallel::makeCluster()), because the results will depend on a package dependencies already being loaded or not. This affects all packages importing later directly or indirectly.
The only workaround for this is to (i) know what packages might be loaded up-front, and (ii) pre-load them all on the parallel workers before performing the actually tasks. In practice, that's not feasible.
Suggestion
I don't know what the RNG is used for during .onLoad(), but could one solution be do draw the random number in stealth mode, i.e. make sure to undo .Random.seed afterward?
Details
It's not one of the package dependencies that forwards the RNG;
It looks like when the Rcpp-wrapped C++ function is run, that causes the random seed to be set. The later package runs some of its C++ functions on load, and that's probably what's causing the seed to be set.
Note that if the random seed is already set (to a non-NULL value) before loading later, then it does not alter the seed:
Issue
Loading later causes the RNG state to be updated, e.g.
Why is this a problem? This makes it near impossible to get numerically reproducible results in parallel processing where the persistent workers are used (e.g.
parallel::makeCluster()
), because the results will depend on a package dependencies already being loaded or not. This affects all packages importing later directly or indirectly.The only workaround for this is to (i) know what packages might be loaded up-front, and (ii) pre-load them all on the parallel workers before performing the actually tasks. In practice, that's not feasible.
Suggestion
I don't know what the RNG is used for during
.onLoad()
, but could one solution be do draw the random number in stealth mode, i.e. make sure to undo.Random.seed
afterward?Details
It's not one of the package dependencies that forwards the RNG;
The text was updated successfully, but these errors were encountered: