nx icon indicating copy to clipboard operation
nx copied to clipboard

Stateless PRNG with splittable keys proposal #333

Open john-sonz opened this issue 3 years ago • 1 comments

  • Implementation of stateless PRNG, based on splittable keys and the Threefry algorithm
  • Based on the JAX PRNG implementation and yield the same results
  • At the moment includes only randint and uniform generators

#333

john-sonz avatar Jul 19 '22 18:07 john-sonz

I've implemented most of the suggestions, some of them are still a little clunky since we don't really have support for 64bits. Probably missed some things, will look for them later.

VenomSolo avatar Jul 20 '22 20:07 VenomSolo

Hi @john-sonz! I am checking on the status of this PR. Anything pending? :) Can we help? TY! :heart:

josevalim avatar Sep 06 '22 20:09 josevalim

Hi @john-sonz! I am checking on the status of this PR. Anything pending? :) Can we help? TY! ❤️

This PR should be good to go after the code formatting ( not counting test errors from linalg :') ) and we'll hopefully start working on vmap. @john-sonz mostly covered batching in linalg functions.

VenomSolo avatar Sep 07 '22 08:09 VenomSolo

Thanks for this work! I have opened a corollary to this PR in Axon here: https://github.com/elixir-nx/axon/pull/350

I noticed that right now Nx.Random.uniform does not correctly preserve the requested type, you may have to cast at the end or cast some of the intermediate values

seanmor5 avatar Sep 09 '22 00:09 seanmor5

Excellent @john-sonz and @VenomSolo! I have done my review and it is mostly minor details to clean up the code and docs. I have also started working on the basic foundation for vmap and I hope to have something to share soon. :)

josevalim avatar Sep 09 '22 11:09 josevalim

Made an adjustment to reduce slicing suggested earlier by @polvalente but somehow glossed over.

VenomSolo avatar Sep 11 '22 22:09 VenomSolo

Amazing work! :green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart:

josevalim avatar Sep 19 '22 16:09 josevalim