This release is a pre-release and may not be stable for production use.
Matrainer
Experiment tracking for machine-learning runs — parameters, git provenance, log files, config artifacts, figures, metric values, and system metrics — logged to whichever backend you use (MLflow, TensorBoard, CSV, Weights & Biases, Aim, ClearML), across whichever training platform you run (PyTorch Lightning, TensorFlow/Keras, Ultralytics, a bare training loop).
Tracking is the core and it stands alone: import matrainer loads no training framework and no
tracker library, and a class that trains can reach for Matrainer only to track the run. Matrainer
also ships the shared trainer machinery a task project builds its runnables on — one abstract API
base and one concrete base per framework (the trainer API) — and a
matrainer console script, the generic runner and the sweep driver. Every framework and tracker
library sits behind an extra.
The name
Matrainer is a portmanteau of mariner — the one who keeps the log, recording every heading, every reading and every condition of the voyage — and trainer, the thing being logged. That is the whole job description: it does not steer the ship, it writes down where it went. A mariner's log is also why the run manifest is the union of everything known about a run rather than whatever the current backend happens to have a field for — a logbook that only recorded what this port cares about would be useless at the next one.
Installation
pip install matrainer
matrainer and its recordstream dependency are on PyPI as pre-releases; pip installs them without
--pre, because no final release exists yet. Leave --pre off: it lets pip take pre-releases of every
dependency too, and pip install --pre "matrainer[all]" then fails outright building an aim alpha.
The core install carries no training framework and no tracker library: import matrainer
pulls in no torch, pytorch-lightning, tensorflow, mlflow or wandb. It is not small on disk —
recordstream, a core dependency, brings its own data stack (pandas, pyarrow, scipy, opencv,
datasets), about 65 packages in all. Every framework and tracker is behind an extra and lazily
imported the first time you use its backend:
| Extra | Pulls in | Enables |
|---|---|---|
matrainer[torch] |
torch, torchmetrics |
matrainer.torch — checkpoint loading, the metric helpers, resolve_device |
matrainer[lightning] |
torch, pytorch-lightning, torchmetrics, tabulate, matplotlib |
matrainer.lightning — Lightning tracking callbacks |
matrainer[mlflow] |
mlflow, psutil, pyobjc (macOS) |
MlflowTracker + system metrics |
matrainer[tensorboard] |
torch (torch.utils.tensorboard) |
TensorBoardTracker |
matrainer[wandb] |
wandb |
WandbTracker |
matrainer[aim] |
aim |
AimTracker |
matrainer[clearml] |
clearml |
ClearMLTracker |
matrainer[fastai] |
torch, fastai (+ two measured upper bounds — see pyproject.toml) |
matrainer.fastai.FastaiRunnable |
matrainer[huggingface] |
torch, transformers, accelerate |
matrainer.huggingface.HuggingFaceRunnable |
matrainer[jax] |
flax, optax, recordstream[keras] |
matrainer.jax.JaxLoopRunnable |
matrainer[mlx] |
mlx (Apple silicon marker) |
matrainer.mlx.MlxLoopRunnable |
matrainer[keras] |
keras |
matrainer.keras.keras_tracking_callback |
matrainer[plot] |
matplotlib |
render_matrix_as_figure / render_vector_as_figure — a confusion matrix as a heatmap, a per-class metric as a bar chart, for log_figure |
matrainer[tensorflow] |
matrainer[keras], tensorflow |
the same helper, with the TensorFlow engine underneath |
matrainer[all] |
lightning, mlflow, tensorboard, wandb, aim, clearml, keras, plot |
every tracker, Lightning and Keras (the other training frameworks stay separate extras) |
Python 3.13: the Aim tracker's library (aim) publishes no Python 3.13 packages yet, so
matrainer[aim] — and matrainer[all], which includes it — install on Python 3.12 only. Every other
extra installs on both.
Install one with pip install "matrainer[mlflow]" (several: "matrainer[lightning,mlflow]").
A missing backend library raises one clear error naming the extra to install — never a bare
ModuleNotFoundError.
A first run
examples/standalone_tracking.py runs the whole Tracker surface — hyperparameters, a metrics
loop, a figure, provenance, finalize — against CsvTracker, with no training framework installed:
python examples/standalone_tracking.py
Tracked run written to: /tmp/matrainer_demo_uwc4_npl/standalone-demo/demo_wild_robin
environment/requirements.txt
hparams.json
manifest.json
manifest.yaml
metrics.csv
tags.json
That is a tracked run: the values you logged (metrics.csv, hparams.json, tags.json) beside the
record of what produced them — manifest.yaml and the installed-package freeze. Point the same code
at another backend by swapping the tracker; nothing else changes.
Configuring it
A tracker is a confluid @configurable, so a run's config
wires it by name and every constructor argument is a key:
trackers:
- !class:matrainer.MlflowTracker
experiment_name: drone-classify
tracking_uri: https://mlflow.example.org
In code, the same thing is MlflowTracker(experiment_name="drone-classify"). Wrap it in
!class:matrainer.ResilientTracker so a dropped connection queues the call instead of stopping the
run, and list several trackers to log to all of them at once — see
tracking a run.
Common tasks
| I want to | Go to |
|---|---|
| log a run from my own loop or platform | Tracking a run |
| choose between MLflow, TensorBoard, CSV, W&B, Aim and ClearML | Choosing a backend |
| know what produced a run, months later | The run manifest |
| track a PyTorch Lightning run | Tracking a Lightning run |
| build my project's runnable on the shared bases | The trainer API |
| name, average or report my metrics | Metrics |
| report a confusion matrix or a per-class vector | Metrics |
| load a checkpoint, pick a device | matrainer.torch |
| hand a trained model to another tool | Model packages |
give my project a train/evaluate/predict CLI |
Building a project CLI |
| run one config across every framework and compare | Running and reading a sweep |
Documentation
| Page | What it covers |
|---|---|
| Tracking a run | the Tracker surface, ResilientTracker, run names, system metrics |
| Choosing a backend | what each backend costs to run, and the three shipped as services |
| The run manifest | automatic provenance, what the capture_* calls collect, portable paths, native slots |
| The trainer API | the four layers, and the checkpoint policies each framework translates |
| Tracking a Lightning run | the three hookup styles and when to use each |
| Metrics | per-split slots, the metrics a loop cannot average, metric names, non-scalar reporting |
matrainer.torch |
checkpoint loading, resolve_device, the dump spellings |
| Model packages | a model as a folder: graph, weights, class names |
| Building a project CLI | the CLI factory and a project's frameworks table |
| Running and reading a sweep | the sweep driver, its isolation and its read-back |
Why a mechanism exists, rather than how to use it: docs/architecture.md.
Environment variables
| Variable | Effect |
|---|---|
KERAS_BACKEND |
Keras 3 backend; matrainer.tensorflow and --framework tensorflow default it to tensorflow |
MLFLOW_TRACKING_URI |
the MLflow server a run is stored on when its tracker names none (MlflowTracker's tracking_uri); unset means MLflow's own default, a local ./mlruns folder, which MLflow 3.15 and later refuse unless MLFLOW_ALLOW_FILE_STORE=true |
MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL |
seconds between system-metric samples (default 10) |
PROJECT_ROOT, DATA_ROOT, MODEL_ROOT |
machine roots; paths under them are recorded as $NAME/... in the manifest |
AIM_REPO |
the Aim repository, written by the Aim service and read as $AIM_REPO by run configs |
PYTORCH_MPS_HIGH_WATERMARK_RATIO, PYTORCH_MPS_LOW_WATERMARK_RATIO |
Apple-GPU memory limits; set them in the shell before the process starts, or let the device options set them |
env.complete lists them.
What lives elsewhere
The runnable protocol and pipeline running are not in Matrainer — they moved to RecordStream:
recordstream.runnable—TorchRunner,ProgressReporting, and theentrypoint/runnable_entrypointsmethod-annotation mechanism a merged train+eval class uses to declare itsfit/evaluate/test/predictcapabilities.recordstream.workflow— theSequence/Conditional/Switchcombinators + predicates.recordstream.processing—DatasetProcessor.recordstream.ensure_record_dataset/RecordSource— normalise a wired dataset slot into a map-styleDatasetof records.recordstream.outputs— the prediction-output contracts (ClassificationOutput/DetectionOutput/SegmentationOutput) and their torch builders, beside the sink that reads them.recordstream.predictions— thePredictionsSinkprotocol +ClassificationPredictionsSink.recordstream.inverse_frequency_weights/class_counts— class-balance weights, a statistic over the labels. What a framework then does with the vector (torch.nn'sweight=, Keras'sclass_weight) is the consuming runnable's business.recordstream run <config.yaml>— the generic runner. A config roots at a top-levelrunnable:key plus atask:; consumers may also ship their own CLI wrapping it.
There is no matrainer.runner / matrainer.progress / matrainer.workflow / matrainer.processing.
The one binary, matrainer, is the generic runner and the sweep driver described above.
Dependencies
| Package | Purpose |
|---|---|
confluid |
YAML configuration + dependency injection (@configurable Trackers/policies) |
liquifai |
provenance's config-include resolution |
loggair |
structured logging + the active-log-file handle capture_log_file uploads |
coolname |
random run names |
pyyaml |
the run manifest's readable half (manifest.yaml) |
recordstream |
the record model the trainer API runs on, and the label-map format run artifacts use |
numpy |
the confusion-matrix metrics (matrainer.metric_functions) |
Everything else — torch, pytorch-lightning, torchmetrics, mlflow, tensorboard, wandb, aim, clearml, tensorflow, matplotlib — is optional and behind an extra.
License
PolyForm Noncommercial License 1.0.0 (the LICENSE file): free for personal, academic and other noncommercial use. Commercial use needs a separate licence from the author.
Metadata
Release files for matrainer 0.1.0a3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| matrainer-0.1.0a3.tar.gz | 313.1 kB | With provenance | Details for matrainer-0.1.0a3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| matrainer-0.1.0a3-py3-none-any.whl | Python 3 | none | any | Details for matrainer-0.1.0a3-py3-none-any.whl |
Total release size: 578.6 kB
Release files / matrainer-0.1.0a3.tar.gz
| Download URL | matrainer-0.1.0a3.tar.gz |
|---|---|
| Size | 313.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4226b1528ace69d186231ed0c4bbc7a1e962dd4ce32d79bec1dbba0fa5cb2667
|
|
BLAKE2b-256 checksum How to use checksums |
95494c44512db0a03b9e89b765c69a5b5add77a4068ff78f4d9ecf1c29d356e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / matrainer-0.1.0a3-py3-none-any.whl
| Download URL | matrainer-0.1.0a3-py3-none-any.whl |
|---|---|
| Size | 265.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd98f319c0f3ec2b0bcd16e23a245163d2abd3ea679aa662b32ed6a727a11bc4
|
|
BLAKE2b-256 checksum How to use checksums |
9a8e931f8dc3be2bf5a8d7de6731db7017bdb18e9dd06fa27dad0392df11017d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for matrainer 0.1.0a3
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for matrainer-0.1.0a3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA 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.