111 points · by caprock · 3y ago · 31 comments
def train(weight, gradient, momentum, lr):
update = interp(gradient, momentum, β1)
update = sign(update)
momentum = interp(gradient, momentum, β2)
weight_decay = weight * λ
update = update + weight_decay
update = update * lr
return update, momentum
The key thing they do, sending the update through sign, means all weight updates turn into either 1 or -1.The authors are reputable and claim to have discovered a simple lr optimizer than trains models up to 5x faster and converges to better local optima than Adam/AdamW.
As usual, YMMV.
You can find a PyTorch implementation here: https://github.com/lucidrains/lion-pytorch
Preliminary tests seem to confirm the paper's claims.
m ← αm + (1-α)g // momentum
c ← βm + (1-β)g // new part
θ ← θ + η sign(c) // update of parameters
The parameter update is via the sign of the weighted average of the momentum and the gradient.
For comparison, the gradient of abs(x) is sign(x), which is the update with L1-norm.
To be fair, I don't think that this operation will fundamentally change the behavior of the algorithm. In fact, I don't think their algorithm has a fundamentally different behavior than SignSGD with momentum, whose convergence behavior is well-understood [1, 2, 3]. Actually, the algorithm you described is equivalent to SignSGD with momentum. In the algorithm you described, m is a convex combination of m and g (with coefficient alpha), then c is a convex combination of updated m and g (with coefficient beta). This is exactly the same as setting c as a convex combination of m and g with coefficient alpha*beta. And that is exactly SignSGD with momentum. The only difference between the algorithm you described (equivalent to SignSGD) and LION is that they further modify the value of the momentum after computing the update with an additional convex combination operation. Again, I am skeptical that this operation will fundamentally change the behavior of the algorithm. But that's just my guess.
[1] https://arxiv.org/abs/1802.04434
I suspect it is equivalent up to slightly different α and β?
c ← 0.9m + (0.1)g
There doesn't seem to be a significant difference between their code:
θ ← θ + η sign(0.9m + (0.1)g)
and just not having the 2nd line at all:
θ ← θ + η sign(m)
Come on now
There is no link between the name "Evolved Sign Momentum" and "Lion". They can call the thing what they want, but they're making up the link.
But at least the algorithm and how they got to it seems dope.
Second, LION (what a sin of an acronym tho) seems like a pretty big deal. Really nice paper to start the saturday with.
[edit] When people say that the road to hell is paved with good intentions, or that a little knowledge is a dangerous thing, or... you know, pick your standard folk wisdom saying... what's so goddamn disappointing to me is how a generation that should know much better than this is eager to take shortcuts with the convenience of enormous and unprecedented processing power, rather than using their own brains to puzzle out clever ways of doing the same thing.