Skip to content

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 runForwardDiffMooncakeEnzyme
Without its rules (geometric mean)––4.5×2.6×
Slower than without its rules––0 of 150 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 loop6 of 158 of 151 of 152 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 runForwardDiffMooncakeEnzyme
Package (μs)19.7280072.256.4
Without its rules––6.3×3.2×
Hand loop1.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 runForwardDiffMooncakeEnzyme
Package (μs)15.7662755.145.0
Without its rules––7.5×1.8×
Hand loop1.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 runForwardDiffMooncakeEnzyme
Package (μs)1851275869816548
Without its rules––10.6×4.1×
Hand loop1.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 runForwardDiffMooncakeEnzyme
Package (μs)4.11274523.211.8
Without its rules––6.6×5.0×
Hand loop1.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 runForwardDiffMooncakeEnzyme
Package (μs)7.6167224.918.5
Without its rules––3.5×1.3×
Hand loop1.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 runForwardDiffMooncakeEnzyme
Package (μs)16.6213654.247.4
Without its rules––2.6×3.2×
Hand loop0.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 runForwardDiffMooncakeEnzyme
Package (μs)8.95133038.039.4
Without its rules––2.8×1.6×
Hand loop1.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 runForwardDiffMooncakeEnzyme
Package (μs)3.867431.282.3
Without its rules––4.4×1.1×
Hand loop2.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 runForwardDiffMooncakeEnzyme
Package (μs)2.6663820.811.9
Without its rules––3.8×1.9×
Hand loop2.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 runForwardDiffMooncakeEnzyme
Package (μs)32.8401399.776.4
Without its rules––4.5×3.1×
Hand loop0.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 runForwardDiffMooncakeEnzyme
Package (μs)38.220060158116
Without its rules––7.6×–
Hand loop1.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 runForwardDiffMooncakeEnzyme
Package (μs)7.11105041.235.6
Without its rules––2.4×5.0×
Hand loop0.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 runForwardDiffMooncakeEnzyme
Package (μs)0.721167.032.51
Without its rules––2.3×2.2×
Hand loop0.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 runForwardDiffMooncakeEnzyme
Package (μs)4.33643715.311.8
Without its rules––4.3×4.3×
Hand loop0.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 runForwardDiffMooncakeEnzyme
Package (μs)38.8437123118
Without its rules––5.6×2.5×
Hand loop1.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.