Skip to content

Add checkpointed reverse AD for native orbit and split-collision solvers - #191

Open
eduardolneto wants to merge 34 commits into
mainfrom
feat/native_ad_split
Open

eduardolneto wants to merge 34 commits into
mainfrom
feat/native_ad_split

Conversation

@eduardolneto

Copy link
Copy Markdown
Contributor

Base branch: feat/native_split_collisions

Add accepted-step reverse differentiation for native Dopri5/Dopri8 orbits and split orbit–collision tracing, consolidated in essos/native_ad.py.

  • Freeze accepted timesteps, Wiener increments, controller decisions and event fractions while differentiating accepted physical updates.
  • Support coil GC/Lorentz and VMEC/Boozer GC, including collision coefficients, pitch/speed diffusion and GC spatial kicks.
  • Add checkpointed replay, explicit tape-capacity checks, and specialized direct-coil derivatives without changing field classes.
  • Restore classifier, target-distance and heat objectives, plus three QI GC ALM examples with scaled coil DOFs and fixed births.
  • Retain reproduction scripts, README documentation and required physical inputs; keep generated reports outside version control.

Validation: Frozen-schedule JVP comparisons, CPU regressions, GC/Lorentz/coordinate GPU audits, and tiny ALM execution checks. The AD test module contains 14 functions covering 17 cases. Full QI optimization runs remain untested.

GPU limitation: Specialized two-species QI compilation was killed locally. Those examples default to validated shared native JAX execution on the selected device; specialized execution remains opt-in.

…enter collision step

The Ito speed drift contains 2 D_par/v, which diverges as v -> 0. Explicit
Euler overshoots it whenever v^2 < 2 D_par h, throwing slow ions to
nonthermal speeds (up to ~100 kT for a 1 keV bath). Applying it as
v -> sqrt(v1^2 + 4 D_par h) keeps the drift to O(h) and v > 0. The Spitzer
test now runs to 6 tau_s and checks relaxation to 3T/2.
…to feat/native_ad_split

# Conflicts:
#	essos/dynamics.py
@rogeriojorge

Copy link
Copy Markdown
Member

Same as other PRs

@rogeriojorge

Copy link
Copy Markdown
Member

Eduardo, status on the native reverse AD.

#198 (into this branch) applies the same trim as #197 on #189, plus:

  • removes the QI augmented-Lagrangian examples with their 2.7 MB .nc and coil JSON, and six thin wrapper examples
  • keeps one example, optimize_coils_native_ad.py (5 iterations take the mean final radius from 0.182 to 0.124)
  • shortens particle_losses.py from 106 to 31 lines (unused helpers)

That is +195 / -3736. The QI examples stay in this branch's history if we want them back later.

#210 builds on #198. It shares the kernel helpers between the split and AD paths and keeps one benchmark script. The native gradient matches the shared JAX path to about 1e-16.

Order I'd suggest: #189 with a merge commit, then this PR, with #198 and #210 merged into it first. split.py (2596 lines) and native_ad.py (1569 lines) are still large. I'll look at cutting them once I have GPU numbers on the A4000s.

@rogeriojorge

Copy link
Copy Markdown
Member

Main moved and this PR now conflicts in essos/dynamics.py. I did not push to your branch. #252 merges main into feat/native_ad_split and targets it.

This branch contains the old head of #189, so #252 merges the resolved #189 merge (#251), which has main in it. That merge had no new textual conflicts. The resolution and the rk.py _vmec_radial parabola, matching main's VMEC extrapolation, come from #251, so it is best to take #251 first.

Tests under JAX_ENABLE_X64=1: test_native_ad.py, test_native_orbit.py, test_native_split.py and test_dynamics.py, 172 passed. Merging #252 clears the conflict here.

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.

2 participants