MOSO: use RMSProp directly (remove double momentum)#252
Conversation
1676bf2 to
7f5ee48
Compare
Greptile SummaryThis PR simplifies MOSO by replacing the inner Adam update with RMSProp-style normalization. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (6): Last reviewed commit: "MOSO: use RMSProp directly instead of Ad..." | Re-trigger Greptile |
7f5ee48 to
b311f4c
Compare
…etas) MOSO already applies a Muon-style first-moment EMA (momentum) to the gradient before preconditioning. The inner Adam previously also exposed beta1, letting it add a second, redundant momentum to the update direction -- an over-damping that hurt convergence. Remove the (beta1, beta2) tuple and expose a single rms_beta: the inner optimizer's first-moment beta is fixed at 0 and only its second-moment (RMS) normalization is configurable, so double momentum is no longer possible. rms_beta (default 0.95) also avoids colliding with the AdamW beta2 used for the 1D/embedding params in the common MOSO+AdamW setup. Behaviorally equivalent to the previous betas=(0.0, 0.95). Updates test_moso.py: the no-EMA case uses rms_beta=0.0, plus a test asserting the betas kwarg is rejected (double momentum is not configurable). Signed-off-by: Mike Chrzanowski <mchrzanowski@nvidia.com>
b311f4c to
c184d74
Compare
| with self.assertRaisesRegex(TypeError, "only supported for 2D"): | ||
| optimizer.step() | ||
|
|
||
| def test_no_inner_first_moment_momentum(self) -> None: |
There was a problem hiding this comment.
Looks it test wrong kwargs name.
Not a very strong test, doesn't hurt to keep it with proper naming, e.g. test_betas_raise_type_error.
There was a problem hiding this comment.
skyw
left a comment
There was a problem hiding this comment.
Testing is weak, but should be OK.
Defer to @mkhona-nvidia for approval.
| with self.assertRaisesRegex(TypeError, "only supported for 2D"): | ||
| optimizer.step() | ||
|
|
||
| def test_no_inner_first_moment_momentum(self) -> None: |
There was a problem hiding this comment.
Looks it test wrong kwargs name.
Not a very strong test, doesn't hurt to keep it with proper naming, e.g. test_betas_raise_type_error.
|
@mchrzanowski can we replace the current Basically we are using the adam function and zeroing out momentum to simulate an RMSProp, might as well do it directly. |
Replace the inner calculate_adam_update(betas=(0.0, rms_beta)) call with a dedicated calculate_rmsprop_update (torch.optim.RMSprop with momentum=0, centered=False) and drop the now-dead exp_avg first-moment state and its eigenbasis reprojection. Addresses review feedback that the Adam-with-zeroed- momentum path was simulating RMSProp; this does it directly. Signed-off-by: Mike Chrzanowski <mchrzanowski@nvidia.com>
|
@mkhona-nvidia done in bc7ba66 — MOSO now calls a dedicated One note: I didn't wire in This does change numerics slightly vs. the old path, which bias-corrected the second moment ( |
|
/ok to test bc7ba66 |
Summary
MOSO applies a Muon-style first-moment EMA (
momentum) to the gradient before preconditioning. The inner Adam previously also exposedbeta1, adding a second, redundant momentum on the projected update direction. This double-averaging over-damps the update and measurably hurts convergence — and it was reachable by default (betas=(0.9, 0.95)).This PR removes the inner first moment entirely and makes double momentum structurally impossible: the inner optimizer is now RMSProp (
calculate_rmsprop_update, matchingtorch.optim.RMSpropwithmomentum=0, centered=False), controlled by a singlerms_beta. The now-deadexp_avgfirst-moment state and its eigenbasis reprojection are removed. There is no longer any API surface to add a second momentum.Evidence
Hybrid Mamba + 128-expert MoE, WSD schedule, per-config LR-tuned. Removing the inner first moment (
beta1 0.9 → 0):beta1=0.9)beta1=0Adam form: the two are identical after the first ~200 steps — RMSProp drops the second-moment bias correction, which only affects the earliest steps (a benign larger-step transient).Behavior / compatibility
betasis removed; userms_beta. The old(0.9, 0.95)behavior is intentionally no longer reachable.beta1=0; numerically identical after the bias-correction warmup.