Skip to content

Commit fe9a22a

Browse files
committed
removed extra args from moso
Signed-off-by: mikail <mkhona@nvidia.com>
1 parent 5bceeca commit fe9a22a

2 files changed

Lines changed: 13 additions & 33 deletions

File tree

emerging_optimizers/soap/moso.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ class MOSO(opt_mixin.WeightDecayMixin, optim.Optimizer):
6161
shampoo_beta: EMA coefficient for the one-sided momentum covariance.
6262
eps: Inner Adam epsilon for numerical stability.
6363
weight_decay: Weight decay coefficient.
64-
weight_decay_method: Method to apply weight decay, see :class:`~emerging_optimizers.mixin.WeightDecayMixin`.
65-
nesterov: Whether to use Nesterov momentum.
66-
correct_bias: Whether to use bias correction in the inner Adam update.
67-
correct_shampoo_beta_bias: Whether to bias-correct the covariance EMA.
68-
fp32_matmul_prec: Precision of the matmul operations in optimizer state GEMMs.
69-
use_eigh: Whether to use full symmetric eigendecomposition for eigenbasis updates after the first step.
70-
qr_fp32_matmul_prec: Precision of the matmul operations in QR decomposition.
71-
power_iter_steps: Number of power iteration steps to perform before QR decomposition.
7264
scale_mode: Muon update scale mode.
7365
extra_scale_factor: Additional update scale factor.
7466
max_update_rms: Clip the update RMS to this value (0 means no clipping).
@@ -84,26 +76,18 @@ def __init__(
8476
eps: float = 1e-8,
8577
weight_decay: float = 0.01,
8678
*,
87-
weight_decay_method: opt_mixin.WeightDecayT = "decoupled",
88-
nesterov: bool = False,
89-
correct_bias: bool = True,
90-
correct_shampoo_beta_bias: bool = True,
91-
fp32_matmul_prec: FP32MatmulPrecT = "highest",
92-
use_eigh: bool = False,
93-
qr_fp32_matmul_prec: FP32MatmulPrecT = "high",
94-
power_iter_steps: int = 1,
9579
scale_mode: MuonScaleT = "spectral",
9680
extra_scale_factor: float = 1.0,
9781
max_update_rms: float = 0.0,
9882
) -> None:
99-
self.nesterov = nesterov
100-
self.correct_bias = correct_bias
101-
self.weight_decay_method = weight_decay_method
102-
self.correct_shampoo_beta_bias = correct_shampoo_beta_bias
103-
self.fp32_matmul_prec = fp32_matmul_prec
104-
self.use_eigh = use_eigh
105-
self.qr_fp32_matmul_prec = qr_fp32_matmul_prec
106-
self.power_iter_steps = power_iter_steps
83+
self.nesterov = False
84+
self.correct_bias = True
85+
self.weight_decay_method = "decoupled"
86+
self.correct_shampoo_beta_bias = True
87+
self.fp32_matmul_prec: FP32MatmulPrecT = "highest"
88+
self.use_eigh = False
89+
self.qr_fp32_matmul_prec: FP32MatmulPrecT = "highest"
90+
self.power_iter_steps = 1
10791
self.scale_mode = scale_mode
10892
self.extra_scale_factor = extra_scale_factor
10993
self.max_update_rms = max_update_rms

tests/test_moso.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ def setUpModule() -> None:
3535

3636

3737
class MOSOTest(parameterized.TestCase):
38-
@parameterized.product( # type: ignore[misc]
39-
shape=[(5, 3), (3, 5), (4, 4)],
40-
use_eigh=[True, False],
38+
@parameterized.parameters( # type: ignore[misc]
39+
{"shape": (5, 3)},
40+
{"shape": (3, 5)},
41+
{"shape": (4, 4)},
4142
)
42-
def test_3steps_smoke(self, shape: tuple[int, int], use_eigh: bool) -> None:
43+
def test_3steps_smoke(self, shape: tuple[int, int]) -> None:
4344
param = torch.randn(shape, requires_grad=True, device=FLAGS.device)
4445
optimizer = MOSO(
4546
[param],
4647
lr=0.001,
4748
weight_decay=0.01,
4849
momentum=0.9,
4950
shampoo_beta=0.95,
50-
use_eigh=use_eigh,
5151
)
5252

5353
for _ in range(3):
@@ -72,7 +72,6 @@ def test_accumulates_momentum_covariance_on_smaller_side(self, shape: tuple[int,
7272
momentum=0.0,
7373
shampoo_beta=0.0,
7474
weight_decay=0.0,
75-
correct_shampoo_beta_bias=False,
7675
)
7776

7877
optimizer.step()
@@ -107,9 +106,6 @@ def test_no_ema_is_close_to_one_sided_adam_in_eigenbasis(self, shape: tuple[int,
107106
shampoo_beta=0.0,
108107
eps=1e-12,
109108
weight_decay=0.0,
110-
correct_shampoo_beta_bias=False,
111-
correct_bias=False,
112-
fp32_matmul_prec="highest",
113109
scale_mode="spectral",
114110
)
115111

0 commit comments

Comments
 (0)