WorksPhysics and Astronomy
Microcaustics: Fast GPU-Accelerated Dynamical Microlensing of Time-Dependent Extended Sources
Abstract
Gravitational microlensing probes unresolved quasar accretion disc structure and compact objects in lens galaxies and is an important systematic in strong-lens time-delay cosmography. Most analyses use static microlensing map simulations because evolving individual microlenses and caustics is computationally prohibitive. We present Microcaustics, a GPU-accelerated Python package built on PyTorch for dynamical microlensing of time-dependent extended sources in strong gravitational lenses. It combines a local-exact/far-field deflection solver, source-directed lens-plane scouting with temporal reuse, and biquadratic inverse polygon mapping (IPM). GPU batching and fused Triton rasterization accelerate the calculation, while binary caustic labels track source-centred crossings. Across three simulated quadruply lensed quasar systems, our package generates a 10-year, 147-frame multiband light curve in an amortized median of 0.68 s (0.88 s with labels) on a consumer GPU with a median light-curve RMSE of 0.35 mmag, while recovering every reference source-centred caustic crossing. At comparable map accuracy, the batched throughput is 780 times higher than that of a recent CUDA IPM implementation and extrapolates to a speedup of millions relative to classic GPU-D. We demonstrate that our IPM converges as , approaching the idealized convergence rate of piecewise-affine IPM and improving upon the inverse ray-shooting rate. We also introduce a GPU-resident general relativistic and reverberating quasar source model and demonstrate our method with an evolving supernova source. These advances make fully dynamical stellar fields practical for Bayesian and simulation-based inference.
Introduction
Quasars are luminous active galactic nuclei (AGN) powered by accretion onto supermassive black holes (Salpeter 1964; Zel’dovich 1964). Their ultraviolet and optical continuum originates on scales too small to resolve directly at cosmological distances. Strong gravitational lensing produces multiple macroimages of the same quasar, with different magnifications and arrival times (Shajib et al. 2024). Stars and other compact objects in the foreground galaxy further split each macroimage into unresolved micromages. Their combined magnification depends on the source’s position, size, and spatial structure. Critical curves are lens-plane locations where the lens-mapping Jacobian determinant vanishes. They map to source-plane caustics, where point-source magnification formally diverges and across which the microimage configuration changes. Compact sources can undergo sharp magnification changes near these caustics, whereas extended sources average over the same structure. Microlensing therefore probes quasar structure far below the angular resolution of a telescope (Schneider et al. 1992; Vernardos et al. 2024).
Most quasar microlensing calculations involve a static magnification map with a source profile and extract light curves along trajectories through that map. This freezes the caustic network. Stellar proper motions instead reshape the network and can produce shorter, steeper, and more frequent events than translation across a fixed pattern (Kundić & Wambsganss 1993; Wambsganss & Kundić 1995). Figure 1 illustrates this evolution. Recomputing maps and consistently labelling caustics at every epoch has historically been prohibitively expensive for large simulation sets. Poindexter & Kochanek (2010a,b) included moving stars in Bayesian analyses of Q2237+0305, with complete inference calculations requiring CPU-years of computation. Making such dynamical calculations inexpensive is the main goal of this work.

