Skip to content

Commit 8a90b18

Browse files
Move Enzyme tests to NoPre test group
This change addresses CI failures on Julia prerelease versions by: - Creating a new 'nopre' test group for tests that use Enzyme - Adding the nopre group to CI configuration for NonlinearSolve and SimpleNonlinearSolve - Excluding nopre tests from running on Julia 'pre' version in CI - Creating enzyme_tests.jl with example Enzyme tests that skip on prerelease All existing Enzyme tests in subpackages already have VERSION.prerelease checks, but this change provides an additional CI-level control to prevent these tests from running on prerelease Julia versions. Fixes test failures seen in https://github.com/SciML/NonlinearSolve.jl/actions/runs/16851672503/job/47738829623 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 4ec8d81 commit 8a90b18

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

.github/workflows/CI_NonlinearSolve.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ jobs:
3636
- downstream
3737
- wrappers
3838
- misc
39+
- nopre
3940
version:
4041
- "1"
4142
- "lts"
4243
- "pre"
4344
os:
4445
- ubuntu-latest
4546
- macos-latest
47+
exclude:
48+
# Don't run nopre tests on prerelease Julia
49+
- group: nopre
50+
version: "pre"
4651
steps:
4752
- uses: actions/checkout@v4
4853
- uses: julia-actions/setup-julia@v2

.github/workflows/CI_SimpleNonlinearSolve.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
- core
3535
- adjoint
3636
- alloc_check
37+
- nopre
3738
steps:
3839
- uses: actions/checkout@v4
3940
- uses: julia-actions/setup-julia@v2

test/enzyme_tests.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
@testitem "PolyAlgorithms with Enzyme" tags=[:nopre] skip=!isempty(VERSION.prerelease) begin
2+
using ADTypes
3+
4+
# Only run these tests on non-prerelease Julia versions
5+
@info "Running Enzyme tests (Julia $(VERSION))"
6+
7+
cache = zeros(2)
8+
function f(du, u, p)
9+
cache .= u .* u
10+
du .= cache .- 2
11+
end
12+
u0 = [1.0, 1.0]
13+
probN = NonlinearProblem{true}(f, u0)
14+
15+
# Test with AutoEnzyme for autodiff
16+
if isempty(VERSION.prerelease)
17+
using Enzyme
18+
sol = solve(probN, RobustMultiNewton(; autodiff = AutoEnzyme()))
19+
@test SciMLBase.successful_retcode(sol)
20+
21+
sol = solve(
22+
probN, FastShortcutNonlinearPolyalg(; autodiff = AutoEnzyme()); abstol = 1e-9
23+
)
24+
@test SciMLBase.successful_retcode(sol)
25+
end
26+
end
27+
28+
@testitem "ForwardDiff with Enzyme backend" tags=[:nopre] skip=!isempty(VERSION.prerelease) begin
29+
using ForwardDiff, ADTypes
30+
31+
# Only run these tests on non-prerelease Julia versions
32+
@info "Running ForwardDiff-Enzyme integration tests (Julia $(VERSION))"
33+
34+
test_f!(du, u, p) = (@. du = u^2 - p)
35+
test_f(u, p) = (@. u^2 - p)
36+
37+
function solve_oop(p)
38+
solve(NonlinearProblem(test_f, 2.0, p), NewtonRaphson(; autodiff = AutoEnzyme())).u
39+
end
40+
41+
if isempty(VERSION.prerelease)
42+
using Enzyme
43+
44+
# Test scalar AD with Enzyme backend
45+
for p in 1.0:0.1:10.0
46+
sol = solve(NonlinearProblem(test_f, 2.0, p), NewtonRaphson(; autodiff = AutoEnzyme()))
47+
if SciMLBase.successful_retcode(sol)
48+
gs = abs.(ForwardDiff.derivative(solve_oop, p))
49+
gs_true = abs.(1 / (2 * p))
50+
@test abs.(gs) abs.(gs_true) atol=1e-5
51+
end
52+
end
53+
end
54+
end

0 commit comments

Comments
 (0)