Comments (4)
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.
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.
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.
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)
- Spurious "Output is complex, so the gradient is not defined" error HOT 2
- NaN in gradient of abs() on complex 0 HOT 1
- Pullback on mean() gives illegal memory access code 700 HOT 32
- test
- Type unstable gradients (@code_warntype) HOT 1
- Type unstable gradients HOT 1
- Zygote gradients different from ForwardDiff/ReverseDiff on Julia 1.10-rc2 HOT 3
- try/catch is not supported when attempting to use `remake` with Zygote HOT 1
- gradient of SVD not working for complex input HOT 1
- `Zygote` doesn't properly work with `Metal.jl` and half precision. HOT 4
- `gradient` broken for `(*)(::Diagonal{Real}, ::Matrix{Complex}, ::Diagonal{Real})` when updating Julia 1.8 -> 1.9 HOT 6
- Method ambiguities reported by Aqua
- slow/high allocation gradient with mapreduce and iterators HOT 11
- error in summation of product iterator HOT 2
- `sort(x; rev=true)` is not supported HOT 1
- Incorrect gradients for `plan_rfft(x) * x` HOT 2
- Gradient of scalar function of gradient giving mutating array error HOT 4
- `sum` with CUDA and view on array errors HOT 3
- Cannot take gradient of sort on 2D CuArray HOT 1
- `Ref` and broadcasting issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zygote.jl.