NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Caustics: A Python Package for Accelerated Strong Gravitational Lensing Simulations

Connor Stone, Alexandre Adam, Adam Coogan, M. J. Yantovski-Barth, Andreas Filipp, Landung Setiawan, Cordero Core, Ronan Legin, Charles Wilson, Gabriel Missael Barco, Yashar Hezaveh, Laurence Perreault-LevasseurJ. Open Source Softw 2024 · DBLP

Introduction

Strong gravitational lensing—the phenomenon where massive foreground objects like galaxies bend and magnify light from distant background sources—is a cornerstone of modern cosmology. It provides a unique window into dark matter distribution, the expansion rate of the universe, and the properties of the earliest stars. However, we are entering a "big data" era in astronomy. Upcoming projects such as the Legacy Survey of Space and Time (LSST), the Euclid wide survey, and the Roman Space Telescope are expected to discover hundreds of thousands of new lensing systems. Traditional modeling tools, which often require days or weeks to analyze a single lens, are ill-equipped for this deluge of data. To meet this challenge, the field requires a simulation framework that is both computationally efficient and compatible with modern machine learning (ML) workflows.

The caustics Framework

To address these needs, we developed caustics, a Python package built on the PyTorch deep learning framework. This architectural choice provides two critical advantages for cosmological simulations:

  1. GPU Acceleration: Unlike traditional C++ or CPU-based Python codes, caustics runs natively on GPUs. This allows it to leverage the massive parallelization required for ray-tracing calculations, which are the primary bottleneck in lensing simulations.
  2. Automatic Differentiation (AD): By building on PyTorch, the entire simulation pipeline is differentiable. This enables researchers to utilize gradient-based optimization and integrate simulations directly into neural network architectures, such as Recurrent Inference Machines or diffusion models.

The package is designed with modularity in mind, following a philosophy similar to PyTorch’s nn.Module. It includes standard parametric lensing profiles (e.g., Singular Isothermal Ellipsoid and Navarro-Frenk-White) and non-parametric options like gridded convergence maps.

Performance and Scalability

To evaluate the performance of caustics, we conducted synthetic benchmarks comparing it against established tools like lenstronomy. The setup involved a Sérsic model background source lensed by a Singular Isothermal Ellipsoid (SIE) mass distribution. Benchmarks were performed on an Intel Gold 6148 Skylake CPU and an NVIDIA V100 GPU across various resolutions and sampling requirements.

Runtime performance comparison between lenstronomy and various caustics backends across standard (left) and realistic upsampled (right) configurations.

As shown in the benchmarking results, the GPU-accelerated version of caustics achieves massive speedups. In high-resolution, realistic simulations that include Point Spread Function (PSF) convolution and upsampling, caustics can be over 1,000 times faster than traditional CPU-based configurations. This level of performance makes it feasible to analyze over 100,000 lenses—a task that was previously computationally prohibitive.

Key Insights and Applications

Beyond raw speed, the "killer app" of caustics is its differentiability. The ability to calculate gradients through the simulator allows researchers to "descend" toward correct model parameters rather than relying on slower "guess and check" sampling methods. This is essential for complex Bayesian inference in high-dimensional parameter spaces.

Furthermore, the package maintains a minimalist design, focusing strictly on the transformation between the source and image planes. By avoiding hard-coded telescope optics or specific sampling algorithms, caustics serves as a flexible "building block" that can be easily integrated into diverse scientific pipelines.

Limitations and Future Outlook

While caustics provides a powerful engine for lensing, it currently places minimal emphasis on modeling specific observational elements like atmospheric effects or complex telescope optics, leaving these for user-specific implementation. Additionally, while it interfaces with optimizers like scipy.optimize or emcee, it is a simulator rather than an optimizer itself.

We envision caustics as a community-driven project. As the astronomical community prepares for the next generation of surveys, we encourage users to extend the core functionality to meet the evolving needs of strong gravitational lensing research.

Summary updated

BibTeX
@article{stone2024caustics,
  author = {Connor Stone and Alexandre Adam and Adam Coogan and M. J. Yantovski-Barth and Andreas Filipp and Landung Setiawan and Cordero Core and Ronan Legin and Charles Wilson and Gabriel Missael Barco and Yashar Hezaveh and Laurence Perreault-Levasseur and M. J. Yantovski-Barth and Andreas Filipp and Landung Setiawan and Cordero Core and Ronan Legin and Charles R. Wilson and Gabriel Missael Barco},
  title = {{Caustics: A Python Package for Accelerated Strong Gravitational Lensing Simulations}},
  journal = {J. Open Source Softw.},
  year = {2024},
  doi = {10.21105/joss.07081},
}
Figure