Better numerical warnings for Cholesky
@@ -43,10 +43,11 @@ def psd_safe_cholesky(A, upper=False, out=None, jitter=None, max_tries=3):
jitter_prev = jitter_new
try:
L = torch.cholesky(Aprime, upper=upper, out=out)
- warnings.warn(f"A not p.d., added jitter of {jitter_new} to the diagonal", NumericalWarning)
+ warnings.warn(f"A not p.d., added jitter of {jitter_new:.1e} to the diagonal", NumericalWarning)
return L
except RuntimeError:
continue
raise NotPSDError(
- f"Matrix not positive definite after repeatedly adding jitter. Original error on first attempt: {e}"
+ f"Matrix not positive definite after repeatedly adding jitter up to {jitter_new:.1e}. "
+ f"Original error on first attempt: {e}"
)
