Conversation
b66a21e to
70bd0d7
Compare
54355a8 to
d5d45a6
Compare
466aa3c to
887be15
Compare
a2f9da9 to
57d245c
Compare
| The seed can also be set globally using :func:`.set_global_seed`. This sets the | ||
| seed globally for all subsequent Hail operations, and a pipeline will be | ||
| guaranteed to have the same results if the global seed is set right beforehand: | ||
|
|
||
| >>> hl.set_global_seed(0) | ||
| >>> hl.eval(hl.array([hl.rand_unif(0, 1), hl.rand_unif(0, 1)])) # doctest: +SKIP_OUTPUT_CHECK | ||
| [0.6830630912401323, 0.4035978197966855] | ||
| >>> hl.reset_global_randomness() | ||
| >>> hl.eval(hl.array([hl.rand_unif(0, 1), hl.rand_unif(0, 1)])) | ||
| [0.9828239225846387, 0.49094525115847415] | ||
|
|
||
| >>> hl.set_global_seed(0) | ||
| >>> hl.eval(hl.array([hl.rand_unif(0, 1), hl.rand_unif(0, 1)])) # doctest: +SKIP_OUTPUT_CHECK | ||
| [0.6830630912401323, 0.4035978197966855] |
There was a problem hiding this comment.
The text above references set_global_seed which the code does not.
I think I'm a bit confused. The text above says that the global seed "is fixed for the entire session", but we appear to modify it here.
There was a problem hiding this comment.
Ah thanks, meant to remove all mentions of set_global_seed
2eac02d to
40bd755
Compare
40bd755 to
0660e1f
Compare
|
I resolved conflicts. There were two issues in ir.py and one in aggregators.py. The former were resolved by: replace if with assert, add a new field about needing randomness. The latter is visible in the diff and switches from frozenset to set. |
|
Bumping this PR, I'd like it to land so I can nail down exactly why my flags PR is causing BN tests to fail. |
tpoterba
left a comment
There was a problem hiding this comment.
Tiny comments. Python IR and Scala RNG changes are super clear, great work.
| static_rng_uid = Env.next_static_rng_uid() | ||
| else: | ||
| if Env._hc is None or not Env._hc._user_specified_rng_nonce: | ||
| warning('To ensure reproducible randomness across Hail sessions, ' |
There was a problem hiding this comment.
warning calls through to initialize, I think -- is this intentional? Fine if yes, just good to be aware.
There was a problem hiding this comment.
I didn't realize, but I think that's fine. The warning is saying you should really initialize manually before doing anything else, not to worry about what functions do or don't implicitly initialize.
| # the spectrum of R. | ||
| assert moment_samples < n, '_spectral_moments: moment_samples must be smaller than num cols of A' | ||
| G = hl.nd.zeros((n, moment_samples)).map(lambda n: hl.if_else(hl.rand_bool(0.5), -1, 1)) | ||
| G = hl.rand_unif(-1, 1, size=(n, moment_samples)).map(lambda x: hl.sign(x)) |
| Env._seed_generator = hail.utils.HailSeedGenerator(seed) | ||
| def next_static_rng_uid(): | ||
| result = Env._static_rng_uid | ||
| assert(result <= 0xFFFF_FFFF_FFFF_FFFF) |
There was a problem hiding this comment.
This should keep Konrad contained for at least a few years
hail/src/main/scala/is/hail/types/physical/PCanonicalNDArray.scala
Outdated
Show resolved
Hide resolved
# Conflicts: # hail/python/hail/ir/__init__.py # hail/python/hail/ir/ir.py # hail/python/test/hail/table/test_table.py # hail/python/test/hail/utils/test_google_fs_utils.py
|
This is still stacked on #12309 as well |
|
This seems to be triggering hail initialization somewhere it not to? |
055d8e2 to
b7314c1
Compare
|
Ah, it was just a new test file that used |
|
@tpoterba Tests are passing |
|
Ship it! |
|
Thank you both! |
Stacked on #12331 and #12309.Design doc here.