Figure 1. Motivation for dynamical magnification maps using the Q2237+0305 image B parameters , , and . The stellar realization contains 3805 microlenses. The six panels show one macroimage at , 2, 4, 6, 8, and 10 yr using a fixed 9.382 as square source-plane window, pixel grid, and shared normalization.
The scientific applications extend beyond measuring a single source size. Wavelength-dependent microlensing constrains the disc temperature profile, inclination, and spatial structure (Poindexter et al. 2008; Poindexter & Kochanek 2010b; Blackburne et al. 2015; Muñoz et al. 2016b; Morgan et al. 2018; Cornachione & Morgan 2020; Best et al. 2024; Vernardos et al. 2024). Measurements often find ultraviolet–optical discs several times larger than luminosity-based thin-disc predictions, with ensemble studies favouring shallower effective temperature profiles from microlensing (Morgan et al. 2010; Cornachione & Morgan 2020) and reverberation mapping (Mudd et al. 2018; Guo et al. 2022; Jha et al. 2022). A high-magnification event (HME), produced by a caustic crossing or close approach, can scan different disc radii and relativistically brightened regions (Best et al. 2024). Forecasting these events can trigger high-cadence multiwavelength or spectroscopic follow-up (Fagin et al. 2025a).
The source itself also evolves. In lamppost reprocessing models, coronal variability illuminates the disc with position-dependent light-travel delays (Cackett et al. 2007). Microlensing then weights regions with different temperatures, variability amplitudes, and reverberation delays (Vernardos & Tsagkatakis 2019; Millon et al. 2022; Best et al. 2024). It can alter both the observed variability and the inferred delay between macroimages ([18] (Tie & Kochanek 2018a)). Those delays constrain the cosmic expansion rate when combined with deflector and line-of-sight models (Refsdal 1964; Treu & Marshall 2016; Birrer et al. 2024), making microlensing a source of cosmographic systematics as well as a probe of disc structure. Evolving transients, including strongly lensed supernovae, likewise require time-dependent source profiles (Huber et al. 2021).
Microlensing also constrains the foreground lens. Compact-source flux anomalies complicate the use of macroimage flux ratios to measure dark-matter substructure (Mao & Schneider 1998; Dalal & Kochanek 2002; Schechter & Wambsganss 2002; Nierenberg et al. 2024; Gilman et al. 2026). Multi-epoch and multiwavelength observations help separate stellar microlensing from more nearly static substructure (Vernardos et al. 2024). Magnification statistics and event time-scales also depend on the microlens mass spectrum, allowing ensembles to constrain the mean stellar mass and, with additional information, extragalactic stellar initial mass functions (Jiménez-Vicente & Mediavilla 2019). Related applications include compact dark matter (Mediavilla et al. 2017), wandering intermediate-mass black holes ([135]), and extragalactic planets (Dai & Guerreras 2018; Tuntsov et al. 2024). These inferences benefit from forward models that vary source structure, velocities, and microlens masses together.
Large precomputed maps are effective for sampling many trajectories through a static field, but a dynamical library adds time as another dimension. The more than 70,000 static GERLUMPH maps already occupy roughly 25 TB (Vernardos et al. 2014; Vernardos & Fluke 2014). Reusing a few realizations limits training diversity, while on-demand simulation can redraw the stars and source without storing a mostly unused map. A precomputed map also fixes the smallest spatial scales available to subsequent convolution and interpolation, which can limit studies of inner-disc emission and early supernova photospheres unless finer maps are generated. Population studies also commonly adopt a single microlens mass and a circular, often Gaussian source (Vernardos & Tsagkatakis 2019; Neira et al. 2020; Neira et al. 2025; Fagin et al. 2025a). Such profiles can reproduce broad statistics at fixed half-light radius (Mortonson et al. 2005), but discard structure that matters during caustic crossings. Intrinsic variability is often removed approximately through time-delay-corrected difference light curves or modelled as a nuisance process (Sluse & Tewes 2014; Tie & Kochanek 2018b; Paic et al. 2022). A resolved evolving source instead allows intrinsic variability and microlensing to be calculated together (Best et al. 2025).
Inverse ray shooting (IRS) constructs maps by accumulating deflected rays in source pixels (Kayser et al. 1986; Schneider & Weiss 1987), whereas inverse polygon mapping (IPM) distributes mapped cell areas among those pixels (Mediavilla et al. 2006, 2011). Tree and direct GPU methods accelerated IRS (Wambsganss et al. 1990; Bate et al. 2010; Thompson et al. 2010), with GPU-D underpinning GERLUMPH (Vernardos et al. 2014). Later implementations use mesh-based Poisson solvers (Shalyapin et al. 2021), interpolated far fields (Zheng et al. 2022), or fast multipole methods (Greengard & Rokhlin 1987; Jiménez-Vicente & Mediavilla 2022). The open-source GPU implementation of Weisenbach (2025a) combines the fast multipole method with IPM, with a companion code for critical curves and caustics (Weisenbach 2025b). These methods emphasize accurate individual maps and caustic calculations. Together with adaptive spatial selection (Meena et al. 2022), they provide the basis for an end-to-end GPU calculation optimized for evolving stellar fields and extended sources.
The Vera C. Rubin Observatory Legacy Survey of Space and Time (LSST) makes this scale of simulation increasingly important. Forecasts predict more than 8000 lensed quasars, including roughly 3000 with well-measured time delays (Oguri & Marshall 2010). LSST will monitor them in six near-UV to near-IR bands over ten years (Ivezić et al. 2019), with dozens of HMEs expected annually across the monitored lens population (Neira et al. 2020; Neira et al. 2025), alongside lensed supernovae and other transients (Sheng et al. 2022; Arendse et al. 2024). Machine-learning methods for parameter inference, light-curve reconstruction, and HME prediction can require diverse multiband training curves (Vernardos & Tsagkatakis 2019; Fagin et al. 2024; Fagin et al. 2025a,b). Bayesian Monte Carlo analyses likewise require many simulated trajectories to marginalize over lens, source, and velocity parameters (Kochanek 2004; Poindexter & Kochanek 2010b; Morgan et al. 2012; Blackburne et al. 2015; Cornachione & Morgan 2020).
Here we introduce MICROCAUSTICS, a GPU-accelerated Python framework for dynamical microlensing of time-dependent extended sources. It combines a local-exact/far-field deflection solver, source-directed lens-plane scouting, IPM, temporal reuse, and batched source evaluation in PyTorch and Triton (Paszke et al. 2019; Tillet et al. 2019). The simulator returns multiband light curves together with critical curves, caustics, and crossing labels. We compare its accuracy and performance with high-resolution references and existing GPU implementations. We also introduce a GPU-resident relativistic, reverberating quasar disc with an adjustable temperature slope and demonstrate an expanding supernova source. The code is publicly available at https://github.com/JFagin/microcaustics.
Sections 2 and 3 define the physical model and numerical method, Section 4 presents the benchmarks, and Section 5 describes the source models and end-to-end examples. We discuss applications and limitations in Section 6 and present our conclusions in Section 7. Throughout, we assume a flat CDM cosmology with and , and report AB magnitudes.
Dynamical Microlensing Model and Observables
Microcaustics separates the slowly varying galaxy-scale lens from the stellar-scale perturbations around each macroimage. The former determines the local convergence, shear, parity, and macroimage time delay, and the latter is evolved explicitly and coupled to a time-dependent extended source. This section defines that physical calculation and its observables. The accelerated evaluation of the same equations is described in § 3, and the source models are specified in § 5. The benchmark sample comprises the four macroimages of each of Q2237+0305, RX J1131−1231, and HE 0435−1223, each simulated as a 10-year, microlensing-only light curve at 25-day intervals (147 frames). The mass and velocity prescriptions below define their fiducial calculations, and their adopted lens and source parameters are collected in § 4.1. The simulator also accepts user-supplied microlens masses, positions, and velocities.
Local macroimage and microlens model
We describe a small region around one macroimage using angular image-plane coordinates and source-plane coordinates , both measured relative to the corresponding macroimage solution. A constant deflection is absorbed into the choice of origin. Over the stellar field, the remaining smooth galaxy deflection is well approximated by a local linear field described by convergence and shear, while the compact component is represented by individual point masses (Schneider et al. 1992; Vernardos et al. 2024). The local lens equation is
Here is the smoothly distributed convergence, are the shear components, and and are the position and angular Einstein radius of microlens (see equation (4)). Differentiating equation (1) away from the microlens positions gives
where , , and is the identity matrix. We write the total convergence as and define the smooth-matter fraction , so that . With
the sign of gives the macroimage parity. Positive-parity images are minima or maxima of the arrival-time surface, whereas negative-parity images are saddles (Schneider et al. 1992; Shajib et al. 2024). For known lens systems, these local quantities can be supplied from an observational macro model. Alternatively, the simulator can solve a complete user-specified macro model, calculate its macroimage positions and relative arrival times, and evaluate the Jacobian at each image to obtain , , , and parity, as demonstrated in § 5.5.1. Each macroimage then defines an independent realization of equation (1).
Dynamical microlens population
For lens and source angular-diameter distances and and lens–source distance , the angular Einstein radius corresponding to the mean microlens mass is
We draw microlens masses from a truncated power law for , with the Salpeter slope (Salpeter 1955; Kroupa 2001; Kochanek 2004). The distribution is specified by its mean and dynamic range. Every benchmark uses and .
Initial microlens positions are uniform within a circular image-plane field. For a diameter in Einstein-angle units, the population is . We size the field using the large-deflection tail criterion (Katz et al. 1986; Weisenbach 2025a), then circumscribe the protected macroimage region with a circle, apply a safety factor , and pad for coherent motion. With source-field side length , mass-moment factor , and nominal tail probability , the shear-aligned half-widths and final stellar diameter are
Here , , , and are in Einstein-angle units, is the coherent image-plane motion in those units per observer day, and is the duration in observer days. The final term enlarges the stellar field for longer simulations so that the protected source region remains covered along the complete coherent track. The reported physical angular diameter is .
We retain the full two-dimensional velocity vectors rather than assigning a single scalar track speed. Let and be the proper transverse peculiar velocities of the lens and source in their local rest frames, and let be the observer velocity projected onto the tangent plane at the lens coordinates. In units of mean-mass Einstein radii per unit observer time, the coherent motion applied to the microlens field is
We implement coherent bulk motion in a source-centred frame. Rather than moving the source through the magnification pattern, we hold the source fixed and translate the local lens model by . This translation includes both the microlenses and the smooth lens component. Accounting for the latter adds the uniform term to the lens mapping. With internal stellar motions switched off, this gives
The equivalent source moves through the stationary pattern in the opposite direction, with effective velocity
Substituting equation (6) recovers the standard geometrical projection (Kayser et al. 1986; Mosquera & Kochanek 2011). Writing the line-of-sight unit vector as , the code evaluates and resolves it into local and components. We use the measured Solar-system cosmic microwave background (CMB) dipole velocity toward Galactic coordinates [91]. Thus the observer contribution has a fixed direction for a given lens rather than a newly drawn random orientation.
For , the Cartesian velocity components indexed by are drawn independently with the same dispersion,
Here is the linear growth rate, with cosmological scale factor , evaluated using the approximation of Lightman & Schechter (1990); Lahav et al. (1991) as written in equation (5) of Hamilton [43]. The redshift scaling and normalization follow Kochanek (2004).
Finally, internal stellar motions are not absorbed into . Each internal tangent-plane velocity component is drawn as
Here is the one-dimensional stellar velocity dispersion of the lens. We adopt for Q2237+0305, RX J1131−1231, and HE 0435−1223, respectively (Chen et al. 2019; Tuntsov et al. 2024). The Q2237 value is an isothermal-model-based fiducial [121]. Assuming isotropic stellar velocities, the root-mean-square two-dimensional stellar speed is , but our stellar-kinematics calculation draws an independent vector for every star rather than replacing the evolving pattern by one bulk vector of that magnitude, as is commonly done for static-map light-curve generation (e.g., Neira et al. 2020; Neira et al. 2025). Microlens trajectories are advanced with angular velocity and specularly reflected within the circular stellar aperture to maintain a stationary finite population. The aperture’s safety and motion padding place this boundary far from the protected source-reaching region, so the reflected trajectories should have negligible influence on the central calculation. Reflection prevents microlenses from diffusing out of the finite aperture, which would otherwise change the stellar centre of mass and affect the local macro parameters. The coherent bulk displacement is then applied to the entire field. The resulting differential motion changes both the locations and topology of the caustic network and is not, in general, equivalent to translating a source through one static map (Wambsganss & Kundic 1995). The relative importance of this deformation is set in part by the ratio of the root-mean-square internal stellar motion to the coherent effective motion, . Larger ratios produce stronger changes in the caustic pattern relative to its bulk translation. Across the 12 benchmark macroimages, this ratio has a median of 0.80 and an observed 16th–84th percentile range of 0.65–1.2.
Time-dependent finite-source observables
Let be the observer-frame specific surface brightness of an arbitrary source in band . The point-source magnification at source position is the sum over all of its micromages,
where identifies the macroimage, runs over all micromage solutions within that macroimage, and the Jacobian is defined in equation (2). This absolute magnification includes the macro model. Its large-area or ensemble mean approaches , but an individual small map need not have this mean.
Gravitational lensing preserves surface brightness (Schneider et al. 1992). At observer time , the lensed band flux is
where is the requested source-plane region and is the macroimage delay. Setting and recovers the unlensed flux at observer time . Numerically, we sum over source pixels, combining each magnification map with the requested source images.
The macroimage delays are supplied or calculated from the macro model using the standard Fermat-potential differences (Refsdal 1964; Treu & Marshall 2016). We set the reference image’s delay to zero, with positive delays corresponding to later arrival.
Note that nothing in the preceding section requires a particular source morphology. The simulator needs only a surface-brightness image or image sequence on a known physical and angular scale. The general relativistic quasar, supernova, and generic source interfaces are described in § 5.
Critical curves and caustics
The critical curves at time are the image-plane zero set of the lensing Jacobian determinant, and their mapping through the lens equation produces the source-plane caustics:
Point-source magnification formally diverges on a caustic, whereas the integral in equation (12) remains finite for an extended source. Across a generic fold caustic, a pair of micromages is created or destroyed (Schneider et al. 1992; Vernardos et al. 2024).
Efficient GPU-Accelerated Dynamical Microlensing Simulation
Numerical pipeline
The direct evaluation of equation (1) for image-plane positions and microlenses requires pairwise interactions. A conventional IRS calculation incurs this cost over a field large enough to contain most of the rays that can map into the source plane, even though a compact source generally receives flux from only a small and irregular subset of that field. A standard dynamical calculation repeats the operation at every epoch.
In contrast, Microcaustics reduces the costs of many-microlens deflection, noncontributing lens-plane area, finite-cell integration, and repeated dynamical evaluation. Several epochs and independent light curves are processed together on the GPU. For each epoch, we update the stellar positions and construct the local-exact/far-field deflection approximation (§ 3.2). A coarse scout identifies lens-plane cells whose mapped footprints can contribute to the source (§ 3.3). Nearby epochs reuse this cell selection while recalculating the lens mapping with the current stellar positions (§ 3.4). Only the selected region is traced at fine resolution. Within each cell, a biquadratic reconstruction supplies a finer virtual lattice without additional lens-equation evaluations, and IPM distributes the mapped areas among source pixels (§ 3.5). We multiply the resulting magnification maps by the multiband source brightness and sum over pixels to obtain the light curves (§ 3.6). When requested, a separate calculation evaluates the Jacobian in the selected regions, extracts critical curves, maps them into source-plane caustics, and assigns caustic-crossing labels (§ 3.7).
Local-exact/far-field deflection solver
Nearby microlenses can produce rapidly varying deflections, whereas the combined contribution from distant microlenses varies smoothly across a small region. We evaluate nearby stars individually and approximate the distant contribution with a polynomial that can be evaluated cheaply at many ray positions. This near/far separation is an established acceleration strategy. In particular, Zheng et al. (2022) combine direct nearby deflections with local Taylor expansions of the distant contribution.
We partition the stellar field into spatial cells. For a ray at in cell , we approximate the point-mass deflection as
where contains nearby microlenses and contains the remaining, distant microlenses. Within each cell, a regular lattice of nodes supplies local polynomial expansions. The index selects the node at the centre of the subcell containing the ray, and gives the corresponding far-field deflection.
Complex notation combines the two deflection components into a single expression. We write and represent the deflection by . A point mass then contributes , where the bar denotes complex conjugation. Expanding about a node uses the geometric series , with and . Summing over distant stars and retaining terms through order gives the nodal expansion
where in the adopted configuration. Its real and imaginary parts give the two physical deflection components, so . Contributions to each coefficient are combined before tracing the rays. Each ray therefore evaluates a short polynomial rather than summing over every distant microlens.
Calculating these coefficients directly at every node would require repeatedly summing over the same distant stars. Instead, we first sum their contributions into an order- expansion about the cell centre. We then shift this expansion to each internal node and retain terms through fourth order. Terms above fourth order contribute to the lower-order coefficients when the expansion centre is shifted, so keeping them during this step improves accuracy. Each ray evaluates only the resulting fourth-order polynomial.
Figure 2 illustrates the adopted configuration. A Cartesian partition covers the circular stellar aperture, with cells outside the aperture containing no microlenses. A microlens enters the exact local sum when its Euclidean distance from the ray-containing cell is smaller than , with . Each cell contains an nodal lattice. Each ray evaluates the polynomial centred on its selected node using its displacement from that node. These nodes store polynomial coefficients rather than deflection values for interpolation. Fourth order was the lowest tested evaluation order that kept the far-field error small at the adopted accuracy target. Higher orders increased storage and arithmetic without a useful reduction in the final error.
Figure 2. Local-exact/far-field deflection solver diagram for a Q2237+0305 image-B realization. Left: the circular microlens field is partitioned into 16 × 16 spatial cells. Middle: for a ray in one cell, microlenses within the one cell width local neighbourhood are summed exactly, while the remaining microlenses define a smooth far field. Right: fourth-order Taylor expansions about the internal nodes of the 8 × 8 lattice approximate the far-field deflection at each ray position. Grey dashed connectors indicate successive enlargement of the same ray-containing cell across the three panels.
The lensing Jacobian uses the same decomposition. We sum the local point-mass derivatives exactly, differentiate the far-field polynomial analytically, and add the smooth macro-lens contribution in equation (2). This avoids finite differencing and keeps the deflection and Jacobian internally consistent.
The nearby-star selection and far-field coefficients are recalculated at every dynamical epoch. Several epochs are processed together on the GPU, and rays assigned to the same node share its polynomial coefficients. For the temporal benchmark references, we use a more conservative nodal lattice and exact-neighbourhood factor . § 4.4 tests the far-field approximation against direct point-mass deflections.
Source-directed lens-plane scouting
A compact source generally receives flux from only a sparse and irregular subset of the full image-plane field. Applying IPM or IRS to that entire field is therefore computationally inefficient. We first use a coarse scout to identify lens-plane cells whose mapped footprints intersect the requested source field, then perform the more expensive fine-grid calculation only in the selected region. The adaptive boundary method similarly refines image-plane regions that map near a compact source (Meena et al. 2022). Our scout performs finite-cell selection on the GPU for repeated calculations with an evolving stellar field.
The nominal ray count specifies the corresponding full-field regular grid, with spacings . The scout uses every th fine-grid vertex, so each scout cell contains fine cells. We trace its corners through the current lens equation and select the cell if the resulting quadrilateral intersects the source field. Testing the quadrilateral rather than only its vertices retains cells whose mapped footprint crosses the source even when every corner lies outside it. Figure 3 illustrates this selection and the subsequent IPM calculation.

