skillfed

lion-pytorch

Lion Optimizer - Pytorch

lion-pytorch v0.2.5 159.3K downloads/30d#10,703 on PyPI
Permissive 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) Active released

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-pytorch

uv

uv add lion-pytorch

poetry

poetry add lion-pytorch

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Artificial Intelligence

Tags

pytorch optimizer alternative to adamlion optimizer pytorchevolved sign momentum optimizerdeep learning optimizerneural network training optimizer
optimizerpytorchtraining

More Artificial Intelligence packages

Further reading