Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More inplace ops for pytorch lion's impl #1186

Open
vadimkantorov opened this issue Feb 23, 2023 · 0 comments
Open

More inplace ops for pytorch lion's impl #1186

vadimkantorov opened this issue Feb 23, 2023 · 0 comments

Comments

@vadimkantorov
Copy link

vadimkantorov commented Feb 23, 2023

https://github.com/google/automl/blob/master/lion/lion_pytorch.py#L79:
Now:

update = exp_avg * beta1 + grad * (1 - beta1)
p.add_(torch.sign(update), alpha=-group['lr'])
# Decay the momentum running average coefficient
exp_avg.mul_(beta2).add_(grad, alpha=1 - beta2)

Can be:

update = torch.lerp(grad, exp_avg, beta1)
p.add_(update.sign_(), alpha=-group['lr'])
# Decay the momentum running average coefficient
exp_avg.lerp_(grad, 1 - beta2)

cc @crazydonkey200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant