glass icon indicating copy to clipboard operation
glass copied to clipboard

Array API: port the RNG functions

Open paddyroddy opened this issue 1 year ago • 3 comments

Is Your Feature Request Related to a Problem? Please Describe

As identified in #383. These are non-trivial as the Array API doesn't appear to plan to have a unified random number generation scheme https://github.com/data-apis/array-api/issues/431. The only effort of an underlying API has been SPEC 7.

  • Ideally, we want something that supports numpy.randomjax.random
  • Seems easier to port JAX to NumPy
  • Best to have a NumPy interface as most users will be using CPU

Describe the Solution You'd Like

No response

Describe Alternatives You've Considered

No response

Additional Context

No response

paddyroddy avatar Nov 11 '24 15:11 paddyroddy

Working on a proof-of-concept random API wrapper for JAX in https://github.com/glass-dev/jrng.

ntessore avatar Dec 12 '24 22:12 ntessore

While not a general solution (see discussion at data-apis/array-api#874) the implementation at https://github.com/glass-dev/rng-jax seems to work well in the GLASS situation where a rng object is passed into Python code. So we could start working on that.

ntessore avatar Jan 27 '25 10:01 ntessore

Looking at this now 👀

Saransh-cpp avatar Apr 07 '25 14:04 Saransh-cpp

some more discussion at https://github.com/data-apis/array-api-extra/issues/308 (we are also planning to discuss this in the community meeting tomorrow)

lucascolley avatar Jul 09 '25 21:07 lucascolley

Thanks for the heads-up @lucascolley! Given the time in the UK, I'm afraid I won't be able to make it to the community meeting. But we definitely have a need to generate random numbers from simple distributions (like what numpy.random.Generator offers) in an array-backend-agnostic manner, and we had to come up with our own solutions for that.

ntessore avatar Jul 10 '25 08:07 ntessore

This has been completed now, closing

paddyroddy avatar Oct 31 '25 17:10 paddyroddy