Skip to content

Commit 8621d90

Browse files
committed
Merge remote-tracking branch 'origin/main' into gd/structured3
2 parents 692ff43 + d6b9e65 commit 8621d90

47 files changed

Lines changed: 4675 additions & 824 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/Benchmark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535
echo $PATH
3636
ls -l ~/.julia/bin
3737
mkdir results
38-
benchpkg ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --url=${{ github.event.repository.clone_url }} --bench-on="${{github.event.repository.default_branch}}" --output-dir=results/ --tune
38+
benchpkg ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --url=${{ github.event.repository.clone_url }} --bench-on="${{github.event.repository.default_branch}}" --output-dir=results/ --tune --add StableRNGs
3939
- name: Create markdown table from benchmarks
4040
run: |
41-
benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --input-dir=results/ --ratio > table.md
41+
benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} --mode="time,memory" --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --input-dir=results/ --ratio > table.md
4242
echo '### Benchmark Results' > body.md
4343
echo '' >> body.md
4444
echo '' >> body.md

.github/workflows/Test-GPU.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test-GPU
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
12+
13+
# needed to allow julia-actions/cache to delete old caches that it has created
14+
permissions:
15+
actions: write
16+
contents: read
17+
18+
jobs:
19+
test:
20+
runs-on: self-hosted
21+
env:
22+
CUDA_VISIBLE_DEVICES: 1
23+
JULIA_DEPOT_PATH: /scratch/github-actions/julia_depot_alexis
24+
JULIA_SMC_TEST_GROUP: "GPU"
25+
strategy:
26+
matrix:
27+
julia-version: ['1.10', '1']
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: julia-actions/setup-julia@v2
31+
with:
32+
version: ${{ matrix.julia-version }}
33+
arch: x64
34+
- uses: julia-actions/julia-downgrade-compat@v1
35+
if: ${{ matrix.version == '1.10' }}
36+
with:
37+
skip: LinearAlgebra, Random, SparseArrays
38+
- uses: julia-actions/cache@v2
39+
- uses: julia-actions/julia-buildpkg@v1
40+
- uses: julia-actions/julia-runtest@v1
41+
- uses: julia-actions/julia-processcoverage@v1
42+
- uses: codecov/codecov-action@v5
43+
with:
44+
files: lcov.info
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
fail_ci_if_error: false

.github/workflows/Test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
julia-version: ['lts', '1', 'pre']
23+
julia-version: ['1.10', '1']
2424

2525
steps:
2626
- uses: actions/checkout@v4
@@ -29,14 +29,14 @@ jobs:
2929
version: ${{ matrix.julia-version }}
3030
arch: x64
3131
- uses: julia-actions/julia-downgrade-compat@v1
32-
if: ${{ matrix.version == 'lts' }}
32+
if: ${{ matrix.version == '1.10' }}
3333
with:
3434
skip: LinearAlgebra, Random, SparseArrays
3535
- uses: julia-actions/cache@v2
3636
- uses: julia-actions/julia-buildpkg@v1
3737
- uses: julia-actions/julia-runtest@v1
3838
- uses: julia-actions/julia-processcoverage@v1
39-
- uses: codecov/codecov-action@v4
39+
- uses: codecov/codecov-action@v5
4040
with:
4141
files: lcov.info
4242
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
playground.jl
22

3+
*.png
34
*.json
45
*.json.tmp
56

@@ -28,3 +29,4 @@ docs/src/index.md
2829
# committed for packages, but should be committed for applications that require a static
2930
# environment.
3031
Manifest.toml
32+
Manifest-v*.**.toml

