torch-ema
PyTorch library for computing moving averages of model parameters.
Decision gist · record as of 2026-08-14
Yes, with conditions. Install if you need EMA for PyTorch model training and can verify the license from the GitHub repository. The package is lightweight, has no security vulnerabilities, and low install friction. However, maintenance is dormant (last release 2021-11-17); test compatibility with your PyTorch version before production use, and monitor the repository for any breaking changes in newer PyTorch releases.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with only torch as a runtime dependency.
- Maintenance is dormant—last release was 2021-11-17 and no updates since, though the repository remains active with recent commits and modest community engagement (445 stars).
License · maintenance · safety
(unclear) — License treatment is unclear; no SPDX identifier or raw license text is available in the metadata. Verify the actual license from the GitHub repository before use in proprietary or restricted contexts.
last release 2021-11-17 (1731 days) · last repo commit 2024-10-02 · 445 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 308,278 downloads/mo, #7,766 on PyPI
Alternatives
Verify before relying
pip install torch-ema
import torch
from torch_ema import ExponentialMovingAverage
model = torch.nn.Linear(10, 2)
optimizer = torch.optim.Adam(model.parameters())
ema = ExponentialMovingAverage(model.parameters(), decay=0.995)
# After each training step:
optimizer.step()
ema.update()
# Evaluate with EMA weights:
with ema.average_parameters():
output = model(x_val)- Actual license terms and restrictions (metadata shows 'unclear' treatment with no SPDX or raw license text)
- Python version compatibility (requires_python is unspecified in metadata)
- Whether dormant status (last release 2021-11-17, no updates for years) affects compatibility with recent PyTorch versions
What it is and what it does
torch-ema is a small PyTorch utility that maintains exponential moving averages of model parameters during training. It wraps your model's parameters and tracks a smoothed version of their values using a configurable decay rate, typically 0.995 or higher. The main use is to evaluate your model using these averaged weights—often producing better generalization—without disrupting the original training loop or optimizer state.
The library provides a context manager (`average_parameters()`) that temporarily swaps your model's weights with their EMA counterparts for validation, then restores the originals. It also supports manual store/copy/restore operations, device movement (GPU/CPU), and serialization via `state_dict()` for resuming training. Its only runtime dependency is torch, making installation straightforward.
Use it for
- Evaluate a model on validation data using EMA-smoothed weights to measure generalization improvement without retraining
- Apply EMA during training to reduce overfitting by using averaged parameters at inference time while keeping original weights for continued optimization
- Transfer EMA weights to a second model for deployment or ensemble methods using the `copy_to()` method
- Checkpoint and resume training with EMA state preserved via `state_dict()` and `load_state_dict()`
- Experiment with different decay rates to tune the balance between tracking recent updates and long-term stability
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, with conditions.
Install if you need EMA for PyTorch model training and can verify the license from the GitHub repository. The package is lightweight, has no security vulnerabilities, and low install friction. However, maintenance is dormant (last release 2021-11-17); test compatibility with your PyTorch version before production use, and monitor the repository for any breaking changes in newer PyTorch releases.
Install
torch-ema on PyPI
Before you install
Low friction: pure Python wheel with only torch as a runtime dependency. Maintenance is dormant—last release was 2021-11-17 and no updates since, though the repository remains active with recent commits and modest community engagement (445 stars).
License in practice
License treatment is unclear; no SPDX identifier or raw license text is available in the metadata. Verify the actual license from the GitHub repository before use in proprietary or restricted contexts.
Quickstart
pip install torch-ema
import torch
from torch_ema import ExponentialMovingAverage
model = torch.nn.Linear(10, 2)
optimizer = torch.optim.Adam(model.parameters())
ema = ExponentialMovingAverage(model.parameters(), decay=0.995)
# After each training step:
optimizer.step()
ema.update()
# Evaluate with EMA weights:
with ema.average_parameters():
output = model(x_val)
Verify before relying
- Actual license terms and restrictions (metadata shows 'unclear' treatment with no SPDX or raw license text)
- Python version compatibility (requires_python is unspecified in metadata)
- Whether dormant status (last release 2021-11-17, no updates for years) affects compatibility with recent PyTorch versions
Package facts
| License | Not declared unclear |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagetorch |
| Maintenance | Dormant 1,731 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 308,278 / month, #7,766 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: torch_ema-0.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 › “EMA model parameters”
- torch-emaComputes exponential moving averages of PyTorch model parameters…
- ema-pytorchMaintains an exponential moving average (EMA) copy of a PyTorch model…
- technicalTechnical provides a collection of technical indicators and utilities…
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 ema-pytorch · torchsde · accelerate · torcheval · schedulefree · timm · torch · lion-pytorch · pytorch-forecasting · pytorch_revgrad