Expose exact pyGVEC energy gradient#49
Open
krystophny wants to merge 23 commits into
Open
Conversation
Member
Author
|
Fixed AD-15 by adding the public pyGVEC flat-q optimizer API, including set_q, energy(q), raw_residual(q), and an explicit raw_gradient fallback mode. Also fixed typed conversion for empty-region Fortran UnsupportedFeatureError messages so unsupported fixed-RZ wrappers skip cleanly in non-RZ builds. Verified with the focused public API test and adjacent AD pyGVEC tests. |
4f247ee to
074dc50
Compare
074dc50 to
fe9bf92
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16.
Expose the optimizer-facing pyGVEC surface:
State.set_q(q)updates the shared flat state with boundary validation.State.energy(q)evaluates MHD energy at a supplied flat vector.State.raw_residual(q)returns raw projected force without changing the loaded state.State.energy_gradient(q)uses the production Enzyme gradient when available.State.raw_gradient(q)remains as a compatibility delegate.UnsupportedFeatureErrorfor exact requests; the explicit raw-force fallback remains available.Verification
Failing before
Passing after
Enzyme off:
Fixed-RZ Enzyme build with LLVM/Flang 22.1.6:
The isolated Flang Python build used a source-built
f90wrapso its derived-type pointer metadata matched the selected Fortran compiler.