JuliaDiff / ReverseDiff.jl

Reverse Mode Automatic Differentiation for Julia
Other
348 stars 56 forks source link

MethodError: ReverseDiff.TrackedReal ... is ambiguous. #217

Open prbzrg opened 1 year ago

prbzrg commented 1 year ago

I got an error when I used Zygote over ReverseDiff for a neural ODE

  Test threw exception
  Expression: !(isnothing(Zygote.gradient(diff_loss, ps)))
  MethodError: ReverseDiff.TrackedReal{ForwardDiff.Dual{ForwardDiff.Tag{ODEFunction{false, SciMLBase.FullSpecialize, ICNF.var"#f_aug#48"{AbstractDifferentiation.ReverseDiffBackend, Planar{Float64, Array}, NamedTuple{(), Tuple{}}, Int64}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Float64}, Float64, 2}, ForwardDiff.Dual{ForwardDiff.Tag{ODEFunction{false, SciMLBase.FullSpecialize, ICNF.var"#f_aug#48"{AbstractDifferentiation.ReverseDiffBackend, Planar{Float64, Array}, NamedTuple{(), Tuple{}}, Int64}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Float64}, Float64, 2}, Nothing}(::ForwardDiff.Dual{ForwardDiff.Tag{ODEFunction{false, SciMLBase.FullSpecialize, ICNF.var"#f_aug#48"{AbstractDifferentiation.ReverseDiffBackend, Planar{Float64, Array}, NamedTuple{(), Tuple{}}, Int64}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Float64}, Float64, 2}) is ambiguous. Candidates:
    (T::Type{<:Real})(x::ForwardDiff.Dual) in Tracker at /home/runner/.julia/packages/Tracker/9xWLl/src/lib/real.jl:110
    ReverseDiff.TrackedReal{V, D, O}(value) where {V, D, O} in ReverseDiff at /home/runner/.julia/packages/ReverseDiff/YkVxM/src/tracked.jl:56
  Possible fix, define
    ReverseDiff.TrackedReal{V, D, O}(::ForwardDiff.Dual) where {V, D, O}

I don't know how to reproduce it with a simple code, If it can't be fixed without the original code; please close this issue.

Stacktrace: https://github.com/impICNF/ICNF.jl/actions/runs/4099293121/jobs/7069064588#step:6:1680