The propagation engine: solprop#

This package no longer steps a field itself. The envelope UPPE is integrated by solprop on its Cartesian free-space route, through the bridge in pnps.bridge; this package defines the instrument, forms the input state and reduces every saved plane to the measured spectra. What solprop integrates, and how the bridge pins it to this package’s model, is in The physical and numerical model; the measurements behind every identity are in How the model is put on solprop, and the measurements behind it.

One delay point#

import numpy as np
from pnps import build_bridge, build_setup, run_delay_point

setup = build_setup(cfg)  # tables only, nothing field-sized
zsave = np.array([0.0, 20e-6, 40e-6])
with build_bridge(setup, zsave, h_target=0.5e-6, backend="auto") as bridge:
    for tau in taus:  # one bridge, every delay point
        result = run_delay_point(bridge, tau)

build_bridge translates the problem and builds solprop’s runner (Simulation.runner()), which holds one backend for every delay point; run_delay_point forms the input on the host (pnps.form_input.form_input()) and runs it (SimulationRunner.run), with an output handler that reduces each plane as it is saved (solprop.output.CallbackOutput, and pnps.reduce_numba.Reducer or solprop’s statistics) and keeps only the reductions. The plane’s field, when there is one, is solprop’s own read-only observation, not a copy. The input is passed without a name, so solprop frees it once loaded, and it is named in solprop’s record by the configuration and the delay rather than by a SHA-256 of its bytes (input_identity). pnps.simulate.simulate_delay_point() builds and closes a bridge around a single point, and pnps.scan.run_scan() builds one per process. A replayed schedule is bit-reproducible: the same delay point on one bridge, run before or after others, or on a fresh bridge, gives the same bits.

What the runner watches#

solprop’s boundary monitor (pnps.bridge.BOUNDARY_CHECK) watches the transverse grid’s edge in real space: a launch or a field with more than 1e-6 of its energy in the outer 5 % of the grid warns, and more than 1e-4 stops the run, since that light wraps round the periodic grid and nothing else here guards against it. A fixed schedule whose steps are longer than the monitor’s read spacing, min(L/16, 4g/v), is reported as coarse: about 2.5 um on a 40 um slab. Config.transverse_monitor=False turns it off, for a grid known to be too small (the test suite’s is a quarter of the sizing rule’s). The time window’s guards are not watched: the lap budget lets walked-off light fill the window by design and removes only what would wrap onto the pulse, and lap_lost reports what it removes (The physical and numerical model).

This package checks every plane itself. The envelope Kerr and Raman responses conserve the photon number \(\sum \eta |E|^2 / \omega\) and every absorber removes photons, so a run whose photon number grows between two planes by more than the march can account for stops with an EngineError (numerical instability). The allowance, pnps.bridge.Bridge.photon_allowance(), is rounding plus \(10^{-2} (\Gamma h)^2\) per step of length \(h\), with \(\Gamma\) the configuration’s peak nonlinear wavenumber \(k_0 n_2 I\) (pnps.bridge.peak_kerr_rate(), recorded as Bridge.kerr_rate; its product with the slab bounds the B-integral). The energy is not checked: the Kerr response raises it by about \(8\times10^{-8}\) of the nonlinear phase, a photon-conserving blue shift (How the model is put on solprop, and the measurements behind it, “Photon number and the growth guard”).

With the dopri5 stepper, solprop logs a warning at a plane whose replayed steps recorded an error norm above one: the step is coarse for the tolerance the norm is scaled by. A replay accepts every step, and this package certifies the step on the observables (Richardson calibration, pnps.calibrate), not on that norm. The low-storage rk4ip march records no estimate.

Delays run one at a time: solprop refuses lockstep batches of spatial problems, so scale out with shards (run_scan(..., shard=(i, n))), one process per node.

Where planes are reduced#

Config.reduction chooses where each save plane becomes the observables:

  • "host": solprop hands the whole field over at every plane (its host observation; on a device that is a copy across the bus) and pnps.reduce_numba.Reducer reduces it in one fused pass;

  • "solprop": the planes are statistics-only (solprop’s design proposal SEP 22, listed among solprop’s proposals): no field crosses, and solprop evaluates its own far-field statistics (SEP 23) on the live state, which pnps.statistics converts back into this package’s units;

  • "auto" (the default): "solprop" whenever solprop accepts the windows as apertures without a warning (pnps.statistics.statistics_unavailable()), "host" otherwise. The bridge, and every scan file’s /grid/reduction, record the resolved choice.

Both reductions measure energy the same way: by the medium’s axial flux (The physical and numerical model, “The measure of energy”), which is solprop’s own measure (its SEP 34).

observable

solprop statistic

i_omega_win

aperture_spectrum, the windows as an ApertureSet

