Numeric modes#
Every mojolearn computation runs under one of two numeric modes. The mode is a promise about the output bits, not a different algorithm: the estimator, its hyperparameters and its API are the same in every mode.
What each mode promises#
Mode |
Promise |
|---|---|
|
The default. In |
|
Apple GPUs only. Tuned for throughput. No identity or repeatability promise. |
The deterministic numeric mode has been removed; use identical.
A release ships only when its recorded Apple, NVIDIA and AMD results agree.
Three things to know about identical:
It holds within one release. Bits may change between releases, for example when a kernel moves to a faster or more accurate fold order. Compare runs made with the same release.
It covers the supported configurations: the families, settings and devices listed in the support matrix.
It is an FP32 guarantee about mojolearn’s own arithmetic. Weights trained in another framework reproduce under mojolearn’s arithmetic, not that framework’s.
Which families offer which mode#
identical is available everywhere.
Family |
|
|
|---|---|---|
Gradient boosting |
yes |
Apple GPUs |
Random forests |
yes |
Apple GPUs |
Extra Trees |
yes |
Apple GPUs |
Other tree models (decision trees, AdaBoost, random-trees embedding, isolation forest) |
yes |
Apple GPUs |
Neural networks, GPU surface ( |
yes |
Apple GPUs |
Every other family |
yes |
Apple GPUs |
fast is opt-in. fast is available on Apple GPUs only. Every CPU binding runs in identical mode only (see
Devices and the CPU). The full table is in the support matrix.
Selecting a mode#
There are three ways to choose a mode. A narrower choice overrides a wider one.
Scope |
How |
|---|---|
Process, before import |
|
Process, at runtime |
|
One estimator |
|
import mojolearn
print(mojolearn.numeric_mode()) # "identical" unless you changed it
previous = mojolearn.set_numeric_mode("fast")
# ... work under fast ...
mojolearn.set_numeric_mode(previous) # restore
set_numeric_mode loads the requested mode’s binaries immediately, so a mode that cannot be honored
fails on that line, not at a later fit.
Estimators that take numeric_mode= include RandomForestClassifier, RandomForestRegressor,
ExtraTreesClassifier, ExtraTreesRegressor, DecisionTreeClassifier, GradientBoostingClassifier,
GradientBoostingRegressor, StandardScaler, MinMaxScaler, MLPClassifier and the sequence and
time-series estimators except ExponentialSmoothing and AutoARIMA, which always use the process mode. Check an estimator’s signature in the API reference.
The default numeric_mode=None means “use the process mode”.
import numpy as np
from mojolearn import RandomForestClassifier
rng = np.random.default_rng(0)
X = rng.random((10_000, 20), dtype=np.float32)
y = (X[:, 0] > 0.5).astype(np.float32)
clf = RandomForestClassifier(n_estimators=100, numeric_mode="identical").fit(X, y)
print(clf.numeric_mode_used())
numeric_mode_used() reports the mode the estimator actually ran on, read back from the binary it
loaded rather than from the string you passed. Record it alongside results.
Refusals#
Asking a family for a mode it does not ship raises a ValueError that names the binding and the
missing mode. mojolearn never runs a weaker mode in its place.
An unknown mode name raises ValueError("numeric_mode must be fast, identical or None").
The verifier also refuses to run under fast (see Verify on your hardware).
Numeric profiles#
A numeric profile is a separate setting from the numeric mode. The mode is the promise; the profile is
the number format the matrix products compute in. fp32_v1 is the default for every family and every
trainer. Other profiles are opt-in and apply only to the families they list.
Function |
Purpose |
|---|---|
|
The profile a call that names none runs under |
|
Set the process default; returns the previous value |
Every registered profile, as dicts |
|
|
Measured rows for a profile |
A profile under identical keeps the cross-vendor promise, just as fp32_v1 does. Choosing a profile
never changes the mode. See Runtime and numeric modes.
What to use when#
Report and publish in
identical. It is the default and the only mode whose results another person can reproduce on other supported hardware with the same release.On Apple GPUs, explore in
fast, for example during hyperparameter search, then rerun the configuration you keep inidentical.Record
mojolearn.__version__,numeric_mode_used(),mojolearn.vendor()andmojolearn.gpu_arch()with any result you intend to compare.