Skip to content

Conversation

@ChrisRackauckas
Copy link
Contributor

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 18, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/test/integration/SciML/runtests.jl b/test/integration/SciML/runtests.jl
index 7c655e40..631ab6a9 100644
--- a/test/integration/SciML/runtests.jl
+++ b/test/integration/SciML/runtests.jl
@@ -9,47 +9,49 @@ using LinearSolve, LinearAlgebra
         du[3] = u[1] * u[2] - (8 / 3) * u[3]
     end
 
-    _saveat =  SA[0.0,0.25,0.5,0.75,1.0,1.25,1.5,1.75,2.0,2.25,2.5,2.75,3.0]
+    _saveat = SA[0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0]
 
     function f_dt(y::Array{Float64}, u0::Array{Float64})
         tspan = (0.0, 3.0)
         prob = ODEProblem{true, SciMLBase.FullSpecialize}(lorenz!, u0, tspan)
-        sol = DiffEqBase.solve(prob, Tsit5(), saveat = _saveat, sensealg = DiffEqBase.SensitivityADPassThrough(), abstol=1e-12, reltol=1e-12)
-        y .= sol[1,:]
+        sol = DiffEqBase.solve(prob, Tsit5(), saveat = _saveat, sensealg = DiffEqBase.SensitivityADPassThrough(), abstol = 1.0e-12, reltol = 1.0e-12)
+        y .= sol[1, :]
         return nothing
-    end;
+    end
 
     function f_dt(u0)
         tspan = (0.0, 3.0)
         prob = ODEProblem{true, SciMLBase.FullSpecialize}(lorenz!, u0, tspan)
-        sol = DiffEqBase.solve(prob, Tsit5(), saveat = _saveat, sensealg = DiffEqBase.SensitivityADPassThrough(), abstol=1e-12, reltol=1e-12)
-        sol[1,:]
-    end;
+        sol = DiffEqBase.solve(prob, Tsit5(), saveat = _saveat, sensealg = DiffEqBase.SensitivityADPassThrough(), abstol = 1.0e-12, reltol = 1.0e-12)
+        sol[1, :]
+    end
 
     u0 = [1.0; 0.0; 0.0]
     fdj = ForwardDiff.jacobian(f_dt, u0)
 
-    ezj = stack(map(1:3) do i
-        d_u0 = zeros(3)
-        dy = zeros(13)
-        y  = zeros(13)
-        d_u0[i] = 1.0
-        Enzyme.autodiff(Forward, f_dt,  Duplicated(y, dy), Duplicated(u0, d_u0));
-        dy
-    end)
+    ezj = stack(
+        map(1:3) do i
+            d_u0 = zeros(3)
+            dy = zeros(13)
+            y = zeros(13)
+            d_u0[i] = 1.0
+            Enzyme.autodiff(Forward, f_dt, Duplicated(y, dy), Duplicated(u0, d_u0))
+            dy
+        end
+    )
 
     @test ezj ≈ fdj
 
     function f_dt2(u0)
         tspan = (0.0, 3.0)
         prob = ODEProblem{true, SciMLBase.FullSpecialize}(lorenz!, u0, tspan)
-        sol = DiffEqBase.solve(prob, Tsit5(), dt=0.1, saveat = _saveat, sensealg = DiffEqBase.SensitivityADPassThrough(), abstol=1e-12, reltol=1e-12)
-        sum(sol[1,:])
+        sol = DiffEqBase.solve(prob, Tsit5(), dt = 0.1, saveat = _saveat, sensealg = DiffEqBase.SensitivityADPassThrough(), abstol = 1.0e-12, reltol = 1.0e-12)
+        sum(sol[1, :])
     end
 
     fdg = ForwardDiff.gradient(f_dt2, u0)
     d_u0 = zeros(3)
-    Enzyme.autodiff(Reverse, f_dt2,  Active, Duplicated(u0, d_u0));
+    Enzyme.autodiff(Reverse, f_dt2, Active, Duplicated(u0, d_u0))
 
     @test d_u0 ≈ fdg
 end
