Skip to content

Commit 1102022

Browse files
committed
rename invere root to root inverse
Signed-off-by: Hao Wu <skyw@nvidia.com>
1 parent 5373fb2 commit 1102022

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

emerging_optimizers/shampoo/shampoo.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,18 @@ def _get_root_inverse(self, kronecker_factor: torch.Tensor) -> torch.Tensor:
148148
return (eigvecs * inv_root_scale) @ eigvecs.mT
149149

150150
def precondition(self, x: torch.Tensor) -> torch.Tensor:
151-
"""Applies both inverse roots to a matrix in the parameter basis.
151+
"""Applies both root inverse to a matrix in the parameter basis.
152152
153153
Args:
154154
x: Matrix in the parameter basis.
155155
156156
Returns:
157157
The preconditioned matrix, in the parameter basis.
158158
"""
159-
inverse_root_pair = precond_base.TensorPair(
160-
self._get_root_inverse(self.kronecker_factor_pair.L),
161-
self._get_root_inverse(self.kronecker_factor_pair.R),
162-
)
159+
root_inv_L = self._get_root_inverse(self.kronecker_factor_pair.L)
160+
root_inv_R = self._get_root_inverse(self.kronecker_factor_pair.R)
163161

164-
return inverse_root_pair.L @ x @ inverse_root_pair.R
162+
return root_inv_L @ x @ root_inv_R
165163

166164

167165
class ShampooBase(optim.Optimizer, opt_mixin.WeightDecayMixin):

0 commit comments

Comments
 (0)