Figure 3. Source-directed lens-plane scouting and biquadratic inverse polygon mapping for the standard , , and configuration. Left: the nested scout grid is traced within the circular stellar aperture. A scout cell is selected when its mapped quadrilateral intersects the finite source. Here, the scouting retains only 0.26% of the full-field cells. The inset shows its four fine-grid vertices and their mapped positions. Right: a selected fine cell is evaluated on the lattice of true ray-traced nodes. A biquadratic reconstruction supplies the virtual lattice, after which each virtual subcell is split into two mapped triangles whose areas are distributed according to their analytic overlap with the intersected source pixels, with an example triangle shown in orange.
We search cells intersecting the circular stellar aperture and one neighbouring layer outside it. Within this search region, we also retain one layer of neighbours around every selected cell to guard against contributions missed by the coarse scout. For the adopted , each scout cell spans fine cells, so each guard layer is two fine cells wide.
At the first epoch, we use the denser scout to estimate a normalization correction for the faster selection. We add this correction uniformly to subsequent magnification maps before integrating the source brightness. It accounts for an approximately uniform missing contribution, but does not recover unresolved spatial structure. The dense selection is then discarded, and subsequent epochs use the faster scout with temporal reuse.
A fixed rectangular shooting region can exclude cells that contribute to the source flux. The resulting error is primarily a missing-flux bias, but the omitted contribution can change as the stars move and therefore alter the light-curve shape. Our scout instead selects contributing cells from across the full circular stellar aperture, whose size is set by the large-deflection criterion in § 2.2.
Temporal scout reuse
Nearby epochs often receive flux from much the same lens-plane region, even as stellar motion changes the magnification within it. exploit this by reusing the selected cells between scout evaluations while recalculating their lens mapping at every epoch.
We repeat the scout calculation every ten frames. Between successive scout evaluations, we retain every cell selected at either endpoint to accommodate motion of the contributing region. The selection at the end of one interval also serves as the starting selection for the next. Only the cell selection is reused. The lens mapping, magnification, and Jacobian are recalculated at every frame using the current stellar positions. Several epochs are processed together on the GPU, each with its own stellar field.
For the benchmark’s 25-day map cadence, the scout evaluations are separated by 250 days. A cell that contributes only between the endpoints can still be missed, so the refresh interval must remain short enough to capture changes in the contributing region. The end-to-end benchmarks in § 4.2 validate the light-curve accuracy and caustic-crossing recovery with the adopted ten-frame scout interval.
Biquadratic inverse polygon mapping
IPM distributes the mapped area of each finite lens-plane cell among the source-plane pixels it intersects, rather than depositing its entire contribution at a single ray position (Mediavilla et al. 2006, 2011). This area-mapping principle is also used in recent FMM–IPM implementations (Jiménez-Vicente & Mediavilla 2022; Weisenbach 2025a). Our implementation reconstructs curvature in the lens mapping from a small grid of traced rays. We then subdivide this reconstructed mapping more finely without additional lens-equation evaluations and calculate the contributions to source pixels together on the GPU.
Classical IPM traces the corners of a lens-plane cell and represents its mapped area with straight triangles. This approximation can miss curvature near critical curves. Within each fine cell retained by the scout, we instead evaluate the lens equation on an grid, including its four already available corners. Our adopted supplies a grid of nine traced nodes. We describe positions within the cell by normalized coordinates , each running from zero to one. The nodes lie at 0, 1/2, and 1 along each axis. To reconstruct the mapping between them, we fit a tensor-product quadratic Lagrange interpolant,
where are the traced source-plane coordinates and are the one-dimensional quadratic Lagrange basis functions for these three node positions. The interpolant reproduces all nine traced values. It reconstructs the lens mapping, not the magnification, which is calculated from the mapped areas.
We evaluate the reconstructed mapping on a finer virtual grid, with in the adopted configuration. These virtual vertices require no additional lens-equation evaluations. Each virtual lens-plane subcell is split into two triangles, whose vertices are mapped through the interpolant. Each triangle’s lens-plane area is then distributed among source pixels in proportion to their overlap with its mapped triangle. The triangle–pixel overlap areas are calculated analytically. The resulting straight-sided triangles approximate the curved mapping without the more complicated calculation of intersections between curved cell boundaries and source pixels.
The parameters and therefore control different parts of the approximation. Increasing samples the physical lens equation at more positions and raises the interpolant’s order. For example, changing from 2 to 4 replaces the nine-node biquadratic reconstruction with a 25-node biquartic reconstruction. Increasing instead subdivides the same reconstructed mapping more finely. At , changing from 2 to 4 retains the nine traced nodes but increases the virtual grid from to . Our adopted configuration uses and .
Fig. 3 illustrates this calculation. A fused Triton kernel performs the virtual interpolation, triangle–pixel clipping, and accumulation together, avoiding the large intermediate arrays required by the corresponding PyTorch calculation (Tillet et al. 2019). This accumulation of mapped areas into source pixels is the rasterization step. The same integrator can be applied to the full stellar aperture, a fixed rectangular region, or the scouted cells. Comparing these variants isolates the effects of spatial selection while holding the integration method fixed. § 4.3 tests convergence with ray count, including the adopted -ray, , configuration, against the high-resolution -ray, , reference.
From magnification maps to light curves
IPM divides the image-plane area deposited in each source pixel by that pixel’s area to obtain its magnification. We multiply the resulting map by the source brightness and sum over pixels to calculate the flux using equation (12). Several epochs and source bands are processed together on the GPU, with each epoch retaining its own magnification map and time-dependent source brightness. We can also process several independent light curves together, each with its own stellar field and source history. Only the final products are transferred to the CPU.
Critical curves, caustics, and binary caustic labels
We identify when a caustic passes across the source centre and measure the distance to the nearest caustic. Rather than tracing the entire caustic network, we construct only the caustics that can affect the requested source field. We then count intersections with these caustics to assign a binary label, using several reference points to make the classification reliable and consistent between frames.
The critical-curve calculation evaluates , with defined in equation (2), using analytic derivatives of the local-exact/far-field deflection. We first search a coarse grid for cells with a determinant sign change or unusually small . We add two neighbouring layers of coarse cells around these candidates, then evaluate the determinant at high resolution only in the selected regions. A complementary coarse scout searches the remainder of the stellar aperture for critical cells whose mapped footprints approach the source. Together, these searches retain relevant critical structure both near the nominal macroimage footprint and elsewhere in the stellar field.
The adopted determinant grid is , with a discovery grid, corresponding to a factor of 16 along each axis. The benchmark reference uses . Rectangular controls retain the same physical pixel spacing as the full-field grid, with their grid dimensions adjusted to the rectangular footprint.
A batched Triton marching-squares calculation locates the zero-determinant contours as image-plane line segments. Ambiguous saddle configurations are resolved using the bilinear asymptotic decider (Nielson & Hamann 1991). We trace the segment endpoints to obtain the source-plane caustics defined in equation (13). Open or incomplete components at the computational boundary are flagged for the subsequent label calculation.
For a source-plane point away from a caustic, we define its binary class relative to a reference point, or anchor, :
where counts transverse intersections between the straight reference segment and the caustics. Even and odd crossing counts give opposite labels, so adjacent caustic regions have different classes. Applying this calculation across the source plane produces the binary caustic map illustrated in Figure 4. The labels zero and one have no absolute physical meaning, and their convention must be aligned between frames before changes can be interpreted as crossings.
Figure 4. Anchor–gauge binary caustic labels for one dynamical frame. Caustics divide the source plane into alternating binary regions. Anchors near the source-field boundary establish a common binary convention within each frame. Gauges keep that convention consistent between frames, with greater weight given to points farther from caustics. The two sets of reference points are spatially offset to avoid coincident paths and boundary degeneracies. Lines to the source centre illustrate the crossing count for one source position. The binary field uses the native 1024 × 1024 source grid.
A single reference segment can give an unreliable count if it passes close to a caustic vertex, is nearly tangent to a caustic, or encounters an incomplete or under-resolved segment. We therefore use nine anchors surrounding the source. Crossing counts between the anchors first place their classifications in a common binary convention. Each anchor then supplies a classification for the source position, and the majority determines its label. The different directions reduce sensitivity to a problem affecting one path.
We reject an anchor vote when its reference segment intersects a flagged incomplete component. The remaining anchors can still determine the class without requiring every caustic component to be fully contained in the computational field. Nine valid votes cannot tie. If rejected votes leave an exact tie, we assign class zero by a fixed convention and report the vote and validity counts so that the ambiguity remains identifiable.
To align the zero and one labels between successive frames, we use a second set of nine fixed reference points, called gauges. Their votes select the convention that best preserves the preceding frame’s labels. A gauge close to a caustic is unreliable because a small displacement of the discretized curve can change which side contains the point. We therefore prefer gauges farther from caustics in both frames and weight their votes by their distance to the nearest caustic. Using several gauges reduces the influence of any one point near a caustic or an incomplete segment. The anchors and gauges are placed near the perimeter of the source field, with small positional offsets to break symmetry, and remain fixed throughout the simulation, as illustrated in Figure 4.
The binary class records only whether the reference path crosses an even or odd number of caustics. By comparison, a winding number counts how many times an oriented caustic curve wraps around a source position, including the direction of wrapping. The complete-field method of Weisenbach (2025b) traces the full critical-curve network and maps it to oriented caustics for this calculation. Our public code also supports complete winding maps, but the principal benchmarks use the less expensive source-centred binary labels.
Once the convention is aligned, we return the binary label, crossing history, and Euclidean distance to the nearest retained caustic segment. These quantities can be evaluated at any source-plane point, although the principal benchmark uses only the source centre. Two caustic crossings between successive epochs leave the binary label unchanged and would therefore be missed. This motivates a sufficiently short sampling interval. At the adopted 25-day cadence, our validation recovers all reference crossings (§ 4.2). A source-centre crossing is a geometric event marker, whereas the extended source’s photometric response can begin earlier and depends on its full brightness profile.
Validation and Performance Benchmarks
Benchmark sample, methods, and timing procedure
For each macroimage, we compare methods using the same physical configuration and stellar realization on the same RTX 5070 Ti GPU. Table 1 gives the lens, source, and field parameters. The 12 macroimages include both parities and contain 1,056–16,840 microlenses. They span a broad range in local convergence, shear, smooth-matter fraction, and number of cells contributing to the source. These systems provide a compact set of contrasting stellar fields with published lens and accretion-disc constraints. We adopt reasonable fiducial values where constraints are weak, since our purpose is to demonstrate numerical accuracy and runtime rather than model these systems individually.
| System | Image | [deg] | [as ()] | [as ()] | |||||
| Q2237+0305 | A | (0.0395, 1.70) | 0.396 | 0.396 | 175 | 0.00 | 4263 | 793 (208) | 9.38 (2.46) |
| B | 0.391 | 0.391 | 142 | 0.00 | 3805 | 754 (197) | |||
| C | 0.715 | 0.715 | 69.1 | 0.00 | 3549 | 539 (141) | |||
| D | 0.604 | 0.604 | 62.5 | 0.00 | 9568 | 962 (252) | |||
| RX J1131−1231 | A | (0.295, 0.658) | 0.526 | 0.410 | 73.2 | 0.571 | 16840 | 638 (546) | 4.60 (3.94) |
| B | 0.459 | 0.412 | 106 | 0.566 | 3352 | 303 (259) | |||
| C | 0.487 | 0.306 | 39.5 | 0.586 | 1394 | 194 (166) | |||
| D | 0.894 | 0.807 | 76.0 | 0.419 | 1056 | 105 (90.2) | |||
| HE 0435−1223 | A | (0.455, 1.69) | 0.473 | 0.358 | 63.8 | 0.653 | 1214 | 195 (172) | 2.89 (2.54) |
| B | 0.630 | 0.540 | 165 | 0.639 | 2208 | 224 (197) | |||
| C | 0.494 | 0.327 | 88.7 | 0.666 | 1104 | 186 (164) | |||
| D | 0.686 | 0.575 | 168 | 0.620 | 1274 | 159 (140) |
Table 1. Benchmark lens and field parameters
Benchmark values are medians across the 12 macroimages, with superscript and subscript offsets reaching the observed 84th and 16th percentiles, respectively. These offsets describe case-to-case spread, not confidence intervals on the median. The four images within each lens system are related, and the benchmark is not a population sample.
Throughout the comparisons, denotes the number of launched rays for IRS and the nominal number of image-plane grid samples for IPM. Our adopted source-scouted biquadratic IPM configuration uses , , , and . It reaches approximately the map accuracy of the calculation of Weisenbach (2025a) at its fiducial setting of one ray per output source pixel along the direction and a 1 per cent light-loss tolerance. This setting is not directly equivalent to our nominal ray count, so we compare the measured accuracy rather than assign an equivalent ray budget.
Our internal IRS controls launch rays on a regular Cartesian lattice and use the same lens fields, deflection solver, nominal ray counts, and batching settings as the corresponding IPM controls. The internal rectangular controls and GPU-D share a shear-aligned 1 per cent light-loss window expanded by 10 per cent along each axis, while retaining the complete circular microlens field. GPU-D uses pseudo-random IRS with the same nominal -ray budget. The calculation Note: Blank redshift and source-field entries repeat the values from the first macroimage of each system. Here is the smooth-matter fraction and is the local shear position angle, modulo and measured counterclockwise from the positive horizontal coordinate. We use the tangential approximation derived from the published macroimage and lens-centre astrometry, rather than treating as an independently measured model parameter. The Q2237 macro parameters are from Tuntsov et al. (2024). RX J1131 and HE 0435 use Chen et al. (2019), with . Their astrometry is from Wertz & Surdej (2014), Witt & Mao (2015), and Fadely & Keeton (2012), respectively. The system-level source tuples are for Q2237, for RX J1131, and for HE 0435. For Q2237, the black-hole mass and spin follow Reynolds et al. (2014), is a fiducial consistent with their upper limit, is a fiducial motivated by Berdina et al. (2021), who assumed a lower black-hole mass, and is a typical value. For RX J1131, the mass, spin, and inclination follow Reis et al. (2014), while is an adopted fiducial and is a typical value. For HE 0435, the mass follows Melo et al. (2023), while , , are adopted fiducials, and is a typical value. We set the shared fiducial source-plane disc position angle to . This is not an observational constraint or the shear direction. Also, . Shared source settings are , , and . The Einstein-radius conversion adopts the benchmark mean microlens mass with and Salpeter slope . Every macroimage uses 147 frames at 25-day intervals. Here denotes the lamp-post luminosity in Eddington units.
of Weisenbach (2025a) uses its native shooting window at the same nominal light-loss tolerance.
We report root-mean-square errors (RMSEs) for light curves and maps, with fractional map RMSE defined in equation (20). The dynamical map and light-curve benchmarks use a reference with nominal rays per epoch, , and at all 147 epochs. The snapshot maps in Figure 5 and convergence tests in Figure 7 use a -ray reference with the same refinement settings. The internal candidate and reference maps share the same source grid and physical pixel boundaries.
Figure 5. Comparison of the high-quality reference, the fast source-scouted IPM calculation, full-field and rectangular IPM controls, and Weisenbach IPM for Q2237+0305 image B. Columns show the magnification map and signed residual, -band source-convolved map and residual, and six-band light curve with its residuals below. Map residuals use on signed linear millimagnitude scales shared within each column. All maps are evaluated on the same shear-aligned source-plane square. The map reference uses rays, while the full light-curve reference uses rays per epoch, both with and . All internal IPM calculations use , , and , with for the source-scouted calculation.
Figure 7. Ray-count convergence and computational cost. Candidate selective biquadratic IPM calculations hold , , and fixed and use million. The left panels show raw and source-convolved fractional map RMSE against the matched -ray, true-, reference, with Q2237+0305 image B highlighted. Both IPM and matched IRS using the same local-exact/far-field deflection solver are evaluated for all 12 macroimages. The other 11 trajectories are shown faintly in the corresponding method colour. The right panel reports the runtime measured after compilation and warm-up for a 147-frame light curve using fixed local-exact/far-field solver settings. The temporal batch size is optimized for each method, macroimage, and ray count, with one timing per point. The runtime power law is fit empirically over near the -ray operating point. The and points are displayed but excluded because fixed launch overhead matters more at low ray counts. The displayed point is excluded because it enters a different GPU memory and chunking regime. Every annotated method slope summarizes 12 independent macroimage fits.
Timings exclude compilation and autotuning. The light-curve time includes magnification-map calculation and integration of the source brightness over all 147 epochs. The time also includes determinant evaluation, caustic construction, and source-centre labels. Internal IPM calculations process cells in groups of 524,288.
Weisenbach (2025a) calculates one map at a time. We measure their light-curve runtime and accuracy over all epochs, and compare their maps with references evaluated on the same complete, shear-aligned native grid. For this method and the direct-deflection controls, we measure the caustic-stage cost at the first epoch and scale it to the full sequence. Our labelled calculation returns source-centre labels, whereas the timing for Weisenbach (2025b) includes construction of the complete critical-curve and caustic network.
GPU-D timings include initialization, memory allocation, transfer of the microlens data to the GPU, ray shooting, and accumulation into source-plane pixels. GPU-D does not calculate caustics or labels.
Accuracy, runtime, and example map residuals
Figure 5 shows magnification maps, finite-source light curves, and residuals for the principal IPM methods before we summarize the full 12-macroimage comparison. The source-scouted and full-field light curves closely follow the reference in all six bands, with residuals on the sub-millimagnitude scale in this example.
In Figure 6 and Table 2, “full” and “rectangle” denote sampling over the full lens-plane field and the restricted rectangular shooting region, respectively. IRS deposits individual rays, whereas IPM distributes mapped cell areas among source pixels. “IPM scout” selects source-reaching cells independently at each epoch. “IPM scout batched” evaluates these independent frames in temporal batches without reusing selected cells or sharing normalization corrections. “IPM scout fast” additionally reuses selected cells between scout refreshes and applies a fixed normalization correction measured at frame zero.
Figure 6. Accuracy and runtime across 3 systems and 12 macroimages for complete 147-frame light curves and magnification maps. The left panels use light-curve-only runtime and the right panels include caustics and source-centre labels, following the timing definitions in § 4.1. The reference uses nominal rays per epoch, , and . GPU-D appears only in the left panels because it provides no labels. Full-field and rectangular controls use the same nominal samples. The rectangle samples its smaller footprint more densely and can have lower fractional map RMSE, while omitted contributions outside it increase light-curve RMSE. Rectangular determinant grids retain the full-field physical pixel spacing without oversampling.
| Method | Batch (LC/labels) | [s] | [s] | LC RMSE [mmag] | Frac. map RMSE | Map RMSE [mmag] |
| Weisenbach IPM | 1 | |||||
| IPM scout fast | 49/30 | |||||
| IPM scout fast (multi-curve) | 49/30 | |||||
| IPM scout batched | 49 | |||||
| IPM scout | 1 | |||||
| IPM full batched | 10 | |||||
| IPM full | 1 | |||||
| IPM rectangle batched | 49/30 | |||||
| IPM rectangle | 1 | |||||
| IPM no far-field approx. | 1 | |||||
| GPU-D IRS | 1 | — | ||||
| IRS full batched | 49/10 | |||||
| IRS full | 1 | |||||
| IRS rectangle batched | 49/30 | |||||
| IRS rectangle | 1 | |||||
| IRS no far-field approx. | 1 |
Table 2. Light-curve and magnification-map benchmark.
At the adopted ray count, IRS sparsely samples the small source field, giving much larger raw-pixel errors than finite-source light-curve errors. The independent GPU-D ray-count test below checks their decrease with increasing ray count against the expected counting-noise scaling.
Figure 6 and Table 2 summarize the accuracy–runtime trade-off across all 12 macroimages. The source-scouted method approaches the full-field IPM accuracy at a fraction of its cost, both for light curves alone and when caustics and labels are included. For the adopted fast simulator configuration, the median 147-frame light-curve runtime is . Including determinant evaluation, caustic construction, and source-centre labels increases the median runtime to . Relative to the all-frame reference, the corresponding median light-curve RMSE is and the raw fractional map RMSE is . Across all 12 macroimages, the adopted labels recover all 41 reference source-centred caustic crossings, and every gauge signature agrees with the reference. The batched full-field IPM control has comparable median light-curve accuracy () and slightly lower fractional map RMSE () but requires 14 s for the light curve, illustrating that cell selection and temporal reuse, rather than a different flux observable, drive the practical speed.
Large simulation sets can also batch independent stellar realizations. To isolate the scheduling gain, we ran up to three separate calculations concurrently with the same seeded inputs as the single-curve control, without sharing maps or fluxes. The memory-heaviest RX J1131−1231 images use one or two curves. The amortized median runtimes are s per curve without labels and s with labels, giving median throughput gains of and times, respectively. These are throughput measurements rather than single-curve latencies. Larger GPUs can evaluate more independent curves concurrently and should increase this advantage.
The calculation of Weisenbach (2025a) takes a median s for the complete light curve, with a median light-curve RMSE of mmag and fractional map RMSE of . Including the extrapolated cost of caustic construction (Weisenbach (2025b)), we expect the complete calculation to take s.
With labels included and independent light curves processed together, our method achieves a median throughput advantage of over this combined calculation. We calculate the runtime ratio for each macroimage before taking the median, rather than dividing the median runtimes.
For comparison with direct pseudorandom-ray shooting, we also ran the published GPU-D code (Thompson et al. 2010; Bate et al. 2010; Vernardos & Fluke 2014). Its rays were launched from the adopted 1 per cent light-loss rectangle while retaining the complete circular microlens field. At rays, the median complete process time across the 12 macroimages was s for 147 independently calculated maps. We then measured frame zero for every macroimage at . Free fits to the two lowest ray counts give a median slope of . We therefore adopt the theoretical counting-noise relation separately for every macroimage,
where is normalized with the and ray measurements for macroimage . The complete GPU-D process time per map is well described over the – interval by
where and are the fitted process-time intercept and cost per ray for macroimage . The median measured coefficient is s per ray. Matching each macroimage’s map RMSE with the IPM raw fractional map RMSE requires a median rays. Equations (18)
Note. The reference and timing definitions are given in § 4.1. Batch is the number of temporal frames evaluated jointly for light curves alone and with labels. A single value applies to both products. The fast path uses batches 49 and 30, respectively, because their throughput optima differ. For the multi-curve row, runtime is the total elapsed time divided by the number of curves, not the time required to calculate one curve alone. This row is omitted from Figure 6. Light-curve RMSE covers the complete light curve. Fractional map RMSE uses pixelwise fractional magnification residuals. Magnitude-map RMSE uses only where both maps have positive magnification, excluding empty IRS pixels.
and (19) predict a median days for 147 maps. Pairing each extrapolated time with the corresponding fast-IPM throughput gives a median speed ratio of .
The measured errors follow the relation through rays, where all 12 cases remain within 0.7 per cent of the prediction normalized at the two lowest ray counts. No finite-support floor is resolved over this range. The matched-accuracy estimate extrapolates this counting-noise relation far beyond the measured ray counts and assumes that missing rays outside the fixed shooting window do not limit the accuracy. It is therefore an idealized comparison favourable to GPU-D, not a demonstration that the fixed window reaches the fast-IPM accuracy. For context, the median extrapolated runtime is GPU-hours per map.
Across independent timing repeats, individual median light-curve runtimes range from 0.50 s for HE 0435−1223 A to 1.8 s for RX J1131−1231 A. Including caustics and labels, they range from 0.73 s to 2.1 s for the same two macroimages. Runtimes vary with the lens parameters, number of stars, aperture size, and number and distribution of cells contributing to the source. The sample is too small to infer a separate scaling with parity or stellar density.
Synchronized timings of individual stages in the same benchmark calculations across the 12 macroimages show where the calculation spends its time. For the light-curve-only workload, the median fractions are 13 per cent for the local-exact/far-field calculation, 15 per cent for source scouting and correction, 68 per cent for shared ray tracing, interpolation, and IPM rasterization, and 2.2 per cent for source evaluation and flux integration. Scheduling accounts for less than 1 per cent. For the separately optimized labelled workload, which uses a total temporal batch of 30, the corresponding medians are 12 per cent, 11 per cent, 51 per cent, and 1.8 per cent. Caustic construction contributes 16 per cent, while source-centre labelling and other computational overhead contribute 7.2 per cent. These are medians of per-macroimage fractions and need not sum exactly to 100 per cent.
Ray-count convergence of the magnification map
We measure the pixelwise fractional map RMSE as
where the average is over the compared source-plane pixels. At fixed map geometry, is the map calculated with rays and is the reference map on the same source-plane grid. This statistic tests relative magnification accuracy across both demagnified and magnified regions. Because each residual is divided by its reference-pixel value, it gives low-magnification pixels greater leverage than a globally normalized error. We write the ray-count dependence as .
Independent random-ray deposition has the familiar Poisson scaling . Regular-lattice IRS can approach when source-pixel boundary cells dominate ((Kayser et al. 1986; Mediavilla et al. 2011)), with a measured relative-error slope of in Mediavilla et al. (2006). Zheng et al. (2022) reported an intermediate slope near . These exponents are expressed in rays per source pixel, which is proportional to the total ray count for the fixed field of view and output grid used below.
IRS assigns the full weight of an image-plane cell to its centre ray, whereas IPM transforms the cell boundary and apportions its mapped area among all intersected source pixels. The practical piecewise-affine IPM error is therefore a deterministic finite-cell or linearization error whose scaling depends on the magnification gradients, cell-to-pixel size, critical-curve curvature, and critical-cell treatment ((Mediavilla et al. 2011)). Our biquadratic reconstruction is integrated using straight-sided subtriangles.
A Taylor argument for affine IPM gives an idealized convergence rate in smooth regions. Let denote the image-plane cell spacing. At fixed field of view, the number of traced lattice vertices scales as . Away from point-mass poles, the lens mapping can be expanded locally as
Here and are the Jacobian and Hessian of the two-dimensional lens mapping. An affine mapped triangle retains the constant and linear terms. The Hessian term gives the leading displacement of the true mapped boundary. This displacement produces an area error per boundary cell. Summing over the cells intersected by a smooth source-pixel boundary gives the idealized integrated error
The exponent is an idealized smooth-region rate, not a universal IPM upper bound. Approximate polygon filling, unresolved critical cells, and finite-field selection can make the observed rate shallower. The isolated point-lens experiment in Appendix C checks the expected Monte Carlo IRS and IPM rates against the analytic solution, without finite-reference uncertainty. IPM also has a lower error normalization. Mediavilla et al. (2006) found that approximately one mapped cell per unlensed pixel was about an order of magnitude more accurate than IRS with roughly 1024 rays per unlensed pixel. This advantage decreases with source convolution ((Mediavilla et al. 2011)), making area mapping most valuable for raw maps and compact sources.
The nominal specifies the full-field lattice before scouting, not the number of lens-equation evaluations actually performed. The convergence experiment fixes the stellar field, source-plane field of view, output grid, scout ratio , true candidate refinement , and biquadratic virtual raster refinement , and varies only million. Fixed and affect the work and error normalization, not the idealized affine rate. Changing the scout ratio changes the selected cells and need not preserve the measured slope. Every candidate and the independent -ray reference use the same conservative far-field settings: a nodal lattice, , and an order-ten expansion about each cell centre. The reference uses , , and the finer virtual raster refinement . Higher ray count reduces finite-reference error when testing candidates up to rays.
We fit all seven ray counts separately for each macroimage before taking the median of the 12 slopes. The raw fractional map RMSE gives , and source convolution steepens the median slope to . Q2237+0305 image B, shown prominently in Figure 7, reaches for the raw map and after source convolution. The quoted values for image B are individual-fit uncertainties, not the 12-macroimage percentile spread. The measured IPM slope near is a finite-range rate over 1–100 million rays rather than an asymptotic prediction, with source-pixel intersections, caustic structure, the finite reference, and fixed reconstruction settings contributing to the measured error.
Although our internal IRS launches rays on a regular Cartesian lattice, its measured raw-map slope has a median slope . This effectively reproduces the counting-noise rate. The non-linear microlensing mapping largely disrupts the regular image-plane sampling before the rays are deposited into source pixels. Many source pixels receive few or no rays. Pixels receiving no rays are assigned zero magnification, without interpolation or an artificial ray count. These effects make the unsmoothed source-plane sampling behave more like random counting noise. Convolution with the extended source averages over neighbouring pixels and suppresses this small-scale ray-count noise. The remaining deterministic lattice and mapped-boundary error then becomes more important, steepening the median finite-range IRS slope to and bringing it close to the expected Cartesian-lattice rate of . This change is specific to the regular lattice. GPU-D uses pseudorandom rays and therefore does not test this Cartesian-lattice behaviour. These empirical slopes depend on the tested lens-system sample.
Method validation
The fiducial local-exact/far-field configuration uses the order-ten Taylor scheme defined above. We fix the biquadratic IPM lattice and compare one complete map for each of the 12 macroimages with direct point-mass deflections, thereby isolating the deflection approximation. The audit also includes a conservative order-ten 16 16 nodal-grid, setting, distinct from the 32 32 far-field grid used for the high-ray-count references. Across the 12 macroimages, the adopted 8 8, calculation has a median fractional map RMSE of and a median magnitude-map RMSE of mmag relative to direct point-mass deflections. The conservative control reduces these errors to and mmag, respectively. Both metrics use the same definitions as Table 2.
The fast configuration estimates its normalization correction by comparing the adopted scout grid with a denser scout grid at frame zero (§ 3.3). The resulting uniform magnification offset is applied at subsequent epochs. The independent-frame controls omit this temporal correction, so batching alone does not explain the accuracy difference. The correction does not restore missing spatial structure or guarantee agreement with an independently evaluated denser scout. Increasing the determinant discovery grid from to leaves the segment counts and source-centre labels unchanged.
The residuals show why the extent of the searched lens-plane region matters. In the representative Q2237+0305 image B map in Figure 5, the Weisenbach residual has a mean of mmag and a centred spatial scatter of 4.1 mmag, compared with an uncentred RMSE of 8.9 mmag. The constant offset therefore contributes 79 per cent of the squared map error, and the mean fractional magnification deficit is 0.72 per cent. The matched full-field control has only mmag bias, whereas the rectangular control has mmag bias. The complete light curves show the same qualitative signature. All 12 Weisenbach residuals have positive mean offsets, with a median bias of 6.2 mmag, a median centred scatter of 1.3 mmag, and a median RMSE of 6.3 mmag. The bias contributes a median 94 per cent of their squared error. We retain the uncentred errors in every benchmark rather than calibrating against the reference. These coherent
offsets are consistent with finite shooting-field losses, although the residuals also include discretization and source-grid interpolation errors. Enlarging the Weisenbach shooting region would reduce the missing-flux contribution at additional cost if the ray density is maintained. A shared nominal light-loss tolerance therefore does not make a fixed rectangular shooting region equivalent to searching the full stellar aperture. Source scouting admits source-reaching cells from anywhere in that aperture, largely avoiding this coherent finite-field bias.
Automated numerical tests compare the uncompiled PyTorch, compiled PyTorch, and Triton implementations and check that temporal and independent-light-curve batching preserve flux and caustic labels. Selected elliptic-integral calculations are checked against SciPy (Virtanen et al. 2020), lens equations against NumPy (Harris et al. 2020) and lენტrometry (Birrer & Amara 2018; Birrer et al. 2021), cosmological distances against Astropy (Astropy Collaboration et al. [2]), and bandpass integration against speclite (Kirkby et al. 2024), complementing the map and caustic validations above and the SIM5 comparison in § 5.6.
General-Relativistic Quasar Discs and Evolving Sources
Once magnification-map generation becomes sufficiently fast, source construction and CPU–GPU transfers can limit the speed of complete light-curve simulations. We therefore implement the evolving source models on the GPU, evaluating their emission and combining it with magnification maps in time and wavelength batches, with only the requested final products transferred to the CPU.
The microlensing calculation accepts any source represented on a fixed pixel grid. Here we couple it to a time-dependent, general-relativistic quasar disc with viscous heating, lamppost reprocessing, and thermal emission. The source conventions follow Fagin et al. (2025b) and Chan et al. (2024). As in AMOEBA (Best et al. 2025), we couple spatially resolved source emission, intrinsic variability, and microlensing. Our contribution is the GPU implementation of the ray-traced Kerr transfers and their batched coupling to dynamical microlensing. We describe this coupling below, with the disc-profile and geodesic details collected in Appendix A. The source model can also be used without microlensing for continuum reverberation calculations. The same interface accepts analytic profiles, supplied images, and time-ordered image cubes, as illustrated by the expanding supernova in Appendix § 10.
Each source image provides a nonnegative observer-frame flux density in erg s cm Hz for pixel and band . Summing over pixels gives the unlensed flux. Weighting the pixels by their magnifications, with the appropriate macroimage delay, gives the lensed flux as in equation (12). The fiducial quasar source uses a grid enclosing 99.9 per cent of the modelled baseline flux, with a 5 per cent radial safety margin.
Disc structure and intrinsic driving
We adopt a geometrically thin, optically thick equatorial disc with a zero-torque inner boundary at the innermost stable circular orbit (ISCO) and no emission at smaller radii (Shakura & Sunyaev 1973; Novikov & Thorne 1973; Page & Thorne 1974). Writing , the viscous temperature is
where is the Stefan–Boltzmann constant, is the dimensionless Novikov–Thorne radial flux profile and is the signed spin. The factor gives an asymptotic temperature slope , with recovering the standard thin disc (Fagin et al. 2025b). The accretion rate is , with the Novikov–Thorne radiative efficiency. The factor preserves the disc-area integral of the local viscous flux, with $N_{3/4}=1. {xref}Appendix A1` gives the flux profile, efficiency, and explicit normalization.
The primary microlensing benchmarks use the mean disc brightness. For the variable-source demonstration, we generate a coronal driver with a smoothly broken power spectral density (PSD),
where sets the normalization, is the break frequency, and and are the low- and high-frequency slopes (McHardy et al. 2004; Uttley & McHardy 2005). Following Timmer & Koenig (1995), we draw Gaussian real and imaginary Fourier coefficients with variance proportional to , impose Hermitian symmetry, and Fourier-transform to the time domain. We generate five times the required duration and retain an interior segment to reduce periodic-boundary effects. After standardizing this latent sequence , we ensure positive irradiation with
For Gaussian , and are the target ensemble mean and standard deviation, not exact finite-sample moments. The PSD specifies , rather than the transformed driver . We use and an observer-frame grid with a 1000-day leading buffer for delayed evaluations. One driver illuminates all disc radii and wavelengths. Although lensing is linear in surface brightness, microlensing weights regions with different variability amplitudes and delays, so applying variability to the resolved source is generally not equivalent to modulating the final light curve.
Relativistic observer and lamppost transfers
The general-relativistic (GR) calculation traces a null geodesic from the centre of every source-screen pixel to its first equatorial-disc intersection (Kerr 1963; Cunningham & Bardeen 1973). We use analytic quartic roots and Jacobi elliptic functions for the intersection, and Carlson symmetric integrals for the emission coordinates and arrival time (Yang & Wang 2013; Gralla & Lupsasca 2020). Appendix A2 specifies the branches and numerical safeguards. The resulting static transfer records emission radius, azimuth, relative arrival time, and frequency shift
where on the equatorial disc, is the photon angular-momentum constant, and is the circular-orbit four-velocity normalization [36] (Cunningham & Bardeen 1973; Page & Thorne 1974). We keep the disc orientation fixed, so positive and negative spin describe prograde and retrograde orbits relative to that orientation. The model retains only the direct primary image and evaluates brightness at the actual emission coordinates without an oversampled screen or ray-deposition kernel.
We adopt two identical, isotropically emitting lampposts at , each with X-ray luminosity . By symmetry, we trace the upper source and include both sources in the heating normalization. With albedo , the corresponding Newtonian profile is (Chan et al. 2024)
The configured height is . The relativistic calculation follows locally emitted rays to their first disc intersection and constructs
where is the lamp-to-disc frequency shift and is the receiving disc-comoving area in units of . We use for the photon-energy and arrival-rate factors (Wilkins & Fabian 2012). Equation (51) normalizes this kernel to the proper-area integral of the flat profile, retaining relativistic redistribution without changing the integrated heating. The comoving area and finite-axis ray calculation are specified in Appendix A4 (Dauser et al. 2013; Ingram et al. 2019).
The two transfers give the observer-frame relative delay
Here and are lamp-to-disc and disc-to-observer coordinate times in gravitational units. We subtract their minimum sum over valid pixels because only relative lags are needed, making the earliest retained disc response occur at . The factor converts to observer-frame seconds, then to days for the driver. Comparison with a directly observed coronal signal would instead require the lamp-to-observer arrival time as the reference.
Time-dependent observer-frame emission
The normalized lamp kernel sets
and the evolving temperature is
The local bolometric flux is . Following Fagin et al. (2025b), sets the mean irradiation and is partly degenerate with in the variable response.
Each disc element emits a colour-corrected blackbody with and dilution (Davis & El-Abd (2019); Chan et al. (2024)). Conservation of gives , evaluated at the quasar-rest-frame wavelength . Cosmological dimming then gives . For physical screen spacing , the observed pixel flux is . Equivalently, , where . The explicit blackbody expression is given in Appendix A5. Pixels with no valid primary disc intersection contribute zero. The disc position angle rotates the observer screen relative to the microlensing field.
We use and evaluate each band at its observed effective wavelength, rather than integrate over the filter throughput. The adopted wavelengths are (3671, 4827, 6223, 7546, 8691, 9712) Å. The reddest rest-frame profile determines the source extent. The Kerr and lamppost transfers are calculated once for each geometry and reused across times and wavelength batches. At each source-evaluation time, we update the delayed driver, temperature, and thermal emission, then integrate the brightness against the magnification map.
Continuum transfer functions
For small variations around the mean driver, define the local response weight . Its explicit form is given in Appendix A5. The microlensed response is
where is the Dirac delta distribution and is the disc delay. The corresponding mean lag is
Setting gives the intrinsic response. Differential magnification reweights regions with different light-travel times, changing the response shape and mean lag (Tie & Kochanek (2018a); Chan et al. (2020); Fagin et al. (2025b)). This image-dependent response acts in addition to the macroimage delay and can bias inter-image delay measurements if neglected (Tie & Kochanek (2018a)). In the Figure 8 snapshot, image A’s -band mean response lag decreases from 5.4 to 4.4 days, a shift of days. This is a response-centroid shift, not a recovered cosmological-delay error.
Figure 8. End-to-end Q2237+0305-like simulation at days, showing macroimage A. The top row shows a pixelwise standardized -band disc fluctuation, the mock HST-like lens image, magnification, binary caustic class, and caustic distance. The middle row compares the combined and intrinsic light curves alongside the source-centre histories. Mock WFD observations appear only on the combined light curve, and the dashed black curve shows the rescaled driver. The bottom row shows response functions at 0.25-day spacing and mean lags, with dotted unlensed comparisons and arrows indicating the microlensing-induced lag shifts. The plotted responses are normalized to unit area. The light curves and response functions use the same source grid. Source emission is evaluated daily and maps every 25 days, with , , , and .
The light curves reported here use the full non-linear source emission rather than the response approximation described in Appendix A5.
Multi-rate intrinsic variability and microlensing
Intrinsic source variability can be quickly evaluated more frequently than the evolving microlensing maps. Let denote the magnification map of macroimage at time on a fixed source-plane grid. For a source-evaluation time , define
. The flux in band is approximated by
where is the evolving observer-frame source brightness and is the macroimage time delay, as in equation (12). At each requested time, we calculate the flux using each neighbouring map on the same pixel grid and linearly combine the two fluxes. This requires no spatial resampling or intermediate map. Evaluating the source at its own cadence retains changes in its spatial profile that scalar light-curve interpolation would miss. Between map epochs, interpolation blends neighbouring magnification maps rather than following individual caustics, so rapidly changing patterns may require a shorter map cadence. For example, we can evaluate the source and light curve daily while calculating microlensing maps every 25 days. Across the 12 benchmark macroimages, evaluating the variable Kerr source daily while interpolating 25-day magnification maps differs from direct daily-map light curves by a median six-band RMSE of mmag.
End-to-end LSST-like observations
We demonstrate the complete pipeline with a four-image Q2237+0305-like lens. Each macroimage has its own lens parameters and independently seeded stellar field, while the shared source is evaluated at the appropriate macroimage arrival time. Figure 8 shows image A’s maps, caustic labels, response functions, and light curves. The driver has , days, and . Daily source emission is combined with the neighbouring 25-day maps using equation (34).
The mock lens image uses the PyTorch-native caustics package (Stone et al. (2024)), with an elliptical power-law lens, external shear, extended lens and host light, and variable quasar images (Tessore & Metcalf (2015); Shajib et al. (2024)). It is an HST-like visualization rather than a calibrated reproduction of an observation. We sample the light curves at the times and filters of 869 visits from a WFD field in the Rubin baseline_v4.3.5_10yrs OpSim realization.2 The visit depths set the photometric noise through the standard LSST prescription, with a 0.005 mag systematic floor (Ivezić et al. (2019); Fagin et al. (2025b)). Rendering and noise parameters are given in Appendix § 9.6. These samples do not include image-level deblending of the macroimages. Extracting such curves from survey images requires scene modelling, for example with STARRED (Millon et al. (2024)).
An optional package spectral layer supplements the physical disc continuum with empirical emission lines, dust, and intergalactic absorption before bandpass integration (Temple et al. (2021); Fagin et al. (2025b)). Lines receive macro magnification but no stellar microlensing, and host light requires an explicit lensing prescription. The figures and benchmarks here instead use the six effective-wavelength disc calculations.
General-relativistic validation and performance
For the direct primary observer-to-disc transfer tested here, the analytic Kerr calculation reaches exactly the same valid observer-screen pixels as SIM5 and gives image normalized mean-square errors of – for the three fiducial systems. After warm-up, the primary-image transfer takes 1.8–1.9 ms, compared with 0.54–0.57 s for the matched single-threaded SIM5 calculations. The detailed image and residual comparison is shown in Appendix § 9.7.
The matched SIM5 comparison isolates only the primary observer-to-disc ray trace and therefore does not characterize the cost of constructing the full relativistic source. Profiling of the benchmark implementation after compilation and warm-up gives a median 0.081 s to construct the complete disc source across the three benchmark prescriptions. This calculation includes the primary image, relative observer delays, lamppost illumination and delay transfer, disc normalization, and intrinsic driving realization. The observer and lamppost transfers are calculated once for a fixed disc geometry and reused throughout the light curve. The one-time compilation cost is excluded. Evaluating the complete 147-epoch, six-band surface-brightness sequence in temporal batches of 49 takes a median 0.069 s. Each source prescription is shared by the four macroimages of its system. These source costs are reported separately from the microlensing-method timings. Rubin visit selection and photometric-noise sampling are also excluded because they are shared post-processing operations rather than part of the magnification calculation.
Other time-dependent sources
An expanding Type Ia-like photosphere demonstrates the same interface with changing luminosity, colour, and spatial extent. We use an early rise Goldstein et al. 2015, an exponential decline, and homologous expansion. The projected elliptical, limb-darkened profile is initially achromatic, motivated by Goldstein et al. (2018), with weak chromatic structure after 21 rest-frame days. Compact early emission is sensitive to fine caustic structure, while expansion averages over it and the later band-dependent spatial profiles allow chromatic microlensing. This is a source-interface demonstration rather than a precision supernova radiative-transfer model. Its prescription and matched 12-macroimage benchmark are given in Appendix § 10.
The benchmark evaluates the source and maps at 51 epochs over 200 observer-frame days. The fast method gives a median light-curve RMSE of 0.44 mmag and runtime of 0.14 s. A separate test with daily source evaluation finds that four-day maps differ from direct daily-map light curves by a median six-band RMSE of mmag. Finer map cadences may be needed near rapidly evolving caustics.
Discussion
Origins of the speedup and relation to prior methods
The speedup is cumulative rather than attributable to one approximation, and most of its ingredients build on established ideas. Our comparisons therefore test complete implementations under a common source and stellar field rather than claim that each numerical idea is new in isolation. The fast source-scouted path is 19 times faster than the batched full-field IPM control at nearly the same fractional map RMSE. Its calculation of one light curve is about 710 times faster than the compared Weisenbach calculation, while batching independent curves raises the measured throughput advantage to 780 times.
Tree methods group distant microlenses hierarchically Wambsganss et al. 1990; Bate et al. 2010. Zheng et al. (2022) combine exact nearby deflections with an interpolated far field, while FMM-based methods use multipole and local expansions Jiménez-Vicente & Mediavilla 2022; Weisenbach 2025a. Our local-exact/far-field solver follows the same near/far principle but uses regular cell-local expansions that can be shared across rays and constructed for several epochs at once. For spatial selection, Meena et al. (2022) showed how image-plane pixels near a compact source can be refined adaptively. Our scout searches the full circular stellar aperture and retains cells whose mapped footprints reach the requested source field. It avoids most noncontributing area while retaining source-reaching cells that a fixed rectangular window can miss. Between scout evaluations, we retain cells selected at either endpoint. The frame-zero correction removes the dominant normalization offset of the faster selection.
The area-conserving principle of IPM was introduced and optimized by Mediavilla et al. (2006, 2011). Virtual refinement resolves the biquadratic mapping more finely without additional lens-equation evaluations. Fused Triton rasterization then avoids the large intermediate tensors required by the corresponding PyTorch calculation. Shared ray tracing, interpolation, and rasterization remain the dominant cost in the stage profiles reported in § 4.2. The IPM maps show a median raw-map convergence slope at , whereas both our Cartesian IRS and the pseudorandom GPU-D calculation scale close to in these caustic-rich fields.
Moving-star calculations showed that evolving caustics can produce shorter, steeper, and more frequent events than bulk motion alone (Wambsganss & Kundic 1995). Processing several epochs together allows fixed-size arrays and allocated GPU memory to be reused. Batching independent light curves further increases throughput. For caustic labels, Weisenbach (2025b) traces the complete critical-curve network and describes winding-number labels from oriented caustics. We instead evaluate and apply marching squares only within the scouted region. Anchors and gauges then track the binary caustic class at the source centre and its distance to the nearest caustic without a complete winding map at every epoch. Caustic construction remains the largest additional cost of the labelled workload.
The adopted configuration is deliberately conservative, with sub-millimagnitude median light-curve error and sub-percent median raw fractional map RMSE. Less stringent applications can reduce the ray density or spatial refinement, while light-curve-only calculations can omit the determinant and labelling passes. The lens and source calculations remain on the GPU until final products are transferred to the CPU. PyTorch and Triton’s support for NVIDIA and AMD backends also offers portability beyond CUDA-only implementations.
Relativistic source effects
Relativistic frequency shifts make the observed disc brightness asymmetric even for an axisymmetric rest-frame temperature profile. Spin sets the ISCO and changes the innermost emitting area, while inclination strengthens the projected asymmetry and Doppler contrast. During a caustic crossing, the high-magnification region scans the Doppler-brightened side, strongly redshifted inner disc, and regions with different reverberation delays. It therefore changes the band-dependent transfer function and mean lag rather than merely rescaling the total flux.
Limitations
The benchmark uses three lenses, four macroimages per lens, and one stellar realization per macroimage, with fixed source and population prescriptions. It is a controlled comparison of numerical methods, not a representative population of lensed quasars. Each additional realization requires a high-quality reference and runs of the much slower external comparison codes, limiting the size of this matched benchmark. The distribution of runtime and error in a diverse training set requires a broader study. The primary quasar timings measure 147 microlensing epochs separated by 25 days. They do not include construction of the GR disc, daily intrinsic variability, or the LSST-like sampling and noise model. These shared source and observation stages are excluded so the benchmark isolates the microlensing methods.
The timings are specific to the RTX 5070 Ti, which is a moderate consumer GPU. Batch and chunk sizes should be retuned for the available hardware. The simulator can use the larger memory and parallel capacity of high-performance GPUs through temporal batching and batching across independent light curves. These forms of batching are not available in the comparison implementations, so larger GPUs can provide an additional practical advantage for our method. Our simulator also works on CPU, but will be significantly slower.
The source scout traces only lens-plane cells selected as capable of reaching the finite source. The initial correction reduces the dominant magnification offset in the faster selection, but finite support and finite ray density can still omit a small amount of flux or an unusually small caustic component. Increasing the ray count, scout support, or determinant resolution reduces these risks at additional cost. The adopted determinant field can also miss caustics below its resolved scale.
The anchor and gauge method does not mathematically guarantee that every caustic crossing will be identified. The adopted nine anchors and nine gauges provide strong redundancy, and no reference crossing was missed in the 12 benchmark light curves. However, very dense caustics, incomplete components, or large changes in the caustic pattern between successive frames can challenge the classification. More anchor and gauge points and shorter temporal intervals increase robustness while raising the runtime. Likewise, temporal scout reuse assumes that the stellar field evolves slowly relative to the refresh interval. This condition is satisfied in the tested systems but should be validated for substantially larger velocities or longer cadences.
The source grid encloses nearly all modelled flux and resolves the wavelength dependent disc, but its fixed sampling only marginally resolves the smallest inner-disc scales in some configurations. Adaptive or locally refined source grids would better isolate the ISCO and compact caustic-crossing structure. The calculations use primarily float32 arithmetic, which is sufficient for the reported map, light-curve, and GR validation errors. Float64 remains available when stricter numerical precision is required, with a substantial cost in memory and runtime.
The benchmark quasar source assumes a thin equatorial disc, symmetric point lampposts, and the primary Kerr image. The optional empirical spectral layer adds unresolved line and attenuation components, but neither it nor the benchmark source provides a self-consistent, spatially resolved broad-line region, diffuse continuum, or extended corona. The supernova uses effective band wavelengths and a simplified photosphere rather than detailed radiative transfer. Users can replace either source through the common image interface. Linear interpolation between dynamical maps can also blur rapidly moving caustics. Applications requiring stricter temporal accuracy should insert intermediate maps and validate the cadence for their velocities and source size.
Applications and future work
The immediate application is LSST-scale forward modelling in which many independent dynamical microlensing histories are combined with source variability and sparse survey sampling. Future work will use matched static and dynamical calculations to determine how neglecting stellar motion biases inferred quasar disc sizes. Large independent ensembles will also support simulation-based inference of quasar parameters and cosmological time delays, as well as predictions of caustic crossings and HMEs for follow-up (Vernardos & Tsagkatakis 2019; Fagin et al. 2025a). The multi-rate interface is important for this scaling because a daily source light curve does not require a daily stellar-field ray trace once the map cadence has been validated.
Future implementations could allocate resolution adaptively in both time and space, inserting microlensing epochs when caustic-distance diagnostics indicate an approaching crossing and locally refining source and magnification-map sampling around compact inner-disc emission and nearby caustic structure.
The expanding-supernova example demonstrates evolving luminosity, colour, and source extent through the same image interface. Detailed radiative-transfer profiles and non-spherical ejecta could replace the prototype without changing the map solver. Other applications include ring-like optical gamma-ray-burst afterglows (Loeb & Perna 1998; Garnavich et al. 2000), kilonovae, and tidal-disruption flares, provided suitable evolving brightness profiles are supplied (Chen et al. 2024; Ganguly & More 2026).
Natural source extensions include continuum and velocity-resolved reverberation, extended coronal geometries, Fe K emission, X-ray microlensing, broad-line regions, and diffuse continuum emission (Morgan et al. 2012; Paic et al. 2022; Best et al. 2025). The same numerical pipeline can study planetary and compact-dark-matter microlenses in macrolensed quasars (Mediavilla et al. 2017; Dai & Guerras 2018; Tuntsov et al. 2024). Compound microlensing in double-source-plane lenses is another possible extension, but stars in multiple deflector planes would require a multi-plane version of the present single-plane calculation (Salama et al. 2026).
Galactic stellar and planetary microlensing is another extension. Explicit point-mass positions and masses, source trajectories, and pixelated stellar brightness profiles fit the present interfaces. A complete exoplanet-event model would need event-specific geometry, limb darkening, blending, parallax, and orbital lens trajectories where relevant, followed by validation against established planetary calculations (Gaudi et al. 2008; Penny et al. 2011).
Cluster-scale macrocaustics provide another application. Intracluster stars break them into microlensing networks that can repeatedly magnify individual background stars (Venumadhav et al. 2017; Kelly et al. 2018). Applying the present local model in this extreme macrocritical regime will require dedicated validation.
The fast evaluation of evolving point-mass lens fields might also inform gravitational-wave and fast-radio-burst microlensing (Muñoz et al. 2016a; Diego et al. 2019). Predicting waveform interference or delayed radio pulses, however, requires arrival-time or wave-optics calculations beyond the present intensity-map model.
and fused rasterization also accelerate static maps, while temporal batching and reuse provide additional gains for dynamical sequences.
Across the 12-macroimage quasar benchmark, the adopted configuration reaches a median light-curve RMSE of 0.35 mmag and a raw fractional map RMSE of relative to the high-resolution reference, recovering all 41 reference source-centred caustic crossings. For the ten-year, 147-epoch, six-band microlensing calculation on an RTX 5070 Ti GPU, concurrent evaluation gives median amortized runtimes of 0.68 s per macroimage, or 0.88 s with caustics and labels. These timings isolate the microlensing calculation after compilation warm-up. The light-curve-only throughput is approximately 780 times higher than that of the compared CUDA IPM implementation at comparable map accuracy, and approximately 2500 times faster including caustic crossing labels. Convergence tests give a median effective raw-map scaling of , approaching the idealized piecewise-affine IPM rate.
The same GPU-resident framework includes a relativistic quasar source that couples stochastic driving variability to spatially resolved disc emission and reverberation. Its analytic primary Kerr transfer agrees with SIM5 and is approximately 300 times faster than the matched single-threaded SIM5 calculation after compilation warm-up. End-to-end examples combine intrinsic variability, independent macroimage microlensing, macroimage time delays, microlensed response functions, and LSST-like sampling. An expanding-supernova prototype demonstrates the generic-source interface, producing 51-epoch light curves with a median RMSE of 0.44 mmag and a median amortized runtime of 0.12 s per curve.
Together, these results change dynamical microlensing from an exceptional calculation into a scalable component of forward modelling. Generating evolving stellar fields, time-dependent relativistic sources, and caustic-crossing information within one framework provides a foundation for Bayesian and simulation-based inference of quasar accretion-disc structure, microlensing-induced time-delay biases for time-delay cosmography, and forecasting of caustic crossings and high-magnification events. Microcaustics is open-source and available at https://github.com/JFagin/microcaustics.
Conclusions
We have presented Microcaustics, a GPU-accelerated simulator for dynamical microlensing of time-dependent extended sources. The method combines a local-exact/far-field deflection solver, source-directed lens-plane scouting, biquadratic IPM, fused Triton rasterization, temporal batching, and reuse of scouted cells. Selective mapping
Acknowledgements
Support was provided by Schmidt Sciences, LLC, for J.F., J.C., S.M., M.O., L.P.L., and Y.H. S.B. is supported by the US Department of Energy Grant DE-SC0026113. C.S. acknowledges the support of an NSERC Postdoctoral Fellowship and a CITA National Fellowship.
This work made use of ChatGPT and Codex (OpenAI) assistance for code development and manuscript editing. The authors reviewed and take responsibility for all the content of this paper. Software used: PyTorch (Paszke et al. 2019), Triton (Tillet et al. 2019), CAUSTICS (Stone et al. 2024), Matplotlib (Hunter 2007), NumPy (Harris et al. 2020), SciPy (Virtanen et al. 2020), Astropy [2], lenstronomy (Birrer & Amara 2018; Birrer et al. 2021), SPECLITE (Kirkby et al. 2024), SIM5 (Bursa 2018), Weisenbach 2025 (Weisenbach 2025a,b), GPU-D (Vernardos & Fluke 2014).
Data availability
The Microcaustics software is publicly available at https://github.com/JFagin/microcaustics. The benchmark data underlying this article are available from the corresponding author upon reasonable request.
Disc Source and Relativistic Transfer Details
This appendix specifies the source prescription and numerical choices used in § 5. The calculation has three stages. The disc profile fixes viscous heating. The observer and lamppost transfers then assign emission coordinates, irradiation, frequency shifts, and delays to the fixed source grid. Finally, the delayed driver determines the brightness and response weights. The transfers are static for a given geometry and are reused throughout a light curve.
Radial disc profile and normalization
We use , signed spin , and the equatorial ISCO radius of Bardeen et al. (1972), with at . Positive and negative spin describe prograde and retrograde motion relative to the fixed disc orientation. The Eddington luminosity is , where is the proton mass and the Thomson cross section. The adopted efficiency is , compared with the Newtonian value .
For completeness, the dimensionless Novikov–Thorne profile used in equation (23) is (Page & Thorne 1974)
where , , , , and . The corresponding Shakura–Sunyaev expression is (Shakura & Sunyaev 1973).
The normalization in equation (23) preserves the disc-area integral of the local viscous flux:
We evaluate these integrals on 20,000 logarithmically spaced radii up to a fixed . This normalization domain is distinct from the source-image extent, which is chosen from the reddest baseline monochromatic profile. The infinite-radius normalization converges only for , but the finite domain remains defined for every supported .
Observer screen to primary disc intersection
For each observer-screen pixel, we trace a photon backward to its first equatorial disc intersection to find its emission radius and frequency shift. SIM5 inspired this implementation (Bursa 2017, 2018). The equations below specify our conventions and branch choices within established analytic Kerr solutions. We use Boyer–Lindquist coordinates with . Radius is measured in units of , with on the disc, and times are recovered using .
The screen position fixes the conserved quantities that determine the ray’s trajectory. For inclination and Bardeen screen coordinates , these are (Cunningham & Bardeen 1973; Yang & Wang 2013)
where and normalize the axial angular momentum and Carter constant by the photon energy at infinity. Carter’s separation of the geodesic equations allows the radial and polar motion to be solved separately (Carter 1968; Gralla & Lupsasca 2020). Their allowed ranges and turning points are determined by the potentials, with ,
Using Mino time , the motion satisfies and (Mino 2003). This is a path parameter, not the photon travel time. The polar solution first gives the observer-to-equator interval at which the ray reaches .
Substituting into gives a quadratic whose roots determine the polar turning points. To express the polar integral in elliptic form, we use
Here gives at the polar turning point. Following equations (29)–(35) of Gralla & Lupsasca (2020), define , , and , with in the nonspinning limit. For an asymptotic observer at , the parameter interval to the first disc crossing is
We write the incomplete first-kind elliptic integral as with parameter , and for its complete form. The vertical Bardeen coordinate is signed so that a backward-traced ray with initially moves toward the pole and turns before reaching the disc. The branch reaches the equator directly.
We next solve the radial quartic with Ferrari’s method. Its real roots identify possible radial turning points, not the emission radius. The exterior four-, two-, and zero-real-root cases use equations (B46), (B75), and (B109) of Gralla & Lupsasca (2020). For four real roots we order , while for two real roots are the real pair. Evaluating the observer-connected radial solution with Jacobi functions at from equation (40) gives . A disc hit requires valid radial and polar domains, an intersection outside the horizon and within the emitting disc, and . Higher-order disc crossings are not retained.
At , we evaluate the disc’s circular velocity . Normalizing it by gives
with , , and on the equatorial plane (Cunningham & Bardeen 1973; Page & Thorne 1974). Substituting , , and the photon’s conserved into equation (26) then gives that pixel’s frequency shift, without spatial deposition or resampling.
Arrival times and emission azimuth
Having found the disc intersection, we integrate the time and azimuth components of the same geodesic equations along that ray. Following equations (10)–(13) of Gralla & Lupsasca (2020), the polar contributions use
For the observer-to-first-disc path, , while and supply the polar contributions to azimuth and coordinate time. The signs follow the motion and reverse at turning points. The corresponding radial contributions are
Adding the radial and polar contributions gives the azimuth and travel time. We evaluate the polar integrals and four-real-root radial endpoints through Carlson symmetric integrals , , and (Carlson 1995; Yang & Wang 2013). Equations (29)–(35) and (B36)–(B44) of Gralla & Lupsasca (2020) give the corresponding Legendre expressions. The Legendre-to-Carlson identities are given in equations (19.25.5), (19.25.9), and (19.25.14) of Olver et al. [86], whose modulus corresponds to our parameter .
We end the radial integrals at a common finite observer radius outside the emitting disc to avoid the divergent travel time to infinity. The polar integral includes the path to infinity, so we subtract its outer time contribution , where and . We evaluate this outer Mino-time interval by eight-point quadrature in . With observer azimuth , we store
where is the source-to-observer azimuthal displacement. Axisymmetric emission does not require the azimuth, but variability requires . We subtract its minimum valid value, then combine it with the lamp travel time using equation (29). Appendix § 9.7 describes numerical checks and fallback evaluations.
Finite-axis lamppost transfer
We separately trace photons from the lamp to the disc to obtain its heating profile and illumination delay. Their conserved quantities are set by the launch direction, independently of the observer rays. For , rays start in the local orthonormal frame of a static lamp at , with for the upper axial lamp. We sample launch angles , measured from the inward radial direction, with solely single-angle weights. Thus launches inward and outward. Axial rays have , and the local direction fixes the Carter constant,
where is required for a static source. We again solve the polar motion to the equator and evaluate the radial solution at the same parameter interval, now starting at the finite lamp height rather than infinity. The initial radial phase is set by the lamp radius and inward or outward launch direction. We use the infinity-connected radial branch unless for four real roots, which requires the inner branch in equation (B27) of Gralla & Lupsasca (2020). Retaining both possibilities avoids discarding valid rays at low lamp heights and high spins.
The frequency shift is the ratio of photon energies measured in the orbiting disc and static lamp frames (Ingram et al. 2019, Appendix § 10),
where follows from equation (26) with . Thus reuses equation (41) at the receiving disc radius, without an additional ray trace.
The same coordinate-time integrals, evaluated from lamp to disc, give the illumination delay,
The polar integral is analytic, while the one-dimensional radial integral uses 24-point Gauss–Legendre quadrature. The Figure 8 source uses 1024 launch angles and 512 radial annuli for both the light curves and response functions.
To turn the ray distribution into illumination, we rebin from the ISCO to the outer radius of the finite source model into annuli that conserve the intercepted lamp solid angle. This outer radius is distinct from the normalization limit in Appendix A1. We then divide by the receiving area and apply the energy and arrival-rate factors in equation (28). The area measured in the orbiting disc frame is (Ingram et al. 2019, Appendix A)
with
on the equatorial plane. Here is the lapse of a zero-angular-momentum observer, and converts the stationary spatial annulus to the disc-comoving area. Areas are in units of . For extreme annuli not reached by accepted launch angles, we use the dimensionless flat-space continuation
whose radial dependence is the Newtonian illumination profile (Dauser et al. 2013). The factor combines with the prefactor in equation (30) to recover the adopted two-lamppost Newtonian flux in equation (27). We match the continuation’s amplitude and Euclidean travel time to the nearest sampled relativistic annulus, then shift all delays by one common zero point. Finally, for the resulting profile , we adopt the normalization
The integrals are sums over annuli weighted by proper area. This prescription retains the relativistic radial redistribution while fixing the integrated heating to the flat-profile value, so its overall amplitude remains controlled by .
Thermal emission and response weights
For each observer pixel, we evaluate the lamp heating and illumination delay at its emission radius. Combining lamp-to-disc and disc-to-observer travel times gives the delay in equation (29). The delayed driver and viscous heating then set through equation (31). With frequency shift and rest-frame wavelength , the colour-corrected intensity is
Here and are the Planck and Boltzmann constants. This is the invariant transformation specialized to a diluted blackbody. The factor preserves the bolometric flux. Cosmological dimming and the pixel solid angle are applied as described in § 5.3.
The response weight measures how this intensity changes under a small lamp-amplitude perturbation about . Writing , differentiating the temperature and Planck functions gives
All quantities on the right are evaluated at . The Planck factor gives the intensity’s temperature sensitivity, while gives the fractional temperature response to the lamp. Weighting pixels by their microlensing magnification and grouping them by delay gives equation (32). We distribute each pixel’s response between neighbouring delay bins, then average monotone cubic Hermite interpolations of the cumulative response on four shifted grids. Differences between cumulative values at the requested bin edges give the response integrated over each bin. The reconstruction preserves the integrated response and supplies both the displayed transfer functions and the optional response-mode convolutions. Mean lags are evaluated directly from the pixel weights. The non-linear light-curve calculation does not use this reconstruction.
Convolving the response with the driver perturbations and adding the baseline flux gives the linear approximation, with the magnification pattern held fixed over the response delay,
where and is the microlensed baseline flux. Microlensing changes the baseline, response amplitude, and response shape. The package offers linear- and quadratic-response modes for dense time-and-wavelength calculations, but their accuracy is not established by the present benchmarks.
Mock image and observing prescription
The mock HST-like image in Figure 8 contains a common elliptical power-law plus external-shear lens, extended lens-galaxy light, a lensed Sérsic host, and the variable quasar point images. It uses a grid with 0.025 arcsec pixels and a 0.08 arcsec full width at half maximum point-spread function, with a realization of Poisson and read noise. The light-curve samples are generated separately from the source fluxes, not extracted from this mock image.
For visit depth , noiseless magnitude , and , the LSST magnitude uncertainty is
We use mag, , and (Ivezić et al. 2019; Suberlak et al. 2021; Sheng et al. 2022). These mock survey samples omit an additional image-deblending error model.
GPU execution and numerical checks
The solvers use PyTorch tensor operations on CPU or CUDA, with float32 real-pair representations of Ferrari roots, Jacobi functions, and Carlson , , and algorithms. Fixed iteration counts support torch.compile and CUDA graphs, while spatial chunking bounds memory use. For rays from the axial lamp, we evaluate the polar integral analytically and use a numerically stable expression for the radial potential at launch, avoiding loss of precision for nearly tangential rays.
Roots are classified as real when . Numerical checks require the radial integral of to reproduce and the polar integral to reproduce . Ill-conditioned polar endpoints are reevaluated in float64 while retaining the radial solution. Rays outside the four-real-root analytic coordinate domain, or failing an endpoint check, use endpoint-regularized Gauss–Legendre quadrature. Any remaining failed coordinates are collected and retried once in float64. A pixel is retained only if its coordinates are finite and the radial and polar solutions agree on the elapsed Mino time.
The SIM5 comparison in § 5.6 and Figure A1 validates the primary observer-to-disc image and transfer, not the lamppost heating or response delays ((Bursa 2017, 2018)). We define the image NMSE as , where indexes image pixels. Separate package tests compare lamp integrations with independent geodesic integration, selected lamp travel times with numerical quadrature, and float32 illumination profiles with float64 calculations.
Figure A1. Visual validation of the direct primary observer-to-disc analytic PyTorch Kerr transfer against SIM5 for the Q2237+0305 fiducial spin and inclination. The same matched calculation is also performed for RX J1131−1231 and HE 0435−1223. The panels show the frequency shift, observed brightness, and signed fractional residuals for Q2237+0305. Typical residuals are consistent with float32 numerical precision, with larger differences confined to localized regions. Colourbar extensions mark residuals outside the displayed range. Both calculations reach exactly the same observer-screen pixels in all three cases. Image NMSE ranges from to , and integrated flux differs by at most .
Expanding Supernova Source Example
Our prototype defines the explosion epoch in the observer frame and all evolutionary time-scales in the rest frame. Its bolometric luminosity is
Here is the peak bolometric luminosity, is its rest-frame peak time, and is the post-peak exponential decay time-scale. The adopted parameters are , days, and days. The photosphere expands as and its colour temperature follows . We adopt cm, , and temperature bounds of 3000–18000 K. Time in the expansion law is converted to seconds. When a temperature bound is active, a wavelength-independent dilution factor renormalizes the bounded blackbody to the prescribed bolometric luminosity. This prevents photospheric expansion from producing an artificial late-time rebrightening. A blackbody continuum and a phenomenological rest-UV blanketing factor supply six-band images. The projected ellipse, position angle, and linear limb-darkening profile evolve on the fixed source grid. Every band-dependent spatial correction is renormalized independently, so it redistributes surface brightness without changing the corresponding band flux. The adopted photospheric parameters are representative prototype values. The approximately three-week achromatic phase is typical rather than universal, but variation in microlensing configuration and filter choice can shorten it to only a few days (Huber et al. 2021). We restrict interpretation to the photospheric phase and do not use this source as a distance estimator or substitute for radiative-transfer templates such as those considered by Huber et al. (2021). The matched 12-macroimage transient benchmark uses 51 map epochs over 200 observer-frame days at a four-day cadence. It uses the same frame-zero dense scout to normalize the subsequent selected maps as in the adopted fast quasar configuration. The correction is source-model independent.
Figure B1 summarizes the corresponding accuracy and runtime distribution across the 12 macroimages. The fast source-scouted biquadratic IPM method has a median light-curve RMSE of mmag and a fractional map RMSE of . The complete light curve takes s, or s with caustics and labels. The Weisenbach comparison evaluates all 51 epochs, with median light-curve and fractional map RMSEs of 10 mmag and . Its complete measured light-curve runtime is 93 s, increasing to 500 s when the extrapolated caustic cost is included. Across individual macroimages, the fast IPM scout method has a median single-curve speed advantage of 520 for the light curve and when the Weisenbach caustic calculation is included. Batching up to four curves increases these median advantages to 620 and .
Figure B1. Accuracy–runtime comparison for the evolving supernova source across the same 12 macroimages as the quasar benchmark. Internal light-curve runtimes refer to all 51 dynamical-map epochs, and fractional map RMSE uses every pixel at every epoch. Light-curve metrics omit only samples below 1 per cent of the peak reference flux in that observer band. For the few above-threshold GPU-D samples with zero candidate flux, the magnitude residual uses the 1 per cent flux-ratio floor. Weisenbach light-curve timing and accuracy use all 51 epochs. Its map errors compare the complete native square with a reference evaluated directly on the same grid. Caustic-stage timing follows § 4.1. GPU-D IRS appears only in the left panels because it does not calculate caustics or labels. Its plotted runtime is the complete measured 51-frame executable process time.
We separately measured throughput for the 51-epoch supernova sequence, which spans 0–200 observer-frame days at a four-day cadence. Batching up to four separate light-curve calculations with matched seed inputs decreases the amortized median runtime from s to s per curve. The median throughput gain is times. For the workload that includes caustics and source-centre labels, the same batching lowers the amortized per-curve runtime from s to s per curve. The corresponding median throughput gain is times.
We also evaluate the published GPU-D implementation for all 51 epochs in each macroimage. At the same nominal -ray budget, its median complete process time is s for the map sequence. Across matched macroimages, this is times slower than the complete fast IPM scout light curve, even though GPU-D does not integrate the source brightness over the magnification maps or calculate caustics and labels. The much smaller transient field is severely undersampled by direct ray deposition at this budget. The median raw fractional map RMSE is 4.2 and 93 per cent of its source-plane pixels receive no ray. The 12 macroimage parameter sets deliberately match the quasar benchmark and are therefore a numerical stress test, not an observability-selected lensed-supernova sample.
Analytic point-lens convergence
An isolated point lens provides an exact end-to-end convergence test without the finite-reference uncertainty of a many-star magnification map. In units of its Einstein radius, the point-source magnification is
where is the angular lens–source separation in units of the point-lens Einstein radius. We compare the numerical maps with this analytic solution using the fractional map RMSE defined in equation (20). The source grid spans on a side, the lens grid spans , and the reported norm uses to exclude the singular point caustic and the finite-field boundary. The IPM calculation retains the fiducial , , scout, scalar-correction, and biquadratic-polygon settings, while evaluating the sole point lens directly so that an unnecessary far-field approximation cannot set the floor.
Figure C1 fits four ray budgets from to . Monte Carlo IRS, shown as the median of eight independent realizations, gives for , recovering the expected sampling law. Cartesian IRS gives over the same low-occupancy interval. It converges more rapidly than random sampling but has not yet reached the nominal boundary-dominated regime. The source-convolved macroimage experiment in § 4.3 suppresses the pixel-occupancy noise and gives the steeper Cartesian IRS rate . The adopted biquadratic IPM calculation gives , recovering the expected piecewise-affine IPM benchmark.
Figure C1. Analytic point-lens convergence over – nominal rays. Teal circles show the fiducial , biquadratic IPM rule. Blue diamonds show Cartesian IRS. Orange squares and their shaded 16th–84th percentile envelope show eight independent Monte Carlo IRS realizations. Dashed coloured lines are log–log fits over the complete displayed interval.
References
- [2]Astropy Collaboration et al., 2018, AJ, 156, 123
- [18]Chan J. H. H., Rojas K., Millon M., Courbin F., Bonvin V., Jauffret G., 2021, A&A, 647, A115
- [36]Gates D. E. A., Hadar S., Lupasca A., 2021, Phys. Rev. D, 103, 044050
- [43]Hamilton A. J. S., 2001, MNRAS, 322, 419
- [86]Olver F. W. J., et al., eds, 2026, NIST Digital Library of Mathematical Functions. Release 1.2.8 of 2026-09-15. National Institute of Standards and Technology, https://dlmf.nist.gov/
- [91]Planck Collaboration 2020, A&A, 641, A1
- [121]van de Ven G., Falcón-Barroso J., McDermid R. M., Cappellari M., Miller B. W., de Zeeuw P. T., 2010, ApJ, 719, 1481
- [135]Wu Z., Ho L. C., 2025, ApJ, 985, 197








