Closed ChrisRackauckas closed 20 hours ago
Can you paste the whole log and inputs.
im probably going to need a reproducer to fix
Im not sure it’s the case here, but one comment I’ll add — make_zero! Can only set the mutable data eg you can’t do make_zero!(1.0)
That doesn’t mean the datastructure you pass in needs to be mutable, you could do make_zero!(([1.],[2.])) even though the data type is a tuple, there is mutable data in the arrays in the tuple. This would fail however for a tuple of floats.
using Enzyme
struct Dense
n_inp::Int
b::Vector{Float64}
end
function Dense(n)
Dense(n, rand(n))
end
nn = Dense(4)
Enzyme.make_zero!(nn)
ERROR: MethodError: no method matching iterate(::Dense)
Closest candidates are:
iterate(::LLVM.FunctionParameterSet)
@ LLVM ~/.julia/packages/LLVM/6cDbl/src/core/function.jl:103
iterate(::LLVM.FunctionParameterSet, ::Any)
@ LLVM ~/.julia/packages/LLVM/6cDbl/src/core/function.jl:103
iterate(::Core.Compiler.InstructionStream, ::Int64)
@ Base show.jl:2778
...
Stacktrace:
[1] in(x::Base.IdSet{Any}, itr::Dense)
@ Base ./operators.jl:1292
[2] make_zero!
@ ~/.julia/packages/Enzyme/qd8AI/src/compiler.jl:1576 [inlined]
[3] make_zero!(prev::Dense)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/qd8AI/src/compiler.jl:1573
[4] top-level scope
@ ~/.julia/dev/SciMLSensitivity/test/enzyme_closure.jl:12
Okay this should be fixable, will take a look at shortly
Fixe don main
It's the error noticed in https://github.com/SciML/SciMLSensitivity.jl/pull/1067
Cutting off the SciML parts.
For some reason this function fails Enzyme.Compiler.guaranteed_const_nongen(typeof(_pf), nothing) false and then in the next iterate it errors. It seems like make_zero! is not robust to active values in closures?
For some reason my attempts at a simple MWE have failed. Maybe @wsmoses knows what's going on, it seems
guaranteed_const_nongen
can be rather particular based on the environment or something.