Repository navigation
Add SignSGD - #130215
Add SignSGD#130215BeeGass wants to merge 13 commits into
Conversation
sign gradient descent
Revert "sign gradient descent"
Implement SignSGD optimizer - Add SignSGD class extending Optimizer - Modify gradient handling to use sign instead of raw values - Support momentum, weight decay, and Nesterov momentum - Implement foreach and fused operations for performance - Add multi-tensor and single-tensor update functions - Include sparse gradient and AMP scaling support - Provide detailed documentation and mathematical formulation
update documentation
The committers listed above are authorized under a signed CLA. |
|
lr = 1/n_params is recommended |
|
Hello, thank you for taking the time to tell us about SignSGD. To save time and facilitate more open discussion, it would be better to open an issue first motivating the feature request before delving into the implementation. I do see that you added some motivation in the PR body, so I shall respond to that here: From what I gather, this PR is intended to be a herald for more sign-based optimizers in core, starting with SignSGD. As you may already know, PyTorch is quite selective with the features we add, see https://github.com/pytorch/pytorch/wiki/Developer-FAQ#i-have-a-new-function-or-feature-id-like-to-add-to-pytorch-should-it-be-in-pytorch-core-or-a-library-like-torchvision. From the perspective of wanting to ensure stability, composability, and extensibility of the core optimizers, I am not convinced that adding a new optimizer class for SignSGD is the right approach. PyTorch is written to promote exploration and encourages everyone to experiment with their own optimizers. To that end, it looks like SignSGD is already implemented in third party libraries such as from the OG author: https://github.com/jxbz/signSGD and also with their improved algorithm (published a year after) at https://github.com/jiaweizzhao/signSGD-with-Majority-Vote. There does not seem to be a need in adding this specific optimizer to live within core pytorch/pytorch. The more interesting question, I believe, is how to introduce more sign based optimizations as an general option across optimizers. The way is likely not to add more and more optimizer classes with lots of duplicated code, but perhaps to add some mechanism that would sign-ify the parameter update value. If there is no generic solution that would be performant, then I would still expect for a lot of the SGD code to be shared in the solution that would be proposed. If you want to pursue this path further, please open a separate issue and we can discuss there! |
|
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
Implement SignSGD optimizer
Motivation:
SignSGD is becoming increasingly important in deep learning research and optimization. The original SignSGD paper has over 1000 citations, and sign-based methods are prevalent in modern optimizers (e.g., variants of RMSprop, Adam, and Lion). However, PyTorch currently lacks native support for SignSGD. This PR aims to address this gap by implementing the SignSGD optimizer.
Implementation details:
SignSGDclass extendingtorch.optim.Optimizer_init_groupmethodforeachandfusedoperationsThe implementation follows PyTorch's optimizer conventions and integrates seamlessly with existing PyTorch functionality.
Benefits:
Performance considerations:
foreachandfusedoperations for potential speedupsDocumentation:
I hope this addition makes it easier for PyTorch users to experiment with sign-based methods and define new sign-based optimizers. Looking forward to your comments and suggestions for improvement.