CITATION.cff

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This CITATION.cff file was generated with cffinit.
2+
# Visit https://bit.ly/cffinit to generate yours today!
3+
4+
cff-version: 1.2.0
5+
title: SparseMatrixColorings.jl
6+
message: >-
7+
If you use this software, please cite it using the
8+
metadata from this file.
9+
type: software
10+
authors:
11+
- given-names: Guillaume
12+
family-names: Dalle
13+
orcid: 'https://orcid.org/0000-0003-4866-1687'
14+
- given-names: Alexis
15+
family-names: Montoison
16+
orcid: 'https://orcid.org/0000-0002-3403-5450'
17+
identifiers:
18+
- type: doi
19+
value: 10.5281/zenodo.11314275
20+
description: Zenodo
21+
repository-code: 'https://github.com/gdalle/SparseMatrixColorings.jl'
22+
abstract: >-
23+
Coloring algorithms for sparse Jacobian and Hessian
24+
matrices
25+
keywords:
26+
- graph coloring
27+
- sparse matrices
28+
- automatic differentiation
29+
- julia programming language
30+
license: MIT
31+
preferred-citation:
32+
authors:
33+
- given-names: Alexis
34+
family-names: Montoison
35+
orcid: 'https://orcid.org/0000-0002-3403-5450'
36+
- given-names: Guillaume
37+
family-names: Dalle
38+
orcid: 'https://orcid.org/0000-0003-4866-1687'
39+
- given-names: Assefaw
40+
family-names: Gebremedhin
41+
orcid: 'https://orcid.org/0000-0001-5383-8032'
42+
title: "Revisiting Sparse Matrix Coloring and Bicoloring"
43+
year: 2025
44+
type: article
45+
url: 'https://arxiv.org/abs/2505.07308'
46+
identifiers:
47+
- type: doi
48+
value: 10.48550/arXiv.2505.07308
49+
description: Arxiv
50+
abstract: "Sparse matrix coloring and bicoloring are fundamental building blocks of sparse automatic differentiation. Bicoloring is particularly advantageous for rectangular Jacobian matrices with at least one dense row and column. Indeed, in such cases, unidirectional row or column coloring demands a number of colors equal to the number of rows or columns. We introduce a new strategy for bicoloring that encompasses both direct and substitution-based decompression approaches. Our method reformulates the two variants of bicoloring as star and acyclic colorings of an augmented symmetric matrix. We extend the concept of neutral colors, previously exclusive to bicoloring, to symmetric colorings, and we propose a post-processing routine that neutralizes colors to further reduce the overall color count. We also present the Julia package SparseMatrixColorings, which includes these new bicoloring algorithms alongside all standard coloring methods for sparse derivative matrix computation. Compared to ColPack, the Julia package also offers enhanced implementations for star and acyclic coloring, vertex ordering, as well as decompression."

Project.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
name = "SparseMatrixColorings"
22
uuid = "0a514795-09f3-496d-8182-132a7b665d35"
33
authors = ["Guillaume Dalle", "Alexis Montoison"]
4-
version = "0.4.6"
4+
version = "0.4.21"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
8-
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
9-
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
108
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
119
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
10+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1211
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
13-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1412
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1513

1614
[weakdeps]
1715
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
1816
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
1917
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
18+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
19+
CliqueTrees = "60701a23-6482-424a-84db-faee86b9b1f8"
20+
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
2021

2122
[extensions]
2223
SparseMatrixColoringsBandedMatricesExt = "BandedMatrices"
2324
SparseMatrixColoringsBlockBandedMatricesExt = ["BlockArrays", "BlockBandedMatrices"]
25+
SparseMatrixColoringsCUDAExt = "CUDA"
26+
SparseMatrixColoringsCliqueTreesExt = "CliqueTrees"
27+
SparseMatrixColoringsColorsExt = "Colors"
2428

