Upper Cholesky factor / use transposes in `rankUpdate!` ?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- julia
- Domain
- performance
Research direction
Start with the rankUpdate! implementation shown in the issue and review the surrounding sparse Cholesky update code. Compare the proposed upper-factor and transpose-based approaches for the dense result, using benchmarks to determine whether the change improves fitting time without changing results.
Written by the indexing model from the issue text.
Description
Copying some discussion from the Julia Slack.
@dmbates wrote:
We have recently begun working with a large data set to stress-test the MixedModels.jl package. Essentially all the time to fit a large model is spent in updating a blocked Cholesky factor. In this example the blocks are of the form
julia> BlockDescription(m4)
rows: item subj fixed
323812: BlkDiag
3172: Sparse BlkDiag/Dense
17: Dense Dense Dense
The [1,1] block is by far the largest but it is block-diagonal with small (4 by 4) blocks. The bottleneck seems to be updating the [2,2] block from the [2,1] block. The [2,2] block is stored as dense even though it starts out as block diagonal with small blocks, like the [1,1] block. We need to evaluate the lower triangle of B22 -= B21*B21' and right now are doing so with this code
function rankUpdate!(C::HermOrSym{T,S}, A::SparseMatrixCSC{T}, α, β) where {T,S}
A.m == size(C, 2) || throw(DimensionMismatch())
C.uplo == 'L' || throw(ArgumentError("C.uplo must be 'L'"))
Cd, rv, nz = C.data, rowvals(A), nonzeros(A)
isone(β) || rmul!(LowerTriangular(Cd), β)
@inbounds for jj in 1:(A.n)
rangejj = nzrange(A, jj)
lenrngjj = length(rangejj)
for (k, j) in enumerate(rangejj)
anzj = α * nz[j]
colj = view(Cd, :, rv[j])
for i in k:lenrngjj
kk = rangejj[i]
colj[rv[kk]] += nz[kk] * anzj
end
end
end
return C
end
On looking at this it seems that we may be better off using the blocked upper Cholesky factor. For the SparseMatrixCSC type I think it is easier and faster to evaluate A'A than AA' because you can collect the inner products of the sparse columns in a temporary location. The penalty we are paying in this way of evaluating AA' is that each product is being written out to memory. If I recall correctly it is also true for column-major dense matrices that evaluating A'A is faster than A*A'.
Tim Davis followed up:
If the result C for C =A'*A is dense (or can be represented in bitmap form efficiently) then the dot products work well. If C is large and sparse then using n^2 dot products is very costly, if C is n by n. Unless the pattern of C is known; then it can be used as a mask to compute C=A' times A and that is very fast.
@dmbates noted that C is indeed dense and Tim added one more note:
Only downside is that dot products are not work optimal. So sometimes they can be slower.
How sparse are the vectors in that B22 matrix? The sparse dot product (cij = A(:,i)' * B(:,j)) where A and B are CSC is delicate, since it's not work-optimal. I have several methods I use, depending on the sparsity of A(:,i) compared with B(:,j): merge-like, binary-search, etc. The code is more complex than the Full += CSC * CSC' code you have above in the rankUpdate. Here to the end of this file: https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/64f6971169877eecc601b23d7115aef8d6b3ea07/Source/Template/GB_AxB_dot_cij.c#L253 . Forgive the macros hiding the computations ... that's templates in pure C. (edited)
- Dominant language
- Julia
- Stars
- 455
- Forks
- 51
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaStats/MixedModels.jl
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
JuliaStats/MixedModels.jl#905 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
JuliaStats/MixedModels.jl#877 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
JuliaStats/MixedModels.jl#868 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
JuliaStats/MixedModels.jl#830 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
JuliaStats/MixedModels.jl#820 · 8 comments ·
All issues in JuliaStats/MixedModels.jl
Similar issues
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
path: splitext treats directory references and leading dots as extensionsPossibly taken @Hiten0305l claimed this today. Open
Difficulty 2/5 Half a day Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
JuliaRegistries/RegistryCI.jl#758 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaParallel/Hwloc.jl#93 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day