-
Notifications
You must be signed in to change notification settings - Fork 7
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
Type instabilities? #36
Comments
I think I encountered something related. the ForwardDiff extension flattens arrays to a vector on output (line 42 in ImplicitDifferentiationForwardDiffExt.jl) having the dimensions preserved should fix it in my case at least |
Unfortunately this seems required for the linear solvers to work: Krylov.jl doesn't work with arbitrary arrays. I tried to use KrylovKit.jl instead a while back and it ended up being type-unstable for different reasons, but I'm willing to try again |
Note that the type stability tests which used to be performed by ChainRules were removed temporarily because I bumped into JuliaDiff/ChainRulesTestUtils.jl#232 |
I see, but can't you just reshape after the solve? |
Not sure what you mean, I think this line does the flattening |
And the issue from the Discourse thread will be taken care of by #47 |
Thanks, I will have a look and let you know. |
it didn't resolve my issue. the MWE is a bit involved (the error occurs at line 94). maybe a high level hint: Zygote works, ForwardDiff doesn't. ForwardDiff breaks when I try to use the result returned from implicit diff in computations because the dimension info is lost and he returns a vector instead of a matrix. the function I try to diff has 1 arg and 2 kwargs and returns a matrix and a bool. the conditions accepts three args, the same kwargs and returns a matrix of the same dimension as the first output form the forward function. in principle it should work and it does for Zygote |
OK I think I know where this is coming from. |
That fixed it. Thanks! |
See this Discourse thread: https://discourse.julialang.org/t/custom-rule-for-differentiating-through-newton-solver-using-forwarddiff-works-for-gradient-fails-for-hessian/93002/20
The text was updated successfully, but these errors were encountered: