-
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
Vectorization run between levels of nested AD #748
Comments
What version of Enzyme, and Julia are you using On latest main and Julia 1.9, I get the following: julia> using Enzyme
julia> function derivative(f::F, x::T) where {F, T<:Real}
adf = @inline xarg -> Enzyme.autodiff(Enzyme.Forward, f, Duplicated(xarg, 1.0))
first(adf(x))
end
derivative (generic function with 1 method)
julia> function secondderivative(f::F, x::T) where {F, T<:Real}
adf = @inline xarg -> Enzyme.autodiff_deferred(Enzyme.Reverse, f, Active(xarg))
first(first(first(autodiff(Forward, adf, Duplicated(x, 1.0)))))
end
secondderivative (generic function with 1 method)
julia> g1(x) = x*x*x*x + 0.0*x*x*x
g1 (generic function with 1 method)
julia> println(secondderivative(g1, 1.0))
12.0 |
Running in Julia 1.8.1 with the following versions.
|
Can you add Enzyme.API.printall!(true) right after the using Enzyme, then post the log output after only running the incorrect result |
Sure Running this:
produces this output:
|
Not sure if this is helpful but this function
will return a correct second derivative of 12.0 Additionally just changing the number of x's in the zero term causes the problem to go away/reappear
will work for example. |
This should now be fixed on main, if you want to retry. Separately I want to leave this open though since clearly we are running a vectorizer in between the rounds of AD, which we shouldn't do (even though now it will be correct). |
Should be resolved by #2161 |
Maybe misusing this but for a simple scalar function when I try to take a second derivative I get some very strange results.
This produces the output
The text was updated successfully, but these errors were encountered: