A fast implementation of the Newton-Schulz algorithm for computing matrix square roots and Gram matrix inverses, with support for JIT-compiled kernels via Quack. Current version 0.1.4, requires Python >=3.10. Released under the Dao-AILab organization, with occasional updates.
pip install gram-newton-schulzNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Compute matrix square root using Gram-Newton-Schulz algorithm.
Ensure your matrix is symmetric and has positive eigenvalues. Consider adding a small regularization term like `A + 1e-6 * torch.eye(A.shape[0])`.
Enable torch.compile by setting `torch.compile(solver.sqrt)` or using the `compile_kwargs` argument.
Replace `from gram_newton_schulz import StandardNewtonSchulz` with `from gram_newton_schulz import GramNewtonSchulz`.
Run `pip install gram-newton-schulz`. The correct import string is `from gram_newton_schulz import ...`.
Ensure both the solver (if it holds state) and input tensors are on the same device. Use `solver = GramNewtonSchulz().to(device)`.