-
-
Notifications
You must be signed in to change notification settings - Fork 51
Move Enzyme tests to NoPre test group to fix prerelease CI failures #672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ChrisRackauckas
merged 5 commits into
SciML:master
from
ChrisRackauckas-Claude:move-enzyme-tests-nopre
Aug 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f7edc13
Move Enzyme tests to NoPre test group
ChrisRackauckas aebeba2
Update .github/workflows/CI_SimpleNonlinearSolve.yml
ChrisRackauckas f0e95bf
Move existing tests that may use Enzyme to nopre group
ChrisRackauckas 13a7483
Merge branch 'master' into move-enzyme-tests-nopre
ChrisRackauckas 35a8bb0
Make Enzyme a conditional test dependency loaded only for nopre group
ChrisRackauckas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@testitem "PolyAlgorithms with Enzyme" tags=[:nopre] skip=!isempty(VERSION.prerelease) begin | ||
using ADTypes | ||
|
||
# Only run these tests on non-prerelease Julia versions | ||
@info "Running Enzyme tests (Julia $(VERSION))" | ||
|
||
cache = zeros(2) | ||
function f(du, u, p) | ||
cache .= u .* u | ||
du .= cache .- 2 | ||
end | ||
u0 = [1.0, 1.0] | ||
probN = NonlinearProblem{true}(f, u0) | ||
|
||
# Test with AutoEnzyme for autodiff | ||
if isempty(VERSION.prerelease) | ||
using Enzyme | ||
sol = solve(probN, RobustMultiNewton(; autodiff = AutoEnzyme())) | ||
@test SciMLBase.successful_retcode(sol) | ||
|
||
sol = solve( | ||
probN, FastShortcutNonlinearPolyalg(; autodiff = AutoEnzyme()); abstol = 1e-9 | ||
) | ||
@test SciMLBase.successful_retcode(sol) | ||
end | ||
end | ||
|
||
@testitem "ForwardDiff with Enzyme backend" tags=[:nopre] skip=!isempty(VERSION.prerelease) begin | ||
using ForwardDiff, ADTypes | ||
|
||
# Only run these tests on non-prerelease Julia versions | ||
@info "Running ForwardDiff-Enzyme integration tests (Julia $(VERSION))" | ||
|
||
test_f!(du, u, p) = (@. du = u^2 - p) | ||
test_f(u, p) = (@. u^2 - p) | ||
|
||
function solve_oop(p) | ||
solve(NonlinearProblem(test_f, 2.0, p), NewtonRaphson(; autodiff = AutoEnzyme())).u | ||
end | ||
|
||
if isempty(VERSION.prerelease) | ||
using Enzyme | ||
|
||
# Test scalar AD with Enzyme backend | ||
for p in 1.0:0.1:10.0 | ||
sol = solve(NonlinearProblem(test_f, 2.0, p), NewtonRaphson(; autodiff = AutoEnzyme())) | ||
if SciMLBase.successful_retcode(sol) | ||
gs = abs.(ForwardDiff.derivative(solve_oop, p)) | ||
gs_true = abs.(1 / (2 * √p)) | ||
@test abs.(gs) ≈ abs.(gs_true) atol=1e-5 | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.