Git Product home page Git Product logo

Comments (4)

ChrisRackauckas avatar ChrisRackauckas commented on July 4, 2024 2

No, it never worked. The MWE is a minimal piece of code that errors for debugging it. The purpose of this issue is to find out how to make it work. Sorry if that wasn't clear.

from zygote.jl.

Krastanov avatar Krastanov commented on July 4, 2024

Does this still work?

I deleted the ForwardDiff stuff for this test.

On a brand new install of julia 1.0.3 with add DifferentialEquations Zygote I simply get a crash when Zygote.derivative is called (no error messages, the notebook kernel simply crashes, with no explanation or a segfault on the terminal).

With add DifferentialEquations#master Zygote#master I get some error about dual numbers:

MethodError: no method matching Float64(::ForwardDiff.Dual{Nothing,Float64,2})
  ...
Stacktrace:
 [1] convert(::Type{Float64}, ::ForwardDiff.Dual{Nothing,Float64,2}) at ./number.jl:7
 [2] (::getfield(Zygote, Symbol("##819#822")){typeof(convert)})(::Type, ::Float64) at /home/stefan/.julia/packages/Zygote/Ohw1K/src/lib/broadcast.jl:113

I even tried a much simplified piece of code, which also fails:

f(x,p,t) = p*x
t = 0:0.1:1
function sol(a)
    pr = ODEProblem(f,1.,(0.,1.),a)
    s = solve(pr,Euler(),dt=0.01, saveat=t)
    s.u
end
Zygote.gradient(a->sum(sol(a)),1.)

I get with add DifferentialEquations#master Zygote#master:

Compiling Tuple{getfield(DiffEqBase, Symbol("##solve#442")),Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:dt, :saveat),Tuple{Float64,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}}},typeof(solve),ODEProblem{Float64,Tuple{Float64,Float64},false,Float64,ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Nothing,DiffEqBase.StandardODEProblem},Euler}: BoundsError: attempt to access 0-element UnitRange{Int64} at index [1]

Stacktrace:
 [1] throw_boundserror(::UnitRange{Int64}, ::Int64) at ./abstractarray.jl:484
 [2] getindex at ./range.jl:597 [inlined]
 [3] getindex at /home/stefan/.julia/packages/IRTools/Y9ACs/src/ir/wrap.jl:23 [inlined]
 [4] first at ./abstractarray.jl:270 [inlined]

from zygote.jl.

Krastanov avatar Krastanov commented on July 4, 2024

I got some debug information from dmesg of all places.

The release version of Zygote crashes with this segfault [111742.546675] julia[28661]: segfault at 10 ip 00007fe630caedc1 sp 00007ffefa6c5440 error 4 in libjulia.so.1.0[7fe630bd7000+236000].

The master branch of Zygote just reports the errors mentioned above.

from zygote.jl.

ChrisRackauckas avatar ChrisRackauckas commented on July 4, 2024

Updated MWE:

using DiffEqSensitivity, OrdinaryDiffEq, Zygote

function fiip(du,u,p,t)
  du[1] = dx = p[1]*u[1] - p[2]*u[1]*u[2]
  du[2] = dy = -p[3]*u[2] + p[4]*u[1]*u[2]
end
function foop(u,p,t)
  dx = p[1]*u[1] - p[2]*u[1]*u[2]
  dy = -p[3]*u[2] + p[4]*u[1]*u[2]
  [dx,dy]
end

p = [1.5,1.0,3.0,1.0]; u0 = [1.0;1.0]
prob = ODEProblem(fiip,u0,(0.0,10.0),p)
proboop = ODEProblem(foop,u0,(0.0,10.0),p)

Zygote.gradient((u0,p)->sum(solve(proboop,Tsit5(),u0=u0,p=p,abstol=1e-14,reltol=1e-14,saveat=0.1,sensealg=ZygoteAdjoint())),u0,p)
Zygote.gradient((u0,p)->sum(solve(proboop,Tsit5(),u0=u0,p=p,abstol=1e-14,reltol=1e-14,saveat=0.1,sensealg=SensitivityADPassThrough())),u0,p)

# Harder!
Zygote.gradient((u0,p)->sum(solve(proboop,Tsit5(),u0=u0,p=p,abstol=1e-14,reltol=1e-14,saveat=0.1,sensealg=ZygoteAdjoint())),u0,p)
Zygote.gradient((u0,p)->sum(solve(proboop,Tsit5(),u0=u0,p=p,abstol=1e-14,reltol=1e-14,saveat=0.1,sensealg=SensitivityADPassThrough())),u0,p)

from zygote.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.