i_omega_reimaged

aperture_on_axis_spectrum

i_omega_full

region_spectrum, one box: the TG signal quadrant

i_omega_beam

beam_spectrum

energy

energy

absorb_omega

absorbed_power[0], the spectral channel: the band edges

absorb_lap

absorbed_power[4], the custom channel: the lap budget

gd_band_power

beam_spectrum over the lap-budget bins

alias_fraction

region_spectrum’s last row, the inner box, against beam_spectrum

absorb_k

absorbed_power[1], the transverse channel

edge_fraction

none: a time-domain quantity, so with edge_diagnostic=True the field is still observed and the fraction computed on the host

The window centres are negated on the way: solprop’s aperture centres are physical mask-plane positions, and a stored column at transverse wavevector \(k\) travels along \(-k\), so this package’s signal corner \((-d,-d)\) is solprop’s \((+d,+d)\). The self-diffraction signal region is the half of the mask beyond the gate-side edge, so in momentum it moves with frequency; solprop expresses it as a hard half-plane row of the aperture set (half_plane_x_ge at \(x = s\), at the input mapping’s distance f_foc), whose aperture_spectrum is SD’s i_omega_full. That row reaches only light inside air’s light cone, \(|k_\perp| < \omega/c\), the light that can leave the slab towards the mask; the host’s region keeps to the same cone, and on the grids the sizing rule gives no column lies beyond it. The units are undone by three constants, with \(U_S = (\varepsilon_0 c/2)(\Delta x^2/N)(\Delta t^2/2\pi)\) for the column-summed spectra, \(U_A = (\varepsilon_0 c/2)(\Delta t^2/2\pi)\) for the on-axis spectra and \(U_P = (\varepsilon_0 c/2)(\Delta x^2/N)(\Delta t/n_t)\) for the absorbed powers (pnps.statistics.StatisticsScale); the energy needs none.

Every statistic weights \(|E|^2\) by the admittance \(\eta = c\,\mathrm{Re}\,k_z/\omega\), and so does the host reduction, so the constants are the vacuum ones on both sides. The on-axis spectrum pairs the coherent on-axis amplitude \(A\) with its magnetic closure \(G\), the same sum with each element weighted by the conjugate admittance: \(\mathrm{Re}(A\,G^*)\).

The two reductions agree to rounding (tests/test_statistics.py, How the model is put on solprop, and the measurements behind it). The solprop path works on both of solprop’s backends (native and numpy_ref both form its far-field statistics) and needs windows solprop can express: one shared profile among hard, tanh, rcos and supergauss, and solprop’s edge limits (for rcos, \(w \le D/4\)). The production windows qualify. On the tiny test grid the default two-bin raised cosine is 0.26 mm wide, over a quarter of the 1 mm window, so those runs reduce on the host.

On a CPU the two cost the same. Measured on the native backend (Apple M5 Max, 18 threads, ten steps of 0.5 um, medians of three), reducing a plane costs 16 ms on the host against 12 ms in solprop at 192 x 192 x 300, and 106 ms against 110 ms at 384 x 384 x 600, against a step of 140 ms and 1.35 s; the two reductions agree to 1.3e-15 of the peak. What the solprop path saves is the field copy: one field volume per plane on the host, 5.3 GiB at the production shape, and on a device the transfer across the bus as well: on an H200 at the production shape a delay point takes 20.6 s with solprop’s statistics against 29.5 s with the host reduction (Performance). Hence "auto".

Backends#

backend is a solprop registry name:

name

what it is

"auto"

native; solprop refuses with no native package, or on a processor below its build’s CPU baseline

"native"

solprop’s compiled backend (OpenMP on a CPU; CUDA or HIP in a device build)

"numpy_ref"

solprop’s NumPy reference backend (slow; the numerical reference)

The backends agree to rounding, not bit for bit. A file records the backend that produced it (/grid/backend, for example solprop:native@<version>), so do not mix backends within one scan. The tests run on one backend per process (PNPS_TEST_BACKEND, default native); poe test-reference runs them on numpy_ref.

Threads and the environment#

Threads are solprop’s, set by environment variables before the process starts:

variable

controls

SOLPROP_THREADS

the process’s thread budget: every pool below stays within it

SOLPROP_NATIVE_THREADS

the native backend’s OpenMP pool

NUMBA_NUM_THREADS

the ceiling of numba’s pool, which this package’s input former and host reducer use

OMP_PROC_BIND, OMP_PLACES

leave unset: binding confines the run to one core (clusters)

