numba-dpex icon indicating copy to clipboard operation
numba-dpex copied to clipboard

Support for RNG in `numba_dpex`

Open fcharras opened this issue 3 years ago • 5 comments

https://github.com/IntelPython/numba-dpex/issues/159 was closed as completed after analogue to np.random functions were added to dpnp but it does not addresses some use cases that are met with numba.cuda.random:

  • generating float32 random numbers. For devices that do not support float64 random numbers, that means no RNG at all:
error: Double type is not supported on this platform.
in kernel: 'typeinfo name for oneapi::mkl::rng::detail::engine_func_mt<oneapi::mkl::rng::mt19937, double, double, oneapi::mkl::rng::detail::gpu::uniform_std<double, double>, double*, false, false>'
error: backend compiler failed build.
  • A lesser but still valid case is fusing random number generation with other compute in the same kernel.

fcharras avatar Oct 21 '22 12:10 fcharras

numba.cuda.random RNG does not come from low level functions but is implemented in numba so in fact the current state of numba.cuda.random is easy to port or to mimic.

E.g here's an attempt at creating dpex.func kernel functions that can be used in dpex.kernel kernels.

fcharras avatar Oct 25 '22 08:10 fcharras

We just merged it see https://github.com/soda-inria/sklearn-numba-dpex/commit/6190f8f2ffc9a3872ac07a58137a7c59131966a8 for module and tests.

It's true that jax rng interface is nicer but the xoroshiro128 pr was on its way to merge before we learn about it. Maybe for future updates =)

fcharras avatar Nov 16 '22 13:11 fcharras

@fcharras sorry for getting to this issue so late. Will you want to open a PR contributing your RNG implementation to numba-dpex? We can review and merge it.

diptorupd avatar Mar 12 '23 17:03 diptorupd

Hello @diptorupd sure I can do that, TY for the invitation ! I will be busy early this week, I'll start working on it mid-week if that's fine for you.

fcharras avatar Mar 13 '23 09:03 fcharras

I will be busy early this week, I'll start working on it mid-week if that's fine for you.

I am out this week. If you want to start next week or later that too is fine.

diptorupd avatar Mar 13 '23 17:03 diptorupd