Skip to content

Export AD field diagnostic arrays#61

Open
krystophny wants to merge 33 commits into
developfrom
ad-24-field-diagnostics
Open

Export AD field diagnostic arrays#61
krystophny wants to merge 33 commits into
developfrom
ad-24-field-diagnostics

Conversation

@krystophny

Copy link
Copy Markdown
Member

Exports Enzyme-ready field diagnostic arrays from the fixed-map flat context.

  • Adds EvalFieldDiagnosticsFlatKernel beside the energy kernel: per-quadrature-point sqrtG, |B|, B^theta, B^zeta from the same flat context, allocation-free with caller-owned buffers.
  • Fixed-map dispatch gvec_mhd3d_flat_field_diagnostics in the AD adapter; cached-context wrapper eval_field_diagnostics in MODgvec_py_state_ad.
  • State.ad_diagnostics(names) returns a dict of flat arrays; unknown names raise the new MissingQuantityError; non-Enzyme builds raise UnsupportedFeatureError.
  • Behavioral check: the diagnostics reconstruct the total MHD energy to rtol=1e-10 against State.energy.

Closes #25.

Verification

Test fails before

$ bash -lc 'test -f test-CI/unit-pygvec/test_ad_objectives.py || { echo "missing diagnostics test before AD-24"; exit 2; }'
missing diagnostics test before AD-24

Test passes after

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

$ pytest test-CI/unit-pygvec/test_ad_objectives.py -q --require-pygvec
4 passed in 1.41s

Enzyme-off isolated build:

$ pytest test-CI/unit-pygvec/test_ad_objectives.py -q --require-pygvec
2 passed, 2 skipped in 0.87s

Fresh fixed-RZ Enzyme ctest: 6/6.

@krystophny krystophny force-pushed the ad-24-field-diagnostics branch from 00c0bdc to 47affb1 Compare July 9, 2026 23:02
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