Skip to content

Exclude Enzyme from pre-release tests #644

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
merged 12 commits into from
Jul 19, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 62 additions & 10 deletions lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@ end
using LineSearches: LineSearches
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
if isempty(VERSION.prerelease)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
if isempty(VERSION.prerelease)
if isempty(VERSION.prerelease)

using Enzyme
end

u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if isempty(VERSION.prerelease)
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset "$(nameof(typeof(linesearch)))" for linesearch in (
LineSearchesJL(; method = LineSearches.Static(), autodiff = ad),
LineSearchesJL(; method = LineSearches.BackTracking(), autodiff = ad),
Expand Down Expand Up @@ -93,14 +104,25 @@ end
using ADTypes, Random, LinearSolve, LinearAlgebra
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
if isempty(VERSION.prerelease)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
if isempty(VERSION.prerelease)
if isempty(VERSION.prerelease)

using Enzyme
end

preconditioners = [
(u0) -> nothing,
u0 -> ((args...) -> (Diagonal(rand!(similar(u0))), nothing))
]

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if isempty(VERSION.prerelease)
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)

@testset "[OOP] u0: $(typeof(u0))" for u0 in u0s
Expand Down Expand Up @@ -176,15 +198,26 @@ end
using ADTypes, LinearSolve, LinearAlgebra
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
if isempty(VERSION.prerelease)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
if isempty(VERSION.prerelease)
if isempty(VERSION.prerelease)

using Enzyme
end

radius_update_schemes = [
RadiusUpdateSchemes.Simple, RadiusUpdateSchemes.NocedalWright,
RadiusUpdateSchemes.NLsolve, RadiusUpdateSchemes.Hei,
RadiusUpdateSchemes.Yuan, RadiusUpdateSchemes.Fan, RadiusUpdateSchemes.Bastin
]

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if isempty(VERSION.prerelease)
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset for radius_update_scheme in radius_update_schemes,
linsolve in (nothing, LUFactorization(), KrylovJL_GMRES(), \)

Expand Down Expand Up @@ -296,9 +329,20 @@ end
using ADTypes, LinearSolve, LinearAlgebra
using BenchmarkTools: @ballocated
using StaticArrays: SVector, @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
if isempty(VERSION.prerelease)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
if isempty(VERSION.prerelease)
if isempty(VERSION.prerelease)

using Enzyme
end

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if isempty(VERSION.prerelease)
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
solver = LevenbergMarquardt(; autodiff = ad)

@testset "[OOP] u0: $(typeof(u0))" for u0 in ([1.0, 1.0], 1.0, @SVector([1.0, 1.0]))
Expand Down Expand Up @@ -394,8 +438,16 @@ end

@testitem "Simple Sparse AutoDiff" setup=[CoreRootfindTesting] tags=[:core] begin
using ADTypes, SparseConnectivityTracer, SparseMatrixColorings

@testset for ad in (AutoForwardDiff(), AutoFiniteDiff(), AutoZygote(), AutoEnzyme())

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Include utility functions for prerelease detection

# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoFiniteDiff(), AutoZygote()]
if isempty(VERSION.prerelease)
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset for u0 in ([1.0, 1.0], 1.0)
prob = NonlinearProblem(
NonlinearFunction(quadratic_f; sparsity = TracerSparsityDetector()), u0, 2.0
Expand Down
32 changes: 23 additions & 9 deletions lib/NonlinearSolveHomotopyContinuation/test/allroots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ using NonlinearSolve
using NonlinearSolveHomotopyContinuation
using SciMLBase: NonlinearSolution
using ADTypes
using Enzyme
import NaNMath

# Conditionally import Enzyme only if not on Julia prerelease
if isempty(VERSION.prerelease)
using Enzyme
end

alg = HomotopyContinuationJL{true}(; threading = false)

@testset "scalar u" begin
Expand All @@ -14,9 +18,13 @@ alg = HomotopyContinuationJL{true}(; threading = false)
jac = function (u, p)
return 2u - p[1]
end
@testset "`NonlinearProblem` - $name" for (jac_or_autodiff, name) in [
(AutoForwardDiff(), "no jac - forwarddiff"), (AutoEnzyme(), "no jac - enzyme"), (
jac, "jac")]
# Filter autodiff backends based on Julia version
autodiff_backends = [(AutoForwardDiff(), "no jac - forwarddiff"), (jac, "jac")]
if isempty(VERSION.prerelease)
push!(autodiff_backends, (AutoEnzyme(), "no jac - enzyme"))
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset "`NonlinearProblem` - $name" for (jac_or_autodiff, name) in autodiff_backends
if jac_or_autodiff isa Function
jac = jac_or_autodiff
autodiff = nothing
Expand Down Expand Up @@ -107,11 +115,17 @@ fjac = function (u, p)
2*p[2]*u[2] 3*u[2]^2+2*p[2]*u[1]+1]
end

