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

What would we need to become backend independent via using DifferentiationInterface? #1040

Open
oxinabox opened this issue Apr 3, 2024 · 7 comments

Comments

@oxinabox
Copy link
Contributor

oxinabox commented Apr 3, 2024

This is a space for a discussion on what would be required to change here and in DifferentiationInterface to make this package backend agnostic.
(it equally could have been made on DifferentiationInterface.jl but I had to pick a location)

I had thought we were a fair way away from that, but i see DifferentiationInterface is already supporting caches and is using ADTypes.

Very likely this would still be a breaking change for SciMLSensitivity, but hopefully not a major one.
I think it would probably be worth it.
@ChrisRackauckas once referred to SciMLSensitivity as "the final boss of julia", because it depends on so many packages. Including ones like Enzyme and Zygote which are sensitive to changes to julias internals, and which sometimes break during precompilation because of this, which makes SciMLSensitivity break on nightly even if you are not using those packages.

cc @gdalle

@gdalle
Copy link

gdalle commented Apr 3, 2024

Happy to discuss anything that might be needed! Note that it would probably help reduce latency on the user side to avoid loading every backend at once.

Cc @adrhill

@ChrisRackauckas
Copy link
Member

Each vjp just has a dispatch. For example, the Zygote one is probably the most basic:

https://github.com/SciML/SciMLSensitivity.jl/blob/master/src/derivative_wrappers.jl#L514-L647

I would say, start by moving them one by one to DifferentiationInterface.jl. I wouldn't try to do them all in one go, Enzyme in particular you will have issues making DifferentiationInterface.jl be performant in its current form, so just try and make a DI dispatch, and remove dispatches one at a time as they are benchmarked to be performant. I think the first few would take only a few hours.

@gdalle
Copy link

gdalle commented Apr 6, 2024

What do you think is needed to make Enzyme perform well with DifferentiationInterface? Is it just adding more overloads to the extension, or something deeper?

@ChrisRackauckas
Copy link
Member

It has some specialized cache handling https://github.com/SciML/SciMLSensitivity.jl/blob/master/src/derivative_wrappers.jl#L658-L681 and differentiates multiple arguments simultaneously (https://github.com/SciML/SciMLSensitivity.jl/blob/master/src/derivative_wrappers.jl#L696-L723). I don't see an interface for that in DI

@gdalle
Copy link

gdalle commented Apr 6, 2024

I'll take a look and make some suggestions

@gdalle gdalle mentioned this issue Nov 28, 2024
9 tasks
@gdalle
Copy link

gdalle commented Nov 28, 2024

Coming back to this old issue, DI now supports multiple arguments (albeit not multiple active arguments). Would that be sufficient to get started?

@ChrisRackauckas
Copy link
Member

That would be enough to get the WIP PR up, but it won't be mergable until we can differentiate both u and p at the same time.

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

No branches or pull requests

3 participants