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

Using DifferentiationInterface #144

Open
gdalle opened this issue Jul 17, 2024 · 2 comments
Open

Using DifferentiationInterface #144

gdalle opened this issue Jul 17, 2024 · 2 comments

Comments

@gdalle
Copy link

gdalle commented Jul 17, 2024

Hi @b-fg! Just opening an issue to chat if you have any more questions or bugs related to DifferentiationInterface.jl. I didn't really understand from JuliaDiff/DifferentiationInterface.jl#355 how you want to use it: outside of WaterLily to try differentiating through it, or inside WaterLily at the few spots where you currently use ForwardDiff?

@b-fg
Copy link
Member

b-fg commented Jul 17, 2024

Hi @gdalle! I appreciate the follow up :) We were planning on using DI.jl to differentiate through WaterLily. For example, users typically define a (parametrized) geometry and then compute flow-induced metrics such as lift or drag forces. To compute the derivative of "d(lift)/d(geometry)" we must differentiate through the whole solver.

Using ForwardDiff.jl directly, or through DI.jl, this currently works on CPU backends. But to be able to differentiate on the GPU backend we need Enzyme.jl. As you suggested, I opened an issue there since this is currently not working. @vchuravy also opened and issue related to this some time ago.
EnzymeAD/Enzyme.jl#1547
EnzymeAD/Enzyme.jl#1647

Once this works as expected, it would be neat to switch to DI.jl because it's a more friendly interface for users. So that's the plan!

@vchuravy
Copy link

I don't think you won't get around using Enzyme internally, but you might be able to define a ChainRule to define something that DI can access.

This is what we did for https://github.com/Argonne-National-Laboratory/Checkpointing.jl

Besides GPU the core challenge is mutation support, which would require writing a CFD simulation in a very different style.

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