Skip to content

Commit 3698dbe

Browse files
authored
[BREAKING] Improve type stability tests and benchmarking (#560)
* Improve type stability tests and benchmarking * Remove `first_order` and `second_order` * Docs * Zero allocs * Fixes * Call count * Fix * Fix * Add count calls * Default count calls * Fix
1 parent bd62b64 commit 3698dbe

26 files changed

Lines changed: 910 additions & 635 deletions

File tree

.github/workflows/Test.yml

Lines changed: 1 addition & 1 deletion
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 # TODO: toggle
2929
matrix:
3030
version:
3131
- "1.10"

DifferentiationInterface/test/Back/ChainRulesBackends/chainrules_zygote.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ test_differentiation(
2323
test_differentiation(
2424
AutoChainRules(ZygoteRuleConfig()),
2525
default_scenarios(; include_normal=false, include_constantified=true);
26-
second_order=false,
26+
excluded=SECOND_ORDER,
2727
logging=LOGGING,
2828
);

DifferentiationInterface/test/Back/ChainRulesBackends/diffractor.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ for backend in [AutoDiffractor()]
1313
end
1414

1515
test_differentiation(
16-
AutoDiffractor(), default_scenarios(; linalg=false); second_order=false, logging=LOGGING
16+
AutoDiffractor(),
17+
default_scenarios(; linalg=false);
18+
excluded=SECOND_ORDER,
19+
logging=LOGGING,
1720
);

DifferentiationInterface/test/Back/Enzyme/test.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ end;
3131

3232
## First order
3333

34-
test_differentiation(backends, default_scenarios(); second_order=false, logging=LOGGING);
34+
test_differentiation(backends, default_scenarios(); excluded=SECOND_ORDER, logging=LOGGING);
3535

3636
test_differentiation(
3737
backends[1:3],
3838
default_scenarios(; include_normal=false, include_constantified=true);
39-
second_order=false,
39+
excluded=SECOND_ORDER,
4040
logging=LOGGING,
4141
);
4242

4343
test_differentiation(
4444
duplicated_backends,
4545
default_scenarios(; include_normal=false, include_closurified=true);
46-
second_order=false,
46+
excluded=SECOND_ORDER,
4747
logging=LOGGING,
4848
);
4949

@@ -54,8 +54,8 @@ test_differentiation(
5454
AutoEnzyme(; mode=Enzyme.Forward), # TODO: add more
5555
default_scenarios(; include_batchified=false);
5656
correctness=false,
57-
type_stability=true,
58-
second_order=false,
57+
type_stability=:prepared,
58+
excluded=SECOND_ORDER,
5959
logging=LOGGING,
6060
);
6161
=#
@@ -65,27 +65,24 @@ test_differentiation(
6565
test_differentiation(
6666
AutoEnzyme(),
6767
default_scenarios(; include_constantified=true);
68-
first_order=false,
68+
excluded=FIRST_ORDER,
6969
logging=LOGGING,
7070
);
7171

7272
test_differentiation(
7373
AutoEnzyme(; mode=Enzyme.Forward);
74-
first_order=false,
75-
excluded=[:hessian, :hvp],
74+
excluded=vcat(FIRST_ORDER, [:hessian, :hvp]),
7675
logging=LOGGING,
7776
);
7877

7978
test_differentiation(
8079
AutoEnzyme(; mode=Enzyme.Reverse);
81-
first_order=false,
82-
excluded=[:second_derivative],
80+
excluded=vcat(FIRST_ORDER, [:second_derivative]),
8381
logging=LOGGING,
8482
);
8583

8684
test_differentiation(
8785
SecondOrder(AutoEnzyme(; mode=Enzyme.Reverse), AutoEnzyme(; mode=Enzyme.Forward));
88-
first_order=false,
8986
logging=LOGGING,
9087
);
9188

DifferentiationInterface/test/Back/FiniteDifferences/test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ end
1515
test_differentiation(
1616
AutoFiniteDifferences(; fdm=FiniteDifferences.central_fdm(3, 1)),
1717
default_scenarios(; include_constantified=true);
18-
second_order=false,
18+
excluded=SECOND_ORDER,
1919
logging=LOGGING,
2020
);

DifferentiationInterface/test/Back/ForwardDiff/test.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ test_differentiation(
2323
);
2424

2525
test_differentiation(
26-
AutoForwardDiff(); correctness=false, type_stability=true, logging=LOGGING
26+
AutoForwardDiff(); correctness=false, type_stability=:prepared, logging=LOGGING
2727
);
2828

2929
test_differentiation(
3030
AutoForwardDiff(; chunksize=5);
3131
correctness=false,
32-
type_stability=(; preparation=true, prepared_op=true, unprepared_op=false),
32+
type_stability=:full,
33+
excluded=[:hessian],
3334
logging=LOGGING,
3435
);
3536

3637
test_differentiation(
3738
backends,
3839
vcat(component_scenarios(), static_scenarios()); # FD accesses individual indices
39-
excluded=[:jacobian], # jacobian is super slow for some reason
40-
second_order=false,
40+
excluded=vcat(SECOND_ORDER, [:jacobian]), # jacobian is super slow for some reason
4141
logging=LOGGING,
4242
);
4343

DifferentiationInterface/test/Back/Mooncake/test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ end
1717
test_differentiation(
1818
backends,
1919
default_scenarios(; include_constantified=true);
20-
second_order=false,
20+
excluded=SECOND_ORDER,
2121
logging=LOGGING,
2222
);

DifferentiationInterface/test/Back/Tracker/test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ end
1515
test_differentiation(
1616
AutoTracker(),
1717
default_scenarios(; include_constantified=true);
18-
second_order=false,
18+
excluded=SECOND_ORDER,
1919
logging=LOGGING,
2020
);

DifferentiationInterface/test/Back/Zygote/test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ test_differentiation(
2828
logging=LOGGING,
2929
);
3030

31-
test_differentiation(second_order_backends; first_order=false, logging=LOGGING);
31+
test_differentiation(second_order_backends; logging=LOGGING);
3232

3333
test_differentiation(
3434
backends[1],
3535
vcat(component_scenarios(), gpu_scenarios());
36-
second_order=false,
36+
excluded=SECOND_ORDER,
3737
logging=LOGGING,
3838
)
3939

DifferentiationInterface/test/Misc/DifferentiateWith/test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ end
2424
test_differentiation(
2525
[AutoForwardDiff(), AutoZygote()],
2626
differentiatewith_scenarios();
27-
second_order=false,
27+
excluded=SECOND_ORDER,
2828
logging=LOGGING,
2929
)

0 commit comments

Comments
 (0)