@testset "vector u - $name" for (rhs, jac_or_autodiff, name) in [
(f, AutoForwardDiff(), "oop + forwarddiff"), (f, AutoEnzyme(), "oop + enzyme"), (
f, fjac, "oop + jac"),
(f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, AutoEnzyme(), "iip + enzyme"), (
f!, fjac!, "iip + jac")]
# Filter test cases based on Julia version
vector_test_cases = [
(f, AutoForwardDiff(), "oop + forwarddiff"), (f, fjac, "oop + jac"),
(f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, fjac!, "iip + jac")
]
if isempty(VERSION.prerelease)
push!(vector_test_cases, (f, AutoEnzyme(), "oop + enzyme"))
push!(vector_test_cases, (f!, AutoEnzyme(), "iip + enzyme"))
end

@testset "vector u - $name" for (rhs, jac_or_autodiff, name) in vector_test_cases
sol = nothing
if jac_or_autodiff isa Function
jac = jac_or_autodiff
Expand Down
28 changes: 20 additions & 8 deletions lib/NonlinearSolveHomotopyContinuation/test/single_root.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ using NonlinearSolveHomotopyContinuation
using SciMLBase: NonlinearSolution
import NaNMath

# Include utility functions for prerelease detection

alg = HomotopyContinuationJL{false}(; threading = false)

@testset "scalar u" begin
Expand All @@ -12,9 +14,13 @@ alg = HomotopyContinuationJL{false}(; threading = false)
jac = function (u, p)
return 2u - (p + 3)
end
@testset "`NonlinearProblem` - $name" for (jac_or_autodiff, name) in [
(AutoForwardDiff(), "no jac - forwarddiff"), (AutoEnzyme(), "no jac - enzyme"), (
jac, "jac")]
# Filter autodiff backends based on Julia version
autodiff_backends = [(AutoForwardDiff(), "no jac - forwarddiff"), (jac, "jac")]
if isempty(VERSION.prerelease)
push!(autodiff_backends, (AutoEnzyme(), "no jac - enzyme"))
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset "`NonlinearProblem` - $name" for (jac_or_autodiff, name) in autodiff_backends
if jac_or_autodiff isa Function
jac = jac_or_autodiff
autodiff = nothing
Expand Down Expand Up @@ -96,11 +102,17 @@ jac = function (u, p)
2*p[2]*u[2] 3*u[2]^2+2*p[2]*u[1]+1]
end

@testset "vector u - $name" for (rhs, jac_or_autodiff, name) in [
(f, AutoForwardDiff(), "oop + forwarddiff"), (f, AutoEnzyme(), "oop + enzyme"), (
f, jac, "oop + jac"),
(f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, AutoEnzyme(), "iip + enzyme"), (
f!, jac!, "iip + jac")]
# Filter test cases based on Julia version
vector_test_cases = [
(f, AutoForwardDiff(), "oop + forwarddiff"), (f, jac, "oop + jac"),
(f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, jac!, "iip + jac")
]
if isempty(VERSION.prerelease)
push!(vector_test_cases, (f, AutoEnzyme(), "oop + enzyme"))
push!(vector_test_cases, (f!, AutoEnzyme(), "iip + enzyme"))
end

@testset "vector u - $name" for (rhs, jac_or_autodiff, name) in vector_test_cases
if jac_or_autodiff isa Function
jac = jac_or_autodiff
autodiff = nothing
Expand Down
48 changes: 42 additions & 6 deletions lib/NonlinearSolveQuasiNewton/test/core_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@ end
using LineSearches: LineSearches
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset "$(nameof(typeof(linesearch)))" for linesearch in (
# LineSearchesJL(; method = LineSearches.Static(), autodiff = ad),
# LineSearchesJL(; method = LineSearches.BackTracking(), autodiff = ad),
Expand Down Expand Up @@ -84,9 +96,21 @@ end
using LineSearches: LineSearches
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset "$(nameof(typeof(linesearch)))" for linesearch in (
# LineSearchesJL(; method = LineSearches.Static(), autodiff = ad),
# LineSearchesJL(; method = LineSearches.BackTracking(), autodiff = ad),
Expand Down Expand Up @@ -157,9 +181,21 @@ end
using LineSearches: LineSearches
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset "$(nameof(typeof(linesearch)))" for linesearch in (
# LineSearchesJL(; method = LineSearches.Static(), autodiff = ad),
# LineSearchesJL(; method = LineSearches.BackTracking(), autodiff = ad),
Expand Down
Loading
Loading