Run files, the command line and clusters#
A scan can be described in a run file and run from the command line, which is how
it runs on a cluster: a TOML file with the configuration ([config], the fields of
pnps.setup.Config) and the scan ([scan]: the delays, the save positions, the
step, the name, the output directory and the backend). pnps.runfile describes the
format; examples/runs/window_series.toml is a complete one at the production pixel
size.
[config]
lam0 = 260e-9
tau_fwhm = 1e-15
energy = 1e-7
thickness = 40e-6
mask_diam = 1e-3
mask_spacing = 1e-3
lam_lims = [143e-9, 600e-9]
trange = 250e-15
r_max = 366e-6
n_transverse = 768
[config.beam]
type = "HE11Beam" # or "GaussianBeam" (w0, f_foc), "UniformBeam" (f_foc)
a = 125e-6
f_coll = 5.0
f_foc = 0.1
[[config.windows]] # one table per collection window
holex = -1e-3
holey = -1e-3
holediam = 1e-3
zmask = 0.1
[scan]
name = "window_series"
taus = {start = -40e-15, stop = 40e-15, num = 161} # or a list
zsave = {start = 0.0, stop = 40e-6, num = 17}
h_target = 0.5e-6
out_dir = "scans"
An injected input pulse is a recipe, [config.input_pulse]: the source file (relative
to the run file), its omega_key and e_omega_key, an optional window = [lam_min, lam_max] with its edge fractions, and whether to centre and normalise it, applied
in that order as pnps.input_pulse does. pnps.runfile.load_run() reads a
run file and pnps.runfile.dump_run() writes one back exactly.
The pnps command#
pnps budget run.toml # the memory a run will need, before launching it
pnps scan run.toml # the whole scan, resuming points already written
pnps scan run.toml --shard 2/8 # delay indices 2, 10, 18, ... into a shard file
pnps merge run.toml --shards 8 # the shard files folded into one collected file
pnps separate tg.toml --shard 2/8 # the transient-grating separation ({doc}`separation`)
python -m pnps is the same command. --backend overrides the run file’s solprop
backend, --indices restricts a scan to some delays and --recompute rewrites points
already in the file.
On a Slurm cluster#
One shard per array task, then one merge (examples/runs/scan.sbatch):
sbatch --array=0-7 scan.sbatch run.toml 8
# once every task has finished:
pnps merge run.toml --shards 8
Ask for the memory pnps budget reports as the peak: 27 GiB for the production shape,
about five field volumes (see The propagation engine: solprop). pnps budget builds the backend to read
its ledger, so run it on a node of the kind the job will run on. Each delay point is independent, so the shards
need no communication and a failed task is rerun as it is: the file resumes.
On a CPU node of several NUMA domains (sockets, or chiplet groups), run one process per
domain, each confined by Slurm to its domain’s cores and memory, rather than one process
per node: the field volumes are tens of GiB, and a process whose threads span domains
spends its time on remote memory. Set the thread budget to the cores a task owns
(SOLPROP_THREADS, which holds solprop’s pools and this package’s numba pool within
it), as the example script does. Calibrate the native backend once per node type before
the array job (solprop calibrate, run with the task’s thread budget), so that no task
spends its first point measuring (The propagation engine: solprop).
Leave OpenMP’s thread binding unset#
Confining a process to a set of cores (Slurm’s allocation, --cpu-bind, taskset,
numactl) is right. Binding OpenMP’s threads inside it is not: do not set
OMP_PROC_BIND or OMP_PLACES (nor GOMP_CPU_AFFINITY or KMP_AFFINITY) for a pnps
run. With none of them set, solprop’s native backend leaves its threads unpinned and
chooses its own wait policy, so OMP_WAIT_POLICY can be left unset too: on 16 cores the
step took 11.4 s with solprop’s choice and 10.5 s with OMP_WAIT_POLICY=passive, one
sample each.
Under OMP_PROC_BIND, importing solprop’s native backend starts its OpenMP runtime, which
binds the main thread to its first place: one CPU. Every thread the main thread starts
afterwards inherits that CPU, numba’s pool (the input former and the host reducer) among
them, and the march itself slows with it: the run uses about one core of the task.
Measured with pnps scan at the production shape, one delay to 2 µm at two steps, on
16 cores of an AMD EPYC node of a Slurm cluster (2026-11-29):
environment |
s per step |
CPU in use |
|---|---|---|
|
75.6 |
about 1.1 cores |
neither set |
14.7 |
about 12 cores |
pnps now undoes the binding itself. When the native backend has confined the main thread
to fewer CPUs than the process had, it restores them before its numba pool starts and
emits a ThreadBindingWarning
(pnps.kernels.release_main_thread()). A bound run restored this way stepped within
10 % of an unbound one (11.5 s against 10.5 s on 16 cores of an AMD EPYC 7513), but the
warning means the job script should drop the variables. To check a running job, read its
main thread’s CPUs: grep Cpus_allowed_list /proc/<pid>/status should list the task’s
cores, not one.