ema-pytorch
Easy way to keep track of exponential moving average version of your pytorch module
Decision gist · record as of 2026-08-14
Yes. The package is lightweight, actively maintained, has no known vulnerabilities, and solves a well-defined problem (EMA tracking) that is standard in modern deep learning. Install it if you are training a PyTorch model and want to leverage weight averaging for better generalization or if you need post-hoc EMA synthesis for research.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires PyTorch to be installed; Python 3.8 or later.
- Low friction: pure Python wheel with only torch as a runtime dependency.
- Active maintenance with a recent release (14 days old) and steady commit history.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions; you must include a copy of the license and copyright notice.
last release 2026-07-31 (14 days) · last repo commit 2026-07-31 · 660 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 253,140 downloads/mo, #8,526 on PyPI
Alternatives
Verify before relying
pip install ema-pytorch
import torch
from ema_pytorch import EMA
net = torch.nn.Linear(512, 512)
ema = EMA(net, beta=0.9999, update_after_step=100, update_every=10)
# After training updates to net:
ema.update()
output = ema(data)- Whether post-hoc EMA synthesis (Karras et al.) offers measurable accuracy gains for your model architecture.
- Performance overhead of EMA updates relative to model size and batch frequency.
- Compatibility with distributed training frameworks (DDP, FSDP) not mentioned in the description.
What it is and what it does
ema-pytorch wraps a PyTorch neural network to automatically maintain an exponential moving average (EMA) copy of its weights during training. Instead of using the latest model weights for inference or validation, you can use the EMA version, which often generalizes better by smoothing out noisy weight updates. The wrapper handles the decay schedule, update frequency, and optional warmup logic so you only need to call update() after each training step.
The package supports three main patterns: standard EMA with configurable decay and update frequency, post-hoc EMA synthesis (where multiple EMA versions are checkpointed and interpolated to create a new EMA at a different decay rate), and target representation routing for nested module architectures where EMA outputs are injected as teacher signals into student submodules. It is commonly used in diffusion models, self-supervised learning, and other training regimes where model averaging improves convergence or generalization.
Use it for
- Improve validation accuracy in diffusion models by using EMA weights instead of the latest training weights.
- Implement teacher-student training in self-supervised learning where EMA outputs guide online module predictions.
- Synthesize a new EMA model at a different decay rate from saved checkpoints without retraining.
- Reduce overfitting in standard supervised learning by averaging weights across training steps.
- Experiment with Switch EMA to update the online model with EMA weights periodically for better loss landscape flatness.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is lightweight, actively maintained, has no known vulnerabilities, and solves a well-defined problem (EMA tracking) that is standard in modern deep learning. Install it if you are training a PyTorch model and want to leverage weight averaging for better generalization or if you need post-hoc EMA synthesis for research.
Install
ema-pytorch on PyPI
Before you install
Low friction: pure Python wheel with only torch as a runtime dependency. Active maintenance with a recent release (14 days old) and steady commit history.
Requires PyTorch to be installed; Python 3.8 or later.
License in practice
MIT license permits commercial and private use with minimal restrictions; you must include a copy of the license and copyright notice.
Quickstart
pip install ema-pytorch
import torch
from ema_pytorch import EMA
net = torch.nn.Linear(512, 512)
ema = EMA(net, beta=0.9999, update_after_step=100, update_every=10)
# After training updates to net:
ema.update()
output = ema(data)
Verify before relying
- Whether post-hoc EMA synthesis (Karras et al.) offers measurable accuracy gains for your model architecture.
- Performance overhead of EMA updates relative to model size and batch frequency.
- Compatibility with distributed training frameworks (DDP, FSDP) not mentioned in the description.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagetorch |
| Maintenance | Actively maintained 14 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 253,140 / month, #8,526 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.8Topic :: Scientific/Engineering :: Artificial Intelligence |
Evidence: ema_pytorch-0.8.3-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “exponential moving average pytorch”
- ema-pytorchMaintains an exponential moving average (EMA) copy of a PyTorch model…
- torch-emaComputes exponential moving averages of PyTorch model parameters…
- pandas-ta-classicPandas TA Classic provides 193 technical indicators and 62 native…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also torch-ema · adam-atan2-pytorch · torchmetrics · torchsummary · torch-model-archiver · vit-pytorch · vector-quantize-pytorch · conformer · schedulefree · lion-pytorch