Repository navigation
Keep the paper momentum sum available without changing the default - #71
Open
shaneraphel wants to merge 1 commit into
Open
shaneraphel wants to merge 1 commit into
shaneraphel wants to merge 1 commit into
Conversation
The shipped update is the running average beta*B+(1-beta)*G. The write-up uses B <- beta*B+G. momentum_sum selects that recurrence and leaves the default path unchanged.
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
Adds an opt-in
momentum_sumflag tomuon_updateand to theMuonandSingleDeviceMuonconstructors. The default isFalse, and with the flag off the update is bitwise identical to the current code.The shipped momentum is the exponential moving average
buf = β·buf + (1−β)·G, written asmomentum.lerp_(grad, 1 - beta). The form in the Muon paper and in the Moonshot reference is the plain sumbuf = β·buf + G. The two differ by a constant factor of1/(1−β)once the buffer has warmed up (about 20× at the default β of 0.95), so swapping the default would silently rescale every existing run. The flag keeps the current behaviour and makes the paper's form available.With the flag on, Nesterov reads
grad + β·bufand the plain case readsbuf, matching the reference.MuonWithAuxAdamandSingleDeviceMuonWithAuxAdamread the flag withgroup.get("momentum_sum", False)and do not grow their asserted group-key set.Test plan
python test_momentum_sum.py— from a zero buffer one step storesGwith the flag and0.05·Gwithout it (β = 0.95); the second step storesβ·G + G₂; the default flag is bitwise identical to omitting it.momentum_sum=Truereach a mean final loss around 1e-10, so the paper's form trains at least as well as the shipped one on this problem. The difference is the scale of the buffer, not whether the run converges.