Skip to content

Broken dtype detection in CHOLMOD in 1.11 #585

@pawel-tarasiuk-quantumz

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions