SciML / LinearSolve.jl

LinearSolve.jl: High-Performance Unified Interface for Linear Solvers in Julia. Easily switch between factorization and Krylov methods, add preconditioners, and all in one interface.
https://docs.sciml.ai/LinearSolve/stable/
Other
245 stars 52 forks source link

precompilation warning #293

Closed t-bltg closed 1 year ago

t-bltg commented 1 year ago

On 1.9.0-rc2:

WARNING: Method definition init_cacheval(LinearSolve.GenericFactorization{F} where F, Any, Any, Any, Any, Any, Int64, Any, Any, Bool, LinearSolve.OperatorAssumptions{issq, condition} where condition where issq) in module LinearSolve at [...]/.julia/packages/LinearSolve/P5a5J/src/factorization.jl:313 overwritten at [...]/.julia/packages/LinearSolve/P5a5J/src/factorization.jl:326.
  ** incremental compilation may be fatally broken for this module **

On [7ed4a6bd] LinearSolve v1.41.1.

thomvet commented 1 year ago

Hitting the same on 1.9.0-rc1. Maybe one can make the dispatch on line 326 sharper? (excluding GenericFactorization, but keeping the cholesky variants?).

I have no deep insight into the package, but if that's workable, then I am happy to do the PR.

ChrisRackauckas commented 1 year ago

Try it. It seemed to fail when I did that, but it's time to now look at it in isolation.

thomvet commented 1 year ago

I’ll give it a try

thomvet commented 1 year ago

Hm, I don't even get to test it properly, because HYPRE errors locally when I run "test LinearSolve":

Failed to precompile HYPRE [b5ffcf37-a2bd-41ab-a3da-4bd9bc8ad771] to "C:\\Users\\username\\.julia\\compiled\\v1.9\\HYPRE\\jl_2BBF.tmp".
ERROR: LoadError: InitError: could not load library "C:\Users\username\.julia\artifacts\fdf5fc024a09684b7e5c8759b433d7c332f20560\bin\liblapack.dll"
The specified module could not be found.

This is before I have made any changes to the code, just with installing LinearSolve v.1.41.1.

Versioninfo:

Julia Version 1.9.0-rc1
Commit 3b2e0d8fbc (2023-03-07 07:51 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i5-8365U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores

Any ideas how I get past that?

fredrikekre commented 1 year ago

You can comment out https://github.com/SciML/LinearSolve.jl/blob/e3bcd87ed196255a3185840f8bb833426f28cc50/test/runtests.jl#L42-L44 (those tests are not relevant for the fix here. xref https://github.com/fredrikekre/HYPRE.jl/issues/11)

thomvet commented 1 year ago

Thanks. I also had to comment out these here due to a libblastrampoline error on Windows: https://github.com/SciML/LinearSolve.jl/blob/e3bcd87ed196255a3185840f8bb833426f28cc50/test/basictests.jl#L192-L193

My analysis so far is the following:

  1. If the definition in L326 is made tighter (i.e., removing GenericFactorization from it), then the fallback starting in L313 is used and factorization using LinearAlgebra.factorize fails with a SingularException. That makes sense, because the fallback essentially converts an identity matrix into a ones(8,8) matrix (which is singular of course). --> In my opinion the fallback is really just erroring for dense matrices (seems OK for sparse). Since nobody is complaining in other issues here, we are probably not hitting the fallback anywhere?
  2. If I comment the fallback and keep the method starting at L326 as is, tests pass and precompilation warning is gone.
  3. If I comment the fallback and the method starting at L335, tests pass as well. Same comment as above.

I'll make a PR and see whether tests pass on a non-Windows machine (will bring back the locally deactivated tests).