Repository navigation
Add discrete distributions to dpnp.random.Generator - #3159
Open
ndgrigorian wants to merge 10 commits into
Open
ndgrigorian wants to merge 10 commits into
ndgrigorian wants to merge 10 commits into
Conversation
ndgrigorian
requested review from
antonwolfy and
vlad-perevezentsev
as code owners
November 4, 2026 19:46
This was referenced Nov 4, 2026
ndgrigorian
force-pushed
the
feature/device-rng-discrete
branch
from
November 4, 2026 19:47
9fa550e to
bb0eae2
Compare
ndgrigorian
force-pushed
the
feature/device-rng-continuous
branch
2 times, most recently
from
November 4, 2026 19:50
0160558 to
adf7178
Compare
ndgrigorian
force-pushed
the
feature/device-rng-discrete
branch
from
November 4, 2026 19:50
bb0eae2 to
7918e32
Compare
Contributor
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3159/index.html |
Contributor
|
Array API standard conformance tests for dpnp=0.22.0dev2=np2py314h8d9cdd5_34 ran successfully. |
Collaborator
ndgrigorian
force-pushed
the
feature/device-rng-continuous
branch
from
November 6, 2026 17:55
adf7178 to
cfa00bd
Compare
ndgrigorian
force-pushed
the
feature/device-rng-discrete
branch
2 times, most recently
from
November 8, 2026 21:54
6388643 to
f48c80e
Compare
ndgrigorian
force-pushed
the
feature/device-rng-continuous
branch
from
November 8, 2026 21:54
df5cb09 to
7c8127b
Compare
Comment on lines
+36
to
+38
| // sycl::mul_hi is not used: optimized DPC++ 2026.2 builds get it wrong on | ||
| // Intel GPUs when one 64-bit operand is a compile-time constant (all results | ||
| // wrong at -O2, right at -O0). oneMKL's device RNG uses 32-bit halves too. |
Contributor
There was a problem hiding this comment.
Nit: This works around a DPC++ bug, and AGENTS.md asks for the full issue URL in such a comment, so it can be reverted later. Is there an intel/llvm issue for the sycl::mul_hi miscompile? The new line in dpnp/libtensor/AGENTS.md could link it too.
ndgrigorian
force-pushed
the
feature/device-rng-discrete
branch
from
November 13, 2026 20:06
f48c80e to
dcabbc2
Compare
ndgrigorian
force-pushed
the
feature/device-rng-continuous
branch
from
November 13, 2026 20:06
7c8127b to
9ed9f9a
Compare
Add integers and the poisson, binomial, negative_binomial, geometric, logseries, zipf and hypergeometric samplers, along with noncentral_chisquare and noncentral_f, which need poisson. The discrete samplers return int64 and compute in double precision, or in single precision on devices without fp64, where host parameters are clipped to stay inside their domain once rounded.
Also move test_usm_type_follows_bounds and test_device_integer_param_dtype into their classes: indented into a fixture and a helper, pytest never collected them.
ndgrigorian
force-pushed
the
feature/device-rng-discrete
branch
from
November 13, 2026 22:41
dcabbc2 to
bb4b69b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
integersand the discrete distributions todpnp.random.Generator, as part of the series splitting #3147. It is stacked on #3158Adds
integers, using NumPy's bounded integer algorithm (Lemire's method)poisson,binomial(inversion and BTPE),negative_binomial,geometric,logseries,zipfandhypergeometric(HRUA)noncentral_chisquareandnoncentral_f, which needpoissonThe discrete samplers return
int64and compute in double precision, or in single precision on devices without fp64. In single precision, host parameters are clipped so that they stay inside the domain once rounded, and the large log-factorial terms of BTPE and HRUA are gathered into onelog1pso that they don't cancel.zipfusesexpm1/log1p, deliberately departing from NumPy, whose tail foraclose to 1 is too heavy above2**53(documented inrandom.rst)As in #3158, every rejection sampler returns the smallest
int64for device parameters that would make it loop foreverAlso adds
umul_hi, which replacessycl::mul_hi; DPC++ 2026.2 miscompilessycl::mul_hion Intel GPUs when one operand is a compile-time constant