Discussion: Forcing parallel reproducibility via the default RNG kind?

未关闭
#354 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
r

调研方向

检查这里描述的 R 标准 multicore 和 socket RNG 入口,以及 parallelMap pull request #80 中的测试。该 issue 未定义实现目标或验收标准,因此在认为工作完成之前,需要先就行为和相应的测试达成一致。

由索引模型根据 Issue 内容生成。

描述

RNG

(This issue should serve as a public place for the discussion @HenrikBengtsson and I had via mail recently)

I wonder if it makes sense to support reproducible parallel streams via the default RNG kind "Mersenne-Twister" within a package to help users who are not aware that this RNG kind does not provide reproducible streams in parallel.

(I am talking about the standard parallel backends in R and not specifically about the way one can do this via the {future} package.)

Multicore backend

   old.seed = .Random.seed 
   seed = sample(1:100000, 1) 
   # we need to reset the seed first in case the user supplied a seed, 
   # otherwise "L'Ecuyer-CMRG" won't be used 
   rm(.Random.seed, envir = globalenv()) 
   set.seed(seed, "L'Ecuyer-CMRG") 

If the user uses set.seed(<number>) and goes parallel via the multicore backend, the code above will ensure parallel RNG streams.

If you want to see in action, https://github.com/mlr-org/parallelMap/pull/80 has some tests to ensure the correct functioning.

Socket backend

Here, one can do

clusterSetRNGStream(cl, iseed = sample(1:100000, 1)) 

to support the default RNG kind in parallel scenarios.

General

Whenever doing this, I wonder if one should at least tell the user that this was done behind the scenes to make them aware of whats happening (including eventual decreases in speed).

主要语言
R
星标
1k
派生
93
平均合并
2 天 4 小时
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

futureverse/future 的其他 Issue

查看 futureverse/future 的全部 Issue

相似的 Issue

更多 R Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。