trainer
General purpose model trainer for PyTorch that is more flexible than it should be, by 🐸Coqui.
What it is and what it does
Trainer is a PyTorch training framework designed to reduce boilerplate in model training loops while maintaining flexibility for advanced use cases. It wraps the training cycle—forward pass, loss computation, backpropagation, and optimization—into a configurable abstraction that handles mixed precision training, gradient accumulation, and multi-GPU distributed training via DDP or Hugging Face Accelerate.
The package is built around subclassing a TrainerModel base class and defining an optimize() method, which can range from a simple auto-optimized loop to a fully custom training procedure (the documentation shows a GAN example with separate discriminator and generator optimization steps). It integrates experiment logging via Tensorboard, ClearML, MLFlow, Aim, and WandB, supports callbacks for custom hooks at training milestones, and includes utilities like a batch size finder to maximize GPU utilization. The codebase is intentionally kept simple and opinionated to avoid over-abstraction.
Use it for:
- Training standard supervised models with automatic optimization and mixed precision support without writing custom training loops.
- Implementing adversarial training (GANs) with separate optimizer steps and gradient accumulation for each component.
- Running multi-GPU distributed training across multiple GPUs or nodes using DDP or Accelerate without managing process spawning.
- Profiling model training with PyTorch profiler and visualizing results in Tensorboard to identify bottlenecks.
- Automatically finding the largest batch size that fits on available hardware to maximize training efficiency.
- Logging training metrics and checkpoints to multiple experiment tracking platforms simultaneously.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Trainer is a PyTorch model training framework that handles the training loop, optimization, and experiment logging for machine learning models with support for mixed precision, distributed training, and callback customization.
Yes, if you are actively training PyTorch models and want to reduce training loop boilerplate without heavyweight abstractions. The package is dormant (last release December 2023) but has no known vulnerabilities and low install friction. It is suitable for research and production use, though you should verify that its dependencies remain compatible with your PyTorch and Python versions. Not recommended if you require active maintenance or support for the latest PyTorch features.
Install
trainer on PyPI
pip
pip install traineruv
uv add trainerpoetry
poetry add trainerInstalling trainer
Before you install
Low install friction with a pure Python wheel. The package is dormant (last commit 2024-03-07, 975 days since release), but remains functional for its stated purpose. Six runtime dependencies—torch, coqpit, psutil, fsspec, tensorboard, soundfile—are standard in the ML ecosystem.
License in practice
Apache 2.0 permissive license allows commercial and private use with minimal restrictions, making it suitable for most projects without legal friction.
Quickstart
pip install trainer
from trainer import Trainer
from trainer.model import TrainerModel
class MyModel(TrainerModel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# define model layers
trainer = Trainer(model=MyModel(), ...)
trainer.fit()
Requires PyTorch (torch) to be installed; supports Python 3.8–3.11 only (capped below current Python versions).
Verify before relying
- Whether the package is actively maintained or will receive security updates going forward, given dormant status since March 2024.
- Compatibility with recent PyTorch versions and whether the six dependencies have known conflicts with modern Python 3.12+.
- Whether the telemetry collection (opt-out via TRAINER_TELEMETRY=0) is still active and what data is actually collected.
Package facts
| License | Apache2 (permissive) |
| Python support | capped below the current Python release (>=3.6.0, <3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — torch, coqpit, psutil, fsspec, tensorboard, soundfile |
| Maintenance | dormant — 975 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 85,910/month — #13,894 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: trainer-0.0.36-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
coqui-tts-trainerA PyTorch model trainer framework that handles…
permissive · top 15,000 on PyPI
torchtntTNT provides training utilities and tools for…
permissive · top 15,000 on PyPI
pytorch-ignitePyTorch Ignite provides a high-level training…
permissive · top 15,000 on PyPI
pytorch-lightningPyTorch Lightning wraps PyTorch training code…
permissive · top 5,000 on PyPI
nv-one-logger-pytorch-lightning-integrationAdds training telemetry collection to Lightning…
permissive · top 15,000 on PyPI
lightningLightning is a framework that organizes PyTorch…
permissive · top 5,000 on PyPI
mmengineMMEngine is a foundational PyTorch training…
permissive · top 5,000 on PyPI
pytorch-metric-learningProvides metric learning loss functions,…
permissive · top 5,000 on PyPI
torch-tb-profilerIntegrates PyTorch profiling data with…
permissive · top 15,000 on PyPI
accelerateAccelerate abstracts away distributed training…
permissive · top 1,000 on PyPI