Skip to main content

Autotrainer

CI PyPI Python License: MIT Code style: ruff

Automatic distributed training and optimization for ML models. Give it a model and data — it detects your hardware (local GPUs or a SLURM cluster), picks the distribution strategy, and can infer the loss function, optimizer, learning rate, and schedule, or search for the best training hyperparameters.

Supports PyTorch (DDP, SLURM multi-node), TensorFlow/Keras (Mirrored / MultiWorker strategies), scikit-learn, XGBoost, and LightGBM — all through one API.

import autotrainer

# 1-Line Full Train: infers recipe, hardware wins, saves model, & prints summary!
autotrainer.train(model, loader, epochs=5, save_path="model.pt")

# Or prepare your custom training loop (DDP + AMP + TF32 + DataLoader workers):
model, loader, opt = autotrainer.prepare(model, loader, opt)

# Or hands-free search & retraining: searches recipe, then trains the winner
model, params, study = autotrainer.fit(model, train_loader, val_loader, save_path="best_model.pt")
python train.py                  # local: prepare() auto-distributes across GPUs
srun autotrainer run train.py    # SLURM multi-node (srun starts the tasks)
autotrainer doctor               # diagnose your environment first

Install

uv pip install autotrainer[torch]            # just PyTorch (recommended)
uv pip install autotrainer[torch,boosting]   # PyTorch + XGBoost/LightGBM

# Or with standard pip:
pip install autotrainer[torch]

Only psutil is required by default; each ML framework is an opt-in extra (torch, sklearn, tf, boosting, tune). Install only what you use.

Setting up for development instead? See CONTRIBUTING.md.

Quickstart

Add one line to your training script, plus set_epoch at each epoch start so distributed shuffling gives every epoch a fresh order, and finish() at the end:

import autotrainer
model, loader, optimizer = autotrainer.prepare(model, loader, optimizer)

for epoch in range(epochs):
    autotrainer.set_epoch(loader, epoch)  # no-op when not distributed
    # ... your normal training loop

# At the end: prints comprehensive training summary & cleans up process groups
autotrainer.finish()

On a GPU, prepare() also enables TF32, cudnn.benchmark, sensible num_workers / pin_memory / persistent_workers, and AMP — without touching your lr, loss, schedule, or optimizer. It is a no-op on CPU, so the same script runs unchanged on a laptop and on an A100. Pass optimize=False to opt out, and see Getting throughput out of your GPUs for what that replaces.

Then launch. On a multi-GPU box prepare() spawns one worker per GPU the first time it's called, so a bare python train.py uses them all with no launcher:

python train.py                   # local: auto-spawns per-GPU workers
autotrainer run train.py          # equivalent, explicit (same spawn machinery)
autotrainer info                  # show what was detected

Which entry point do I want?

You want Call Guide
My loop, but using the hardware properly prepare(model, loader, opt) GPU optimization
The whole step written for me train_step(...) GPU optimization
Loss / optimizer / LR / schedule inferred auto(model, loader) —
The best recipe searched, then trained fit(model, train, val) One-call training
Just the search, not the final train tune(model, train, val) One-call training
A learning rate suggestion find_lr(model, loader, loss_fn) Training loop
The largest batch size that fits find_batch_size(model, step_fn) Training loop
Post-training summary & metrics finish(), log_epoch(), step() Training loop
To know if the loader is the bottleneck BottleneckMonitor() Monitors
To know if training is going wrong TrainingMonitor() Monitors
To shard a model too big for one GPU prepare(..., fsdp=True) Scaling up
XGBoost/LightGBM params with sane threads boost_params(lib="xgboost") —
TensorFlow strategy scope scope(), scale_batch_size(n) —

Everything in autotrainer.__all__ is public and stable; the rest is internal.

How this differs from the alternatives

Most tools in this space ask you to hand over your training loop, your launcher, or both. Autotrainer's bet is that you shouldn't have to give up either to use your hardware properly.

Tool What it gives you What you change to adopt it
torch.distributed + torchrun The primitives Write the DDP wrap, the sampler, the launcher flags — every time
HF Accelerate Device/precision/distribution abstraction Restructure around accelerator.*; configure and use accelerate launch
PyTorch Lightning A full training framework Move your code into a LightningModule + Trainer
Optuna Hyperparameter search Write the objective and the loop it calls; distribution is yours
Ray Train / Tune Distributed execution + search Adopt the Ray runtime and wrap your function in it
autotrainer All of the above paths, on your existing loop One line: prepare(model, loader, opt)

