diff --git a/.github/workflows/CI_BracketingNonlinearSolve.yml b/.github/workflows/CI_BracketingNonlinearSolve.yml index 57cfd2daf..e10b90523 100644 --- a/.github/workflows/CI_BracketingNonlinearSolve.yml +++ b/.github/workflows/CI_BracketingNonlinearSolve.yml @@ -24,6 +24,7 @@ jobs: matrix: version: - "1.10" + - "1.11" - "1" os: - ubuntu-latest diff --git a/.github/workflows/CI_NonlinearSolve.yml b/.github/workflows/CI_NonlinearSolve.yml index aeee30f84..64db32335 100644 --- a/.github/workflows/CI_NonlinearSolve.yml +++ b/.github/workflows/CI_NonlinearSolve.yml @@ -38,6 +38,7 @@ jobs: - nopre version: - "1" + - "1.11" - "lts" - "pre" os: diff --git a/.github/workflows/CI_NonlinearSolveBase.yml b/.github/workflows/CI_NonlinearSolveBase.yml index 456f981f9..40aa858f8 100644 --- a/.github/workflows/CI_NonlinearSolveBase.yml +++ b/.github/workflows/CI_NonlinearSolveBase.yml @@ -23,6 +23,7 @@ jobs: matrix: version: - "1.10" + - "1.11" - "1" os: - ubuntu-latest diff --git a/.github/workflows/CI_NonlinearSolveFirstOrder.yml b/.github/workflows/CI_NonlinearSolveFirstOrder.yml index 27bc96312..c7e002549 100644 --- a/.github/workflows/CI_NonlinearSolveFirstOrder.yml +++ b/.github/workflows/CI_NonlinearSolveFirstOrder.yml @@ -24,6 +24,7 @@ jobs: matrix: version: - "1.10" + - "1.11" - "1" os: - ubuntu-latest diff --git a/.github/workflows/CI_NonlinearSolveHomotopyContinuation.yml b/.github/workflows/CI_NonlinearSolveHomotopyContinuation.yml index ccf650c7d..f63874062 100644 --- a/.github/workflows/CI_NonlinearSolveHomotopyContinuation.yml +++ b/.github/workflows/CI_NonlinearSolveHomotopyContinuation.yml @@ -23,6 +23,7 @@ jobs: matrix: version: - "1.10" + - "1.11" - "1" os: - ubuntu-latest diff --git a/.github/workflows/CI_NonlinearSolveQuasiNewton.yml b/.github/workflows/CI_NonlinearSolveQuasiNewton.yml index cf6a2038b..8bef9142e 100644 --- a/.github/workflows/CI_NonlinearSolveQuasiNewton.yml +++ b/.github/workflows/CI_NonlinearSolveQuasiNewton.yml @@ -24,6 +24,7 @@ jobs: matrix: version: - "1.10" + - "1.11" - "1" os: - ubuntu-latest diff --git a/.github/workflows/CI_NonlinearSolveSciPy.yml b/.github/workflows/CI_NonlinearSolveSciPy.yml index 6882d4fd9..fc32286f6 100644 --- a/.github/workflows/CI_NonlinearSolveSciPy.yml +++ b/.github/workflows/CI_NonlinearSolveSciPy.yml @@ -23,6 +23,7 @@ jobs: matrix: version: - "1.10" + - "1.11" - "1" os: - ubuntu-latest diff --git a/.github/workflows/CI_NonlinearSolveSpectralMethods.yml b/.github/workflows/CI_NonlinearSolveSpectralMethods.yml index 33180d05a..864c245a1 100644 --- a/.github/workflows/CI_NonlinearSolveSpectralMethods.yml +++ b/.github/workflows/CI_NonlinearSolveSpectralMethods.yml @@ -24,6 +24,7 @@ jobs: matrix: version: - "1.10" + - "1.11" - "1" os: - ubuntu-latest diff --git a/.github/workflows/CI_SCCNonlinearSolve.yml b/.github/workflows/CI_SCCNonlinearSolve.yml index 7b2b6b79f..bed8979ed 100644 --- a/.github/workflows/CI_SCCNonlinearSolve.yml +++ b/.github/workflows/CI_SCCNonlinearSolve.yml @@ -24,6 +24,7 @@ jobs: matrix: version: - "lts" + - "1.11" - "1" os: - ubuntu-latest diff --git a/.github/workflows/CI_SciMLJacobianOperators.yml b/.github/workflows/CI_SciMLJacobianOperators.yml index e031009d7..2f600cc27 100644 --- a/.github/workflows/CI_SciMLJacobianOperators.yml +++ b/.github/workflows/CI_SciMLJacobianOperators.yml @@ -22,6 +22,7 @@ jobs: matrix: version: - "1.10" + - "1.11" - "1" os: - ubuntu-latest diff --git a/.github/workflows/CI_SimpleNonlinearSolve.yml b/.github/workflows/CI_SimpleNonlinearSolve.yml index 72c0b3d5c..bc842214a 100644 --- a/.github/workflows/CI_SimpleNonlinearSolve.yml +++ b/.github/workflows/CI_SimpleNonlinearSolve.yml @@ -25,6 +25,7 @@ jobs: matrix: version: - "1.10" + - "1.11" - "1" os: - ubuntu-latest diff --git a/lib/NonlinearSolveBase/ext/NonlinearSolveBaseEnzymeExt.jl b/lib/NonlinearSolveBase/ext/NonlinearSolveBaseEnzymeExt.jl index 3bdc7f42e..8ad6fde4b 100644 --- a/lib/NonlinearSolveBase/ext/NonlinearSolveBaseEnzymeExt.jl +++ b/lib/NonlinearSolveBase/ext/NonlinearSolveBaseEnzymeExt.jl @@ -1,6 +1,6 @@ module NonlinearSolveBaseEnzymeExt -@static if isempty(VERSION.prerelease) +@static if isempty(VERSION.prerelease) && VERSION < v"1.12" using NonlinearSolveBase import SciMLBase: SciMLBase, value using Enzyme diff --git a/lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl b/lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl index a1c1968fb..0d122c2d6 100644 --- a/lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl +++ b/lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl @@ -12,7 +12,7 @@ end using Zygote, ForwardDiff, FiniteDiff # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end @@ -20,7 +20,7 @@ end # Filter autodiff backends based on Julia version autodiff_backends=[AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, AutoEnzyme()) end @@ -110,7 +110,7 @@ end using Zygote, ForwardDiff, FiniteDiff # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end @@ -121,7 +121,7 @@ end # Filter autodiff backends based on Julia version autodiff_backends=[AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, AutoEnzyme()) end @@ -207,7 +207,7 @@ end using Zygote, ForwardDiff, FiniteDiff # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end @@ -219,7 +219,7 @@ end # Filter autodiff backends based on Julia version autodiff_backends=[AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, AutoEnzyme()) end @@ -340,13 +340,13 @@ end using Zygote, ForwardDiff, FiniteDiff # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end # Filter autodiff backends based on Julia version autodiff_backends=[AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, AutoEnzyme()) end @@ -451,7 +451,7 @@ end # Filter autodiff backends based on Julia version autodiff_backends=[AutoForwardDiff(), AutoFiniteDiff(), AutoZygote()] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, AutoEnzyme()) end diff --git a/lib/NonlinearSolveHomotopyContinuation/test/allroots.jl b/lib/NonlinearSolveHomotopyContinuation/test/allroots.jl index aa813e0c1..afccae586 100644 --- a/lib/NonlinearSolveHomotopyContinuation/test/allroots.jl +++ b/lib/NonlinearSolveHomotopyContinuation/test/allroots.jl @@ -5,7 +5,7 @@ using ADTypes import NaNMath # Conditionally import Enzyme only if not on Julia prerelease -if isempty(VERSION.prerelease) +if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end @@ -20,7 +20,7 @@ alg = HomotopyContinuationJL{true}(; threading = false) end # Filter autodiff backends based on Julia version autodiff_backends = [(AutoForwardDiff(), "no jac - forwarddiff"), (jac, "jac")] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, (AutoEnzyme(), "no jac - enzyme")) end @@ -120,7 +120,7 @@ vector_test_cases = [ (f, AutoForwardDiff(), "oop + forwarddiff"), (f, fjac, "oop + jac"), (f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, fjac!, "iip + jac") ] -if isempty(VERSION.prerelease) +if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(vector_test_cases, (f, AutoEnzyme(), "oop + enzyme")) push!(vector_test_cases, (f!, AutoEnzyme(), "iip + enzyme")) end diff --git a/lib/NonlinearSolveHomotopyContinuation/test/single_root.jl b/lib/NonlinearSolveHomotopyContinuation/test/single_root.jl index 289116f33..73b12ae78 100644 --- a/lib/NonlinearSolveHomotopyContinuation/test/single_root.jl +++ b/lib/NonlinearSolveHomotopyContinuation/test/single_root.jl @@ -14,7 +14,7 @@ alg = HomotopyContinuationJL{false}(; threading = false) end # Filter autodiff backends based on Julia version autodiff_backends = [(AutoForwardDiff(), "no jac - forwarddiff"), (jac, "jac")] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, (AutoEnzyme(), "no jac - enzyme")) end @@ -105,7 +105,7 @@ vector_test_cases = [ (f, AutoForwardDiff(), "oop + forwarddiff"), (f, jac, "oop + jac"), (f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, jac!, "iip + jac") ] -if isempty(VERSION.prerelease) +if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(vector_test_cases, (f, AutoEnzyme(), "oop + enzyme")) push!(vector_test_cases, (f!, AutoEnzyme(), "iip + enzyme")) end diff --git a/lib/NonlinearSolveQuasiNewton/test/core_tests.jl b/lib/NonlinearSolveQuasiNewton/test/core_tests.jl index 367e23246..7e89f196c 100644 --- a/lib/NonlinearSolveQuasiNewton/test/core_tests.jl +++ b/lib/NonlinearSolveQuasiNewton/test/core_tests.jl @@ -12,7 +12,7 @@ end using Zygote, ForwardDiff, FiniteDiff # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end @@ -20,7 +20,7 @@ end # Filter autodiff backends based on Julia version autodiff_backends=[AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, AutoEnzyme()) end @@ -100,13 +100,13 @@ end using Zygote, ForwardDiff, FiniteDiff # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end # Filter autodiff backends based on Julia version autodiff_backends=[AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, AutoEnzyme()) end @@ -186,13 +186,13 @@ end using Zygote, ForwardDiff, FiniteDiff # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end # Filter autodiff backends based on Julia version autodiff_backends=[AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, AutoEnzyme()) end diff --git a/lib/SciMLJacobianOperators/test/core_tests.jl b/lib/SciMLJacobianOperators/test/core_tests.jl index 7160ae0ec..53eef7df1 100644 --- a/lib/SciMLJacobianOperators/test/core_tests.jl +++ b/lib/SciMLJacobianOperators/test/core_tests.jl @@ -4,7 +4,7 @@ using SciMLJacobianOperators # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end @@ -14,7 +14,7 @@ AutoTracker(), AutoFiniteDiff() ] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(reverse_ADs, AutoEnzyme()) push!(reverse_ADs, AutoEnzyme(; mode = Enzyme.Reverse)) end @@ -23,7 +23,7 @@ AutoForwardDiff(), AutoFiniteDiff() ] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(forward_ADs, AutoEnzyme()) push!(forward_ADs, AutoEnzyme(; mode = Enzyme.Forward)) end @@ -102,7 +102,7 @@ end using SciMLJacobianOperators # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end @@ -110,7 +110,7 @@ end AutoReverseDiff(), AutoFiniteDiff() ] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(reverse_ADs, AutoEnzyme()) push!(reverse_ADs, AutoEnzyme(; mode = Enzyme.Reverse)) end @@ -119,7 +119,7 @@ end AutoForwardDiff(), AutoFiniteDiff() ] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(forward_ADs, AutoEnzyme()) push!(forward_ADs, AutoEnzyme(; mode = Enzyme.Forward)) end @@ -204,7 +204,7 @@ end using SciMLJacobianOperators # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end @@ -214,7 +214,7 @@ end AutoReverseDiff(), AutoFiniteDiff() ] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(reverse_ADs, AutoEnzyme()) push!(reverse_ADs, AutoEnzyme(; mode = Enzyme.Reverse)) end @@ -223,7 +223,7 @@ end AutoForwardDiff(), AutoFiniteDiff() ] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(forward_ADs, AutoEnzyme()) push!(forward_ADs, AutoEnzyme(; mode = Enzyme.Forward)) end diff --git a/lib/SimpleNonlinearSolve/test/core/rootfind_tests.jl b/lib/SimpleNonlinearSolve/test/core/rootfind_tests.jl index def3b9ab1..dd71211f6 100644 --- a/lib/SimpleNonlinearSolve/test/core/rootfind_tests.jl +++ b/lib/SimpleNonlinearSolve/test/core/rootfind_tests.jl @@ -3,7 +3,7 @@ using ADTypes, PolyesterForwardDiff, ReverseDiff # Conditionally import Enzyme only if not on Julia prerelease - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" using Enzyme end @@ -59,7 +59,7 @@ end AutoReverseDiff(), nothing ] - if isempty(VERSION.prerelease) + if isempty(VERSION.prerelease) && VERSION < v"1.12" push!(autodiff_backends, AutoEnzyme()) end diff --git a/test/adjoint_tests.jl b/test/adjoint_tests.jl index 8882c1916..90dba8ffe 100644 --- a/test/adjoint_tests.jl +++ b/test/adjoint_tests.jl @@ -1,27 +1,33 @@ @testitem "Adjoint Tests" tags = [:nopre] begin - using ForwardDiff, ReverseDiff, SciMLSensitivity, Tracker, Zygote, Enzyme, Mooncake + # Skip adjoint tests on Julia 1.12+ due to Enzyme/SciMLSensitivity compatibility issues + # To re-enable: change condition to `false` or `VERSION >= v"1.13"` + @static if VERSION < v"1.12" + using ForwardDiff, ReverseDiff, SciMLSensitivity, Tracker, Zygote, Enzyme, Mooncake - ff(u, p) = u .^ 2 .- p + ff(u, p) = u .^ 2 .- p - function solve_nlprob(p) - prob = NonlinearProblem{false}(ff, [1.0, 2.0], p) - sol = solve(prob, NewtonRaphson()) - res = sol isa AbstractArray ? sol : sol.u - return sum(abs2, res) - end + function solve_nlprob(p) + prob = NonlinearProblem{false}(ff, [1.0, 2.0], p) + sol = solve(prob, NewtonRaphson()) + res = sol isa AbstractArray ? sol : sol.u + return sum(abs2, res) + end - p = [3.0, 2.0] + p = [3.0, 2.0] - ∂p_zygote = only(Zygote.gradient(solve_nlprob, p)) - ∂p_forwarddiff = ForwardDiff.gradient(solve_nlprob, p) - ∂p_tracker = Tracker.data(only(Tracker.gradient(solve_nlprob, p))) - ∂p_reversediff = ReverseDiff.gradient(solve_nlprob, p) - ∂p_enzyme = Enzyme.gradient(Enzyme.set_runtime_activity(Enzyme.Reverse), solve_nlprob, p)[1] + ∂p_zygote = only(Zygote.gradient(solve_nlprob, p)) + ∂p_forwarddiff = ForwardDiff.gradient(solve_nlprob, p) + ∂p_tracker = Tracker.data(only(Tracker.gradient(solve_nlprob, p))) + ∂p_reversediff = ReverseDiff.gradient(solve_nlprob, p) + ∂p_enzyme = Enzyme.gradient(Enzyme.set_runtime_activity(Enzyme.Reverse), solve_nlprob, p)[1] - cache = Mooncake.prepare_gradient_cache(solve_nlprob, p) - ∂p_mooncake = Mooncake.value_and_gradient!!(cache, solve_nlprob, p)[2][2] + cache = Mooncake.prepare_gradient_cache(solve_nlprob, p) + ∂p_mooncake = Mooncake.value_and_gradient!!(cache, solve_nlprob, p)[2][2] - @test ∂p_zygote ≈ ∂p_tracker ≈ ∂p_reversediff ≈ ∂p_enzyme - @test ∂p_zygote ≈ ∂p_forwarddiff ≈ ∂p_tracker ≈ ∂p_reversediff ≈ ∂p_enzyme - @test_broken ∂p_forwarddiff ≈ ∂p_mooncake + @test ∂p_zygote ≈ ∂p_tracker ≈ ∂p_reversediff ≈ ∂p_enzyme + @test ∂p_zygote ≈ ∂p_forwarddiff ≈ ∂p_tracker ≈ ∂p_reversediff ≈ ∂p_enzyme + @test_broken ∂p_forwarddiff ≈ ∂p_mooncake + else + @info "Skipping adjoint tests on Julia $(VERSION) - Enzyme/SciMLSensitivity not compatible with 1.12+" + end end diff --git a/test/runtests.jl b/test/runtests.jl index 3ed6985dc..a84b3f88b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,14 +24,18 @@ end const GROUP = lowercase(get_from_test_args_or_env("GROUP", "all")) +# Disable Enzyme on Julia 1.12+ due to compatibility issues +# To re-enable: change condition to `true` or `VERSION < v"1.13"` +const ENZYME_ENABLED = VERSION < v"1.12" + const EXTRA_PKGS = Pkg.PackageSpec[] if GROUP == "all" || GROUP == "downstream" push!(EXTRA_PKGS, Pkg.PackageSpec("ModelingToolkit")) push!(EXTRA_PKGS, Pkg.PackageSpec("SymbolicIndexingInterface")) end if GROUP == "all" || GROUP == "nopre" - # Only add Enzyme for nopre group if not on prerelease Julia - if isempty(VERSION.prerelease) + # Only add Enzyme for nopre group if not on prerelease Julia and if enabled + if isempty(VERSION.prerelease) && ENZYME_ENABLED push!(EXTRA_PKGS, Pkg.PackageSpec("Enzyme")) push!(EXTRA_PKGS, Pkg.PackageSpec("Mooncake")) push!(EXTRA_PKGS, Pkg.PackageSpec("SciMLSensitivity")) @@ -51,12 +55,14 @@ const RETESTITEMS_NWORKERS = if GROUP == "wrappers" 0 # Sequential execution for wrapper tests else tmp = get(ENV, "RETESTITEMS_NWORKERS", "") - isempty(tmp) && (tmp = string(min(ifelse(Sys.iswindows(), 0, Hwloc.num_physical_cores()), 4))) + isempty(tmp) && + (tmp = string(min(ifelse(Sys.iswindows(), 0, Hwloc.num_physical_cores()), 4))) parse(Int, tmp) end const RETESTITEMS_NWORKER_THREADS = begin tmp = get(ENV, "RETESTITEMS_NWORKER_THREADS", "") - isempty(tmp) && (tmp = string(max(Hwloc.num_virtual_cores() ÷ max(RETESTITEMS_NWORKERS, 1), 1))) + isempty(tmp) && + (tmp = string(max(Hwloc.num_virtual_cores() ÷ max(RETESTITEMS_NWORKERS, 1), 1))) parse(Int, tmp) end