solprop’s thread budget (solprop.backends.thread_budget()) is the smallest of the CPU affinity, the physical cores, the control groups’ CPU quota and SOLPROP_THREADS. solprop sizes its pools within it, and this package holds numba’s pool within it too (pnps.kernels.size_thread_pool()). In a container that matters: containers commonly report every core of the host, and a pool wider than the quota stalls at every barrier. On a Mac whose chip has cores of more than one kind the budget is the cores of the fastest kind (6 on an M5 Max) unless SOLPROP_THREADS is set. On a 128 x 128 x 600 grid, ten steps on an Apple M5 Max took 2.34 s per delay point on those 6 cores and 1.93 s with SOLPROP_THREADS=8, so time your own grid both ways.

Leave OpenMP’s thread binding to solprop. Under OMP_PROC_BIND, starting the native backend binds the main thread to one CPU, and everything that inherits it, numba’s pool and the march with it, then runs on that CPU: about one core of the allocation, five times slower per step at the production shape on 16 cores. pnps restores the thread’s CPUs when it finds it confined, and warns (ThreadBindingWarning); Run files, the command line and clusters has the measurements and how to check a running job.

The native backend fits itself to the machine (solprop’s calibration): the first native CPU run with no profile for its machine, build and thread allocation measures how to thread and plan its transforms, in about 30 s, warns that it is doing so (CalibrationNotice), and keeps the profile for every later run. Run solprop calibrate once per machine, or node type, before a scan, so that no shard spends its first point calibrating; SOLPROP_CALIBRATION=use uses a kept profile and never measures, off ignores profiles. The test suite runs with it off.

Config.node_budget (default 1 GiB) is solprop’s per-chunk memory budget: larger chunks are faster up to a point and hold more memory (see solprop’s resource guide).

On a GPU#

solprop’s native backend runs on an NVIDIA or AMD GPU from a source build (Installation); backend="native" then propagates on the device, one device per process. The input is formed and handed over on the host once per delay point. With reduction="solprop" (which "auto" chooses for windows solprop can express) nothing field-sized crosses back; with the host reduction every save plane is copied to the host and reduced there by the CPU. Size the device memory with pnps.memory.memory_budget(), run on the device: its engine part is the device’s ledger, and the formed input it also counts lives in host memory. At the production shape on an H200 the device peaked at 22.4 GiB on either reduction, the ledger’s 21.7 GiB plus the CUDA context (Performance), where under solprop 0.1 it held 28.7 GB with the host reduction and 33.7 GB with solprop’s statistics.

Memory#

One field volume is F = 16 n_x n_y n_t bytes: 0.165 GiB at 192 x 192 x 300, 1.32 GiB at 384 x 384 x 600, 5.27 GiB at the 768 x 768 x 600 production shape.

pnps.memory.memory_budget() estimates a run before it is launched, from the arguments of pnps.bridge.build_bridge(): the backend’s own ledger of its buffers, and this package’s own parts, in bytes and field volumes. solprop has no estimate that does not build the backend, so the budget builds it, reads the ledger and closes it again: run it where the job will run.

from pnps import memory_budget

budget = memory_budget(setup, zsave, 0.5e-6, backend="native")
print(budget.report())  # one line per part, then the peak
budget.peak, budget.volumes

At the production shape (768 x 768 x 600, 17 planes to 40 um, h = 0.5 um), on the native backend’s CPU build (examples/runs/window_series.toml, solprop 0.2.0):

part

GiB

F

solprop’s engine (rk4ip), with reduction="host"

21.6

4.10

the translated problem’s placeholder input (one broadcast row)

0.00

0.00

the formed input of a delay point (transient)

5.27

1.00

solprop’s host copy of a plane, with reduction="host" (transient)

5.27

1.00

the host reducer and the setup tables

0.09

0.02

peak (the two transients are never alive together)

27.0

5.12

With solprop’s statistics the engine holds 21.7 GiB (4.12 F) and no plane is copied, so the peak is the same 27.1 GiB. Under solprop 0.1 the peak was 32.0 GiB (6.07 F): the translated problem kept a full copy of the placeholder input, which solprop 0.2 keeps as the one row a broadcast repeats. This package adds nothing field-sized beyond the formed input: the beamlets are never stored, and the reduction needs only per-row partials.

The bridge lets go of the formed input as soon as solprop has copied it into its state, and on every backend it is then freed, before the first step.

What is recorded#

Every scan file’s /grid carries the engine’s provenance (pnps.io_h5.ENGINE_KEYS): backend, stepper (solprop-rk4ip-lowstorage or solprop-erk-dopri5-fixed), pnps_engine (solprop), solprop_tableau (RK4IP or DOPRI5), frame_pinned, gamma_k_applied (the transverse ramp’s rate), evanescent_clamp (200 /m), index_model (optmat), measure (flux) and reduction (host or solprop). pnps.io_h5.engine_metadata() reads them back, so a merge target can be created without building the engine.