Concretely, four things are unusual here:

  1. Your loop stays yours. prepare() returns the same three objects you passed in. There is no base class to inherit, no trainer object to configure, and no callback system to learn. Deleting the import leaves a working script.
  2. Your hyperparameters are never touched silently. lr, loss, schedule, and optimizer choice are yours unless you explicitly call auto() or fit() to have them inferred or searched. Everything optimize=True does — TF32, cudnn.benchmark, workers, AMP — is throughput, not recipe. And it prints every change it makes, so nothing is a surprise.
  3. No launcher to configure. python train.py spawns one worker per GPU on its own. There is no config file to generate and no separate launch command, and under SLURM the auto-spawn correctly stands down so srun autotrainer run behaves.
  4. Search and distribution are the same tool. fit() runs an ASHA search split across your ranks and then trains the winner distributed. Getting that from Optuna + DDP means wiring a shared study and a launcher yourself.

It is also framework-plural: PyTorch, TensorFlow/Keras, scikit-learn, XGBoost, and LightGBM go through one API, where most of the tools above are PyTorch-only.

Reach for something else when

  • You're already happy on Lightning, Accelerate, or Ray. Autotrainer doesn't integrate with them — it's an alternative to that layer, not an addition. If their abstractions already fit your work, switching buys you little.
  • You need multi-node beyond SLURM, or a scheduler-agnostic cluster abstraction. Ray covers ground autotrainer doesn't.
  • You need experiment tracking, model registries, or a UI. This library prints to stdout and returns objects; it is not a platform.
  • You need architecture search. Width/depth are deliberately out of scope — the model is yours.
  • You can't take pre-1.0 churn. The public API has been frozen since 0.10, but this is 0.x and multi-node SLURM validation is still the open item before 1.0 (see Roadmap).

Documentation

Guide

Reference

Roadmap

Toward 1.0:

  • Stabilization: the public API is frozen as of 0.10; 1.0 now only blocks on real multi-node SLURM validation.

Understanding your training run (the theme after 1.0 — autotrainer should explain runs, not just launch them):

  • Preflight estimation (doctor --profile): dry-run a few batches, then report projected training time, memory headroom, and cost per GPU count — answer "how many GPUs do I actually need?" before burning an allocation.
  • Training cards: every fit() emits a reproducibility card (recipe, seeds, environment, val curve) and replay reruns it.

Deeper SLURM ergonomics:

  • autotrainer sbatch train.py --nodes 2 --time 4h: generate and submit a correct sbatch script (no more --ntasks-per-node != GPUs footguns).
  • Automatic requeue: fit(checkpoint=...) already stops cleanly on a written checkpoint when preempted, but resubmitting is still yours to do (--requeue, or scontrol requeue). Issuing it from inside the handler is the remaining step.

More breadth:

  • Multi-node boosting (xgboost.dask / lightgbm.dask across a SLURM allocation) — currently single-node threads only.
  • Richer augmentation policies: the recipe search covers a single aug_strength scalar over flip + cutout for CNNs. Label-mixing policies (mixup/cutmix) and per-op RandAugment-style search are the next step — both need to rewrite targets and the loss, so they are a larger change to the contract than a searchable scalar.
  • Architecture-aware search: width/depth remain out of scope (a bigger, opt-in commitment that would step beyond "the model is yours").

Open or upvote issues to prioritize these.

Metadata

Release files for autotrainer 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autotrainer 0.14.0
File Size Uploaded
autotrainer-0.14.0.tar.gz 146.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autotrainer 0.14.0
File Interpreter ABI Platform
autotrainer-0.14.0-py3-none-any.whl Python 3 none any Details

Total release size: 243.5 kB

Release files / autotrainer-0.14.0.tar.gz

Download URL autotrainer-0.14.0.tar.gz
Size 146.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1ec37aa3d317a952db18d0e317d9fb6634a6d0aa34ff4bf5186dade9e03f1fa9
BLAKE2b-256 checksum
How to use checksums
e16abd5f61ffcb05950ae2e5386fbe92682d61ecfe6e623c308d3024ec257795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Jul 31, 2026.

Transparency log

Release files / autotrainer-0.14.0-py3-none-any.whl

Download URL autotrainer-0.14.0-py3-none-any.whl
Size 96.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4fc92b95b184cd91b5ade6e0cf30464ee6f4ecdb28085d016705ecfaa9076031
BLAKE2b-256 checksum
How to use checksums
c17b569b49f21c7a3127913f6513e75bf1927a6abadf4312c605408d7f4b7b1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Jul 31, 2026.

Transparency log

Release history Release notifications | RSS feed

0.16.0

2 release files

This release

0.14.0 This release

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page