Skip to content

Commit 5aaed92

Browse files
authored
Sort tests into single and double backends (#245)
* Sort tests into single and double backends * Fix test deps * Fix paths * Fix ENzyme * DIT * DataFrame
1 parent c8e6bd5 commit 5aaed92

26 files changed

+89
-135
lines changed

DifferentiationInterface/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
8080
PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b"
8181
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
8282
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
83+
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
8384
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
8485
Tapir = "07d77754-e150-4737-8c94-cd238a1fb45b"
8586
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
@@ -104,6 +105,7 @@ test = [
104105
"PolyesterForwardDiff",
105106
"ReverseDiff",
106107
"SparseArrays",
108+
"SparseConnectivityTracer",
107109
"Symbolics",
108110
"Tapir",
109111
"Test",

DifferentiationInterface/test/translation/forwarddiff_zygote.jl renamed to DifferentiationInterface/test/Double/ForwardDiff-Zygote.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
using DifferentiationInterface, DifferentiationInterfaceTest
2+
import DifferentiationInterface as DI
23
import DifferentiationInterfaceTest as DIT
34
using ForwardDiff: ForwardDiff
45
using Zygote: Zygote
56

7+
backends = [
8+
SecondOrder(AutoForwardDiff(), AutoZygote()),
9+
MyAutoSparse(SecondOrder(AutoForwardDiff(), AutoZygote())),
10+
]
11+
12+
for backend in backends
13+
@test check_available(backend)
14+
@test !check_twoarg(backend)
15+
@test check_hessian(backend)
16+
end
17+
18+
test_differentiation(backends; first_order=false, logging=LOGGING);
19+
20+
test_differentiation(
21+
MyAutoSparse(SecondOrder(AutoForwardDiff(), AutoZygote())),
22+
sparse_scenarios();
23+
first_order=false,
24+
sparsity=true,
25+
logging=LOGGING,
26+
);
27+
28+
## Translation
29+
630
function zygote_breaking_scenarios()
731
onearg_scens = filter(default_scenarios()) do scen
832
DIT.nb_args(scen) == 1

DifferentiationInterface/test/first_order/enzyme.jl renamed to DifferentiationInterface/test/Single/Enzyme.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ end
1616

1717
test_differentiation(backends; second_order=false, logging=LOGGING);
1818

19+
test_differentiation(
20+
MyAutoSparse(AutoEnzyme(Enzyme.Reverse)),
21+
sparse_scenarios();
22+
second_order=false,
23+
sparsity=true,
24+
logging=LOGGING,
25+
);
26+
1927
test_differentiation(
2028
AutoEnzyme(; mode=Enzyme.Forward); # TODO: add more
2129
correctness=false,
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
using DifferentiationInterface, DifferentiationInterfaceTest
22
using FiniteDiff: FiniteDiff
33

4-
backends = [AutoFiniteDiff()]
5-
6-
for backend in backends
4+
for backend in [AutoFiniteDiff()]
75
@test check_available(backend)
86
@test check_twoarg(backend)
97
@test check_hessian(backend)
108
end
119

1210
test_differentiation(
13-
backends; excluded=[SecondDerivativeScenario, HVPScenario], logging=LOGGING
11+
AutoFiniteDiff(); excluded=[SecondDerivativeScenario, HVPScenario], logging=LOGGING
1412
);
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using DifferentiationInterface, DifferentiationInterfaceTest
22
using FiniteDifferences: FiniteDifferences
33

4-
backends = [AutoFiniteDifferences(; fdm=FiniteDifferences.central_fdm(3, 1))]
5-
6-
for backend in backends
4+
for backend in [AutoFiniteDifferences(; fdm=FiniteDifferences.central_fdm(3, 1))]
75
@test check_available(backend)
86
@test !check_twoarg(backend)
97
@test_broken !check_hessian(backend; verbose=false)
108
end
119

12-
test_differentiation(backends; second_order=false, logging=LOGGING);
10+
test_differentiation(
11+
AutoFiniteDifferences(; fdm=FiniteDifferences.central_fdm(3, 1));
12+
second_order=false,
13+
logging=LOGGING,
14+
);

DifferentiationInterface/test/efficiency/forwarddiff.jl.jl renamed to DifferentiationInterface/test/Single/ForwardDiff.jl

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1-
using DataFrames: DataFrame
21
using DifferentiationInterface, DifferentiationInterfaceTest
3-
import DifferentiationInterface as DI
42
using ForwardDiff: ForwardDiff
5-
using Symbolics: Symbolics
6-
using Test
3+
using DataFrames: DataFrame
4+
5+
for backend in [AutoForwardDiff(), AutoSparse(AutoForwardDiff())]
6+
@test check_available(backend)
7+
@test check_twoarg(backend)
8+
@test check_hessian(backend)
9+
end
10+
11+
test_differentiation([AutoForwardDiff(), AutoSparse(AutoForwardDiff())]; logging=LOGGING);
712

8-
@testset verbose = false "Dense" begin
13+
test_differentiation(
14+
MyAutoSparse(AutoForwardDiff()), sparse_scenarios(); sparsity=true, logging=LOGGING
15+
);
16+
17+
test_differentiation(
18+
AutoForwardDiff(),
19+
# ForwardDiff access individual indices
20+
vcat(component_scenarios(), static_scenarios());
21+
# jacobian is super slow for some reason
22+
excluded=[JacobianScenario],
23+
second_order=false,
24+
logging=LOGGING,
25+
);
26+
27+
## Efficiency
28+
29+
@testset verbose = false "Dense efficiency" begin
930
# derivative and gradient for `f(x)`
1031

1132
results1 = benchmark_differentiation(
@@ -48,14 +69,10 @@ using Test
4869
end
4970
end;
5071

51-
@testset verbose = false "Sparse" begin
72+
@testset verbose = false "Sparse efficiency" begin
5273
# sparse jacobian for f!(x, y)
5374

54-
b_sparse = AutoSparse(
55-
AutoForwardDiff(; chunksize=1);
56-
sparsity_detector=DI.SymbolicsSparsityDetector(),
57-
coloring_algorithm=DI.GreedyColoringAlgorithm(),
58-
)
75+
b_sparse = MyAutoSparse(AutoForwardDiff(; chunksize=1);)
5976

6077
results1 = benchmark_differentiation(
6178
[b_sparse],
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using DifferentiationInterface, DifferentiationInterfaceTest
22
using PolyesterForwardDiff: PolyesterForwardDiff
33

4-
backends = [AutoPolyesterForwardDiff(; chunksize=1)]
5-
6-
for backend in backends
4+
for backend in [AutoPolyesterForwardDiff(; chunksize=1)]
75
@test check_available(backend)
86
@test check_twoarg(backend)
97
@test check_hessian(backend)
108
end
119

12-
test_differentiation(backends; logging=LOGGING);
10+
test_differentiation(AutoPolyesterForwardDiff(; chunksize=1); logging=LOGGING);

DifferentiationInterface/test/first_order/symbolics.jl renamed to DifferentiationInterface/test/Single/Symbolics.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using DifferentiationInterface, DifferentiationInterfaceTest
22
using Symbolics: Symbolics
33

4-
backends = [AutoSymbolics(), AutoSparse(AutoSymbolics())]
5-
6-
for backend in backends
4+
for backend in [AutoSymbolics(), AutoSparse(AutoSymbolics())]
75
@test check_available(backend)
86
@test check_twoarg(backend)
97
@test check_hessian(backend)
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using DifferentiationInterface, DifferentiationInterfaceTest
22
using Tapir: Tapir
33

4-
backends = [AutoTapir()]
5-
6-
for backend in backends
4+
for backend in [AutoTapir()]
75
@test check_available(backend)
86
@test check_twoarg(backend)
97
@test !check_hessian(backend; verbose=false)
108
end
119

12-
test_differentiation(backends; second_order=false, logging=LOGGING);
10+
test_differentiation(AutoTapir(); second_order=false, logging=LOGGING);
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using DifferentiationInterface, DifferentiationInterfaceTest
22
using Tracker: Tracker
33

4-
backends = [AutoTracker()]
5-
6-
for backend in backends
4+
for backend in [AutoTracker()]
75
@test check_available(backend)
86
@test !check_twoarg(backend)
97
@test !check_hessian(backend; verbose=false)
108
end
119

12-
test_differentiation(backends; second_order=false, logging=LOGGING);
10+
test_differentiation(AutoTracker(); second_order=false, logging=LOGGING);

DifferentiationInterface/test/first_order/forwarddiff.jl

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

DifferentiationInterface/test/runtests.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
using Pkg
2-
32
Pkg.develop(
43
Pkg.PackageSpec(; path=joinpath(@__DIR__, "..", "..", "DifferentiationInterfaceTest"))
54
)
65

6+
using ADTypes
77
using DifferentiationInterface
8+
using SparseConnectivityTracer: SparseConnectivityTracer
89
using Test
910

11+
function MyAutoSparse(backend::AbstractADType)
12+
coloring_algorithm = DifferentiationInterface.GreedyColoringAlgorithm()
13+
sparsity_detector = SparseConnectivityTracer.TracerSparsityDetector()
14+
return AutoSparse(backend; sparsity_detector, coloring_algorithm)
15+
end
16+
1017
LOGGING = get(ENV, "CI", "false") == "false"
1118

1219
## Main tests
1320

1421
@testset verbose = true "DifferentiationInterface.jl" begin
22+
@info "Testing formalities"
1523
@testset verbose = true "Formal tests" begin
1624
include("formal.jl")
1725
end
1826

19-
@testset verbose = true "$folder" for folder in [
20-
"first_order", "second_order", "sparse", "translation", "efficiency", "internals"
21-
]
27+
@testset verbose = true "$folder" for folder in ["Single", "Double", "Internals"]
2228
folder_path = joinpath(@__DIR__, folder)
23-
@testset verbose = true "$file" for file in readdir(folder_path)
29+
@testset verbose = true "$(file[1:end-3])" for file in readdir(folder_path)
30+
@info "Testing $folder - $(file[1:end-3])"
2431
include(joinpath(folder_path, file))
2532
end
2633
end

DifferentiationInterface/test/second_order/forwarddiff_zygote.jl

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

DifferentiationInterface/test/sparse/enzyme.jl

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

DifferentiationInterface/test/sparse/forwarddiff.jl

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

DifferentiationInterface/test/sparse/forwarddiff_zygote.jl

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

0 commit comments

Comments
 (0)