TL;DR
The paper treats the design of an optimizer as a search problem. It writes candidate training rules as small programs, runs an evolutionary search over them on cheap proxy tasks, keeps the programs that still do well on larger tasks, and simplifies the winner by hand. The winner is Lion, which keeps only one momentum vector per parameter and updates each parameter by the sign of a momentum mix. On the paper's benchmarks Lion matched or beat AdamW on many image and language tasks, and it needed less memory.
Builds on: AdamW Optimizer, Symbolic Regression · Leads to: Lion Optimizer
Why it mattered
Most optimizers in deep learning are hand-designed variants of one idea. Adam, from 2014, and AdamW, from 2017, remained the default for most large models, including the Vision Transformers in ViT and the large language models that followed. The paper showed that a search could find a rule that competes with them. Its main training results are on Vision Transformers, on contrastive image-text training in the style of CLIP, on diffusion models, and on autoregressive language models.
The paper reports concrete savings. On JFT pre-training, Lion let a ViT-L/16 match a ViT-H/14 trained with AdamW at about 3 times less pre-training cost, and the abstract states up to 5 times savings. In the vision-language setting, replacing Adafactor with Lion in the BASIC system gave 88.3 percent zero-shot ImageNet accuracy and 91.1 percent after fine-tuning, which the paper reports as improvements of 2 and 0.1 points over the earlier best.
The problem
Before this paper, the question was how to find a better optimizer. Handcrafted optimizers each change one or two pieces of Adam: the momentum decay, the second moment, the bias correction, or the weight decay. Tuning these by hand is slow, and the space of such tweaks is small. The authors asked whether the space of all update rules that can be written as a short program is searchable, and whether a rule found on a cheap task would transfer to an expensive one.
Two obstacles make this hard. The first is that the space is huge and sparse: most random programs do nothing useful or do not run at all. The second is that a rule found on a small proxy task may only work on that task. The paper addresses the first with efficient search techniques and the second with selection on larger tasks and simplification of the result.
How it works
The method has five stages. Each one is a step in the pipeline, and the output of one is the input of the next.
- Encode each optimizer as a program. A candidate is a
trainfunction over arrays. Its inputs are the weight , the gradient and the learning-rate value at the current step, and its output is the weight update. It may keep extra variables, initialised to zero, to store history. Adam fits this format with two such variables, and . The building blocks are 45 common math functions, such as sums, products, and a linear interpolation. - Search by evolution. A population of programs is improved in cycles. In each cycle a few programs are picked at random, the best of them becomes the parent, and the parent is copied and mutated by inserting, deleting or changing one statement. The child joins the population and the oldest member leaves. Before a child is run, an abstract execution step checks its shapes and removes programs that are duplicates in function, so the search does not waste time on them.
- Score on proxy tasks. Each candidate is trained on a small proxy task: a smaller model, fewer examples and fewer steps. One proxy evaluation takes about 20 minutes on one TPU v2 chip. Each full search ran on 100 chips for about 72 hours and generated 200,000 to 300,000 programs, of which 20,000 to 30,000 were actually run because the rest were caught by the cache or by the abstract execution.
- Select on larger tasks. Search fitness tends to rise while the program overfits the proxy, a failure the paper calls meta-overfitting. Candidates are therefore re-checked on meta-validation tasks that are larger. A funnel does this cheaply: a candidate that beats the baseline on a task 10 times larger moves on to a task 100 times larger, and the rest are dropped.
- Simplify. The surviving program is cut down. Statements that do not affect the output are removed using the abstract execution. Statements whose removal changes little are removed too. The remaining statements are rearranged and renamed by hand.
Stage 5 produced Lion. In the paper's derivation, the three statements that compute the update collapse into one sign function, the second moment is dropped because its effect on the momentum can be written with a single constant, and the bias correction is removed because it does not change the direction of the update. The result is the rule in Lion Optimizer.
flowchart LR A["candidate programs"] --> B["evolve by mutation"] B --> C["score on proxy task"] C --> D["funnel on larger meta-validation tasks"] D --> E["simplify by hand"] E --> F["Lion"] D -. "rejected at each size" .-> B
The math
The search space can be counted roughly. The paper estimates the number of programs as
where is the number of available functions, is the program length in statements, is the number of local variables, and is the average number of arguments per statement. This counts programs with fixed length and ignores constants.
For a rough feel, take the paper's 45 functions, programs of statements, variables and arguments. Then . Since and , the logarithm of is about . The space holds about programs of this size. A real search generates 200,000 to 300,000 of them, and only 20,000 to 30,000 are actually run.
The search objective is a fitness , the validation accuracy or negative perplexity of the trained model when the program is used as the optimizer on a proxy task. Selection then compares candidates on the meta-validation task , which is the -th funnel stage. A candidate survives stage only when its score on beats the baseline. Written as a rule, the funnel keeps
Here is the set of candidates still in the funnel at stage , and stands for the tuned baseline. For accuracy the inequality means a higher score is better; for perplexity a lower one is, so the comparison is flipped on language tasks.
The final rule is the one derived in Lion Optimizer. With gradient , momentum , and decay factors and , its step is
where is the learning rate at step , is the weight decay, and are the weights. The momentum is updated by . The paper's defaults are and .
Results
The main results are on image classification. Table 2 compares models trained from scratch on ImageNet. With the stronger augmentation, which combines RandAugment and Mixup, Lion gives ViT-B/16 a top-1 accuracy of 80.77 against 80.12 for AdamW, and ViT-S/16 79.46 against 78.89. Without the stronger augmentation the gaps are larger: 77.44 against 75.48 for ViT-B/16, a gain of 1.96 points, and 76.70 against 76.12 for ViT-S/16. The paper notes that the gain grows with the training batch size and shrinks under strong augmentation.
When pre-trained on ImageNet-21K and then fine-tuned, Lion gives ViT-L/16 85.59 against 85.07 for AdamW, and ViT-B/16 84.45 against 84.12. On JFT the paper reports that Lion lets ViT-L/16 match ViT-H/14 trained with AdamW, at about 3 times less pre-training cost. Fine-tuning results on ImageNet show ViT-L/16 matching the previous ViT-H/14 while being half the size.
The limits are stated in the paper's Section 6. The advantage shrinks with strong augmentation. Lion also prefers larger batches: on ViT-B/16 its best batch size is 4,096, against 256 for AdamW, although it stays robust down to a batch of 64. On ResNets the methods are close, which the authors attribute to convolutional networks being easier to optimize. Lion performs about the same as AdamW on some tasks, including the base text-to-image model of Imagen and the perplexity of a large autoregressive language model. The paper also notes that the update's larger norm calls for a smaller learning rate, which is a practical difference rather than a limit of the method.
Reading guide
Read the paper in this order, with the prerequisites each part leans on.
- Section 1, Introduction. Needs Adam Optimizer, AdamW Optimizer, and Transformer for the models that use these optimizers.
- Section 2, Symbolic discovery. Needs Symbolic Regression for the idea of searching formulas, and Genetic Algorithm for evolutionary search. Sections 2.1 to 2.3 cover the search space, the efficiency tricks and the funnel.
- Section 3, Derivation and analysis. Needs Momentum, Exponential Moving Average and Learning Rate. The derivation in 3.1 is the step from raw program to Lion, and 3.2 is about the sign update and its effect on the norm.
- Section 4.1, Image classification. Needs Vision Transformer (ViT), Mixup, and Cosine Annealing for the schedule used in training.
- Section 4.2 and 4.3, Vision-language and diffusion. Needs Contrastive Learning, Zero-Shot Learning, and Diffusion Model, with U-Net for the image synthesis models.
- Section 4.4, Language modeling. Needs Transformer for the language models, and Mixed-Precision Training for the bfloat16 momentum that the memory comparison in 3.2 assumes.
- Section 5, Hyperparameter tuning. Needs Learning Rate and Critical Batch Size, the reason the advantage grows with batch size.
- Section 6, Limitations. Needs the same batch-size idea and the notes in section 4.