Skip to content

Add PCG64DXSM and MRG32k3a bit generators to dpnp.random - #3161

Open
ndgrigorian wants to merge 1 commit into
feature/device-rng-multivariatefrom
feature/device-rng-bit-generators
Open

ndgrigorian wants to merge 1 commit into
feature/device-rng-multivariatefrom
feature/device-rng-bit-generators

Conversation

@ndgrigorian

@ndgrigorian ndgrigorian commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds two more bit generators to dpnp.random, as part of the series splitting #3147. It is stacked on #3160

  • PCG64DXSM, a custom engine (oneMKL's pcg64_dxsm has a hard-coded increment) that is bit-identical with NumPy's for random_raw, random (f32/f64), uniform and bytes, and exchanges states with numpy.random.PCG64DXSM. The samplers taking a fixed number of draws per element use a new sequential layout, which reproduces NumPy's stream order; the others give work-item w the stream of NumPy's jumped(w)
  • MRG32k3a, on oneMKL's device mrg32k3a, where work-item w draws from substream w. Each work-item produces 128 elements, since moving to a substream costs a matrix product per digit, and 8 elements per work-item were 2x (GPU) to 10x (CPU) slower than Philox

items_per_work_item is now a per-engine trait, exposed to Python as _rng_impl.items_per_work_item

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

PCG64DXSM is a custom engine bit-identical with NumPy's for raw values,
random, uniform and bytes, drawn in a sequential layout for the samplers
taking a fixed number of draws. MRG32k3a uses oneMKL's device engine,
with work-item w on substream w.

sycl::mul_hi is replaced with a limb-based umul_hi, as DPC++ 2026.2
miscompiles it on Intel GPUs.
@ndgrigorian
ndgrigorian force-pushed the feature/device-rng-bit-generators branch from 3565820 to e06fd8c Compare November 4, 2026 19:50
@ndgrigorian
ndgrigorian force-pushed the feature/device-rng-multivariate branch from 742674f to 9c726f8 Compare November 4, 2026 19:50
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/3161/index.html

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.22.0dev0=np2py314h8d9cdd5_31 ran successfully.
Passed: 1491
Failed: 0
Skipped: 6

@coveralls

coveralls commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage is 81.826% — feature/device-rng-bit-generators into feature/device-rng-multivariate. No base build found for feature/device-rng-multivariate.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants