Skip to content

Test latest Enzyme #1224

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Test latest Enzyme #1224

wants to merge 1 commit into from

Conversation

ChrisRackauckas
Copy link
Member

No description provided.

@ChrisRackauckas
Copy link
Member Author

@ChrisRackauckas
Copy link
Member Author

Reproducer 1:

using SciMLSensitivity, OrdinaryDiffEq, Enzyme

u0 = [0.0]
p = [2.0, 1.0]
prob = NonlinearProblem((du, u, p) -> du[1] = u[1] - p[1] + p[2], u0, p)

function test_loss(p, prob, alg)
    _prob = remake(prob, p = p)
    sol = sum(solve(_prob, alg,
        sensealg = SteadyStateAdjoint(autojacvec = ReverseDiffVJP())))
    return sol
end

function enzyme_gradient(p, prob, alg)
    dp = Enzyme.make_zero(p)
    dprob = Enzyme.make_zero(prob)
    Enzyme.autodiff(Reverse, test_loss, Active, Duplicated(p, dp),
        Duplicated(prob, dprob), Const(alg))
    return dp
end
dp1_enzyme = enzyme_gradient(p, prob, NewtonRaphson())

Reproducer 2, I think, it's a bit hard to read the GC corruption because it messes with the line numbers, but it seems like it's this:

using OrdinaryDiffEq, SciMLSensitivity, Enzyme
Enzyme.API.typeWarning!(false)

odef(du, u, p, t) = du .= u .* p
const prob = ODEProblem(odef, [2.0], (0.0, 1.0), [3.0])

struct senseloss0{T}
    sense::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))
end
u0p = [2.0, 3.0]
du0p = zeros(2)
Enzyme.autodiff(Reverse, senseloss0(InterpolatingAdjoint()), Active, Duplicated(u0p, du0p))

@ChrisRackauckas
Copy link
Member Author

Both are related to Enzyme on the outside, not the EnzymeVJP. So it's GC corruption related to https://github.com/SciML/DiffEqBase.jl/blob/master/ext/DiffEqBaseEnzymeExt.jl. But I'm not sure what weird stuff is in that rule...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant