Skip to main content

mkl_random -- a NumPy-based Python interface to Intel® oneAPI Math Kernel Library (OneMKL) Random Number Generation functionality

Conda package Editable build using pip and pre-release NumPy Conda package using conda-forge Coverity Scan Build Status OpenSSF Scorecard

mkl_random started as a part of Intel® Distribution for Python optimizations to NumPy.

Per NumPy's community suggestions, voiced in https://github.com/numpy/numpy/pull/8209, it is being released as a stand-alone package.

Prebuilt mkl_random can be installed into conda environment from Intel's channel using:

  conda install -c https://software.repos.intel.com/python/conda mkl_random

or from conda forge channel:

   conda install -c conda-forge mkl_random

To install mkl_random PyPI package please use following command:

   python -m pip install -i https://software.repos.intel.com/python/pypi --extra-index-url https://pypi.org/simple mkl_random

If command above installs NumPy package from the Pypi, please use following command to install Intel optimized NumPy wheel package from Intel Pypi Cloud:

   python -m pip install -i https://software.repos.intel.com/python/pypi --extra-index-url https://pypi.org/simple mkl_random numpy==<numpy_version>

Where <numpy_version> should be the latest version from https://software.repos.intel.com/python/conda/


mkl_random is not fixed-seed backward compatible drop-in replacement for numpy.random, meaning that it implements sampling from the same distributions as numpy.random.

For distributions directly supported in Intel® OneMKL, method keyword is supported:

   mkl_random.standard_normal(size=(10**5, 10**3), method='BoxMuller')

Additionally, mkl_random exposes different basic random number generation algorithms available in MKL. For example to use SFMT19937 use

   mkl_random.RandomState(77777, brng='SFMT19937')

For generator families, such that MT2203 and Wichmann-Hill, a particular member of the family can be chosen by specifying brng=('WH', 3), etc.

The list of supported by mkl_random.RandomState constructor brng keywords is as follows:

  • 'MT19937'
  • 'SFMT19937'
  • 'WH' or ('WH', id)
  • 'MT2203' or ('MT2203', id)
  • 'MCG31'
  • 'R250'
  • 'MRG32K3A'
  • 'MCG59'
  • 'PHILOX4X32X10'
  • 'NONDETERM'
  • 'ARS5'

Patching Mechanisms

mkl_random provides convenient patch methods to enable MKL-accelerated random operations in NumPy with or without modifying your code.

CLI Quickstart

Persistent patch (all Python sessions)

# Install
python -m mkl_random --patch install

# Status (exit code: 0 = installed, 1 = not installed)
python -m mkl_random --patch status

# Remove
python -m mkl_random --patch uninstall

Verify current random backend

python -c "import numpy; print(f'numpy.random.normal.__module__: {numpy.random.normal.__module__}')"

One-shot patch (single command only)

# Script
python -m mkl_random --with-numpy-patch my_script.py

# Pytest
python -m mkl_random --with-numpy-patch -m pytest tests/

# One-liner
python -m mkl_random --with-numpy-patch -c "import numpy; print(f\"numpy.random.normal.__module__: {numpy.random.normal.__module__}\")"

# Non-Python command
python -m mkl_random --with-numpy-patch -- <command> [args...]

Programmatic Quickstart

import mkl_random
import numpy

mkl_random.patch_numpy_random()
print(mkl_random.is_patched())
# run your accelerated numpy workloads here!
mkl_random.restore_numpy_random()
import mkl_random
import numpy
with mkl_random.mkl_random():
   # run your accelerated workloads here!
   pass

Building from source

A C++ compiler, Intel® oneAPI Math Kernel Library (oneMKL), and NumPy are required to build mkl_random from source.

Executing

python -m pip install .

will pull in the required build dependencies, including mkl and numpy, and build mkl_random.

If you already have mkl and numpy installed (from your system or a conda environment) and want to reuse them instead of pulling fresh copies into an isolated build, first install the build dependencies:

pip install meson-python cmake ninja cython numpy mkl-devel

then build against the existing installation with:

python -m pip install --no-build-isolation --no-deps .

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mkl_random-1.5.0-0-cp314-cp314-win_amd64.whl (309.2 kB view details)

Uploaded CPython 3.14Windows x86-64

