Repository navigation
Match weight decay parameters by key - #219
Merged
jpuigcerver merged 1 commit intoOct 15, 2026
Merged
jpuigcerver merged 1 commit into
jpuigcerver merged 1 commit into
Conversation
sylvesterkaczmarek
marked this pull request as ready for review
September 22, 2026 21:30
sylvesterkaczmarek
force-pushed
the
fix/weight-decay-parameter-keys
branch
2 times, most recently
from
September 30, 2026 14:24
c29452b to
9800d2f
Compare
Contributor
Author
|
Could a maintainer review the key-based weight-decay matching and unblock the workflow approval and Copybara import? |
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.
Summary
Look up each flattened parameter by its gradient's key when adding weight decay. Zipping two dictionaries' values pairs unrelated parameters when their insertion orders differ, which occurs naturally when
jax.gradrebuilds the gradient tree in key order.For
params = {'b': [10, 20], 'a': [1, 2]}and gradients of the squared norm, decay0.1currently producesa=[3, 6],b=[20.1, 40.2]in eager execution instead ofa=[2.1, 4.2],b=[21, 42]. Differently shaped leaves can raise a broadcasting error. The jitted path already produces the correct result for this example.The change matches names explicitly without changing the decay formula, first-match regex rules, or serialization/container handling.
Validation
Python 3.12.11, JAX 0.11.2, Flax 0.12.9, Optax 0.2.8, NumPy 2.5.3, macOS arm64 CPU:
6dcc8c0; all ten pass after the fix.git diff --checkpass.The complete data/checkpoint/training test suite, end-to-end image training, and accelerator/multihost execution were not run. No build metadata or CI configuration is changed.