Skip to content
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

Can DifferentiationInterface.jl replace the AD backend extensions here? #26

Open
gdalle opened this issue Apr 2, 2024 · 9 comments
Open

Comments

@gdalle
Copy link

gdalle commented Apr 2, 2024

As you may know, @adrhill and I are putting the finishing touches to an AD interface package:

https://github.com/gdalle/DifferentiationInterface.jl

One of our goals is to make life easier for everyone who ever had to write one package extension per AD backend. It seems that this is the case for you @tpapp, and that LogDensityProblemsAD.jl falls into the spectrum of cases we cover (one array in, one scalar out).
Would you like to try it out as a potential tool for simplification? Happy to help if that's the case.

Related:

@tpapp
Copy link
Owner

tpapp commented Apr 3, 2024

Yes, I think it would be great to add API for that backend too, but I would be reluctant to replace existing ones since there may be user code out there using it.

@gdalle
Copy link
Author

gdalle commented Apr 3, 2024

I'm not sure my question was clear, sorry.
DifferentiationInterface.jl is not really a backend, it's a door to a dozen backends. In that way, it contains much of the code that is in your package extensions: take a look at

The general idea is that many package developers have had to write such glue code, and if we put it in a single place it will be easier to maintain and optimize

@gdalle
Copy link
Author

gdalle commented Apr 3, 2024

This would also allow a clean switch from symbol-based to ADTypes.jl-based backend specification, although symbols can still be supported if necessary.

Related:

@devmotion
Copy link
Collaborator

This would also allow a clean switch from symbol-based to ADTypes.jl-based backend specification

LogDensityProblemsAD already supports ADTypes (this functionality is eg used by Turing).

@gdalle
Copy link
Author

gdalle commented Apr 3, 2024

True, what I meant is that it supports ADTypes by falling back on symbols

https://github.com/tpapp/LogDensityProblemsAD.jl/blob/master/ext/LogDensityProblemsADADTypesExt.jl

If you wanna give a shot to DifferentiationInterface, it would probably become the other way around, symbols being translated into ADTypes

@tpapp
Copy link
Owner

tpapp commented Apr 3, 2024

@gdalle: Again, I am happy to expose unifying interfaces in this package. We can even use it as a fallback under the hood by translating ADTypes.

@devmotion: We probably should replace the examples in the README and the manual with ADTypes at some point.

@gdalle
Copy link
Author

gdalle commented Apr 3, 2024

If you want I can open a demo PR changing one backend, so that you see what it would look like? E.g. ForwardDiff?

@tpapp
Copy link
Owner

tpapp commented Apr 3, 2024

Yes, PRs are always welcome.

@wsmoses
Copy link
Contributor

wsmoses commented May 11, 2024

For the reason specified in my comment #29 (review) this would present issues for Enzyme users until DI supports multiple arguments and activity states.

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 a pull request may close this issue.

4 participants