@@ -61,7 +63,7 @@ struct senseloss0{T}
 end
 function (f::senseloss0)(u0p)
     prob = ODEProblem{true}(odef, u0p[1:1], (0.0, 1.0), u0p[2:2])
-    sum(solve(prob, Tsit5(), abstol = 1e-12, reltol = 1e-12, saveat = 0.1))
+    return sum(solve(prob, Tsit5(), abstol = 1.0e-12, reltol = 1.0e-12, saveat = 0.1))
 end
 
 @testset "SciMLSensitivity Adjoint Interface" begin
@@ -73,12 +75,12 @@ end
     @test du0p ≈ dup
 end
 
-  @testset "LinearSolve Adjoints" begin
+@testset "LinearSolve Adjoints" begin
     n = 4
-    A = rand(n, n);
-    dA = zeros(n, n);
-    b1 = rand(n);
-    db1 = zeros(n);
+    A = rand(n, n)
+    dA = zeros(n, n)
+    b1 = rand(n)
+    db1 = zeros(n)
 
     function f(A, b1; alg = LUFactorization())
         prob = LinearProblem(A, b1)

@codecov
Copy link

codecov bot commented Sep 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.10%. Comparing base (5c4e91e) to head (8e88477).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2593   +/-   ##
=======================================
  Coverage   75.10%   75.10%           
=======================================
  Files          56       56           
  Lines       17724    17724           
=======================================
  Hits        13312    13312           
  Misses       4412     4412           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wsmoses
Copy link
Member

wsmoses commented Sep 19, 2025

