gyaradax : Local Gyrokinetics JAX Code

Gianluca Galletti, Eric Volkmann, Johannes Brandstetter · 2026

Read gyaradax : Local Gyrokinetics JAX Code by Gianluca Galletti, Eric Volkmann, Johannes Brandstetter (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2604-06085.txt.

Introduction

Galletti, Volkmann, and Brandstetter's 2026 paper presents gyaradax, a minimal JAX/CUDA solver for local flux-tube gyrokinetics. Gyrokinetic simulations matter for fusion plasma turbulence, yet many live in legacy CPU-bound code that resists machine-learning workflows. Built on GKW with GPU speed and automatic differentiation, gyaradax matches GKW with formal agreement, statistical parity, and a big speedup. The authors also show coding agents, guided by experts, structured prompts, and unit tests, turned complex Fortran code around very fast. Cases cover inverse problems and sensitivity analysis.

Catalog record

CREATORGianluca Galletti, Eric Volkmann, Johannes Brandstetter
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE63988
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2604.06085

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

gyaradax : Local Gyrokinetics JAX Code Gianluca Galletti, Eric Volkmann, Johannes Brandstetter Abstract Gyrokinetic simulations are essential for understanding and controlling turbulence in fusion plasmas, yet they are oftentimes implemented in legacy codebases, in many cases CPU-bound. These are both hard to maintain and especially incompatible with optimization and ML workflows. gyaradax is a minimal JAX/CUDA solver for local flux-tube gyrokinetics. We base our implementation on GKW ( 26 ) , but with added native GPU acceleration and automatic differentiation. We validate gyaradax against analytical cases and empirical benchmarks, achieving formal agreement and statistical parity with GKW alongside a substantial speedup. We deliberately and extensively utilized agentic workflows in this project. A key contribution is showing that coding agents, guided by human expertise, structured prompting, and measurable progress through unit testing enabled extremely fast translation of complex Fortran code, and further optimizations. gyaradax facilitates research at the intersection of ML and plasma physics. We showcase this through practical examples in inverse problems and sensitivity analysis. † † affiliationnotice: gerkone/gyaradax 1 Introduction Plasma turbulence is one of the most challenging multiscale problems in computational physics. The community has for decades relied on highly optimized and widely accepted codebases like GKW ( 26 ) and GENE ( 19 ) . Built for CPU clusters, they rely on complex MPI parallelization that makes them quite rigid. Although newer codes like CGYRO ( 5 ) and modern versions of GENE offer GPU support, their underlying architecture still lacks the flexibility to easily expand or integrate into ML workflows. In this work, we present gyaradax , a slim JAX code for local flux-tube gyrokinetics, supporting both adiabatic and kinetic electron models. We pick JAX ( 4 ) following the path of recent works across scientific domains, for example JAXFLUIDS ( 2 ) and JAX-SPH ( 29 ) for fluid dynamics, TORAX ( 7 ) for fast tokamak transport simulation, and JAX-MD ( 28 ) for molecular dynamics. gyaradax bridges the gap between legacy gyrokinetics and the JAX ecosystem, enabling hardware-accelerated automatic differentiation for plasma turbulence research ( 25 ; 17 ; 35 ) . A welcome side effect of using JAX is the increased accessibility: the core integrator and field solver are implemented in approximately 3 000 lines of JAX, compared to over 30 000 lines of functionally equivalent Fortran. We developed gyaradax with the heavy use of coding agents ( 34 ) and vibecoding ( 16 ) , applying emerging AI-driven software engineering practices to complex scientific codebases ( 6 ; 9 ) . A central challenge in deploying agents is oversight ( 3 ) : how can we verify that generated code is correct as systems grow in complexity? For numerical codebases this issue is naturally dampened, as correctness can be rigorously verified against analytical cases and reference results or implementations. With this strong “reward” signal coupled with (aspiring) experts, we find that coding agents can effectively navigate and implement extensive scientific computing frameworks, freeing resources for more fundamental research. In this work, we outline the underlying gyrokinetic equations ( Section 2 ), the implementation and optimization of gyaradax ( Section 3 ), and notes on the agent-assisted development process ( Section 3.4 ). We formally verify our solver on the 27 zonal flow test and on the Cyclone Base Case ( 8 ) . Furthermore, we run extensive empirical evaluations against GKW ( 26 ) reference data, comparing statistical quantities (time-averaged transport fluxes, wavenumber spectra, growth rates) across a broad set of equilibrium configurations for both adiabatic and kinetic electrons ( Section 4.1 ). Finally, we demonstrate differentiable programming experiments, including gradient-based recovery of R/L_{T} and sensitivity analysis of growth rates ( Section 4.3 ). 2 Gyrokinetics Within computational plasma physics, gyrokinetics ( 10 ; 20 ) is the foundational framework for turbulent transport modeling. By averaging over the fast gyro-angle dependency, it decouples high-frequency modes, isolating low-frequency fluctuations at the gyroradius scale while preserving finite Larmor radius effects in the distribution function f . This effectively reduces the 6D Vlasov-Maxwell equations to a 5D guiding-center formulation, making the system numerically tractable. To this end, gyaradax uses the standard \delta f form ( 10 ) , decomposing f into a stationary Maxwellian background F_{M} and a fluctuating component \delta f(v_{\parallel},\mu,s,\mathbf{k}_{\perp}) . Here, v_{\parallel} and \mu are the parallel velocity and magnetic moment, s goes along the magnetic field line, and \mathbf{k}_{\perp} includes radial k_{\psi} ( k_{x} ) and bi-normal k_{\zeta} ( k_{y} ). 2.1 Physical Components We clearly mark each term in the right-hand side of the Vlasov-Poisson equation (I to VIII), and adopt a naming convention similar to 26 , \displaystyle\begin{aligned} \frac{\partial f}{\partial t}=\hskip-5.01874pt&\underbrace{\hbox{\pagecolor{jaxpurple!15}$\displaystyle\vphantom{\frac{ZeF_{M}}{T}\left(v_{\parallel}\nabla_{\parallel}\bar{\phi}+i(\mathbf{k}_{\perp}\cdot\mathbf{v}_{D})\bar{\phi}\right)}-v_{\parallel}\nabla_{\parallel}f$}}_{\text{Parallel Advection (I)}}\underbrace{\hbox{\pagecolor{jaxpurple!15}$\displaystyle\vphantom{\frac{ZeF_{M}}{T}\left(v_{\parallel}\nabla_{\parallel}\bar{\phi}+i(\mathbf{k}_{\perp}\cdot\mathbf{v}_{D})\bar{\phi}\right)}-i(\mathbf{k}_{\perp}\cdot\mathbf{v}_{D})f$}}_{\text{Magnetic Drift (II)}}\underbrace{\hbox{\pagecolor{jaxpurple!15}$\displaystyle\vphantom{\frac{ZeF_{M}}{T}\left(v_{\parallel}\nabla_{\parallel}\bar{\phi}+i(\mathbf{k}_{\perp}\cdot\mathbf{v}_{D})\bar{\phi}\right)}+\mu\nabla_{\parallel}B\frac{\partial f}{\partial v_{\parallel}}$}}_{\text{Mirror Term (IV)}}\\ &\underbrace{\hbox{\pagecolor{jaxtealdark!15}$\displaystyle\vphantom{\frac{ZeF_{M}}{T}\left(v_{\parallel}\nabla_{\parallel}\bar{\phi}+i(\mathbf{k}_{\perp}\cdot\mathbf{v}_{D})\bar{\phi}\right)}-\mathbf{v}_{E}\cdot\nabla F_{M}$}}_{\text{Equilibrium Drive (V)}}\underbrace{\hbox{\pagecolor{jaxtealdark!15}$\displaystyle\vphantom{\frac{ZeF_{M}}{T}\left(v_{\parallel}\nabla_{\parallel}\bar{\phi}+i(\mathbf{k}_{\perp}\cdot\mathbf{v}_{D})\bar{\phi}\right)}-\frac{ZeF_{M}}{T}\left(v_{\parallel}\nabla_{\parallel}\bar{\phi}+i(\mathbf{k}_{\perp}\cdot\mathbf{v}_{D})\bar{\phi}\right)$}}_{\text{Field Drives (VII and VIII)}}\\ &\underbrace{\hbox{\pagecolor{jaxred!15}$\displaystyle\vphantom{\frac{ZeF_{M}}{T}\left(v_{\parallel}\nabla_{\parallel}\bar{\phi}+i(\mathbf{k}_{\perp}\cdot\mathbf{v}_{D})\bar{\phi}\right)}-\mathbf{v}_{E}\cdot\nabla_{\perp}f$}}_{\text{Nonlinear (III)}}\underbrace{\hbox{\pagecolor{jaxblue!15}$\displaystyle\vphantom{\frac{ZeF_{M}}{T}\left(v_{\parallel}\nabla_{\parallel}\bar{\phi}+i(\mathbf{k}_{\perp}\cdot\mathbf{v}_{D})\bar{\phi}\right)}-\mathcal{D}(f)$}}_{\text{Dissipation}}\end{aligned} Kinetic Dynamics (I, II, IV). They describe the collisionless trajectories of particles in the background magnetic configuration. Parallel Advection (I) represents motion along magnetic field lines, while Magnetic Drift (II) accounts for curvature and \nabla B drifts. The Mirror Term (IV) models the force arising from the parallel gradient of the magnetic field magnitude, which leads to particle trapping. Energy Drives (V, VII, VIII). The Equilibrium Drive (V) originates from thermodynamic gradients ( \nabla F_{M} ), providing the energy source for turbulence. Field Drives (VII and VIII) represent the linear coupling between the electrostatic potential and the background distribution. Nonlinear Advection (III). The Nonlinear Term E\times B represents advection of the gyro-averaged distribution function by the fluctuating electric field. E\times B is responsible for the saturated turbulent state, and the energy transfer across different spatial scales which pushes back on mode growth. Dissipation . A numerical dissipation term is added for stability: 4th-order upwinded dissipation in the parallel direction, centered 4th-order smoothing in velocity space, and spectral hyper-viscosity in the perpendicular dimensions. Neoclassical (VI, omitted). -\mathbf{v}_{D}\cdot\nabla F_{M} is the coupling of the magnetic drift (curvature/ \nabla B , Coriolis, centrifugal) to equilibrium gradients. It is active only for rotating or neoclassical plasmas and we omit it for simplicity. 3 gyaradax Implementation gyaradax solves the collisionless electrostatic gyrokinetic equations in the local flux-tube limit, supporting both adiabatic and kinetic electrons. We designed it to be a slim, modern and ML-friendly alternative to GKW, written in JAX with the core integrator and solver in about 3 000 lines. 3.1 Time Integration gyaradax is designed as a purely functional solver, where the simulation state is evolved through a chain of stateless transformations. We use explicit fourth-order Runge-Kutta (RK4) as integrator. Integration across sequential timesteps is fused with jax.lax.scan , reducing the Python interpreter overhead. Spatial derivatives in the parallel and velocity coordinates are computed using 4th-order central and upwinded stencils. The perpendicular dimensions are resolved pseudospectrally with 3/2-rule dealiasing to prevent aliasing errors in the nonlinear E\times B term. 3.2 Performance All species-dependent coefficients (Bessel functions, Maxwellians, drift velocities, and fused finite-difference stencils) are precomputed once before the time loop, eliminating redundant computation across the 4 RHS evaluations required by each RK4 step. Moreover, transitioning to JAX opens up performance optimizations that would be not always trivial to implement in Fortran. Specifically, for gyaradax we employed two orthogonal performance axes: mixed precision and custom CUDA kernels . Together, these optimizations yield a

Read the complete text