Skip to content

Add reverse boundary adjoint#57

Open
krystophny wants to merge 31 commits into
developfrom
ad-22-reverse-boundary-adjoint
Open

Add reverse boundary adjoint#57
krystophny wants to merge 31 commits into
developfrom
ad-22-reverse-boundary-adjoint

Conversation

@krystophny

@krystophny krystophny commented Jul 9, 2026

Copy link
Copy Markdown
Member

Adds the one-solve reverse boundary adjoint for scalar objectives.

  • Solves the interior transpose system through the tested symmetric raw-Hessian contract.
  • Returns the direct boundary derivative minus the interior coupling term.
  • Matches forward sensitivities on every boundary degree of freedom.
  • Matches MHD-energy finite differences that re-solve the interior for sampled boundary perturbations.
  • Uses State.raw_residual_jvp for all matvecs: exact Enzyme derivatives when the build provides them, centered FD otherwise. The adjoint solve uses rtol=1e-7.

Closes #23.

Verification

Test fails before

$ pytest test-CI/unit-pygvec/test_ad_boundary.py -q --require-pygvec -p no:cacheprovider
2 failed, 4 passed in 2.04s

Both failures report that adjoint_boundary_gradient is missing.

Test passes after

Enzyme-off isolated build (FD path):

$ pytest test-CI/unit-pygvec/test_ad_boundary.py -q --require-pygvec
6 passed in 3.51s

Enzyme-on isolated build (exact path, fixed RZ, LLVM/Flang 22.1.6):

$ pytest test-CI/unit-pygvec/test_ad_boundary.py -q --require-pygvec
6 passed in 1.03s

Full stack AD suite at this tip: 31 passed on both builds.

@krystophny krystophny force-pushed the ad-22-reverse-boundary-adjoint branch from fa95663 to 7edbf42 Compare July 9, 2026 22:09
@krystophny krystophny force-pushed the ad-22-reverse-boundary-adjoint branch from 7edbf42 to 2d9b2b5 Compare July 9, 2026 22:22
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