Skip to content

Conversation

@vchuravy
Copy link

Took a stab at defining a rule for Enzyme, still need to port the reverse rule

@gdalle
Copy link
Member

gdalle commented Nov 14, 2025

Hi, thanks for the contribution! I didn't think anyone was actually using this package.
Are you sure you pushed all the commits?

@vchuravy
Copy link
Author

sigh missed the extension itself.

I was looking at ImplicitDifferentiation for AD through non linear problems and adjoint models for implicit time integration.

@gdalle
Copy link
Member

gdalle commented Nov 14, 2025

I was looking at ImplicitDifferentiation for AD through non linear problems and adjoint models for implicit time integration.

Feel free to suggest any improvements!
Right now the biggest limitations are

  • the out-of-place linear operator
  • the allocating linear solver of KrylovKit (but it was the one that came closest to idiomatic Julia without type restrictions, as opposed to Krylov which has lots of weird conversions)

EnzymeRules.forward(config, implicit, RT, Const(prep), x, args...)
end

@inline function EnzymeRules.forward(config, implicit::Const{<:ImplicitFunction}, RT::Type, prep::Const{<:ImplicitFunctionPreparation{R}}, x, args...) where R
Copy link
Member

@gdalle gdalle Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced we should define a rule for the version with a prep. The main reason that one exists in the ForwardDiff extension was to enable the use of sparse Jacobian matrices inside the linear system, where the sparsity pattern and coloring are contained in prep. But in theory, including prep in an Enzyme rule means we should define derivatives of the result with respect to prep, which seems complicated?

@gdalle
Copy link
Member

gdalle commented Nov 15, 2025

Thanks for the contribution! Before I review, can you add Enzyme to the systematic tests, both as an inner and as an outer backend, to see if they run?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants