Skip to content

Commit 14a502c

Browse files
authored
Merge branch 'main' into skyw/remove-fstring-in-log
2 parents 540af3f + cfde876 commit 14a502c

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

emerging_optimizers/orthogonalized_optimizers/muon_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ def newton_schulz(
215215
if not normalize_in_double:
216216
X = torch.nn.functional.normalize(x, p=2, dim=(-2, -1), eps=eps) # type: ignore[arg-type]
217217
else:
218-
# eps is ignored when normalize in double.
218+
# eps is ignored when normalize in double so that zero division can happen if norm is exact 0.
219+
# However, if norm is 0 in double precision, it means the entire input is 0, which usually
220+
# suggests something wrong has happened in training. So we don't guard it here.
219221
norm = torch.linalg.vector_norm(x, dim=(-2, -1), keepdim=True, dtype=torch.float64).to(x.dtype)
220222
X = x / norm
221223

tests/soap_reference.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,6 @@ def update_preconditioner(self, grad, state, max_precond_dim=10000, merge_dims=F
278278
state["exp_avg"], state, merge_dims=merge_dims, max_precond_dim=max_precond_dim
279279
)
280280

281-
# print("wtf1", state["exp_avg"])
282-
283281
def project_back(self, grad, state, merge_dims=False, max_precond_dim=10000):
284282
"""
285283
Projects the gradient back to the original space.

0 commit comments

Comments
 (0)