Entry point for agent context in this repo.
mkl_random is a NumPy-based interface to Intel® oneMKL random number
generation. MKLRandomState exposes the distributions of legacy
numpy.random.RandomState with a choice of MKL basic generators (brng).
mkl_random.interfaces.numpy_random is a drop-in replacement for legacy
numpy.random, and runtime patching can install it in NumPy's place.
- Package and public API:
mkl_random/,mkl_random/__init__.py - Cython extension:
mkl_random/mklrand.pyx - C++ kernels:
mkl_random/src/ - NumPy interface:
mkl_random/interfaces/ - Patching:
mkl_random/_patch_numpy.py, plus persistent and one-shot patching inmkl_random/patch.py,mkl_random/with_patch.py,mkl_random/_patch_startup.py, and themkl_random/__main__.pyCLI - Tests:
mkl_random/tests/ - Docs:
docs/(Sphinx) - Packaging:
conda-recipe/for the conda packages,pyproject.tomlfor the wheels - CI scripts:
ci/ - Benchmarks:
benchmarks/ - Examples:
examples/(parallel Monte Carlo with generator families) - Coverity:
coverity/(Coverity Scan triage guide)
- Build system:
pyproject.toml+meson.build - Build deps:
mkl-devel,numpy,meson-python,cmake,ninja,cython, and C and C++ compilers - Runtime deps:
numpy; the conda recipe and[tool.gh-ci]inpyproject.tomladd MKL - Setup, checks, and style:
CONTRIBUTING.md - Single test:
pytest mkl_random/tests/<file>.py::<test>, from the editable install inCONTRIBUTING.md - Single-file lint:
pre-commit run --files <path>, from a branch (seeCONTRIBUTING.md)
- Keep signatures and accepted arguments compatible with legacy
numpy.random. - Seeded output is part of the contract: a change to what a fixed seed produces needs a CHANGELOG entry naming the affected streams.
- Edit
mkl_random/mklrand.pyxandmkl_random/src/, not the Cython-generated C++. - Keep patching reversible, with
is_patched()reporting the truth. - Keep the extension free-threading compatible.
meson.buildchanges must keep both the GCC-syntax (Linux) and MSVC-syntax (Windows) branches working; CI covers both.- Distribution and BRNG changes must preserve statistical properties.
- Claim performance or statistical improvements only with a reproducible validation.
- Pair behavior changes with tests and keep diffs minimal.
- Avoid hardcoding mutable versions/matrices/channels in docs.
- Build/config:
pyproject.toml,meson.build - Dependencies:
pyproject.toml,conda-recipe/meta.yaml - CI/workflows:
.github/workflows/*.yml,ci/README.md - Public API:
mkl_random/__init__.py,mkl_random/interfaces/numpy_random.py - Tests:
mkl_random/tests/
For behavior policy, see .github/copilot-instructions.md.
Use nearest local AGENTS.md when present:
.github/AGENTS.md— CI workflows and automation policymkl_random/AGENTS.md— package modules, the extension, and generatorsmkl_random/src/AGENTS.md— C++ kernelsmkl_random/interfaces/AGENTS.md—numpy.randomdrop-in interfacemkl_random/tests/AGENTS.md— test scope and conventionsdocs/AGENTS.md— Sphinx documentationconda-recipe/AGENTS.md— the conda recipebenchmarks/AGENTS.md— ASV performance suite