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:
- GPU Acceleration: Unlike traditional C++ or CPU-based Python codes,
causticsruns natively on GPUs. This allows it to leverage the massive parallelization required for ray-tracing calculations, which are the primary bottleneck in lensing simulations. - 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.
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