torch-optimizer
pytorch-optimizer
What it is and what it does
torch-optimizer is a collection of alternative optimization algorithms for PyTorch training, including AdaBound, RAdam, Lamb, DiffGrad, NovoGrad, MADGRAD, and many others. Each optimizer implements a different adaptive or momentum-based gradient descent variant, all exposing the same interface as PyTorch's standard optim module so they can be used as drop-in replacements.
You import the package and instantiate an optimizer by name, passing your model parameters and a learning rate, then call step() during training just as you would with standard optimizers. The package bundles research implementations of algorithms from academic papers, letting you experiment with different optimization strategies without implementing them yourself.
Use it for:
- Experimenting with alternative optimizers like RAdam or Lamb to improve convergence on your specific model and dataset
- Replacing standard Adam with AdaBound to get faster convergence with automatic learning rate scheduling
- Using DiffGrad or NovoGrad when you want gradient-based adaptive methods beyond PyTorch's built-in optimizers
- Prototyping with Ranger for potentially better generalization in deep learning
- Comparing multiple optimizers systematically by swapping them in and out with the same interface
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a collection of alternative optimization algorithms for PyTorch that are compatible with the standard optim module interface.
Yes, if you want to experiment with alternative optimizers and your PyTorch version is not significantly newer than late 2021. The package is dormant but functional, has no known vulnerabilities, and installs cleanly. Be aware that it may not be actively maintained for the latest PyTorch releases, so test compatibility with your environment first.
Install
torch-optimizer on PyPI
pip
pip install torch-optimizeruv
uv add torch-optimizerpoetry
poetry add torch-optimizerInstalling torch-optimizer
Before you install
Low install friction with a pure Python wheel. Maintenance is dormant—last release was October 2021 and last commit March 2024—but the package remains functional and the repository is not archived.
License in practice
Licensed under Apache 2 (permissive), so you can use it freely in commercial and private projects without copyleft obligations.
Quickstart
pip install torch-optimizer
import torch_optimizer as optim
optimizer = optim.DiffGrad(model.parameters(), lr=0.001)
optimizer.step()
Verify before relying
- Whether all listed optimizers remain well-maintained or have known issues in recent PyTorch versions
- Compatibility with PyTorch versions released after the package's last update in October 2021
Package facts
| License | Apache 2 (permissive) |
| Python support | supports the current Python release (>=3.6.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — torch, pytorch-ranger |
| Maintenance | dormant — 1,748 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 166,479/month — #10,494 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: torch_optimizer-0.3.0-py3-none-any.whl
Keywords: torch-optimizer, pytorch, accsgd, adabound, adamod, diffgrad, lamb, lookahead, madgrad, novograd, pid, qhadam, qhm, radam, sgdw, yogi, ranger
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
nevergradNevergrad is a gradient-free optimization…
permissive · top 15,000 on PyPI
pytorch_optimizerProvides a collection of modern optimizers,…
permissive · top 15,000 on PyPI
pytorch-rangerRanger is a PyTorch optimizer that combines…
permissive · top 15,000 on PyPI
schedulefreeProvides schedule-free optimizers for PyTorch…
permissive · top 15,000 on PyPI
flashoptimFlashOptim provides drop-in replacements for…
permissive · top 15,000 on PyPI
entmaxEntmax provides PyTorch implementations of…
permissive · top 15,000 on PyPI
torchsdeSolves stochastic differential equations (SDEs)…
permissive · top 5,000 on PyPI
lion-pytorchLion is a PyTorch optimizer that implements an…
permissive · top 15,000 on PyPI
torchdiffeqProvides PyTorch-based ODE solvers with…
permissive · top 5,000 on PyPI
ropt-dakotaProvides Dakota optimization algorithms as a…
copyleft · top 15,000 on PyPI