Performance summary
Each documented example is timed against up to three alternatives:
the package with its rules turned off by
NoAdjoint, so the backend differentiates the forward loop;a hand-written loop of the same model, differentiated by the same backend;
for the case study's kernels, that loop with hand-written Mooncake rules.
Each cell is the other method's minimum time over the package's, at the example's largest size. Above 1 the package is faster; below 1 it is slower. The rules are reverse-mode adjoints, which the forward run and ForwardDiff never call, so those columns have no time without the rules. Plain Enzyme on the spatial model has no time either: benchmark/matrix.jl skips it because it gives a wrong gradient on a repeated sparse mul!.
Overview
The geometric mean is taken over the examples, and the counts give how many are slower than each alternative.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Without its rules (geometric mean) | – | – | 4.5× | 2.6× |
| Slower than without its rules | – | – | 0 of 15 | 0 of 14 |
| Hand loop (geometric mean) | 1.1× | 1.3× | 4.1× | 2.3× |
| Hand loop (range) | 0.56–2.16× | 0.76–3.74× | 0.98–10.85× | 0.79–7.05× |
| Slower than the hand loop | 6 of 15 | 8 of 15 | 1 of 15 | 2 of 15 |
Minimum times at each example's largest size, revision d41af96e.
The rules gain most on the reverse backends. The forward run and ForwardDiff are near the hand loop's speed and slower than it on several examples, and the reverse backends are slower on a few, which issue #417 tracks. Against hand-written code lists every example in one table and names the slower cases.
By example
Three towns
The model of Three towns, step by step.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 19.7 | 2800 | 72.2 | 56.4 |
| Without its rules | – | – | 6.3× | 3.2× |
| Hand loop | 1.5× | 2.2× | 10.9× | 4.3× |
| Hand rules | – | – | 1.4× | – |
Minimum times at T200_L20_S3, revision d41af96e.
Case study: renewal kernel
The renewal kernel of Porting a patch model from hand-written loops.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 15.7 | 6627 | 55.1 | 45.0 |
| Without its rules | – | – | 7.5× | 1.8× |
| Hand loop | 1.8× | 3.6× | 4.1× | 2.9× |
| Hand rules | – | – | 1.2× | – |
Minimum times at T400_L60_S1, revision d41af96e.
Case study: patch kernel
The patch kernel of Porting a patch model from hand-written loops.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 185 | 1275869 | 816 | 548 |
| Without its rules | – | – | 10.6× | 4.1× |
| Hand loop | 1.5× | 2.2× | 9.1× | 4.4× |
| Hand rules | – | – | 1.7× | – |
Minimum times at T400_L60_S11, revision d41af96e.
Case study: delay kernel
The delay kernel of Porting a patch model from hand-written loops.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 4.11 | 2745 | 23.2 | 11.8 |
| Without its rules | – | – | 6.6× | 5.0× |
| Hand loop | 1.0× | 3.7× | 5.2× | 2.3× |
| Hand rules | – | – | 1.3× | – |
Minimum times at T400_L60_S1, revision d41af96e.
Renewal then delay
The model of Renewal then delay.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 7.61 | 672 | 24.9 | 18.5 |
| Without its rules | – | – | 3.5× | 1.3× |
| Hand loop | 1.4× | 0.8× | 4.0× | 1.7× |
| Hand rules | – | – | 1.2× | – |
Minimum times at T200_L20_S1, revision d41af96e.
Vaccination
The model of Vaccination.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 16.6 | 2136 | 54.2 | 47.4 |
| Without its rules | – | – | 2.6× | 3.2× |
| Hand loop | 0.7× | 0.9× | 2.4× | 1.0× |
| Hand rules | – | – | 0.9× | – |
Minimum times at T200_L20_S1, revision d41af96e.
Imported cases
The model of Imported cases.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 8.95 | 1330 | 38.0 | 39.4 |
| Without its rules | – | – | 2.8× | 1.6× |
| Hand loop | 1.2× | 1.0× | 2.7× | 0.8× |
| Hand rules | – | – | 1.1× | – |
Minimum times at T200_L20_S1, revision d41af96e.
Clinical outcomes
The model of Clinical outcomes.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 3.8 | 674 | 31.2 | 82.3 |
| Without its rules | – | – | 4.4× | 1.1× |
| Hand loop | 2.2× | 1.4× | 6.5× | 5.0× |
| Hand rules | – | – | 1.4× | – |
Minimum times at T200_L20_S1, revision d41af96e.
Forecasting
The model of Forecasting.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 2.66 | 638 | 20.8 | 11.9 |
| Without its rules | – | – | 3.8× | 1.9× |
| Hand loop | 2.1× | 0.8× | 4.5× | 1.8× |
| Hand rules | – | – | 1.0× | – |
Minimum times at T200_L20_S1, revision d41af96e.
Reproduction number
The model of Reproduction number.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 32.8 | 4013 | 99.7 | 76.4 |
| Without its rules | – | – | 4.5× | 3.1× |
| Hand loop | 0.6× | 1.0× | 3.9× | 1.2× |
| Hand rules | – | – | 0.8× | – |
Minimum times at T200_L20_S3, revision d41af96e.
Spatial models
The model of Spatial models.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 38.2 | 20060 | 158 | 116 |
| Without its rules | – | – | 7.6× | – |
| Hand loop | 1.1× | 1.0× | 7.0× | 7.1× |
| Hand rules | – | – | 1.2× | – |
Minimum times at T200_L20_S5, revision d41af96e.
Occupancy and capacity
The model of Occupancy and capacity.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 7.11 | 1050 | 41.2 | 35.6 |
| Without its rules | – | – | 2.4× | 5.0× |
| Hand loop | 0.6× | 0.8× | 1.0× | 2.2× |
| Hand rules | – | – | 0.8× | – |
Minimum times at T200_L20_S1, revision d41af96e.
Latent processes
The model of Latent processes.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 0.72 | 116 | 7.03 | 2.51 |
| Without its rules | – | – | 2.3× | 2.2× |
| Hand loop | 0.9× | 0.8× | 1.7× | 0.8× |
| Hand rules | – | – | 1.4× | – |
Minimum times at T200_L20_S1, revision d41af96e.
Time-varying delays
The model of Time-varying delays.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 4.33 | 6437 | 15.3 | 11.8 |
| Without its rules | – | – | 4.3× | 4.3× |
| Hand loop | 0.9× | 0.8× | 4.6× | 5.8× |
| Hand rules | – | – | 1.6× | – |
Minimum times at T200_L15_S1, revision d41af96e.
Branching processes
The model of Branching processes.
| Forward run | ForwardDiff | Mooncake | Enzyme | |
|---|---|---|---|---|
| Package (μs) | 38.8 | 437 | 123 | 118 |
| Without its rules | – | – | 5.6× | 2.5× |
| Hand loop | 1.1× | 1.1× | 5.1× | 1.6× |
| Hand rules | – | – | 0.9× | – |
Minimum times at T200_L20_S5, revision d41af96e.
The data
The tables read benchmark/results/docs.csv, so the docs build times nothing. Each example is a case in test/ADFixtures/src/matrix_cases.jl, timed at the docs tier, and task -t benchmark/Taskfile.yml matrix-docs regenerates the file.