Enzyme (Both Forward and Reverse) fails to differentiate the total energy of a simulation using the linear scalar advection equation wrt k #1
Labels
bug
Something isn't working
help wanted
Extra attention is needed
question
Further information is requested
Difficulty with differentiating total energy w.r.t. wave number using Enzyme.jl and Trixi.jl:
Description:
Successfully applying Enzyme in simple cases like differentiating the sine function:
However, when extending this approach to a more complex scenario using Trixi.jl to differentiate the total energy with respect to the wave number, I encountered an issue. Here’s the minimal working example (MWE):
MWE:
ForwardDiff Considerations:
ForwardDiff.jl
uses dual numbers, which store both the result and its derivative with respect to a specified parameter. This means we need to ensure that we can handleForwardDiff.Dual
numbers throughout the computation. In this case, we can address this by specifying the element type foruEltype
in theSemidiscretizationHyperbolic
call:semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, uEltype=typeof(k))
Enzyme Considerations:
Enzyme works by operating on LLVM's intermediate representation (IR), so additional modifications might be needed. For instance, we might need to expose certain parts of the cache for differentiation to succeed.
Additionally, I received the following warning from Enzyme.jl:
Warning: Using fallback BLAS replacements for (["dgemm_64_"]), performance may be degraded
This suggests that the BLAS linear algebra library could also be causing some issues, although according to Enzyme’s documentation, this is unlikely to be the main problem.
Error:
I encountered the following error when trying to differentiate
energy_at_final_time
using Enzyme's reverse-mode autodiff.Request:
The text was updated successfully, but these errors were encountered: