lion-pytorch
Lion Optimizer - Pytorch
What it is and what it does
Lion is a PyTorch optimizer implementing an evolved sign momentum algorithm that the description positions as a potential successor to AdamW. It depends only on torch and integrates directly into PyTorch's optimizer interface. The optimizer requires careful hyperparameter tuning: learning rates should typically be 3–10x smaller than AdamW equivalents, weight decay values 3–10x larger, and default β1 and β2 values differ from AdamW (0.9 and 0.99 versus 0.9 and 0.999). The description documents mixed empirical results—positive outcomes reported for language modeling and text-to-image training when tuned correctly, but negative results outside the paper's tested domains (reinforcement learning, feedforward networks, hybrid architectures). The author recommends Lion primarily for high batch sizes (64 or above) and notes sensitivity to batch size, data volume, and augmentation.
Use it for:
- Training large language models where a 3x smaller learning rate than AdamW yields better convergence
- Text-to-image model training when hyperparameters are carefully tuned to the specific architecture
- Vision transformer training with cosine decay learning rate schedules
- Scenarios with high batch sizes (64+) where Lion's sign momentum approach may outperform adaptive methods
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Lion is a PyTorch optimizer that implements an evolved sign momentum algorithm discovered by Google Brain as an alternative to AdamW for training neural networks.
Yes, with conditions. Lion is permissively licensed, has low install friction, and is actively maintained. Install it if you are training models in domains the paper evaluated (language modeling, vision transformers, text-to-image) and are willing to invest in hyperparameter tuning. The description's own updates acknowledge it performs worse than Adam without careful learning rate adjustment and shows negative results outside tested architectures. Not recommended for reinforcement learning, standard feedforward networks, or exploratory work where you cannot afford tuning overhead.
Install
lion-pytorch on PyPI
pip
pip install lion-pytorchuv
uv add lion-pytorchpoetry
poetry add lion-pytorchInstalling lion-pytorch
Before you install
Low install friction with a single runtime dependency on torch. Actively maintained with a recent release 36 days ago.
License in practice
MIT License permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install lion-pytorch
import torch
from torch import nn
from lion_pytorch import Lion
model = nn.Linear(10, 1)
opt = Lion(model.parameters(), lr=1e-4, weight_decay=1e-2)
loss = model(torch.randn(10))
loss.backward()
opt.step()
opt.zero_grad()
Requires Python 3.9 or later. Learning rate and weight decay require careful tuning (typically 3–10x smaller/larger than AdamW); default hyperparameters may not work without adjustment.
Verify before relying
- Whether Lion's performance gains over AdamW hold across a broad range of model architectures and training regimes beyond those tested in the original paper
- Optimal learning rate schedules and hyperparameter tuning strategies for specific problem domains
- Stability and convergence behavior with batch sizes below 64, given the author's recommendation for high batch sizes
Package facts
| License | MIT License Copyright (c) 2023 Phil Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — torch |
| Maintenance | actively maintained — 36 days since the last release |
| First released | |
| Downloads | 159,256/month — #10,703 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: lion_pytorch-0.2.5-py3-none-any.whl
Keywords: artificial intelligence, deep learning, optimizers
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
adam-atan2-pytorchProvides an Adam optimizer variant using atan2…
permissive · top 15,000 on PyPI
flashoptimFlashOptim provides drop-in replacements for…
permissive · top 15,000 on PyPI
schedulefreeProvides schedule-free optimizers for PyTorch…
permissive · top 15,000 on PyPI
pytorch-rangerRanger is a PyTorch optimizer that combines…
permissive · top 15,000 on PyPI
prodigyoptProdigy is a PyTorch optimizer that adapts the…
permissive · top 15,000 on PyPI
pytorch_optimizerProvides a collection of modern optimizers,…
permissive · top 15,000 on PyPI
hyper-connectionsImplements multiple residual streams in neural…
permissive · top 15,000 on PyPI
opt-einsum-fxOptimizes PyTorch einsum operations and…
permissive · top 15,000 on PyPI
torch-optimizerProvides a collection of alternative…
permissive · top 15,000 on PyPI
omnimallocOmniMalloc solves static memory allocation for…
permissive · top 15,000 on PyPI