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
gh-39025: Add reseed_rng option to p_iter_fork
This PR implements a convenience feature for the `@parallel` decorator,
or more precisely, for `p_iter_fork`.
By setting `reseed_rng=True` the random number generator is reset in
each subprocess by running `set_random_seed(self.worker_seed)`.
It is ensured that the worker seeds are deterministically derived and
thus, the results are always reproducible.
The new behaviour is useful for running probabilistic experiments and
taking advantage of multiple cores.
The PR adds one "doc test". It would make sense to have additional
(randomized) tests to assert that future modifications don't break the
reproducibility. But I failed to locate a comprehensive test suite for
sage/parallel, in particular, no existing tests for reproducibility of
parallel computations. The `sage/tests` folder seems to contain other
non-specific tests?
Coding style w.r.t. <https://doc.sagemath.org/html/en/reference/misc/sag
e/misc/randstate.html>
- The documentation said `with seed(worker_seed)` should be used. I
did not use it, because the current implementation reseeds the whole
subprocess once and for all.
- The documentation says NTL does not reproduce. This is a very
surprising and unfortunate state of affairs. I expect that `reseed_rng`
inherits this caveat. I did not make it explicit in the doc string,
because if the problem occurs, then also `reseed_rng=False` should have
it, but there is no mention of it.
### 📝 Checklist
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
The doc tests passed for me, but preview via running `sage --docbuild
tutorial html` gives me `ImportError: cannot import name
count_all_local_good_types_normal_form' from
'sage.quadratic_forms.count_local_2'` so doc tests don't work although
that has probably nothing to with this PR.
URL: #39025
Reported by: mklss
Reviewer(s): Kwankyu Lee
0 commit comments