You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* move sort to its own function
Signed-off-by: Hao Wu <skyw@nvidia.com>
* move eigen bases based sort to its own function and share between QR and eigh path
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: mikail <mkhona@nvidia.com>
Copy file name to clipboardExpand all lines: emerging_optimizers/utils/eig.py
+15-31Lines changed: 15 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -69,51 +69,35 @@ def eigh_with_fallback(
69
69
70
70
71
71
deforthogonal_iteration(
72
-
approx_eigvals: torch.Tensor,
73
-
kronecker_factor: torch.Tensor,
74
-
eigenbasis: torch.Tensor,
75
-
ind: int,
76
-
exp_avg_sq: torch.Tensor,
72
+
kronecker_factor: Tensor,
73
+
eigenbasis: Tensor,
77
74
power_iter_steps: int,
78
-
) ->tuple[torch.Tensor, torch.Tensor]:
79
-
"""Computes the eigenbases of the preconditioner using power iteration and QR decomposition.
75
+
) ->Tensor:
76
+
"""Refines an eigenbasis via power iteration with QR re-orthogonalization.
80
77
81
-
This function performs multiple rounds of power iteration followed by QR decomposition
82
-
to recompute the eigenbases of the preconditioner kronecker factor. Generalizes Vyas et al.'s (SOAP) algorithm of 1 step of power iteration for updating the eigenbasis.
78
+
Performs ``power_iter_steps`` rounds of ``Q = QR(kronecker_factor @ Q)`` starting from
79
+
``eigenbasis``. The columns of ``eigenbasis`` are expected to already be aligned with the
80
+
intended descending-eigenvalue ordering of ``kronecker_factor`` (see
0 commit comments