oneMKL SYCL RNG

raw JSON →
2026.0.0 verified Fri May 01 auth: no python

Intel® oneAPI Math Kernel Library (oneMKL) Random Number Generators (RNG) component for SYCL. Provides high-performance pseudorandom and quasi-random number generation on Intel GPUs and CPUs. Current version 2026.0.0. Released as part of the Intel oneAPI 2026.0 toolkit. Follows Intel's release cadence (yearly).

pip install onemkl-sycl-rng
error ModuleNotFoundError: No module named 'onemkl_sycl_rng'
cause Direct import of the installed package name instead of the correct submodule path.
fix
Use: from onemkl._sycl_rng import rng
error ValueError: Data type not supported
cause Passing a numpy array instead of a dpnp array or usm_ndarray.
fix
Convert to dpnp array: result = dpnp.empty(shape, dtype=np.float64)
error RuntimeError: No SYCL queue provided
cause generate() called without a queue argument or queue is None.
fix
Always pass a valid dpctl.SyclQueue object as first argument to generate().
breaking Top-level import path changed: use onemkl._sycl_rng.rng (not onemkl.sycl_rng.rng). The underscore prefix indicates private module – no stability guaranteed.
fix Update import to: from onemkl._sycl_rng import rng as mkl_rng
deprecated The mkl_random module (from older mkl-random package) is deprecated. Use onemkl-sycl-rng for SYCL-based random number generation.
fix Replace mkl_random imports with onemkl._sycl_rng.rng and use dpnp arrays.
gotcha All data buffers must be dpnp arrays (or usm_ndarray). NumPy arrays are not supported and will cause runtime errors.
fix Use dpnp.array(...) or dpctl.tensor.usm_ndarray to allocate memory.
gotcha Engine and distribution objects must be re-created for each queue. Attempting to reuse an engine on a different device queue may cause silent failures.
fix Create engine and distribution per queue.
pip install onemkl-sycl-rng==2026.0.0

Basic usage: create engine, create distribution, generate random numbers into a dpnp array.

import dpctl
import dpnp as np
from onemkl._sycl_rng import rng as mkl_rng

# Create a SYCL queue (e.g., GPU)
queue = dpctl.SyclQueue("gpu")

# Create an RNG engine and distribution
engine = mkl_rng.create_engine(queue, mkl_rng.brng.mrg32k3a)
dist = mkl_rng.create_distribution(mkl_rng.distribution.uniform, 0.0, 1.0)

# Generate random numbers
result = np.empty(1000, dtype=np.float64)
mkl_rng.generate(queue, engine, dist, result)
print(result[:5])