Suppose the two slopes at your current point are 1 and 100. Should the second coordinate move a hundred times farther? If each coordinate can move by at most 0.1, the largest decrease predicted by a linear model uses the full 0.1 on both. Lion makes this decision using a smoothed gradient. We can test it by restoring the curvature that the linear model leaves out. 假设当前位置沿两个坐标的斜率分别为 1 和 100,第二个坐标就该多走一百倍吗?如果每个坐标最多只能移动 0.1,要让局部线性模型的预测值降得最多,两个坐标都应走满 0.1。Lion 用平滑后的梯度判断方向。要知道这一步在真实损失上是否划算,还得把线性模型略去的曲率算回来。
The geometry of a sign step 逐个限制坐标,符号步怎样出现
Let c be the estimated slopes and d the displacement. Their inner product is the predicted change in loss. With a per-coordinate limit η the feasible set is a square in two dimensions and a box in higher dimensions. Each term of the sum can be minimized separately. 把估计的斜率记为向量 c,位移记为 d。两者的内积就是线性模型预测的损失变化。令各坐标的位移上限为 η,可行域在二维是一块正方形,在高维是一个盒子。目标中的每一项都能单独取到最小值。
For a positive slope, the left endpoint gives the lowest value. For a negative slope, the right endpoint does. At zero slope all feasible displacements tie on that coordinate and Lion chooses zero. This geometry depends on the chosen axes. Rotating them rotates the box and can change the physical direction of a step. 斜率为正时,沿这一坐标走到左端最划算;斜率为负时则应走到右端。斜率恰好为零时,任意可行位移对线性目标的贡献都相同,Lion 取零位移。这个结论依赖坐标系。旋转坐标轴,也就旋转了允许位移的盒子,原空间里的更新方向可能随之变化。
One stored vector, two mixtures 一份动量,两个混合系数
Chen and colleagues found Lion by searching over update programs in 2023. Let
With the reference values 0.9 and 0.99, a fresh gradient supplies 10% of the direction estimate and 1% of the new stored average. If the old scalar momentum is +1 and the new gradient is −12, the first mixture is −0.3 and the stored mixture is +0.87. The gradient-driven step moves the parameter up while the history remains positive. Lion stores one running tensor per parameter tensor, compared with two in ordinary AdamW. Activations, gradients and parameter copies count separately. 按参考实现中的 0.9 和 0.99,当前梯度在方向估计中占 10%,在新存入的动量中占 1%。例如,某一坐标的旧动量是 +1,新梯度是 −12,两次加权分别得到 −0.3 和 +0.87。单看梯度贡献,这一步会让参数增大,留给下一步的动量仍是正数。每组参数只需保存一组同形状的动量,常规 AdamW 则保存一阶矩和二阶矩两组。这里算的是优化器状态,训练还需要为激活值、梯度和参数副本留出空间。
When a downhill direction sends the loss uphill 为什么方向选对了,损失还会上升
On the series quadratic, start at (1, 0.01) with zero momentum. The gradient is (1, 1), although the second coordinate lies only 0.01 from the bottom. Set η = 0.1 and λ = 0. Both coordinates move down by 0.1. The Taylor expansion is exact on this quadratic, whose Hessian H has diagonal entries 1 and 100 and zero off-diagonals. 仍用本专题的二次函数,从 (1, 0.01) 出发,动量初始化为零。两个坐标的梯度都是 1,可第二个坐标离谷底只有 0.01。取 η = 0.1、λ = 0,符号步让两个坐标各减去 0.1。这个函数的 Hessian 矩阵 H 的对角元素为 1 和 100,非对角元素为零。二次函数的泰勒展开到二阶就给出了损失的实际变化。
Loss rises from 0.505 to 0.81. The initial slope is downhill, but the high-curvature coordinate crosses the bottom and climbs the opposite side. At this particular starting point the change is
What changes with batch size? 批量大小为何值得单独看
Consider one coordinate with true slope g. If the smoothed sign is wrong with probability p and never ties, its expected first-order contribution to the loss change is
In the authors’ ImageNet batch-size sweep, ViT-B/16 trained for 300 epochs at batch size 32K reached 77.9% accuracy with Lion and 75.4% with AdamW. For a new task, match the example budget and tune each learning rate. With k active coordinates the Euclidean length of Lion’s gradient-driven step is