mkl_random-1.5.0-0-cp314-cp314-manylinux_2_28_x86_64.whl (399.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

mkl_random-1.5.0-0-cp313-cp313-win_amd64.whl (311.7 kB view details)

Uploaded CPython 3.13Windows x86-64

mkl_random-1.5.0-0-cp313-cp313-manylinux_2_28_x86_64.whl (397.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

mkl_random-1.5.0-0-cp312-cp312-win_amd64.whl (309.6 kB view details)

Uploaded CPython 3.12Windows x86-64

mkl_random-1.5.0-0-cp312-cp312-manylinux_2_28_x86_64.whl (395.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

mkl_random-1.5.0-0-cp311-cp311-win_amd64.whl (327.4 kB view details)

Uploaded CPython 3.11Windows x86-64

mkl_random-1.5.0-0-cp311-cp311-manylinux_2_28_x86_64.whl (401.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

mkl_random-1.5.0-0-cp310-cp310-win_amd64.whl (328.1 kB view details)

Uploaded CPython 3.10Windows x86-64

mkl_random-1.5.0-0-cp310-cp310-manylinux_2_28_x86_64.whl (402.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

Details for the file mkl_random-1.5.0-0-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 04311a6238454a4206a3966449d44484efce6ac40a2ed6457f20896c5d2b9373
MD5 9790ff14c5c4982883886818d1b05a8c
BLAKE2b-256 c7f1addce66df856ea250598e9200993e0a83ad6fd0b7e3645f07e260156322b

See more details on using hashes here.

File details

Details for the file mkl_random-1.5.0-0-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa3966ab9145326abb0de98174bb6de1ae941490b3681f6a51f9637c7f26a5a4
MD5 89f28cbc0463ea9248a42bb683958a5f
BLAKE2b-256 88d766d090dadbc8ab4b2f75b3199630ef312116d2daf5c30ad14781e853675c

See more details on using hashes here.

File details

Details for the file mkl_random-1.5.0-0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2d883acb4543fdb20fc8ab8fe5a36e7d1995e1411f4f1aa3304b3637ec508f9b
MD5 cb40c6d601575aaa828ff09afa7394eb
BLAKE2b-256 f5484de0fe05a11b06b158965b6e24c229bbe56ef2bffad4dfe8ecc08a0aacd0

See more details on using hashes here.

File details

Details for the file mkl_random-1.5.0-0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd0a0ce0a6ffb6a9c70d1222e198201df67e0f653ffc0d9f1aa84a3be76c6f24
MD5 6ac48a108f1dab40b1be7edcc71ebaef
BLAKE2b-256 a17207bf2a0031b3999be16fb7489c8b36af8f3c225fee0264bdf5b4f7fa8afa

See more details on using hashes here.

File details

Details for the file mkl_random-1.5.0-0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e988feb46c6b6866af07234b805ca5ee706961d334d9e6617c6f7c9371e0f0f3
MD5 6733a6ed946b8fd691e9ac8096755905
BLAKE2b-256 d3446867dcbc8e74cc87128eb2eb02e72e4258a752efa4b151920b382ec2d53c

See more details on using hashes here.

File details

Details for the file mkl_random-1.5.0-0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b883aeebccc4549590d3cbdd23f7276bea188cf431d115504a341b32e5d258b2
MD5 78a54cff0b5944f505985a2d1207363a
BLAKE2b-256 d5fac96afffc42b328d9a72e495099e018d9b02f6d5cac2f35b120f0f034a0b6

See more details on using hashes here.

File details

Details for the file mkl_random-1.5.0-0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 72b6625b70c745094d01cd774a6ea738bf39906a9a3ec617130d566f8708818b
MD5 9f7bbd81f0b20dee4bed20def371ab27
BLAKE2b-256 9633d86ad171f1a40f0d1031dcea5ad1a614e072c055d7c1f558ad211c6981a7

See more details on using hashes here.

File details

Details for the file mkl_random-1.5.0-0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eec40130df69032c543522be0213a9320779b9b5e29c5fe0112529db81b1bd68
MD5 a068be95de89aedc72a31664689eedc3
BLAKE2b-256 ddfe93ed089e5930913c7fde507d32e52ad0f3739703824c39b9847ba1995b58

See more details on using hashes here.

File details

Details for the file mkl_random-1.5.0-0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 41b9c1efee1a087bb01cfce964794a16db6d365b683027b918b6851ee9683f0e
MD5 2f9c5fbc3c81b75562bb628de79a39d9
BLAKE2b-256 65f98e169234b470f6a7c3a564e2de8f4a79b7de327d69346ef5211aae3465e3

See more details on using hashes here.

File details

Details for the file mkl_random-1.5.0-0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mkl_random-1.5.0-0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1f2a49d6ea1dd4fec2d1aa8767a198e81d1061cdab2f197a921df639b9ff4a91
MD5 7fa1522892ffb1fcbab58fb933f6f0e8
BLAKE2b-256 bac43c9f7a477941fb4a21da9738ff7836abed21f2c94d035a273da04eac9b6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page