ERROR: Unsatisfiable requirements detected for package SciMLBase [0bca4576]:
 SciMLBase [0bca4576] log:
 ├─possible versions are: 1.0.0-2.120.0 or uninstalled
 ├─restricted by compatibility requirements with DiffEqBase [2b5f629d] to versions: 2.115.0-2.120.0
 │ └─DiffEqBase [2b5f629d] log:
 │   ├─possible versions are: 3.13.2-6.190.2 or uninstalled
 │   └─restricted to versions 6.190.0-6 by project [beb9ea09], leaving only versions: 6.190.0-6.190.2
 │     └─project [beb9ea09] log:
 │       ├─possible versions are: 0.0.0 or uninstalled
 │       └─project [beb9ea09] is fixed to version 0.0.0
 └─restricted by compatibility requirements with LinearSolve [7ed4a6bd] to versions: 2.26.3-2.77.2 — no versions left
   └─LinearSolve [7ed4a6bd] log:
     ├─possible versions are: 0.1.0-3.40.1 or uninstalled
     └─restricted to versions 2.35.0-2 by project [beb9ea09], leaving only versions: 2.35.0-2.39.1
       └─project [beb9ea09] log: see above
       ```

@wsmoses
Copy link
Member

wsmoses commented Sep 19, 2025

Run julia --color=yes --project=test/integration/SciML --threads=auto --check-bounds=yes -O1 test/integration/SciML/runtests.jl
Run '/home/runner/k8s/index.js'
using script executor
ERROR: LoadError: syntax: unsupported `const` declaration on local variable around /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:12
Stacktrace:
 [1] top-level scope
   @ /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:5
in expression starting at /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:5
Error: Error: ScriptExecutorError when trying to execute: "Error: Job failed with exit code 1."

@ChrisRackauckas
Copy link
Contributor Author

BTW, it looks like this test just regressed in the latest release 😅

https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/17887294458/job/50863591248?pr=2869

@giordano
Copy link
Member

giordano commented Sep 21, 2025

https://github.com/EnzymeAD/Enzyme.jl/actions/runs/17889611301/job/50873551207?pr=2593#step:9:11 (only in v1.11)

Direct Differentiation of Explicit ODE Solve: Error During Test at /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:5
  Got exception outside of a @test
  Enzyme execution failed.
  Enzyme: could not deduce element type of value within generic_memory_copyto of   %18 = phi {} addrspace(10)* [ %17, %L12.i ], [ addrspacecast ({}* inttoptr (i64 135785871080672 to {}*) to {} addrspace(10)*), %entry ] within   call void @jl_genericmemory_copyto({} addrspace(10)* noundef %18, i64 %36, {} addrspace(10)* noundef %265, i64 %275, i64 %16) #20, !dbg !291
  
  Stacktrace:
    [1] unsafe_copyto!
      @ ./genericmemory.jl:125 [inlined]
    [2] unsafe_copyto!
      @ ./array.jl:284 [inlined]
    [3] getindex
      @ ./array.jl:952 [inlined]
    [4] _getindex
      @ ~/.julia/packages/RecursiveArrayTools/jieUI/src/vector_of_array.jl:430 [inlined]
    [5] getindex
      @ ~/.julia/packages/RecursiveArrayTools/jieUI/src/vector_of_array.jl:499 [inlined]
    [6] getindex
      @ ~/.julia/packages/RecursiveArrayTools/jieUI/src/vector_of_array.jl:0 [inlined]
    [7] fwddiffejulia_getindex_32551_inner_5wrap
      @ ~/.julia/packages/RecursiveArrayTools/jieUI/src/vector_of_array.jl:0
    [8] macro expansion
      @ /__w/Enzyme.jl/Enzyme.jl/src/compiler.jl:5695 [inlined]
    [9] enzyme_call
      @ /__w/Enzyme.jl/Enzyme.jl/src/compiler.jl:5229 [inlined]
   [10] ForwardModeThunk
      @ /__w/Enzyme.jl/Enzyme.jl/src/compiler.jl:5131 [inlined]
   [11] macro expansion
      @ /__w/Enzyme.jl/Enzyme.jl/src/rules/jitrules.jl:324 [inlined]
   [12] runtime_generic_fwd(::Type{Val{(false, true, false, false)}}, ::Val{false}, ::Val{false}, ::Val{1}, ::Val{@NamedTuple{1, 2}}, ::typeof(getindex), ::Nothing, ::ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, Nothing, ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, SciMLBase.NullParameters, ODEFunction{true, SciMLBase.FullSpecialize, var"#lorenz!#2", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}, OrdinaryDiffEqCore.InterpolationData{ODEFunction{true, SciMLBase.FullSpecialize, var"#lorenz!#2", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, Nothing, OrdinaryDiffEqTsit5.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}, Nothing}, SciMLBase.DEStats, Nothing, Nothing, Nothing, Nothing}, ::ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, Nothing, ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, SciMLBase.NullParameters, ODEFunction{true, SciMLBase.FullSpecialize, var"#lorenz!#2", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}, OrdinaryDiffEqCore.InterpolationData{ODEFunction{true, SciMLBase.FullSpecialize, var"#lorenz!#2", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, Nothing, OrdinaryDiffEqTsit5.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}, Nothing}, SciMLBase.DEStats, Nothing, Nothing, Nothing, Nothing}, ::Int64, ::Nothing, ::Colon, ::Nothing)
      @ Enzyme.Compiler /__w/Enzyme.jl/Enzyme.jl/src/rules/jitrules.jl:357
   [13] f_dt
      @ /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:18 [inlined]
   [14] f_dt
      @ /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:0 [inlined]
   [15] fwddiffejulia_f_dt_3510_inner_1wrap
      @ /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:0
   [16] macro expansion
      @ /__w/Enzyme.jl/Enzyme.jl/src/compiler.jl:5695 [inlined]
   [17] enzyme_call
      @ /__w/Enzyme.jl/Enzyme.jl/src/compiler.jl:5229 [inlined]
   [18] ForwardModeThunk
      @ /__w/Enzyme.jl/Enzyme.jl/src/compiler.jl:5131 [inlined]
   [19] autodiff
      @ /__w/Enzyme.jl/Enzyme.jl/src/Enzyme.jl:669 [inlined]
   [20] autodiff
      @ /__w/Enzyme.jl/Enzyme.jl/src/Enzyme.jl:558 [inlined]
   [21] autodiff(::ForwardMode{false, FFIABI, false, false, false}, ::var"#f_dt#3"{SVector{13, Float64}, var"#lorenz!#2"}, ::Duplicated{Vector{Float64}}, ::Duplicated{Vector{Float64}})
      @ Enzyme /__w/Enzyme.jl/Enzyme.jl/src/Enzyme.jl:530
   [22] (::var"#1#4"{Vector{Float64}})(i::Int64)
      @ Main /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:37
   [23] iterate
      @ ./generator.jl:48 [inlined]
   [24] _collect(c::UnitRange{Int64}, itr::Base.Generator{UnitRange{Int64}, var"#1#4"{Vector{Float64}}}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
      @ Base ./array.jl:811
   [25] collect_similar(cont::UnitRange{Int64}, itr::Base.Generator{UnitRange{Int64}, var"#1#4"{Vector{Float64}}})
      @ Base ./array.jl:720
   [26] map(f::Function, A::UnitRange{Int64})
      @ Base ./abstractarray.jl:3371
   [27] macro expansion
      @ /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:32 [inlined]
   [28] macro expansion
      @ /__w/_tool/julia/1.11.7/x64/share/julia/stdlib/v1.11/Test/src/Test.jl:1709 [inlined]
   [29] top-level scope
      @ /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:6

BTW, it looks like this test just regressed in the latest release 😅

That's why we need these tests!

@ChrisRackauckas
Copy link
Contributor Author

Yes that's the expected failure from the latest release

@wsmoses
Copy link
Member

wsmoses commented Sep 21, 2025

the above error is now fixed, however now it hits:

SciMLSensitivity Adjoint Interface: Error During Test at /__w/Enzyme.jl/Enzyme.jl/test/integration/SciML/runtests.jl:57
  Got exception outside of a @test
  BoundsError: attempt to access MemoryRef{Vector{Float64}} at index [1]
  Stacktrace:
    [1] getindex
      @ ./essentials.jl:917 [inlined]
    [2] size
      @ ~/.julia/packages/RecursiveArrayTools/jieUI/src/vector_of_array.jl:579 [inlined]
    [3] axes
      @ ~/.julia/packages/RecursiveArrayTools/jieUI/src/vector_of_array.jl:583 [inlined]
    [4] to_indices
      @ ./indices.jl:359 [inlined]
    [5] view
      @ ~/.julia/packages/RecursiveArrayTools/jieUI/src/vector_of_array.jl:678 [inlined]
    [6] #mapreduce#57
      @ ~/.julia/packages/RecursiveArrayTools/jieUI/src/vector_of_array.jl:907 [inlined]
    [7] augmented_julia__mapreduce_57_77511_inner_1wrap
      @ ~/.julia/packages/RecursiveArrayTools/jieUI/src/vector_of_array.jl:0
    [8] macro expansion
      @ /__w/Enzyme.jl/Enzyme.jl/src/compiler.jl:5695 [inlined]
    [9] enzyme_call
      @ /__w/Enzyme.jl/Enzyme.jl/src/compiler.jl:5229 [inlined]
   [10] AugmentedForwardThunk
      @ /__w/Enzyme.jl/Enzyme.jl/src/compiler.jl:5179 [inlined]
   [11] macro expansion
      @ /__w/Enzyme.jl/Enzyme.jl/src/rules/jitrules.jl:447 [inlined]

which I really need an MWE for to figure out/fix

@ChrisRackauckas
Copy link
Contributor Author

approve to see? locally it's just the testset.

@ChrisRackauckas
Copy link
Contributor Author

yeah I don't know why that case doesn't work with Enzyme inside of a testset, but that is the case 🤷

#@testset "SciMLSensitivity Adjoint Interface" begin
Enzyme.API.typeWarning!(false)

odef(du, u, p, t) = du .= u .* p
Copy link
Member

Choose a reason for hiding this comment

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

what if instead you put the function defns outside of the testset (but kept the testset)

@ChrisRackauckas
Copy link
Contributor Author

Seems to work like this locally. Not sure why Enzyme is sensitive here while Zygote isn't but I think it's ignorable.

@wsmoses
Copy link
Member

wsmoses commented Sep 26, 2025

probably closure causing sadness

@ChrisRackauckas
Copy link
Contributor Author

done

@wsmoses wsmoses merged commit 0928441 into EnzymeAD:main Sep 26, 2025
13 checks passed
@ChrisRackauckas ChrisRackauckas deleted the sciml_integration branch September 26, 2025 21:00
@giordano giordano mentioned this pull request Sep 26, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants