ACEsuit / ACEfit.jl

Generic Codes for Fitting ACE models
MIT License
7 stars 6 forks source link

Catch Exception in BLR #72

Open cortner opened 11 months ago

cortner commented 11 months ago

The following error seems to occur quite frequently:

ERROR: LoadError: PosDefException: matrix is not positive definite; Cholesky factorization failed.
Stacktrace:
  [1] checkpositivedefinite
    @ ~/julia-1.9.3/share/julia/stdlib/v1.9/LinearAlgebra/src/factorization.jl:18 [inlined]
  [2] #cholesky!#152
    @ ~/julia-1.9.3/share/julia/stdlib/v1.9/LinearAlgebra/src/cholesky.jl:268 [inlined]
  [3] cholesky! (repeats 2 times)
    @ ~/julia-1.9.3/share/julia/stdlib/v1.9/LinearAlgebra/src/cholesky.jl:266 [inlined]
  [4] log_marginal_likelihood_overdetermined!(lml::Float64, grad::Vector{Float64}, X::Matrix{Float64}, y::Vector{Float64}, var_c::Vector{Float64}, var_e::Float64, XTX::Matrix{Float64})
    @ ACEfit.BayesianLinear ~/miniconda3/envs/ase_env/share/julia/packages/ACEfit/eR8hX/src/bayesianlinear.jl:285
.... 

and it keeps going for a while. Maybe this could be caught with a nicer error message explaining what might have gone wrong and what to try next, e.g. adding better data or trying a different solver.

If the solver can be fixed to actually handle this case, even better.

YuanbinLiu commented 4 months ago

I also encountered this issue recently. Has it been resolved? Could it be a solution to change BLR to LSQR?

wcwitt commented 4 months ago

This definitely does need better error handling and a more helpful message. I can't do it today but will push something later this week.