From 4abf3f43f023b85db006a060b52b0e2b43140e8f Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Fri, 11 Sep 2026 17:46:37 -0400 Subject: [PATCH] Add AirspeedVelocity benchmarking CI Adds a benchmark workflow (Julia 1 and lts) and a benchmark/benchmarks.jl suite covering representative workloads so PRs check for performance regressions. Co-Authored-By: Chris Rackauckas Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: devin 3000.10.21 (611c1cba) Agent-Model: SWE-2 High Agent-Session: local session transcript /home/crackauc/sandbox/tmp_20260911_112052_59120/history_6a789c0b69c64ca3.md --- .github/workflows/benchmark.yml | 29 +++++++++++++++++++ benchmark/benchmarks.jl | 51 +++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/benchmark.yml create mode 100644 benchmark/benchmarks.jl diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 0000000..87afbc1 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,29 @@ +name: Benchmark this PR + +on: + pull_request: + branches: [main] + paths-ignore: ['docs/**'] + +permissions: + pull-requests: write + contents: read + +jobs: + benchmark: + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + version: ["1", "lts"] + env: + # Force consistent Julia depot path for self-hosted runners + JULIA_DEPOT_PATH: ~/.julia + steps: + - uses: MilesCranmer/AirspeedVelocity.jl@action-v1 + with: + julia-version: ${{ matrix.version }} + script: "benchmark/benchmarks.jl" + extra-pkgs: "" + job-summary: true diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl new file mode 100644 index 0000000..74facf5 --- /dev/null +++ b/benchmark/benchmarks.jl @@ -0,0 +1,51 @@ +using ADTypes, BenchmarkTools +using SparseArrays + +const SUITE = BenchmarkGroup() + +# ============================================================================= +# Backend construction +# ============================================================================= + +SUITE["construct"] = BenchmarkGroup() + +SUITE["construct"]["AutoForwardDiff"] = @benchmarkable AutoForwardDiff() +SUITE["construct"]["AutoFiniteDiff"] = @benchmarkable AutoFiniteDiff() +SUITE["construct"]["AutoZygote"] = @benchmarkable AutoZygote() +SUITE["construct"]["AutoEnzyme"] = @benchmarkable AutoEnzyme() +SUITE["construct"]["AutoForwardDiff_chunk"] = @benchmarkable AutoForwardDiff( + chunksize = 8 +) +SUITE["construct"]["AutoSparse"] = @benchmarkable AutoSparse(AutoForwardDiff()) + +# ============================================================================= +# Interface queries +# ============================================================================= + +SUITE["interface"] = BenchmarkGroup() + +afd = AutoForwardDiff() +asp = AutoSparse(AutoForwardDiff()) + +SUITE["interface"]["mode"] = @benchmarkable ADTypes.mode($afd) +SUITE["interface"]["dense_ad"] = @benchmarkable ADTypes.dense_ad($asp) +SUITE["interface"]["dense_ad_dense"] = @benchmarkable ADTypes.dense_ad($afd) + +# ============================================================================= +# Sparsity detection (known-pattern path) +# ============================================================================= + +SUITE["sparsity"] = BenchmarkGroup() + +N = 100 +f_jac(x) = x .* x +x_vec = ones(N) +J_pattern = sparse(ones(N, N)) +detector = ADTypes.KnownJacobianSparsityDetector(J_pattern) + +SUITE["sparsity"]["construct_detector"] = @benchmarkable ADTypes.KnownJacobianSparsityDetector( + $J_pattern +) +SUITE["sparsity"]["jacobian_sparsity"] = @benchmarkable jacobian_sparsity( + $f_jac, $x_vec, $detector +)