2529
[compat]
2630
ADTypes = "1.2.1"
2731
BandedMatrices = "1.7.5"
2832
BlockArrays = "1.1.1"
2933
BlockBandedMatrices = "0.13.1"
30-
Compat = "3.46,4.2"
31-
DataStructures = "0.18"
32-
LinearAlgebra = "<0.0.1, 1"
34+
CUDA = "5.8.2"
35+
CliqueTrees = "1"
36+
Colors = "0.12.11, 0.13"
3337
DocStringExtensions = "0.8,0.9"
38+
LinearAlgebra = "<0.0.1, 1"
39+
PrecompileTools = "1.2.1"
3440
Random = "<0.0.1, 1"
35-
Requires = "1.3.0"
3641
SparseArrays = "<0.0.1, 1"
37-
julia = "1.6"
38-
39-
[extras]
40-
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
41-
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
42-
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
42+
julia = "1.10"

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Dev Documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://gdalle.github.io/SparseMatrixColorings.jl/dev/)
66
[![Coverage](https://codecov.io/gh/gdalle/SparseMatrixColorings.jl/branch/main/graph/badge.svg)](https://app.codecov.io/gh/gdalle/SparseMatrixColorings.jl)
77
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/JuliaDiff/BlueStyle)
8+
[![arXiv](https://img.shields.io/badge/arXiv-2505.07308-b31b1b.svg)](https://arxiv.org/abs/2505.07308)
89
[![DOI](https://zenodo.org/badge/801999408.svg)](https://zenodo.org/doi/10.5281/zenodo.11314275)
910

1011
Coloring algorithms for sparse Jacobian and Hessian matrices.
@@ -19,7 +20,11 @@ pkg> add SparseMatrixColorings
1920

2021
## Background
2122

22-
The algorithms implemented in this package are taken from the following articles:
23+
The algorithms implemented in this package are described in the following preprint:
24+
25+
- [_Revisiting Sparse Matrix Coloring and Bicoloring_](https://arxiv.org/abs/2505.07308), Montoison et al. (2025)
26+
27+
and inspired by previous works:
2328

2429
- [_What Color Is Your Jacobian? Graph Coloring for Computing Derivatives_](https://epubs.siam.org/doi/10.1137/S0036144504444711), Gebremedhin et al. (2005)
2530
- [_New Acyclic and Star Coloring Algorithms with Application to Computing Hessians_](https://epubs.siam.org/doi/abs/10.1137/050639879), Gebremedhin et al. (2007)
@@ -35,5 +40,18 @@ Some parts of the articles (like definitions) are thus copied verbatim in the do
3540

3641
## Citing
3742

38-
Please cite this software using the Zenodo DOI of the version you used.
39-
The link <https://zenodo.org/doi/10.5281/zenodo.11314275> resolves to the latest version.
43+
Please cite this software using the provided `CITATION.cff` file or the `.bib` entry below:
44+
45+
```bibtex
46+
@unpublished{montoison2025revisitingsparsematrixcoloring,
47+
title={Revisiting Sparse Matrix Coloring and Bicoloring},
48+
author={Alexis Montoison and Guillaume Dalle and Assefaw Gebremedhin},
49+
year={2025},
50+
eprint={2505.07308},
51+
archivePrefix={arXiv},
52+
primaryClass={math.NA},
53+
url={https://arxiv.org/abs/2505.07308},
54+
}
55+
```
56+
57+
The link <https://zenodo.org/doi/10.5281/zenodo.11314275> resolves to the latest version on Zenodo.

benchmark/benchmarks.jl

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,78 @@
11
using BenchmarkTools
22
using LinearAlgebra
33
using SparseMatrixColorings
4+
import SparseMatrixColorings as SMC
45
using SparseArrays
6+
using StableRNGs
57

68
SUITE = BenchmarkGroup()
79

810
for structure in [:nonsymmetric, :symmetric],
9-
partition in (structure == :nonsymmetric ? [:column, :row] : [:column]),
10-
decompression in (structure == :nonsymmetric ? [:direct] : [:direct, :substitution]),
11+
partition in (structure == :nonsymmetric ? [:column, :row, :bidirectional] : [:column]),
12+
decompression in (
13+
if (structure == :nonsymmetric && partition in [:column, :row])
14+
[:direct]
15+
else
16+
[:direct, :substitution]
17+
end
18+
),
1119
n in [10^3, 10^5],
1220
p in [2 / n, 5 / n, 10 / n]
1321

1422
problem = ColoringProblem(; structure, partition)
15-
algo = GreedyColoringAlgorithm(; decompression)
16-
17-
SUITE[:coloring][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable coloring(
18-
A, $problem, $algo
19-
) setup = ( #
20-
A = sparse(Symmetric(sprand($n, $n, $p)))
23+
algo = GreedyColoringAlgorithm(
24+
RandomOrder(StableRNG(0), 0); decompression, postprocessing=true
2125
)
2226

23-
SUITE[:decompress][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable decompress(
24-
B, result
25-
) setup = ( #
26-
A = sparse(Symmetric(sprand($n, $n, $p)));
27-
result = coloring(A, $problem, $algo);
28-
B = compress(A, result)
29-
)
27+
# use several random matrices to reduce variance
28+
nb_samples = 5
29+
As = [sparse(Symmetric(sprand(StableRNG(i), Bool, n, n, p))) for i in 1:nb_samples]
30+
results = [coloring(A, problem, algo; decompression_eltype=Float64) for A in As]
31+
Bs = [compress(Float64.(A), result) for (A, result) in zip(As, results)]
32+
33+
bench_col = @benchmarkable begin
34+
for A in $As
35+
coloring(A, $problem, $algo)
36+
end
37+
end
38+
39+
bench_dec = @benchmarkable begin
40+
for (B, result) in zip($Bs, $results)
41+
if B isa AbstractMatrix
42+
decompress(B, result)
43+
elseif B isa Tuple
44+
decompress(B[1], B[2], result)
45+
end
46+
end
47+
end
48+
49+
SUITE[:coloring][structure][partition][decompression]["n=$n"]["p=$p"] = bench_col
50+
SUITE[:decompress][structure][partition][decompression]["n=$n"]["p=$p"] = bench_dec
51+
end
52+
53+
for structure in [:nonsymmetric, :symmetric],
54+
partition in (structure == :nonsymmetric ? [:column, :row] : [:column]),
55+
order in [LargestFirst(), SmallestLast(), IncidenceDegree(), DynamicLargestFirst()],
56+
n in [10^3, 10^5],
57+
p in [2 / n, 5 / n, 10 / n]
58+
59+
nb_samples = 5
60+
As = [sparse(Symmetric(sprand(StableRNG(i), Bool, n, n, p))) for i in 1:nb_samples]
61+
if structure == :symmetric
62+
gs = [SMC.AdjacencyGraph(A) for A in As]
63+
bench_ord = @benchmarkable begin
64+
for g in $gs
65+
SMC.vertices(g, $order)
66+
end
67+
end
68+
else
69+
gs = [SMC.BipartiteGraph(A) for A in As]
70+
valside = partition == :row ? Val(1) : Val(2)
71+
bench_ord = @benchmarkable begin
72+
for g in $gs
73+
SMC.vertices(g, $valside, $order)
74+
end
75+
end
76+
end
77+
SUITE[:order][structure][partition][string(order)]["n=$n"]["p=$p"] = bench_ord
3078
end

docs/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
[deps]
22
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
3+
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
34
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
45
DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656"
6+
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
57
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
8+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
9+
10+
[sources]
11+
SparseMatrixColorings = {path=".."}

docs/make.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ makedocs(;
1111
authors="Guillaume Dalle and Alexis Montoison",
1212
sitename="SparseMatrixColorings.jl",
1313
format=Documenter.HTML(),
14-
pages=["Home" => "index.md", "api.md", "dev.md"],
14+
pages=[
15+
"Home" => "index.md",
16+
"tutorial.md",
17+
"api.md",
18+
"Developer Documentation" => ["dev.md", "vis.md"],
19+
],
1520
plugins=[links],
1621
)
1722

18-
deploydocs(; repo="github.com/gdalle/SparseMatrixColorings.jl", devbranch="main")
23+
deploydocs(;
24+
repo="github.com/gdalle/SparseMatrixColorings.jl", push_preview=true, devbranch="main"
25+
)

0 commit comments

Comments
 (0)