mojolearn
GPU machine learning in Mojo, with an explicit reproducibility contract.
mojolearn provides Python APIs with familiar scikit-learn shapes over one Mojo source tree targeting Apple Metal, NVIDIA CUDA, and AMD HIP. Its defining feature is a choice of numerical contract on every supported estimator:
| mode | contract |
|---|---|
fast |
Optimize for throughput; repeated fits need not return identical bits. |
deterministic |
The same build, input, and device return the same bits on repeated runs. |
identical |
Certified configurations return the same bits across Metal, CUDA, and HIP. |
IDENTICAL is supported by stage-level identity cards and separating
sabotage tests. It is not inferred from a final-output hash. Claims apply only
to configurations recorded in the support matrix.
Install
python3 -m venv .venv
source .venv/bin/activate
pip install mojolearn
Published wheels target Apple silicon on macOS and selected NVIDIA/AMD architectures on Linux x86-64. There is no CPU fallback. Run the diagnostic command before depending on a new machine:
mojolearn doctor
The exact wheel, architecture, Python, and evidence boundaries live in SUPPORT_MATRIX.md. Source builds may support hardware outside the architectures packaged in a released wheel; that is not the same as released-wheel support.
Quick start
import numpy as np
import mojolearn
rng = np.random.default_rng(0)
X = rng.random((100_000, 20), dtype=np.float32)
y = (X[:, 0] + X[:, 1] > 1.0).astype(np.float32)
model = mojolearn.GradientBoosting(
loss="Logloss", n_estimators=200, max_depth=6,
numeric_mode="deterministic",
)
model.fit(X, y)
print(model.predict_proba(X[:5]))
print(model.numeric_mode_used(), mojolearn.vendor())
Choose a process default with mojolearn.set_numeric_mode("identical"), or
set the starting default before import:
MOJOLEARN_NUMERIC_MODE=identical python train.py
More than one tier may be loaded in one process through per-estimator
numeric_mode= arguments.
Public API
Classical estimators include:
- Gradient boosting, random forests, and Extra Trees
- K-means, nearest-neighbor estimators, DBSCAN, hierarchical and spectral clustering
- PCA, truncated SVD, linear and logistic regression, ridge, lasso, and elastic net
- SVC, SVR, kernel density, isolation forest, and Gaussian-process regression
- Exponential smoothing and batched ARIMA
- UMAP embeddings with dense Euclidean input and 2D/3D spectral initialization
Additional modules provide scoring metrics, FP32 matrix multiplication, optimizer/training primitives, and reference-pinned Mamba and transformer blocks. These surfaces do not all have the same validation depth; consult the support matrix before treating an experimental surface as release-qualified.
UMAP in the 0.5.0 API supports fitting and embedding the supplied samples:
X = np.array([0, 1, 2.2, 4, 6.5, 10, 14.5, 20], dtype=np.float32)[:, None]
embedding = mojolearn.UMAP(
n_neighbors=3, n_components=2, n_epochs=4, random_state=19,
numeric_mode="identical",
).fit_transform(X)
Its graph uses quadratic memory. Transforming new samples, supervised targets, alternate metrics, and alternate initialization are not yet supported.
The APIs intentionally resemble scikit-learn, but mojolearn is not a drop-in replacement. Defaults follow the upstream GPU implementation mirrored by an algorithm where applicable. Unsupported parameters raise explicitly rather than being silently ignored.
What the identity claim means
Cross-vendor identity is a profile, not a statement that every GPU operation is universally identical. A profile fixes relevant reduction order, partitioning, FMA policy, flush-to-zero seams, transcendental spellings, and tie rules. A numerical change must either prove bit-inertness against the profile or introduce a new profile version.
The project distinguishes four artifact classes:
source check -> Python binding -> built native artifact -> installed wheel
Evidence for one class does not automatically validate the next. Current
certificates, configurations, and outstanding vendor legs are listed in
SUPPORT_MATRIX.md. Historical cards and investigations
under bench/results/ and archive/ are evidence, not current guidance.
Limitations
- GPU hardware is required.
- Released-wheel support is narrower than source-build support.
fastdeliberately makes no repeatability promise.deterministicdoes not promise agreement between different devices.identicalcovers certified profiles and fixtures, not arbitrary untested shapes or future toolchains.- Some recent Python and neural-operator surfaces still have vendor legs or independent-reference checks pending.
- Parameter coverage is intentionally smaller than scikit-learn, CatBoost, or cuML.
mojolearn is beta software. Pin the package version and numerical profile for production or archival work.
Development
Start with docs/START_HERE.md. The shortest full local
check is pixi run probe.
A numerical test counts as evidence only after a separating arm demonstrates that it fails when the relevant rule is broken. Contributors need one supported GPU; maintainers close cross-vendor certification columns.
Current priorities are in ROADMAP.md. See also verification, release, porting rules, contributing, and attribution.
Provenance and citation
The shipped implementation is Mojo. Algorithmic designs derive in part from
CatBoost, cuML, cuVS, RAFT, and FAISS; exact provenance and licenses are in
NOTICE, DERIVATION_MAP.tsv, source headers, and the archived derivation
ledger.
To cite mojolearn, use CITATION.cff. The concept DOI is 10.5281/zenodo.22068632.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mojolearn-0.5.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: mojolearn-0.5.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 21.6 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4652f8ecbf8f131f7707e08972af3126f12ef0ebb93f05230d389075c6ea64cc
|
|
| MD5 |
e19e7017dc2d2f3f5b79dcad3f8844d2
|
|
| BLAKE2b-256 |
8615f5564ebf3c93846c1ce550c75b6655ff6384270a7c09e0c47c94ece84ad1
|
Provenance
The following attestation bundles were made for mojolearn-0.5.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
release-provenance.yml on mojolearn/mojolearn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mojolearn-0.5.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
4652f8ecbf8f131f7707e08972af3126f12ef0ebb93f05230d389075c6ea64cc - Sigstore transparency entry: 2723869540
- Sigstore integration time:
-
Permalink:
mojolearn/mojolearn@529ec5ec73c81c14826135fe615fac1a7631bf54 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/mojolearn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-provenance.yml@529ec5ec73c81c14826135fe615fac1a7631bf54 -
Trigger Event:
workflow_dispatch
-
Statement type: