Skip to content

Commit b262365

Browse files
authored
Use SparseMatrixColorings (#270)
* Use SparseMatrixColorings * Add docs * Fix * Compat * Fix signature * Docs * Clean up tests * Name tests * Fix * Shorten * Fixes * Fix * Add out of place sparse stuff * Update SCT
1 parent cebfca6 commit b262365

Some content is hidden

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

43 files changed

+340
-701
lines changed

.github/workflows/Test.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ concurrency:
1717
jobs:
1818

1919
test-DI:
20-
name: DI (${{ matrix.group }}) - Julia ${{ matrix.version }}
20+
name: DI (${{ matrix.group }}) - ${{ matrix.version }}
2121
runs-on: ubuntu-latest
2222
timeout-minutes: 60
2323
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
@@ -77,6 +77,8 @@ jobs:
7777
arch: x64
7878
- uses: julia-actions/cache@v2
7979
- uses: julia-actions/julia-buildpkg@v1
80+
- name: Update registry
81+
run: julia -e 'using Pkg; Pkg.Registry.update()'
8082
- uses: julia-actions/julia-runtest@v1
8183
with:
8284
project: ./DifferentiationInterface
@@ -92,7 +94,7 @@ jobs:
9294
fail_ci_if_error: true
9395

9496
test-DIT:
95-
name: DIT - Julia ${{ matrix.version }}
97+
name: DIT (${{ matrix.group }}) - ${{ matrix.version }}
9698
runs-on: ubuntu-latest
9799
timeout-minutes: 60
98100
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
@@ -104,6 +106,13 @@ jobs:
104106
version:
105107
- '1'
106108
- '1.6'
109+
group:
110+
- Formalities
111+
- Zero
112+
- ForwardDiff
113+
exclude:
114+
- version: '1.6'
115+
group: Formalities
107116

108117
steps:
109118
- uses: actions/checkout@v4
@@ -122,6 +131,8 @@ jobs:
122131
- uses: julia-actions/julia-runtest@v1
123132
with:
124133
project: ./DifferentiationInterfaceTest
134+
env:
135+
JULIA_DI_TEST_GROUP: ${{ matrix.group }}
125136
- uses: julia-actions/julia-processcoverage@v1
126137
with:
127138
directories: ./DifferentiationInterfaceTest/src,./DifferentiationInterfaceTest/ext

DifferentiationInterface/Project.toml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1212
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930"
1313
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
14+
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
1415

1516
[weakdeps]
1617
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
@@ -59,6 +60,8 @@ PackageExtensionCompat = "1.0.2"
5960
PolyesterForwardDiff = "0.1.1"
6061
ReverseDiff = "1.15.1"
6162
SparseArrays = "<0.0.1,1"
63+
SparseConnectivityTracer = "0.4.2"
64+
SparseMatrixColorings = "0.3.1"
6265
Symbolics = "5.27.1"
6366
Tapir = "0.2.4"
6467
Tracker = "0.2.33"
@@ -84,22 +87,12 @@ PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b"
8487
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
8588
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
8689
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
90+
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
8791
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
8892
Tapir = "07d77754-e150-4737-8c94-cd238a1fb45b"
8993
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
9094
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
9195
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
9296

9397
[targets]
94-
test = [
95-
"ADTypes",
96-
"Aqua",
97-
"DataFrames",
98-
"DifferentiationInterfaceTest",
99-
"JET",
100-
"JuliaFormatter",
101-
"Pkg",
102-
"SparseArrays",
103-
"SparseConnectivityTracer",
104-
"Test",
105-
]
98+
test = ["ADTypes", "Aqua", "DataFrames", "DifferentiationInterfaceTest", "JET", "JuliaFormatter", "Pkg", "SparseArrays", "SparseConnectivityTracer", "SparseMatrixColorings", "Test"]

DifferentiationInterface/docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b"
1818
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
1919
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
2020
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
21+
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
2122
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
2223
Tapir = "07d77754-e150-4737-8c94-cd238a1fb45b"
2324
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"

DifferentiationInterface/docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ using Zygote: Zygote
2222
links = InterLinks(
2323
"ADTypes" => "https://sciml.github.io/ADTypes.jl/stable/",
2424
"SparseConnectivityTracer" => "https://adrianhill.de/SparseConnectivityTracer.jl/stable/",
25+
"SparseMatrixColorings" => "https://gdalle.github.io/SparseMatrixColorings.jl/stable/",
2526
)
2627

2728
cp(joinpath(@__DIR__, "..", "README.md"), joinpath(@__DIR__, "src", "index.md"); force=true)

DifferentiationInterface/docs/src/api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ check_hessian
9696

9797
```@docs
9898
DifferentiateWith
99-
GreedyColoringAlgorithm
10099
```
101100

102101
## Internals

DifferentiationInterface/docs/src/tutorial.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,14 @@ To compute sparse Jacobians or Hessians, you need three ingredients (read [this
148148
- [`TracerSparsityDetector`](@extref SparseConnectivityTracer.TracerSparsityDetector), implemented by [SparseConnectivityTracer.jl](https://github.com/adrhill/SparseConnectivityTracer.jl) (our default recommendation)
149149
- [`SymbolicsSparsityDetector`](@ref DifferentiationInterface.SymbolicsSparsityDetector), implemented by DifferentiationInterface.jl with [Symbolics.jl](https://github.com/JuliaSymbolics/Symbolics.jl) but not exported nor part of the public API (it will soon be [transferred](https://github.com/JuliaSymbolics/Symbolics.jl/pull/1134))
150150
3. A coloring algorithm like:
151-
- [`GreedyColoringAlgorithm`](@ref), implemented by DifferentiationInterface.jl
151+
- `GreedyColoringAlgorithm`, implemented by [SparseMatrixColorings.jl](https://github.com/gdalle/SparseMatrixColorings.jl) and re-exported by DifferentiationInterface.jl
152152

153153
ADTypes.jl v1.0 provides the [`AutoSparse`](@extref ADTypes.AutoSparse) wrapper to combine these three ingredients, and DifferentiationInterface.jl re-exports it.
154154
Here's an example:
155155

156156
```@example tuto
157-
using SparseConnectivityTracer
157+
using SparseConnectivityTracer: TracerSparsityDetector
158+
using SparseMatrixColorings: GreedyColoringAlgorithm
158159
159160
dense_backend = AutoForwardDiff()
160161

DifferentiationInterface/src/DifferentiationInterface.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ using FillArrays: OneElement
3434
using LinearAlgebra: Symmetric, Transpose, dot, parent, transpose
3535
using PackageExtensionCompat: @require_extensions
3636
using SparseArrays: SparseMatrixCSC, nonzeros, nzrange, rowvals, sparse
37+
using SparseMatrixColorings:
38+
GreedyColoringAlgorithm,
39+
color_groups,
40+
decompress_columns!,
41+
decompress_columns,
42+
decompress_rows!,
43+
decompress_rows
3744

3845
abstract type Extras end
3946

@@ -57,10 +64,8 @@ include("second_order/hvp.jl")
5764
include("second_order/hessian.jl")
5865

5966
include("sparse/detector.jl")
60-
include("sparse/matrices.jl")
61-
include("sparse/coloring.jl")
62-
include("sparse/compressed_matrix.jl")
6367
include("sparse/fallbacks.jl")
68+
include("sparse/matrices.jl")
6469
include("sparse/jacobian.jl")
6570
include("sparse/hessian.jl")
6671

DifferentiationInterface/src/sparse/coloring.jl

Lines changed: 0 additions & 204 deletions
This file was deleted.

0 commit comments

Comments
 (0)