-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Cholesky factorization of SparseMatrixCSC{BigFloat,Int} fails #374
Comments
Slightly more information: The linked |
So far, I think it has been the view that the generic fallback would be so slow for sparse matrices that it wouldn't be an attractive solution. I hope that https://github.com/weijianzhang/Multifrontal.jl eventually will be a candidate for a generic alternative to CHOLMOD. I haven't tried it lately so I don't know that status. Regarding |
Though I appreciate that argument, legitimate use cases exist where suboptimal runtime is not important. For example, runtime often matters little when prototyping or coding exploratorily, but that operations work does matter. Another concrete example: When teaching with, demo'ing, or learning Julia, having operations generally work, no matter runtime, is valuable. (These are both concrete instances of the abstract situation described in JuliaLang/julia#15568 (comment) second block, beginning 'This is really nicely stated!'. I make a more thorough argument for the preceding position in that comment.) Best! |
How would applying the current generic implementation (which is not at all designed with sparsity in mind) to a sparse input compare to first converting the input to dense? This is the type of thing that SciPy has sparse performance warnings for. |
The performance difference is less than one might imagine. For example, below I compare applying the current generic cholesky implementation to julia> VERSION
v"0.6.0-dev.987"
julia> using BenchmarkTools
julia> function relcost(A)
sparseA = Hermitian(SparseMatrixCSC(A), :U)
denseA = Hermitian(Array(A), :U)
sb = @benchmarkable Base.LinAlg.chol!(x) setup=(x = copy($sparseA))
db = @benchmarkable Base.LinAlg.chol!(x) setup=(x = copy($denseA))
# can't tune!(sb/db) due to https://github.com/JuliaCI/BenchmarkTools.jl/issues/24
warmup(sb)
warmup(db)
sbr = run(sb)
dbr = run(db)
ratio(median(sbr), median(dbr))
end
relcost (generic function with 1 method)
julia> centraldiff(N) = SymTridiagonal(fill(BigFloat(2), N), fill(BigFloat(-1), N-1))
centraldiff (generic function with 1 method)
julia> arrowhead(N) = (A = N*eye(BigFloat, N); A[2:end, 1] = 1; A[1, 2:end] = 1; A)
arrowhead (generic function with 1 method)
julia> relcost(centraldiff(10))
BenchmarkTools.TrialRatio:
time: 2.086049883333711
gctime: 1.0
memory: 1.9538632573652028
allocs: 1.9530685920577617
time tolerance: 5.00%
memory tolerance: 1.00%
julia> relcost(centraldiff(100))
BenchmarkTools.TrialRatio:
time: 2.145691787873939
gctime: 1.996690587140026
memory: 2.4467762510528224
allocs: 2.446774772220918
time tolerance: 5.00%
memory tolerance: 1.00%
julia> relcost(centraldiff(500))
BenchmarkTools.TrialRatio:
time: 1.5364927471228857
gctime: 1.5199039968667396
memory: 2.4894690116430507
allocs: 2.489468999306479
time tolerance: 5.00%
memory tolerance: 1.00%
julia> relcost(arrowhead(10))
BenchmarkTools.TrialRatio:
time: 1.3626963460730785
gctime: 1.0
memory: 1.1586066333148046
allocs: 1.0914560770156438
time tolerance: 5.00%
memory tolerance: 1.00%
julia> relcost(arrowhead(100))
BenchmarkTools.TrialRatio:
time: 1.1750865474464056
gctime: 0.9891396374134706
memory: 1.0227380105450325
allocs: 1.0143392671795848
time tolerance: 5.00%
memory tolerance: 1.00%
julia> relcost(arrowhead(500))
BenchmarkTools.TrialRatio:
time: 1.2188040436060177
gctime: 0.9818427271420406
memory: 1.004373821851527
allocs: 1.0029731595057436
time tolerance: 5.00%
memory tolerance: 1.00% |
This needs a full sparse solver - something that we are unlikely to have in Base. It is best done in an external package. |
cholfact
does not fall back to the generic Cholesky implementation forSparseMatrixCSC{BigFloat,Int}
:The signature here might be too permissive. Best!
The text was updated successfully, but these errors were encountered: