-
Notifications
You must be signed in to change notification settings - Fork 68
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
Missing Rule for Roots.jl #2035
Comments
Looks like Roots.jl is missing a rule |
@mhauru can you reduce this to just the roots.jl call which errs? |
It's probably easiest to just switch to SimpleNonlinearSolve.jl? @avik-pal was adding a specialized adjoint for that case. We can do a PR to Bijectors? SciML/NonlinearSolve.jl#478 |
We switched to Roots.jl at some point since (Simple)NonlinearSolve.jl caused problems. IIRC Roots.jl was also more lightweight. It's just missing a rule which is available in closed form and implemented for the other supported AD backends. We don't rely on any generic adjoints in Roots.jl. |
That PR isn't 1-1 because it's comparing NonlinearSolve vs Roots, whereas BracketingNonlinearSolve (a simplified SimpleNonlinearSolve with only the bracketing methods?) is the direct comparison and that is a much smaller library? Also, you'd likely want to use ITP these days instead of Falsi in order to enforce robustness. |
BracketingNonlinearSolve didn't exist back then but it's still a heavier dependency than Roots.jl. Roots.jl also supports ITP. For a bit more context: Root finding is only needed for a specific method with a closed-form adjoint, so there's no need for very generic root-finding support. |
@wsmoses here's a more barebones version: module MWE
using Roots: Roots
using Enzyme: Enzyme
function f(y)
lower = -1.0
upper = 1.0
α0 = Roots.find_zero(x -> y*x, (lower, upper), Roots.ITP())
return α0
end
y = 1.0
Enzyme.autodiff(Enzyme.Forward, f, Enzyme.Duplicated(y, 0.0))
end Also, if the issue is just that Roots.jl is missing a rule, I think the error message should reflect that. The current error is confusing and, to the average Julia user, very intimidating. |
MWE:
Output:
Affects both forward and reverse mode. Enzyme current main branch.
The text was updated successfully, but these errors were encountered: