-
Notifications
You must be signed in to change notification settings - Fork 169
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
Fix LR schedule handling for low-bit optimizers #736
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
af8de67
update benchmark script
gau-nernst aecc1c4
try CPU Tensor lr
gau-nernst 55077cf
update
gau-nernst 487ede0
Merge branch 'pytorch:main' into optim_lr
gau-nernst dc0e2f9
consolidate adam
gau-nernst 87d3be7
remove unnecessary requires_grad in subclass
gau-nernst cdf283c
update README
gau-nernst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the right place to set it? i would advocate for making this very obvious with users what is going on, and i would modify the AdamW constructor below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless you’re adamant that this optimizer will only support Tensor lrs. In pytorch/pytorch, we support python float lrs in eager because it is faster to compute python math than launch kernels, though that may be less relevant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative I’d suggest for max visibility from user is changing line 165 below to be torch.tensor(1e-3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think to keep it simple, we just enforce lr to be a scalar tensor here. If lr is not changed during training, whether it is a tensor or not would not matter. But if it is changed during training, we need lr to be a tensor anyway since torch.compile will recompile when python float lr changes value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, but I still think it’d be most visible/clear to users if the constructors of Adam and AdamW clearly set the default as Tensors and if this base would just error if lr was not a Tensor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, do you mean that forcing users to pass in LR as Tensor instead of Python float? i.e. error is raised if LR is not a Tensor.
And is it your view that converting Python float to Tensor in the constructor might seem unexpected to the users?
Personally when using optimizers, I never pass in Tensor LR before, so it feels strange to me 😅 (doesn't mean I'm correct, just a feeling from my limited experience). I think that converting LR from float to Tensor inside the constructor is an implementation detail that the users shouldn't need to care about.
Also, most (if not all?) other optimizers will work if I pass in a Python float LR? So feel kinda strange (again 🤣) if users are forced to pass in Tensor LR to this particular optimizer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it'd be good to have users pass in Tensor lrs, so they're most aware of what is going on. I think it is not great to switch it up under the hood and have the user be confused if there's ever an error regarding the Tensorness of the lr.