FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Optimized implementation for structured matrices V2 by ErikQQY · Pull Request #319 · JuliaDiff/SparseMatrixColorings.jl · GitHub

Optimized implementation for structured matrices V2 - #319

Draft
ErikQQY wants to merge 2 commits into
JuliaDiff:mainfrom
ErikQQY:qqy/structured3
Draft

Optimized implementation for structured matrices V2#319
ErikQQY wants to merge 2 commits into
JuliaDiff:mainfrom
ErikQQY:qqy/structured3

Conversation

ErikQQY commented Apr 29, 2026

Copy link
Copy Markdown

Basically #139 with new implementations

end
return SMC.BipartiteGraph(S1, S2)
end

ErikQQY Apr 29, 2026
edited
Loading

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@gdalle For now I just want to make sure the structured coloring algorithms working for Diagonal, Bidiagonal and Tridiagonal matrices, but it turns out we still need to make transpose to be GPU-compatiable to allow colorings and decompression. Do these implementations look resonable to you, if do, I will continue on this direction.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

See above, I think I need additional context to understand what you did here

gdalle marked this pull request as draft May 10, 2026 08:54

gdalle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for getting this started!

Comment on lines +274 to +276
B_rcolor_indices = mod1.(
(row_shift + 1):(row_shift + maximum(row_colors(res))), length(colorscheme)
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If possible, it's better to avoid formatting changes that only add noise

Comment thread src/graph.jl
Comment on lines +20 to +21
colptr::AbstractVector{Ti}
rowval::AbstractVector{Ti}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is a really bad idea because it will introduce type instability throughout the coloring and decompression algorithms. Can you explain why you deem it necessary?
I hope the tests catch it, if not we need more type stability tests with JET

silent && set_silent(model)
# one variable per vertex to color, removing some renumbering symmetries
@variable(model, 1 <= color[i=1:n] <= i, Int)
@variable(model, 1 <= color[i = 1:n] <= i, Int)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same comment about formatting noise

Comment thread test/utils.jl
if VERSION >= v"1.10" || A isa Union{Diagonal,Bidiagonal,Tridiagonal}
# banded matrices not supported by ArrayInterface on Julia 1.6
# @test color == ArrayInterface.matrix_colors(A) # TODO: uncomment
if algo isa StructuredColoringAlgorithm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We should also restrict this to the matrix types that ArrayInterface supports

Comment thread test/utils.jl
# banded matrices not supported by ArrayInterface on Julia 1.6
# @test color == ArrayInterface.matrix_colors(A) # TODO: uncomment
if algo isa StructuredColoringAlgorithm
@test color == ArrayInterface.matrix_colors(A)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We may also want to test that decompression returns a matrix of the correct type

Comment thread src/structured.jl
Comment on lines +69 to +75
function decompress!(A::Diagonal, B::AbstractMatrix, result::RowColoringResult)
color = row_colors(result)
for i in axes(A, 1)
A[i, i] = B[color[i], i]
end
return A
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This will not work for a Diagonal matrix stored on GPU. My idea was that we could vectorize index accesses like we do for the CSC/CSR formats on GPU, and then do something like

diag(A) .= getindex.(B, color, 1:n)

Comment on lines +14 to +20
for R in (:Diagonal, :Bidiagonal, :Tridiagonal)
@eval function SMC.BipartiteGraph(
A::$R{T,<:CuArray}; symmetric_pattern::Bool=false
) where {T}
return SMC.BipartiteGraph(CuSparseMatrixCSC(A); symmetric_pattern)
end
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why is this necessary? The coloring will take place on the CPU anyway so I don't see why we would need a GPU-based graph structure

end
return SMC.BipartiteGraph(S1, S2)
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

See above, I think I need additional context to understand what you did here

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL