JuliaSmoothOptimizers/QRMumps.jl

Corrupted unsorted chunks on sparse array

Closed this issue · 4 comments

cols.txt
rows.txt
vals.txt

In a problem, I had the following representation of some matrix $A \in \mathbb{R}^{ 361\times 802}$. I have an issue which I think comes from QRMumps. Here is a minimal working example (the .txt files are attached):

using QRMumps, DelimitedFiles
n = 802
m = 361

rows = dropdims(readdlm("rows.txt",Int64);dims =2)
cols = dropdims(readdlm("cols.txt",Int64);dims =2)
vals = dropdims(readdlm("vals.txt");dims =2)

spmat = qrm_spmat_init(m,n,rows,cols,vals; sym=false)
spfct = qrm_spfct_init(spmat)
qrm_analyse!(spmat, spfct; transp='t')

returns the error message

free(): corrupted unsorted chunks

[10334] signal (6.-6): Aborted

I have tried this on both Julia 1.10.3 and 1.10.2. I get similar errors on both Linux and Windows, here is my versioninfo() on Ubuntu:

Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)

Have you ever seen similar errors ?
I don't know if this is useful but if I cast my sparse array $A$ back to a dense array and then back again to a sparse one I no longer have the error:

A = SparseMatrixCOO(Matrix(SparseMatrixCOO(m,n,rows,cols,vals)))


spmat = qrm_spmat_init(A; sym=false)
spfct = qrm_spfct_init(spmat)
qrm_analyse!(spmat, spfct; transp='t')

I can reproduce the error:

using QRMumps, DelimitedFiles
m = 361
n = 802

rows = readdlm("rows.txt",Int32)[:]
cols = readdlm("cols.txt",Int32)[:]
vals = readdlm("vals.txt")[:]

spmat = qrm_spmat_init(m,n,rows,cols,vals; sym=false)
spfct = qrm_spfct_init(spmat)
qrm_analyse!(spmat, spfct; transp='t')

I don't have any error with a SparseMatrixCSC:

using QRMumps, DelimitedFiles
m = 361
n = 802

rows = readdlm("rows.txt",Int32)[:]
cols = readdlm("cols.txt",Int32)[:]
vals = readdlm("vals.txt")[:]
A = sparse(rows, cols, vals)

spmat = qrm_spmat_init(A; sym=false)
spfct = qrm_spfct_init(spmat)
qrm_analyse!(spmat, spfct; transp='t')

If we drop the zeros it works:

using QRMumps, DelimitedFiles
m = 361
n = 802

rows = readdlm("rows.txt",Int32)[:]
cols = readdlm("cols.txt",Int32)[:]
vals = readdlm("vals.txt")[:]
A = sparse(rows, cols, vals)
rows, cols, vals = findnz(A)

spmat = qrm_spmat_init(m,n,rows,cols,vals; sym=false)
spfct = qrm_spfct_init(spmat)
qrm_analyse!(spmat, spfct; transp='t')

Ok, I found the culprit.
You have duplicate entries in your sparse matrix in COO format (rows, cols, vals).
qr_mumps can't handle them:

julia> t = Tuple{Int32, Int32, Float64}[]
Tuple{Int32, Int32, Float64}[]

julia> for i = 1 : 11252
  push!(t, (rows[i], cols[i], vals[i]))
end

julia> t
11252-element Vector{Tuple{Int32, Int32, Float64}}:
 ...

julia> unique(t)
6274-element Vector{Tuple{Int32, Int32, Float64}}:
...

Many thanks !!
This array came from the package PDENLPModels.jl, I am opening an issue there to fix this.

dpo commented

@abuttari This is the discussion where it appears QRMumps does not support duplicate entries in COO format, which I found quite surprising.