Repository navigation
Add continuous distributions to dpnp.random.Generator - #3158
ndgrigorian wants to merge 33 commits into
Conversation
dbdb2c8 to
3963d20
Compare
0160558 to
adf7178
Compare
3963d20 to
6c3ff46
Compare
|
Array API standard conformance tests for dpnp=0.22.0dev3=np2py314h8d9cdd5_101 ran successfully. |
9fef498 to
1bd3cee
Compare
adf7178 to
cfa00bd
Compare
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3158/index.html |
df5cb09 to
7c8127b
Compare
9f9f13e to
88c286e
Compare
|
Comments on lines outside the diff:
|
88c286e to
ef331fa
Compare
7c8127b to
9ed9f9a
Compare
78535ba to
6317de6
Compare
antonwolfy
left a comment
There was a problem hiding this comment.
Docs of the continuous distributions checked against NumPy 2.5.5: every method links to NumPy's page and states NumPy's parameter constraints. Only the two Raises sections below are missing.
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
I tested the PR on Linux and Windows, on GPU and CPU, on a GPU without fp64 (Iris Xe) and with free-threaded Python 3.14t, and the samples match across them. Two comments below: the KS tests without fp64 and a race with threads. Agreed with @antonwolfy on the Raises sections.
dd59c79 to
048cdf3
Compare
6317de6 to
37d8b1e
Compare
d17b470 to
dcd4617
Compare
Give the Generator methods from lognormal to beta the Parameters, Returns and Examples sections that normal has, with their dtype, usm_type and out defaults. The examples check statistics of 10**5 samples, so they hold for any stream.
…nsion The device link keeps the shared engine helpers of the first source that has them, and normal.cpp's kernels then called a second copy of the oneMKL Philox internals, which the OpenCL CPU compiler handles much worse.
4 * scale overflowed, which made the sample inf / inf; dividing Y by 4 * scale instead gives the mean for an infinite scale, as NumPy does.
The cast rounds the top 128 32-bit words to 2**32, which made u1 exactly 1, both values of the pair 0, and standard_cauchy 0 / 0.
The products with the other degrees of freedom overflowed to inf / inf in float32 from about 2e19.
As for beta, a positive host value that is 0 in float32 made every sample NaN. Also say in the Generator notes what parameters outside the float32 range give.
NumPy takes inversion for any method but "zig", and both are inversion here.
The checks were skipped as soon as one parameter was on the device, though comparing two host ones doesn't wait for the device.
For a tiny a in float32, log(U) / a is -inf, and with V == 0 log(V) / b is too, which made the difference of the logarithms NaN.
1833fae to
a9d4bf7
Compare
This PR adds the continuous distributions to
dpnp.random.Generator, as part of the series splitting #3147. It is stacked on #3157The samplers are device ports of NumPy's algorithms:
exponential,standard_exponential,pareto,weibull,power,rayleighgamma,standard_gamma,beta,chisquare,standard_t,flognormal,standard_cauchy,wald,laplace,gumbel,logistic,triangular,vonmisesParameters on the device aren't checked, since that would wait for the device. The rejection samplers instead return NaN for parameters that would make them loop forever, including valid ones that round badly in single precision