Skip to content

Enzyme Jacobian for PhasorDynamics::Load within GridKit #124

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

Closed
wants to merge 35 commits into from

Conversation

nkoukpaizan
Copy link
Collaborator

@nkoukpaizan nkoukpaizan commented Jun 3, 2025

Description

Enzyme Jacobian for PhasorDynamics::Load within GridKit. This is done within the model library directly.

Proposed changes

  • Added a wrapper in src/AutomaticDifferentiation/Enzyme/ to compute the Jacobians. This requires the residual wrapper to be in global namespace, but other definitions can be inside the GridKit::Enzyme namespace.
  • Moved most of the implementation for the PhasorDynamics::Load into LoadImpl.hpp. This file in then included in Load.cpp (which calls Enzyme and provides a Jacobian) and LoadDependencyTracking.cpp, such that the two automatic differentiation approaches are compiled in different compilation units.
  • Added a enzyme_jacobian unit test in LoadTest.hpp.
  • Extended the use of templates in examples/Enzyme/ in preparation for converting these into unit test.
  • Made the EnzymeVector tests more interesting to yield a lower triangular Jacobian rather than a diagonal one.
  • Moved src/LinearAlgebra/SparsityPattern/ to src/AutomaticDifferentiation/DependencyTracking/
  • Placed COO_Matrix into the GridKit::LinearAlgebra namespace.

Checklist

  • All tests pass.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.

Further comments

  • This is an example implementation for the PhasorDynamics::Load. Extending to other models will be straight forward, so I'd like some feedback here before extending.
  • I wouldn't worry about the compliance of the code in examples/Enzyme/ for now. I will move this to test/UnitTests/Enzyme/.

…es, but need to check features and performance.
…lized... COO_Matrix class is too permissive.
… residual wrapper needs to remain in global space. though.
@nkoukpaizan nkoukpaizan self-assigned this Jun 3, 2025
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 this pull request may close these issues.

1 participant