Skip to content

Commit

Permalink
Use the same device for splitting keys.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 556806725
  • Loading branch information
hamzamerzic authored and copybara-github committed Aug 14, 2023
1 parent 1377a0d commit 3e503c9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion haiku/_src/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,8 @@ def reserve(self, num):
# key, subkey3, subkey4 = jax.random.split(key, 3) # reserve(2)
#
# Where subkey1->subkey4 are provided to the user in order when requested.
new_keys = tuple(jax.random.split(self._key, num + 1))
with jax.default_device(self._key.device()):
new_keys = tuple(jax.random.split(self._key, num + 1))
self._key = new_keys[0]
self._subkeys.extend(new_keys[1:])

Expand Down

0 comments on commit 3e503c9

Please sign in to comment.