Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken dtype detection in CHOLMOD in 1.11 #585

Open
pawel-tarasiuk-quantumz opened this issue Nov 20, 2024 · 2 comments · May be fixed by #586
Open

Broken dtype detection in CHOLMOD in 1.11 #585

pawel-tarasiuk-quantumz opened this issue Nov 20, 2024 · 2 comments · May be fixed by #586

Comments

@pawel-tarasiuk-quantumz

Computing qr factorization on SparseMatrixCSC{Float32} causes an error with Julia 1.11:

using SparseArrays, LinearAlgebra
A = sprandn(Float32, 10, 10, 0.5)
qr(Float64.(A))  # works proprely
qr(A)   # !!!

Message:

ERROR: SparseArrays.CHOLMOD.CHOLMODException("dtype=0 not supported")
Stacktrace:
 [1] SparseArrays.CHOLMOD.Dense{Float32}(ptr::Ptr{SparseArrays.LibSuiteSparse.cholmod_dense_struct})
   @ SparseArrays.CHOLMOD ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/SparseArrays/src/solvers/cholmod.jl:276
 [2] qr(A::SparseMatrixCSC{Float32, Int64}; tol::Float32, ordering::Int32)
   @ SparseArrays.SPQR ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/SparseArrays/src/solvers/spqr.jl:209
 [3] qr(A::SparseMatrixCSC{Float32, Int64})
   @ SparseArrays.SPQR ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/SparseArrays/src/solvers/spqr.jl:195
 [4] top-level scope
   @ REPL[4]:1

Tested on clean Julia 1.11 setup with juliaup on Ubuntu 22.04, x86_64. Eqivalent setup with Julia 1.10 works for either element type.

It would seem that

HTau = Ref{Ptr{CHOLMOD.cholmod_dense}}(C_NULL)
does not indicate the proper dtype, as unsafe_load(HTau[]).dtype is 0 when run for either type. This is incidentally equal to CHOLMOD_DOUBLE, which allows the computation for Float64.

@ViralBShah
Copy link
Member

Thanks! If you have a PR, much appreciated!

@pawel-tarasiuk-quantumz
Copy link
Author

pawel-tarasiuk-quantumz commented Nov 21, 2024

Since dtype mismatch is possible, it might be worth it to support varied results with no assumptions, as proposed in #586.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants