Skip to content

Commit 96c7eaa

Browse files
committed
Add Enzyme testing as a separate CI action
1 parent cf2ca27 commit 96c7eaa

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/Enzyme.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Enzyme on demo models
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
# needed to allow julia-actions/cache to delete old caches that it has created
10+
permissions:
11+
actions: write
12+
contents: read
13+
14+
# Cancel existing tests on the same PR if a new commit is added to a pull request
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
17+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: julia-actions/setup-julia@v2
26+
with:
27+
version: "1"
28+
29+
- uses: julia-actions/cache@v2
30+
31+
- uses: julia-actions/julia-buildpkg@v1
32+
33+
- name: Run AD with Enzyme on demo models
34+
shell: julia --color=yes {0}
35+
run: |
36+
# Set up fresh environment
37+
using Pkg
38+
Pkg.activate(; temp=true)
39+
Pkg.develop(path=".")
40+
Pkg.add(["Enzyme", "ForwardDiff", "ADTypes", "Test"])
41+
42+
using DynamicPPL.TestUtils: DEMO_MODELS
43+
using DynamicPPL.TestUtils.AD: run_ad
44+
using ADTypes: AutoEnzyme
45+
using Test: @test, @testset
46+
import Enzyme: set_runtime_activity, Forward, Reverse
47+
import ForwardDiff # run_ad uses FD for correctness test
48+
49+
ADTYPES = Dict(
50+
"EnzymeForward" => AutoEnzyme(mode=set_runtime_activity(Forward)),
51+
"EnzymeReverse" => AutoEnzyme(mode=set_runtime_activity(Reverse)),
52+
)
53+
54+
@testset "$(model.f)" for model in DEMO_MODELS
55+
@testset "$ad_key" for (ad_key, ad_type) in ADTYPES
56+
@test run_ad(model, ad_type) isa Any
57+
end
58+
end

0 commit comments

Comments
 (0)