-
Notifications
You must be signed in to change notification settings - Fork 69
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
make_zero!
can sometimes fail on closures?
#1588
Comments
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 SciML/SciMLSensitivity.jl#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.The text was updated successfully, but these errors were encountered: