mkl_random -- a NumPy-based Python interface to Intel® oneAPI Math Kernel Library (OneMKL) Random Number Generation functionality
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>=3.1.0" numpy mkl-devel
then build against the existing installation with:
python -m pip install --no-build-isolation --no-deps .
Metadata
Release files for mkl-random 1.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 5.2 MB
Release files / mkl_random-1.6.0-0-cp314-cp314t-win_amd64.whl
| Download URL | mkl_random-1.6.0-0-cp314-cp314t-win_amd64.whl |
|---|---|
| Size | 410.8 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0c166bb7331e882c454980918242184af946ba862a7d4b7488ea28879c9c0d30
|
|
BLAKE2b-256 checksum How to use checksums |
cbbb16d6eee7513e544c1df53642fe3ef6863e32cefe0e20bc856153bb68c384
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp314-cp314t-manylinux_2_28_x86_64.whl
| Download URL | mkl_random-1.6.0-0-cp314-cp314t-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 476.9 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
a941e8d5d5a59d2ca941045c3288a8a2da936c0fc97a5ddb653fbb219be16214
|
|
BLAKE2b-256 checksum How to use checksums |
392bfb756fae857e7b352bcb79af6e84cec1a60027b4db3fdd0abb3b6003f25e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp314-cp314-win_amd64.whl
| Download URL | mkl_random-1.6.0-0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 371.6 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
21c2b9234d235576ae2f845fae16cc7f70b70bf2a62a32c66d20615b3be4a0d1
|
|
BLAKE2b-256 checksum How to use checksums |
6fd926374bf5360c870734bd7ac30a5596ca848b3c5c68b4ade3e270413e95dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp314-cp314-manylinux_2_28_x86_64.whl
| Download URL | mkl_random-1.6.0-0-cp314-cp314-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 482.7 kB |
| Tags | CPython 3.14 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
934b8b88d077e49366d44d15628621564e5d4abb8c638ebb73a501b3138574fb
|
|
BLAKE2b-256 checksum How to use checksums |
0917c04e5bfda08bedf68725591bf2cc694db1dc5937e13859d44246191c89dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp313-cp313-win_amd64.whl
| Download URL | mkl_random-1.6.0-0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 371.5 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f64ae0af6bb7f4ac64abb9283401ea9d94980852eec2ed86a257ced98a895660
|
|
BLAKE2b-256 checksum How to use checksums |
474581b4a03e01ed6f244a866914631cc2fc27e6494b3a4d45a01e5cd43b5752
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | mkl_random-1.6.0-0-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 483.0 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
d7d2ae03a8e06b7bdd8bc134a1881ecacba9b5bccb3569edd92953a1e370f483
|
|
BLAKE2b-256 checksum How to use checksums |
0e8acf86150f5995bc8e761ec5eb52661f660b913c4c5d49d77702ce018bc61b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp312-cp312-win_amd64.whl
| Download URL | mkl_random-1.6.0-0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 373.0 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2a12f14aa403fb299a513f6d853298805ad2df99104c7224486fabae992e73d4
|
|
BLAKE2b-256 checksum How to use checksums |
411f7460e0fb2ac60161e32dc8f5f5d3b767fd4fd55ae982aaf449eff732f89c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | mkl_random-1.6.0-0-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 484.0 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
d30b21e9ea0d18261ee8a0543a751a8bf02551572d01460e462a0258b0bff837
|
|
BLAKE2b-256 checksum How to use checksums |
34d4f8de7a40d391041d16ea1cdc515ccbdba35a939b1af129cefd0494f6daea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp311-cp311-win_amd64.whl
| Download URL | mkl_random-1.6.0-0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 406.6 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
87777ac3d3c9148ad42fa6a427b6957899da9bd028f5ac5324d90979d2d54012
|
|
BLAKE2b-256 checksum How to use checksums |
debc3898e28f9aeba395bf1ba5370daf7055d6372d565a72ac995d1ea0196814
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | mkl_random-1.6.0-0-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 490.4 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
ae11284879084d0b54cbe5250c18118751fa4efa8f690a57aac727d4d3d8b166
|
|
BLAKE2b-256 checksum How to use checksums |
6e60df9c823867bd5176acb8d6ee9dc88c2e854a059acecf76218f88f96594cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp310-cp310-win_amd64.whl
| Download URL | mkl_random-1.6.0-0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 407.5 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1e2092f1f293bb549984fe02284ae35648ca9d267aa57857d0ee79890f9b6d33
|
|
BLAKE2b-256 checksum How to use checksums |
1e90cf3945221219a0ccf24159822c0b57cc939c3de01bebe4fad2b3bc4be0d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / mkl_random-1.6.0-0-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | mkl_random-1.6.0-0-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 492.1 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
5c67a35db8bd9fcf9cbae419aaf03f1ddccddc41ec9015121494df92e9ce0666
|
|
BLAKE2b-256 checksum How to use checksums |
e99692f779a9708a70bba5a1c757f0089767f66308a0400765a2b552b76f705e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for mkl-random 1.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.