Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/361-device-split-collar.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On a CUDA or HIP build, a free-space envelope's split-step temporal collar transforms every row of the state at once, in place, rather than a node chunk at a time, whatever `node_budget` says. At 768 x 768 x 600 a step takes 14 kernels and 10 transforms where it took 119 and 220, and on an AMD Instinct MI300X a point takes 1.6 % less time. Results are unchanged to rounding.
1 change: 1 addition & 0 deletions changelog.d/365-volume-order.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On a CUDA build, a Kerr-only free-space envelope's stage holds its transverse scratch in the state's order, so its rank-3 transform keeps frequency contiguous and its input and fold no longer cross layouts. A step on an NVIDIA H200 takes 204 ms at 768 x 768 x 600 where it took 225 ms, and 36 ms at 384 x 384 x 600 where it took 51 ms, with 1.3 GiB less memory there. Results are unchanged to rounding.
1 change: 1 addition & 0 deletions changelog.d/529-shared-work-area.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On a CUDA or HIP build, a free-space run's transforms of the transverse scratch share one work area instead of holding one each. At 768 x 768 x 600 a run holds about 16 GiB less, 22.6 GiB against 38.5 GiB on an NVIDIA A40, and 23.4 GiB on an AMD Instinct MI300X. Results are unchanged.
17 changes: 17 additions & 0 deletions docs/dev/accuracy.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,23 @@ which that target does not bound.
accuracy_figures.backend_equivalence()
```

**A hard aperture edge** decides exactly as `numpy_ref` decides on every backend, a
stronger contract than the ladder's. SEP 23's mask-plane radius rounds each product and
sum on its own and takes a correctly rounded square root. On a CPU and in a CUDA build
that root is IEEE 754's (`std::sqrt`, `__dsqrt_rn`). In a HIP build it is the
compiler's. HIP's `sqrt(double)` is `__builtin_sqrt`, which becomes `llvm.sqrt.f64`.
LLVM defines that intrinsic to match a conforming IEEE 754 library unless the call
carries the approximate-functions flag `afn`, and solprop's HIP build sets no fast-math
option. The AMDGPU backend has expanded it that way since 2023 (LLVM `e3fd8f8`): for
`gfx942` under ROCm 7.2.4 a kernel's double `sqrt` compiles to a reciprocal-root
estimate refined by fused multiply-adds, not the bare `v_sqrt_f64`. AMD's documentation of HIP's
math functions promises less. It lists `__dsqrt_rn` as round-to-nearest-even and `sqrt`
at 1 ulp, both measured over `[0, 100]` rather than guaranteed. The device tests'
hard-edge fuzz in `tests/backends/test_native_far_field.py` holds the contract on each
card it runs on. On an AMD Instinct MI300X it fails 31 of its 120 cases with the far
field's contraction pragma removed
([#504](https://github.com/LupoLab/solprop/issues/504)).


## 8. Where Luna is not converged, and where the two codes still differ

Expand Down
6 changes: 5 additions & 1 deletion docs/dev/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,11 @@ free-space envelope whose material response is the Kerr term alone, with one
polarisation, on a time grid the spectrum fills (`n_t = n_to = n_omega`, the crop the
identity) takes its stage core on a device through one rank-3 transform of the scratch
volume each way, forming the polarisation in place between them, instead of the chunks'
transposing pack and crop and their temporal transforms. The state crosses the seam once
transposing pack and crop and their temporal transforms. On CUDA the stage holds that
scratch as `(y, x, omega)`, the state's own order, so the transform keeps frequency
contiguous and the stage's input and fold stream beside the registers. Every other pass
over the scratch forms its own input in `(omega, y, x)`, and an in-stage absorber keeps
that order for the stage too. The state crosses the seam once
at a load and once at an observation, straight between the memory space and the NumPy
buffer.

Expand Down
36 changes: 35 additions & 1 deletion docs/dev/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,8 @@ An NVIDIA H200 (driver 580.196.07, `nvcc` 13.1, an Intel Xeon Platinum 8592+ hos

The crossings are native's own byte count in `tests/backends/test_native_edge_reading.py`, which ran on both cards, and the point's profile, which lists no crossing. No separate Kokkos trace was taken on these cards. At 51 steps the temporal monitor's sums take most of what the check still costs: on the H200 0.38 s of 0.58 s, and the edge's 18 reads 0.11 s.

**At the head, on an AMD Instinct MI300X** ([#541](https://github.com/LupoLab/solprop/issues/541)). This ran the later commits the MI325X above did not: ROCm 10.0.0, `gfx942`, an Intel Xeon Platinum 8568Y+ host, 20 cores, at `c0bd23f2`, on 2026-11-06. `pytest -m gpu` passed over `tests`, 251 with 1 skipped, and over `native/tests`, 31. The modules of the edge, the collar, the split rows, the transverse backends, the scans, the runner and the stop passed too, 270 with 3 skipped. The same probe at 768 x 768 x 600, 8 steps, 4 planes, takes 2.87 s with the check on and 2.13 s with it off, x1.35. At 384 x 384 x 600, 51 steps, 17 planes, the check costs x1.19. At 768 a step takes 241 ms and an edge read 32 ms. `field_to_host` takes 168 ms, `energy` 6.7, `on_axis_intensity` 14.5, `beam_radius` and `fwhm_r` 48, and `peak_intensity` 78. Every aim holds. These figures are the MI300X's own, not the MI325X's at a later commit. A whole `Local` scan of 5 points through `with_input`, check on, ran two rounds each way, and every point finished. Keeping the backend took 768 x 768 x 600, 8 steps, from 37.4 and 36.2 s to 29.2 and 28.9 s, x0.79, and 384 x 384 x 600, 51 steps, from 27.7 and 27.0 s to 23.7 and 23.7 s, x0.87. With the far field's `clang fp contract(off)` removed, as on #497's base, 31 of the hard-edge fuzz's 120 cases fail (12 of the circle's 40 seeds, 19 of the ellipse's, none of the half-plane's), and so does the older hard-edge test. So the fuzz sees that bug on HIP too.

`python -m benchmarks ab --device` against `main` at `8ed26dd7`, 3 rounds, the same work:

| | H200 | Fields | MI325X | Fields |
Expand Down Expand Up @@ -955,6 +957,19 @@ So a `Local` scan on a device now keeps the backend while each point is the last
| 864 | 6.67 | 26.70 | 48.80 | 2.515 | 0.377 |
| 900 | 7.24 | 14.48 | 38.30 | 2.373 | 0.328 |

**One work area.** A device's plans of the scratch now share one, as cuFFT's guide allows for plans launched one after another, so the table's Plans column is what each size held before. On an NVIDIA A40, CUDA 12.8.1, 8 steps, check off, two interleaved rounds of three runs each, against the commit before:

| N x N x 600 | Plans, GiB | Total, GiB | Point, s |
|---:|---:|---:|---:|
| 384 | 2.64 to 1.32 | 8.04 to 6.73 | 4.84, 4.94 to 4.86, 4.79 |
| 750 | 10.06 to 5.03 | 26.68 to 21.66 | 20.24, 20.19 to 20.28, 20.10 |
| 768 | 21.09 to 5.28 | 38.46 to 22.64 | 21.37, 21.41 to 21.37, 21.46 |
| 900 | 14.48 to 7.24 | 37.80 to 30.56 | 28.74, 28.61 to 28.64, 28.50 |

`python -m benchmarks ab --device --length 0.3`, 3 rounds, the same steps and final fields with no difference: `kerr_beam_384` x0.994 (0.984–1.048), `kerr_beam_192` x1.030 (1.001–1.035, a window of two steps). So a size no longer costs more memory for its rank-2 pair, and 768 x 768 x 600 now holds less than 900 x 900 x 600. The size still sets the seconds per GiB.

rocFFT's plans share it as well. On an AMD Instinct MI300X (ROCm 10.0.0, `gfx942`) at `c0bd23f2`, 8 steps, check off, the plans grow by 1.35, 5.07, 5.76 and 7.28 GiB at 384, 750, 768 and 900 x 900 x 600, and a run holds 7.01, 21.95, 23.37 and 30.85 GiB. Asked of rocFFT directly, in place, Z2Z, a rank-3 plan's work area is one state at every N from 320 to 1200 and every T from 512 to 1024. A rank-2 plan batched over T takes one state at 192 and 384, none at 256 and 512, and 1.10, 1.08 and 1.06 states at 640, 768 and 1024. A rank-1 plan takes none. So at 768 x 768 x 600 four areas of their own would hold 22.0 GiB, as the MI325X's 22.02 GiB at `9a5d2346` did, and the shared one holds the largest of them.

### The transverse edge against 0.1.0

[#453](https://github.com/LupoLab/solprop/issues/453) found the tracking set's `kerr_beam`
Expand Down Expand Up @@ -2435,6 +2450,8 @@ node chunk, and `Transform` needs no field to tell a stated budget from the defa
cards, and cuFFT's work area is small (at 589,824 rows of 600 points each plan holds 9 MiB, in place or not, 0.1 MiB at the node chunk). A CPU keeps the
chunk for its own reason: on an Intel Xeon Gold 6240, nine cores, at 384 x 384 x 600, FFTW's threaded plan of a whole state took 2.5 s a step in transforms against 1.5 s.

**A whole state again.** #361's 10 % is asked of a change that costs default memory, and this one costs none, so the maintainer asked for it back if an interleaved run on an AMD card shows a consistent gain. A device now takes every row at once whatever the node budget, with no seam field: in place, the block's only memory is its plans' work area. On an NVIDIA A40, CUDA 12.8.1, `python -m benchmarks ab --device --length 0.3`, 3 rounds, against the same tree at the node chunk, the same steps and final fields with no difference: `kerr_beam_384` x0.989 (0.958–0.994), `kerr_beam_192` x0.971 (0.951–1.065), and every route without the collar between x0.998 and x1.004. On an AMD Instinct MI300X, ROCm 10.0.0, at `c0bd23f2` against the same tree at the node chunk: a field-free point of 8 steps with the check off, the median of a runner's second and third runs, three interleaved rounds of fresh processes. At 384 x 384 x 600 the rounds give x0.990, x0.988 and x0.990 (0.576 to 0.569 s), and at 768 x 768 x 600 x0.984, x0.983 and x0.986 (2.172 to 2.138 s), with the plans' memory the same. `ab --device --length 0.3`, 3 rounds, gives `kerr_beam_384` x0.952 (0.912–0.999), with the final fields identical. Every round gained, so it stays, though at about 1.5 % of a point it is far from #361's 10 %.

**The fold.** A flow's magnitude on a lossless bin is `exp(+-0)`, exactly one, and took a binary64 `exp` per element: 13.4 ms a pass on the A40, whose reduced binary64 rate
overstates it. Runge-Kutta's `stage_input` and `finish_transform` fall by 13 % the same way. The flowless pass forms no exponent (64.3 to 61.5 ms). The first input crosses the
plane's stride through tiles of team scratch (42.5 to 24.9 ms). On a host the branch is out of line: inlined there, it took the tabulated fold's kernel past GCC's inlining limit,
Expand All @@ -2458,11 +2475,28 @@ against the build before them: `he_rdw_averaged` 0.988 (0.986–1.007), `rdw` 0.

**Scratch-order registers on the volume route**, tried on the A40 and not adopted, take the fold from 407 to 387 ms and the step to 2,538 ms, with the fold's tile staging the state rather than the scratch. A layout change needs its own issue.

**The scratch in the registers' order** ([#365](https://github.com/LupoLab/solprop/issues/365)), on CUDA only. A stage of the volume route views the scratch as `(y, x, omega)`, the state's and the
registers' order, so its rank-3 pair is cuFFT's frequency-fastest `{N,N,T}`, and its input and fold stream instead of crossing. A probe of the two orders on an NVIDIA H200, CUDA 13.1,
T = 600, took `{N,N,T}` 2.49, 11.08, 14.71, 17.62 and 13.81 ms a transform at N = 384, 750, 768, 800 and 900, against 3.74, 14.97, 17.63, 17.97 and 18.96 ms for `{T,N,N}`, and `{N,N,T}`
needs no work area at those sizes but 768. A step, from a field-free point with the check off, (24 steps - 8 steps) / 16, three interleaved rounds against the build before it
(`c0bd23f2` against `8e9b4e76`):

| N x N x 600, NVIDIA H200 | Before, ms | After, ms | Ratio | A run's memory, GiB |
|---:|---:|---:|---:|---:|
| 384 | 50.96–51.17 | 36.22–36.49 | 0.713 | 7.23 → 5.91 |
| 768 | 225.21–225.78 | 203.88–204.13 | 0.905 | 23.14 → 23.14 |

At 768 the transforms account for it: eight of them are 23.4 ms apart in the probe, and the step gains 21.6 ms. `python -m benchmarks ab --device --length 0.3`, 3 rounds:
`kerr_beam_384` x0.971 (0.928–1.003), fields to 3.2e-17. On the NVIDIA A40, CUDA 12.8.1, where the orders are within 1 % at 768, two rounds against `29e9e156`, whose native code is
the same: 2,535 and 2,578 ms a step before, 2,556 and 2,597 after, at 768; 559 and 560 ms before, 513 and 513 after, at 384; `ab --device` geometric mean 0.998, with `kerr_beam_384`
x1.010 (0.997–1.042) and `kerr_beam_192` x0.977 (0.950–1.070). The device tests pass on both cards. With the stage's window read in the old order, nine of them fail across the three
marches, and with the fold reading the old order, three low-storage ones do. HIP keeps the scratch's order until rocFFT's orders are measured.

On a CPU, `python -m benchmarks ab` against the merge base on an Intel Xeon Gold 6240 (nine cores of one socket, bound passive threads, on a machine others shared; three rounds, the same steps): `kerr_beam_192` 0.982 (0.978–0.996) at one thread and 0.974 (0.973–0.987) at nine; `kerr_beam_384` 0.981 (0.981–0.982) at nine, fields to 6.4e-16.
`rdw` under `rk` and `multistep-interaction`, one and nine threads, without the host's fold fix, which they do not reach: 1.011, 0.974, 0.996 and 0.999.
Before the fold's fix, `radial_filament_256` 0.993 and `planar` 0.980 at nine threads, five rounds, took neither path.

A data-centre card has to confirm the step on an H200 and an MI325X, what rocFFT's plans hold, and what the launches are worth.
The H200 has since measured the step in the scratch's order, above. An AMD Instinct MI300X has measured what rocFFT's plans hold and what a whole state's collar is worth. No MI325X has run the head.

## Reference tables

Expand Down
3 changes: 2 additions & 1 deletion docs/guide/performance/tuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ plane's columns in node chunks, each paying a fixed cost for its launches, its t
transforms and its gather and scatter. Their default budget is therefore 1 GiB, against
64 MiB on modal routes; `SimulationSettings.node_budget` sets it explicitly. On a laptop
short of memory a smaller budget saves memory at some speed; on a large device a larger
one can still help.
one can still help. A device takes an envelope's split collar every row at once, whatever
the budget: it transforms the state's own rows in place and holds no buffer for them.

**Where a free-space step goes.** On the native backend the stages of a free-space
evaluation are profiling regions (`solprop_native.free.*`) that any Kokkos Tools timer
Expand Down
5 changes: 3 additions & 2 deletions native/include/solprop_native/far_field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ KOKKOS_INLINE_FUNCTION std::size_t far_field_band_edge(const std::size_t band,
* input (an exact hard-mask contract). A device compiler keeps its own contraction
* default, so a CUDA build spells each operation with a round-to-nearest intrinsic and
* a HIP build, whose intrinsics are no protection, takes the block above. A HIP
* device's square root is the compiler's own, which decided every edge the device tests
* tried; its correct rounding is observed there, not guaranteed by its documentation.
* device's square root is `__builtin_sqrt`, so `llvm.sqrt.f64`, which LLVM defines as a
* conforming IEEE 754 square root, correctly rounded, unless the call carries `afn`;
* AMD's own math documentation promises less (docs/dev/accuracy.md section 7).
*/
SOLPROP_NATIVE_STRICT_FUNCTION
KOKKOS_INLINE_FUNCTION double far_field_radius(const double scale, const double k_x,
Expand Down
Loading
Loading