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

Add Lion optimizer and a "skip step" version of it #43

Merged
merged 14 commits into from
Sep 6, 2024
Merged

Conversation

epwalsh
Copy link
Member

@epwalsh epwalsh commented Sep 6, 2024

I don't really intend to use the Lion optimizer, this is more meant as a proof of concept for two things:

  • an efficient (no host-device sync) implementation of the "skip step" optimizer idea that @2015aroras is investigating, and
  • compiling the optimizer step

Copy link
Contributor

@2015aroras 2015aroras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I want to log the step_factor, do I lose all the benefits of avoiding host-device sync?

if self._grad_norms:
grad_norm_std = torch.std(torch.stack(self._grad_norms[:-1]))
return (
self.latest_loss <= self.sigma_factor * loss_std
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Karpathy thing actually filters out when loss/grad norm is sigma_factor standard deviations above the mean (this does above 0). A number that is s standard deviations above the mean is said to have a "z-score" of s.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, duh, that's embarrassing after having spent 4 years in a stats PhD program

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot the .abs() but just pushed a fix for that.

@epwalsh epwalsh merged commit 5036d90 into main Sep 6, 2024
14 checks passed
@epwalsh epwalsh deleted the epwalsh/lion branch September 6, 2024 22:38
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

Successfully merging this pull request may close these issues.

2 participants