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

Integrate TrixiCUDA.jl with Enzyme.jl for Differentiable Programming #43

Open
junyixu opened this issue Sep 17, 2024 · 4 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@junyixu
Copy link
Collaborator

junyixu commented Sep 17, 2024

I propose integrating the GPU version of Trixi.jl with Enzyme.jl for differentiable programming.

Benefits:

  • Differentiable Programming: Allows for gradient-based optimizations in CFD simulations.
  • Unified Workflow: Provides a seamless experience for differentiable programming.

Note: Jacobian matrices computed on CPU and GPU may differ due to:

  • Precision Differences: GPUs often use lower precision (e.g., FP32) compared to CPUs (e.g., FP64), affecting numerical accuracy.
  • Parallelism Effects: GPUs handle parallel computations differently, potentially introducing slight numerical differences.
@junyixu junyixu added the enhancement New feature or request label Sep 17, 2024
@huiyuxie
Copy link
Member

huiyuxie commented Sep 24, 2024

Thanks for your advice @junyixu! You mentioned about Jacobian matrices - are they the only parts that could benefit from auto differentiation on GPU?

@huiyuxie huiyuxie changed the title Integrate TrixiGPU.jl with Enzyme.jl for Differentiable Programming Integrate TrixiCUDA.jl with Enzyme.jl for Differentiable Programming Nov 5, 2024
@junyixu
Copy link
Collaborator Author

junyixu commented Dec 15, 2024

Some potential benefits: When computing large-scale Jacobians, we avoid data transfer overhead between CPU and GPU. In DG methods, with 100k elements, that matrix gets too big to store on CPU. If we compute derivatives directly on GPU, we can use matrix-free methods and compute them on the fly when needed.

This is especially useful for optimization problems - when studying how inlet conditions affect shock positions, or doing mesh adaptation where gradients are needed frequently. Computing directly on GPU is much faster than shuffling data back and forth.

Though it is trickier to implement than on CPU, and requires more careful memory management. Some existing CPU code might need rewriting.

@huiyuxie
Copy link
Member

How does this issue relate to your work here https://github.com/junyixu/TrixiEnzyme.jl?

@junyixu
Copy link
Collaborator Author

junyixu commented Dec 15, 2024

Enzyme.jl allows direct AD on GPU, avoiding CPU-GPU data transfer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants