jz-fmm documentation
jz-fmm (JAX z-order tree, Fast Multipole Method) is a GPU-native FMM implementation for fast and differentiable gravitational N-body simulations. It builds on jz-tree for GPU-native tree construction, traversal, and distributed communication. Its high-level interface is written in JAX, while performance-critical operations use a CUDA backend through JAX’s foreign function interface.
Features
GPU-native force evaluation: the fast multipole method on one or many GPUs, including multi-host execution, with isolated boundary conditions.
Differentiable simulations: gradients with respect to particle positions, velocities, and masses through force calculations and time integration.
Reproducible forces: bit-perfect reproducibility of repeated FMM calculations with the same inputs and configuration on the same hardware.
Reversible time integration: bit-perfect backwards integration with the integer-lattice integrator, alongside a standard floating-point integrator.
Configurable accuracy: selectable multipole orders in two and three dimensions, with single- and double-precision calculations.
Extensibility: custom external potentials and support for adding new interaction kernels beyond gravitational N-body applications.
Convenient Python/JAX interface: compose force calculations, integrators, and external potentials to customize N-body simulations in a few lines of Python, while retaining JIT-compiled GPU performance.
Reference calculations: direct summation for checking approximate forces.
Start with the Getting started, see Multi-GPU guide for distributed execution, or consult JAX compatibility and helpers for function-specific support.
Performance and scaling
The figures below show force accuracy versus evaluation time and weak scaling across multiple GPUs, from the paper.
Accuracy and performance. Force evaluation in a Hernquist sphere with \(4 \times 10^7\) particles on a node with four NVIDIA A100 GPUs and 32 CPU cores. GADGET-4 uses the CPUs, jz-fmm uses the GPUs, and PKDGRAV3 uses both. Labels give the opening angle; jz-fmm curves show multipole orders \(p=3\ldots7\) in single precision. Lines show mean runtimes; shading shows one standard deviation. Timings include tree construction and force evaluation; GADGET-4 also includes domain decomposition and Peano sorting.
Multi-GPU scaling. Uniform particle distributions on one to 64 A100 GPUs, with \(p=5\), opening angle \(\theta=0.8\) and single precision. The horizontal axis gives particles per GPU; each point is the mean of ten synchronized evaluations. At \(10^8\) particles per GPU, runtime increases by about 1.8 times from one to 64 GPUs.