Boilerplate-free, reproducible ML experiment workflows built on PyTorch Lightning and hydra-zen. Carved out of MIT-LL's responsible-ai-toolbox.
Project description
mushin
Boilerplate-free, reproducible machine-learning experiment sweeps
built on PyTorch Lightning and
hydra-zen.
Decorate an experiment, sweep over parameters, and get the results back as a
labeled xarray.Dataset — not rows in a dashboard you have to export.
- Boilerplate-free — one decorator, no subclassing or callbacks; results come back as a labeled dataset you can slice and plot.
- Reproducible — every run captures its config + provenance, sweeps resume durably after a hard kill or cluster preemption, and auto-tuning pins a hardware-independent effective batch size.
- Scalable — the same task runs in-process, across cores, or on a multi-node SLURM cluster (validated on real GPU hardware); change only the launcher.
- Framework-agnostic — your task just returns a
dict, so scikit-learn, XGBoost, or any Python model works, not only PyTorch.
Quickstart
import mushin
@mushin.sweep
def experiment(lr, seed):
# ... train a model with this lr/seed, then evaluate it ...
acc = ... # your validation accuracy
return dict(accuracy=acc) # whatever you return becomes a data variable
ds = experiment.run(
lr=mushin.multirun([0.01, 0.1, 1.0]),
seed=mushin.multirun([0, 1, 2]),
) # 9 runs, returned as a labeled xarray.Dataset
# <xarray.Dataset> Dimensions: (lr: 3, seed: 3)
# Data variables: accuracy (lr, seed)
ds["accuracy"].mean("seed") # average over seeds, per learning rate
# Prefer pandas? One call gives a tidy table — no xarray required:
experiment.workflow.to_dataframe() # lr seed accuracy
# 0 0.01 0 ...
The decorator version above runs as
examples/parallel_sweep.py;
examples/sweep_to_dataset.py is the same flow
written with the class API. Need the full tool (.failures, provenance, custom
analysis)? Drop to experiment.workflow, or subclass
MultiRunMetricsWorkflow.
What else it does
Each links to a guide with a runnable example:
- Compare methods with statistics —
benchmark.compareruns a metric battery (torchmetrics) across seeds and returns a labeled dataset plus significance (scipy);Studyruns the training sweep and feeds it straight in. - Compare LLM systems — the same significance spine for LLM evals, with Holm-corrected p-values and an optional output cache.
- Built-in batteries — classification, segmentation, detection, regression, retrieval, image-quality, audio.
- Resilient & resumable sweeps —
on_error="nan", durableresume=Trueacross hard kills/preemption, and per-run provenance. - Parallel & out-of-process launchers —
run(..., launcher="joblib")or submitit; stdlib-picklable dispatch. - Multi-node & sharded training —
HydraDDP/HydraFSDPandpin_gpu_round_robinGPU packing, validated on a real SLURM cluster. - Auto-tuning —
tune_batch_size/tune_learning_rate, pinned for reproducibility. - Analyze from Claude Code (MCP) — an optional read-only MCP server to load and inspect completed runs.
Installation
pip install mushin-py # the sweep -> dataset core
pip install "mushin-py[eval]" # + compare, metric batteries, LLM eval, Study
The PyPI distribution is mushin-py, but you import mushin (like
scikit-learn → sklearn). The eval extra adds the evaluation layer
(compare, the metric batteries, LLM evaluation, Study) and its heavier
dependencies (torchmetrics, scipy) — keeping the core install lean; accessing
those features without it raises a clear install hint. Other optional extras:
viz, netcdf, detection, image, audio, mcp (the battery extras imply
eval) — e.g. pip install "mushin-py[eval,viz]". Supported Python: 3.10 – 3.14.
Versioning & scope
mushin follows SemVer with pre-1.0 semantics: a minor bump (0.8 → 0.9) may
contain breaking changes, always listed with migration notes in the
changelog; patch releases never break. The public API is the
top-level mushin namespace plus the documented mushin.benchmark /
mushin.llm symbols — underscore modules are internal. The project's scope is
deliberately narrow: boilerplate-free, reproducible sweep → dataset, with
an optional evaluation layer behind the eval extra. It complements — and
does not replace — experiment trackers like W&B or TensorBoard (see the
workflows guide for
using both together).
Citation
If you use mushin in your research, please cite it (the concept DOI always resolves to the latest release):
@software{martinez_mushin,
author = {Martínez-Martínez, Josué},
title = {mushin: boilerplate-free, reproducible machine-learning experiment sweeps},
year = {2026},
version = {0.9.0},
doi = {10.5281/zenodo.21436444},
url = {https://github.com/martinez-hub/mushin}
}
GitHub's "Cite this repository" button (from CITATION.cff)
generates this for you.
Contributing
Issues and pull requests are welcome. Local development uses uv:
uv sync
uv run pytest tests/ --hypothesis-profile fast # tests (DDP test needs >=2 GPUs)
uv run ruff check . && uv run ruff format --check .
Or make check (lint + format + spell + tests, as CI runs). See
CONTRIBUTING.md.
Disclaimer
mushin is a maintained, standalone carve-out of the rai_toolbox.mushin
subpackage from MIT Lincoln Laboratory's
responsible-ai-toolbox
(no longer maintained). This is a fork/extraction, not a replacement endorsed by
MIT-LL; the original MIT copyright is retained (see LICENSE.txt).
The configuration engine it builds on, hydra-zen, is actively maintained by the
same group.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 mushin_py-0.9.0.tar.gz.
File metadata
- Download URL: mushin_py-0.9.0.tar.gz
- Upload date:
- Size: 130.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e5fe629c0acca307e4cfe4c64e435947f5439a409c571deea6ab296eeb8312d
|
|
| MD5 |
6971e21284a4730109dfd6a000c8eeb5
|
|
| BLAKE2b-256 |
9d5e9ae9c352a4b66118c448fa47cd6a38eb388c0eb79c3a4fb29cc33f5aaadf
|
Provenance
The following attestation bundles were made for mushin_py-0.9.0.tar.gz:
Publisher:
publish.yml on martinez-hub/mushin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mushin_py-0.9.0.tar.gz -
Subject digest:
5e5fe629c0acca307e4cfe4c64e435947f5439a409c571deea6ab296eeb8312d - Sigstore transparency entry: 2210221162
- Sigstore integration time:
-
Permalink:
martinez-hub/mushin@68bceee1446c2754d89fc488b07470e9d9dd1ece -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/martinez-hub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68bceee1446c2754d89fc488b07470e9d9dd1ece -
Trigger Event:
release
-
Statement type:
File details
Details for the file mushin_py-0.9.0-py3-none-any.whl.
File metadata
- Download URL: mushin_py-0.9.0-py3-none-any.whl
- Upload date:
- Size: 102.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
820fa5d6b12cf0f19a7a424503a4ca5f4ae1566f76b68a0cce91988482826427
|
|
| MD5 |
27b5231118a0d1800ea573c4df2623d0
|
|
| BLAKE2b-256 |
37c0797265e20d6d2048b3d927bb06d55f2389ab104aa47dffdbe2b26eb10e23
|
Provenance
The following attestation bundles were made for mushin_py-0.9.0-py3-none-any.whl:
Publisher:
publish.yml on martinez-hub/mushin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mushin_py-0.9.0-py3-none-any.whl -
Subject digest:
820fa5d6b12cf0f19a7a424503a4ca5f4ae1566f76b68a0cce91988482826427 - Sigstore transparency entry: 2210221191
- Sigstore integration time:
-
Permalink:
martinez-hub/mushin@68bceee1446c2754d89fc488b07470e9d9dd1ece -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/martinez-hub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68bceee1446c2754d89fc488b07470e9d9dd1ece -
Trigger Event:
release
-
Statement type: