contrib: add SOAP optimizer (arXiv:2409.11321)#1692
Open
irhyl wants to merge 3 commits into
Open
Conversation
SOAP (Improving and Stabilizing Shampoo using Adam) combines Shampoo's
Kronecker-factored preconditioning with Adam's per-coordinate adaptivity.
For each 2-D weight matrix it maintains left/right Kronecker factors
whose eigenbases define a rotation; Adam's moment buffers are tracked in
that rotated space and the final update is unprojected back. Parameters
with fewer than two dimensions fall back to standard Adam.
New files:
optax/contrib/_soap.py – scale_by_soap and soap implementations
optax/contrib/_soap_test.py – 14 unit tests (shapes, orthogonality,
convergence, JIT stability, Adam fallback,
weight decay, mu_dtype, frequency control)
Modified files:
optax/contrib/__init__.py – export soap / scale_by_soap / ScaleBySOAPState
optax/contrib/_common_test.py – add soap to the shared optimizer test matrix
and mark precondition_frequency as static
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Move test_utils and transform imports to file top (C0415), fix dict iteration to use .items() (C0206), and wrap the 81-char docstring line in _soap.py (E501).
Change count field type from jax.Array to jax.typing.ArrayLike to match the established pattern in transform.py (ScaleByAdamState). Add pyrefly ignore comments for the GradientTransformation and add_decayed_weights calls, matching the pattern used in alias.py.
99dc5d9 to
7735263
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SOAP (Improving and Stabilizing Shampoo using Adam) combines Shampoo's Kronecker-factored preconditioning with Adam's per-coordinate adaptivity. For each 2-D weight matrix it maintains left/right Kronecker factors whose eigenbases define a rotation; Adam's moment buffers are tracked in that rotated space and the final update is unprojected back. Parameters with fewer than two dimensions fall back to standard Adam.
New files:
optax/contrib/_soap.py: scale_by_soap and soap implementations
optax/contrib/_soap_test.py : 14 unit tests (shapes, orthogonality, convergence, JIT stability, Adam fallback, weight decay, mu_dtype, frequency control)
Modified files:
optax/contrib/init.py: export soap / scale_by_soap / ScaleBySOAPState
optax/contrib/_common_test.py: add soap to the shared optimizer test matrix and mark precondition_frequency as static