Skip to content

Commit

Permalink
Merge pull request #788 from SciML/vjp_stacktrace
Browse files Browse the repository at this point in the history
Re-throw the VJP failure stack traces with a verbose option
  • Loading branch information
ChrisRackauckas committed Feb 26, 2023
2 parents b9eee8a + 5490bf5 commit 92c20de
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions src/concrete_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ function inplace_vjp(prob, u0, p, verbose)
nothing
end
true
catch
catch e
if verbose
@warn "EnzymeVJP tried and failed in the automated AD choice algorithm with the following error. (To turn off this printing, add `verbose = false` to the `solve` call)\n"
showerror(stderr,e)
println()
end
false
end
if ez
Expand All @@ -41,7 +46,12 @@ function inplace_vjp(prob, u0, p, verbose)
return vec(du1)
end
ReverseDiffVJP(compile)
catch
catch e
if verbose
@warn "ReverseDiffVJP tried and failed in the automated AD choice algorithm with the following error. (To turn off this printing, add `verbose = false` to the `solve` call)\n"
showerror(stderr,e)
println()
end
false
end

Expand All @@ -65,15 +75,25 @@ function automatic_sensealg_choice(prob::Union{SciMLBase.AbstractODEProblem,
vjp = try
Zygote.gradient((u, p) -> sum(prob.f(u, p, prob.tspan[1])), u0, p)
ZygoteVJP()
catch
catch e
if verbose
@warn "ZygoteVJP tried and failed in the automated AD choice algorithm with the following error. (To turn off this printing, add `verbose = false` to the `solve` call)\n"
showerror(stderr,e)
println()
end
false
end

if vjp == false
vjp = try
ReverseDiff.gradient((u, p) -> sum(prob.f(u, p, prob.tspan[1])), u0, p)
ReverseDiffVJP()
catch
catch e
if verbose
@warn "ReverseDiffVJP tried and failed in the automated AD choice algorithm with the following error. (To turn off this printing, add `verbose = false` to the `solve` call)\n"
showerror(stderr,e)
println()
end
false
end
end
Expand All @@ -82,7 +102,12 @@ function automatic_sensealg_choice(prob::Union{SciMLBase.AbstractODEProblem,
vjp = try
Tracker.gradient((u, p) -> sum(prob.f(u, p, prob.tspan[1])), u0, p)
TrackerVJP()
catch
catch e
if verbose
@warn "TrackerVJP tried and failed in the automated AD choice algorithm with the following error. (To turn off this printing, add `verbose = false` to the `solve` call)\n"
showerror(stderr,e)
println()
end
false
end
end
Expand Down

0 comments on commit 92c20de

Please sign in to comment.