Skip to content

Commit efb5acf

Browse files
authored
Make more tests compatible with 1.11 (#552)
* Make more tests compatible with 1.11 * No fail fast * Reorganize tests * Fixes * Type stability * Fix * Fix hvp mode * Fixes
1 parent a074f88 commit efb5acf

15 files changed

Lines changed: 116 additions & 202 deletions

File tree

.github/workflows/Test.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
actions: write
2626
contents: read
2727
strategy:
28-
fail-fast: true
28+
fail-fast: false
2929
matrix:
3030
version:
3131
- "1.10" # TODO: 1 (as of 2024.10.08, 1 means 1.11 and we're not ready yet)
@@ -44,7 +44,6 @@ jobs:
4444
- Back/Mooncake
4545
- Back/PolyesterForwardDiff
4646
- Back/ReverseDiff
47-
- Back/SecondOrder
4847
- Back/SymbolicBackends
4948
- Back/Tracker
5049
- Back/Zygote
@@ -61,12 +60,6 @@ jobs:
6160
group: Back/Enzyme
6261
- version: "1.11"
6362
group: Back/Mooncake
64-
- version: "1.11"
65-
group: Back/SecondOrder
66-
- version: "1.11"
67-
group: Misc/Internals
68-
- version: "1.11"
69-
group: Misc/SparsityDetector
7063
env:
7164
JULIA_DI_TEST_GROUP: ${{ matrix.group }}
7265
steps:

DifferentiationInterface/src/utils/traits.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ function hvp_mode(ba::SecondOrder)
134134
return ReverseOverForward()
135135
elseif Bool(pullback_performance(outer(ba))) && Bool(pullback_performance(inner(ba)))
136136
return ReverseOverReverse()
137-
elseif Bool(pushforward_performance(outer(ba))) &&
138-
Bool(pushforward_performance(inner(ba)))
137+
else
139138
return ForwardOverForward()
140139
end
141140
end

DifferentiationInterface/test/Back/ChainRulesBackends/chainrules_zygote.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ test_differentiation(
1717
AutoChainRules(ZygoteRuleConfig()),
1818
default_scenarios();
1919
excluded=[:second_derivative],
20-
second_order=VERSION >= v"1.10",
2120
logging=LOGGING,
2221
);
2322

DifferentiationInterface/test/Back/Enzyme/test.jl

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,72 +5,48 @@ using ADTypes: ADTypes
55
using DifferentiationInterface, DifferentiationInterfaceTest
66
import DifferentiationInterfaceTest as DIT
77
using Enzyme: Enzyme
8-
using SparseConnectivityTracer, SparseMatrixColorings
98
using Test
109

1110
LOGGING = get(ENV, "CI", "false") == "false"
1211

13-
dense_backends = [
12+
backends = [
1413
AutoEnzyme(; mode=nothing),
1514
AutoEnzyme(; mode=Enzyme.Forward),
1615
AutoEnzyme(; mode=Enzyme.Reverse),
1716
AutoEnzyme(; mode=Enzyme.Forward, function_annotation=Enzyme.Const),
1817
AutoEnzyme(; mode=Enzyme.Reverse, function_annotation=Enzyme.Const),
1918
]
2019

21-
duplicated_function_backends = [
20+
duplicated_backends = [
2221
AutoEnzyme(; mode=Enzyme.Forward, function_annotation=Enzyme.Duplicated),
2322
AutoEnzyme(; mode=Enzyme.Reverse, function_annotation=Enzyme.Duplicated),
2423
]
2524

26-
sparse_backends =
27-
AutoSparse.(
28-
dense_backends[1:3],
29-
sparsity_detector=TracerSparsityDetector(),
30-
coloring_algorithm=GreedyColoringAlgorithm(),
31-
)
32-
3325
@testset "Checks" begin
34-
@testset "Check $(typeof(backend))" for backend in vcat(dense_backends, sparse_backends)
26+
@testset "Check $(typeof(backend))" for backend in backends
3527
@test check_available(backend)
3628
@test check_inplace(backend)
3729
end
3830
end;
3931

40-
## Dense backends
32+
## First order
4133

42-
test_differentiation(
43-
dense_backends, default_scenarios(); second_order=false, logging=LOGGING
44-
);
34+
test_differentiation(backends, default_scenarios(); second_order=false, logging=LOGGING);
4535

4636
test_differentiation(
47-
dense_backends[1:3],
37+
backends[1:3],
4838
default_scenarios(; include_normal=false, include_constantified=true);
4939
second_order=false,
5040
logging=LOGGING,
5141
);
5242

5343
test_differentiation(
54-
duplicated_function_backends,
44+
duplicated_backends,
5545
default_scenarios(; include_normal=false, include_closurified=true);
5646
second_order=false,
5747
logging=LOGGING,
5848
);
5949

60-
test_differentiation(
61-
[AutoEnzyme(; mode=nothing), AutoEnzyme(; mode=Enzyme.Reverse)];
62-
first_order=false,
63-
excluded=[:second_derivative],
64-
logging=LOGGING,
65-
);
66-
67-
test_differentiation(
68-
[AutoEnzyme(; mode=nothing), AutoEnzyme(; mode=Enzyme.Forward)];
69-
first_order=false,
70-
excluded=[:hessian, :hvp],
71-
logging=LOGGING,
72-
);
73-
7450
#=
7551
# TODO: reactivate type stability tests
7652
@@ -84,20 +60,37 @@ test_differentiation(
8460
);
8561
=#
8662

87-
## Sparse backends
63+
## Second order
8864

8965
test_differentiation(
90-
sparse_backends,
91-
default_scenarios();
92-
excluded=[:derivative, :gradient, :pullback, :pushforward, :second_derivative, :hvp],
93-
second_order=false, # TODO: make true
66+
AutoEnzyme(),
67+
default_scenarios(; include_constantified=true);
68+
first_order=false,
9469
logging=LOGGING,
9570
);
9671

9772
test_differentiation(
98-
sparse_backends,
99-
sparse_scenarios();
100-
sparsity=true,
101-
second_order=false, # TODO: make true
73+
AutoEnzyme(; mode=Enzyme.Forward);
74+
first_order=false,
75+
excluded=[:hessian, :hvp],
76+
logging=LOGGING,
77+
);
78+
79+
test_differentiation(
80+
AutoEnzyme(; mode=Enzyme.Reverse);
81+
first_order=false,
82+
excluded=[:second_derivative],
83+
logging=LOGGING,
84+
);
85+
86+
test_differentiation(
87+
SecondOrder(AutoEnzyme(; mode=Enzyme.Reverse), AutoEnzyme(; mode=Enzyme.Forward));
88+
first_order=false,
10289
logging=LOGGING,
10390
);
91+
92+
## Sparse
93+
94+
test_differentiation(
95+
MyAutoSparse.(AutoEnzyme()), sparse_scenarios(); sparsity=true, logging=LOGGING
96+
);

DifferentiationInterface/test/Back/ForwardDiff/test.jl

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,22 @@ Pkg.add("ForwardDiff")
44
using ComponentArrays: ComponentArrays
55
using DifferentiationInterface, DifferentiationInterfaceTest
66
using ForwardDiff: ForwardDiff
7-
using SparseConnectivityTracer, SparseMatrixColorings
87
using StaticArrays: StaticArrays
98
using Test
109

1110
LOGGING = get(ENV, "CI", "false") == "false"
1211

13-
dense_backends = [AutoForwardDiff(; tag=:hello), AutoForwardDiff(; chunksize=5)]
12+
backends = [AutoForwardDiff(; tag=:hello), AutoForwardDiff(; chunksize=5)]
1413

15-
sparse_backends =
16-
AutoSparse.(
17-
dense_backends;
18-
sparsity_detector=TracerSparsityDetector(),
19-
coloring_algorithm=GreedyColoringAlgorithm(),
20-
)
21-
22-
for backend in vcat(dense_backends, sparse_backends)
14+
for backend in backends
2315
@test check_available(backend)
2416
@test check_inplace(backend)
2517
end
2618

27-
## Dense backends
19+
## Dense
2820

2921
test_differentiation(
30-
dense_backends, default_scenarios(; include_constantified=true); logging=LOGGING
22+
backends, default_scenarios(; include_constantified=true); logging=LOGGING
3123
);
3224

3325
test_differentiation(
@@ -42,26 +34,19 @@ test_differentiation(
4234
);
4335

4436
test_differentiation(
45-
dense_backends,
46-
# ForwardDiff accesses individual indices
47-
vcat(component_scenarios(), static_scenarios());
48-
# jacobian is super slow for some reason
49-
excluded=[:jacobian],
37+
backends,
38+
vcat(component_scenarios(), static_scenarios()); # FD accesses individual indices
39+
excluded=[:jacobian], # jacobian is super slow for some reason
5040
second_order=false,
5141
logging=LOGGING,
5242
);
5343

54-
## Sparse backends
44+
## Sparse
5545

56-
test_differentiation(
57-
sparse_backends,
58-
default_scenarios();
59-
excluded=[:derivative, :gradient, :hvp, :pullback, :pushforward, :second_derivative],
60-
logging=LOGGING,
61-
);
46+
test_differentiation(MyAutoSparse.(backends), default_scenarios(); logging=LOGGING);
6247

6348
test_differentiation(
64-
sparse_backends,
49+
MyAutoSparse.(backends),
6550
sparse_scenarios(; include_constantified=true);
6651
sparsity=true,
6752
logging=LOGGING,

DifferentiationInterface/test/Back/PolyesterForwardDiff/test.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,5 @@ for backend in backends
1818
end
1919

2020
test_differentiation(
21-
backends, #
22-
default_scenarios(; include_constantified=true);
23-
logging=LOGGING,
21+
backends, default_scenarios(; include_constantified=true); logging=LOGGING
2422
);
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
using Pkg
2-
Pkg.add("ReverseDiff")
2+
Pkg.add(["ForwardDiff", "ReverseDiff"]) # ForwardDiff already in ReverseDiff's deps
33

44
using DifferentiationInterface, DifferentiationInterfaceTest
5+
using ForwardDiff: ForwardDiff
56
using ReverseDiff: ReverseDiff
67
using StaticArrays: StaticArrays
78
using Test
89

910
LOGGING = get(ENV, "CI", "false") == "false"
1011

11-
dense_backends = [AutoReverseDiff(; compile=false), AutoReverseDiff(; compile=true)]
12+
backends = [AutoReverseDiff(; compile=false), AutoReverseDiff(; compile=true)]
13+
second_order_backends = [SecondOrder(AutoForwardDiff(), AutoReverseDiff())]
1214

13-
for backend in dense_backends
15+
for backend in vcat(backends, second_order_backends)
1416
@test check_available(backend)
1517
@test check_inplace(backend)
1618
end
1719

20+
## Dense
21+
1822
test_differentiation(
19-
dense_backends, default_scenarios(; include_constantified=true); logging=LOGGING
23+
vcat(backends, second_order_backends),
24+
default_scenarios(; include_constantified=true);
25+
logging=LOGGING,
2026
);
2127

22-
test_differentiation(AutoReverseDiff(), static_scenarios(); logging=LOGGING);
28+
test_differentiation(backends[1], static_scenarios(); logging=LOGGING);
29+
30+
## Sparse
31+
32+
test_differentiation(
33+
MyAutoSparse.(vcat(backends, second_order_backends)),
34+
sparse_scenarios();
35+
sparsity=true,
36+
logging=LOGGING,
37+
);

DifferentiationInterface/test/Back/SecondOrder/test.jl

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

0 commit comments

Comments
 (0)