Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tensorflow_probability/python/util/seed_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ def __call__(self):
seed: A fresh integer usable as a seed in downstream operations,
or `None`.
"""
# Under JAX_MODE, `_seed` has already been converted (in `__init__`) into
# a real `jax.random.PRNGKey`, not a plain int/None -- so this must
# dispatch to `_call_jax`, which correctly derives a new key via
# `jaxrand.fold_in`, rather than falling through to the SHA512-of-a-
# string-repr path below, which was previously reachable even under
# JAX_MODE and returns a plain Python int that is not a valid JAX PRNG
# key (confirmed: passing that int straight to e.g. `jax.random.normal`
# raises `TypeError: JAX encountered invalid PRNG key data`).
if JAX_MODE:
return self._call_jax()
self._counter += 1
if self._seed is None:
return None
Expand Down
Loading