Skip to content

Trim the native stack: shared kernel helpers, one benchmark script, JAX 0.12 split fix - #210

Open
rogeriojorge wants to merge 19 commits into
simplify/native-adfrom
simplify/native-trim
Open

rogeriojorge wants to merge 19 commits into
simplify/native-adfrom
simplify/native-trim

Conversation

@rogeriojorge

@rogeriojorge rogeriojorge commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Trims #198 further. Based on simplify/native-ad, so the diff is the delta only.

What

  • Shares the kernel helpers (kernel_tableau, save_loop, launch_kernel, require_cuda, validation) in rk.py; 16 benchmark scripts become examples/benchmarks/benchmark_native.py (--suite orbit|collisions).
  • No CUDA path for Boozer (slower than the shared path); a Boozer native_execution="cuda" raises.
  • Removes the independent Pallas split kernel from split.py (execution="independent", interpret, the scalar-graph helpers, its tests and the split benchmark suite). trace_split keeps the portable path.
  • Removes native_ad.py, tests/test_native_ad.py, optimize_coils_native_ad.py, the adjoint="accepted"/native_adjoint options in solve_rk, solve_split and Tracing, the AD README section and the AD benchmark suite. Gradients go through Diffrax/JAX AD.
  • Keeps Dopri5/8, the coil and VMEC CUDA kernels in rk.py, and the portable split path.
  • prepare_solver(..., execution="cuda") lowers a small Pallas probe once; if the installed JAX cannot lower it, it warns and uses the portable path. Test: test_unsupported_pallas_lowering_falls_back_to_portable_path.
  • Also removes the committed results file, 6 figures, the QI augmented-Lagrangian examples with their 2.7 MB wout and coil file, the unused loss helpers and six wrapper examples.

Why

  • Coil kernel: 2.1x (adaptive) and 1.7x (fixed) faster than Diffrax. Kept.
  • Split kernel: 2.3x faster than the portable path, but 181 s compile time, and it fails to lower on JAX 0.6.2. Cut.
  • Native AD: 1.3x faster than the Diffrax checkpointed adjoint at N=256 (gradients agree to ~1e-10), slower at N=8 to 64; memory was not measured. 1569 lines plus a kernel for that. Cut; it can return as its own PR with a memory measurement on long orbits against Diffrax checkpointed adjoint.

Size

  • Last commit: 10 files, +95 / -3772 (native_ad.py 1569, split.py 2596 -> 1215 lines).

Checks

  • CPU, JAX 0.12, x64, -n 2: tests/test_native_orbit.py and tests/test_native_split.py, 41 passed in 7 min at load about 150-250. Not run on GPU (office box busy); the kernel probe returns False on CPU, so only the fallback branch is covered.
  • Earlier numbers for the kept coil and VMEC kernels (RTX A4000, JAX 0.12, float64) are in the README forward table.

Open

…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.
…mples; add Ito/Stratonovich, absent-bath and low-energy tests
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