Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
56101a6
refactor(numpy_ref): workspace, engines and marches that own their state
jtravs Nov 16, 2026
48436c6
test(numpy_ref): the engines' commit contract and the marches' narrow…
jtravs Nov 16, 2026
f2db108
test: port the last tests the broad sweep found on the moved members
jtravs Nov 16, 2026
2a92a17
Merge branch 'sep52-p3a' into feature/sep-0052-backend-shape-p3
jtravs Nov 16, 2026
aa5dedb
Merge branch 'feature/sep-0052-backend-shape-p2' into feature/sep-005…
jtravs Nov 16, 2026
8afa846
refactor(numpy_ref): the session owns the schedule; HostDriver is del…
jtravs Nov 16, 2026
ef64e82
Merge branch 'feature/sep-0052-backend-shape-p2' into feature/sep-005…
jtravs Nov 16, 2026
2ba9603
test: port the reference's tests to its session, workspace and engines
jtravs Nov 16, 2026
090c6ae
docs: the reference's session owns the schedule
jtravs Nov 16, 2026
19e1059
docs(backends): mend cross-references the restructure split or left s…
jtravs Nov 16, 2026
8564397
test: port the tests the broad sweep found on the session's structure
jtravs Nov 16, 2026
e3b157b
Merge branch 'sep52-p3b' into feature/sep-0052-backend-shape-p3
jtravs Nov 16, 2026
8c3f93e
docs(sep-0052): report milestone 3 (the reference restructured) [skip…
jtravs Nov 16, 2026
2b8cd6d
docs(sep-0052): link milestone 3's pull request
jtravs Nov 16, 2026
95bcb16
fix(sep-0052): the last step-driver imports, and yield-proof session …
jtravs Nov 16, 2026
9dab470
test: narrow the launch field before its use, for the type check [ski…
jtravs Nov 16, 2026
21bab7a
test(sep-0052): cover the reference's refusals; delete what the sessi…
jtravs Nov 16, 2026
6eb0de3
docs: the quadrature score names no deleted attribute
jtravs Nov 16, 2026
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
31 changes: 16 additions & 15 deletions benchmarks/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
if TYPE_CHECKING:
import numpy as np

from solprop.backends.protocol import Backend, HostStepping
from solprop.backends.protocol import Backend
from solprop.driver import Simulation
from solprop.monitor import BoundaryMonitor
from solprop.output.store import FieldRetention, Output
Expand Down Expand Up @@ -202,8 +202,8 @@ class _Loaded:
loaded, before the output opens and the launch plane is saved. Within the block
the backend's load is wrapped to read the clock and the counter as it returns; it
is restored on exit. The load is the native backend's own ``_load`` where it has
one (SEP 47 phase 5), else ``set_initial``, the reference's and an earlier
native build's.
one (SEP 47 phase 5), else the reference's workspace's ``load``, which its session
calls (SEP 52), else ``set_initial``, an earlier build's.

Attributes
----------
Expand All @@ -215,28 +215,29 @@ class _Loaded:

def __init__(self, engine: Backend) -> None:
self._engine = engine
self._name = (
"_load"
if callable(getattr(type(engine), "_load", None))
else ("set_initial")
)
workspace = getattr(engine, "workspace", None)
self._owner: object = engine
if callable(getattr(type(engine), "_load", None)):
self._name = "_load"
elif callable(getattr(type(workspace), "load", None)):
self._owner, self._name = workspace, "load"
else:
self._name = "set_initial"
self.ended = 0
self.calls: int | None = None

def _load(self, *args: object, **keywords: object) -> object:
loaded = getattr(type(self._engine), self._name)(
self._engine, *args, **keywords
)
loaded = getattr(type(self._owner), self._name)(self._owner, *args, **keywords)
self.calls = source_calls(self._engine)
self.ended = time.perf_counter_ns()
return loaded

def __enter__(self) -> _Loaded:
setattr(self._engine, self._name, self._load)
setattr(self._owner, self._name, self._load)
return self

def __exit__(self, kind: type[BaseException] | None, *rest: object) -> None:
delattr(self._engine, self._name)
delattr(self._owner, self._name)
if kind is None and not self.ended:
msg = "the run never loaded its backend, so nothing was timed"
raise SuiteError(msg)
Expand Down Expand Up @@ -298,7 +299,7 @@ def timed_run(
if Start is None:
# A build from before SEP 47's sessions: run_problem takes a loaded backend,
# so the load comes first and the window starts after it, as it did then.
cast("HostStepping", engine).set_initial(
cast("Any", engine).set_initial(
problem.initial.field0, None, z=problem.initial.z
)
before = source_calls(engine)
Expand Down Expand Up @@ -542,7 +543,7 @@ def warm_up(engine: Backend, problem: PropagationProblem, until: float) -> None:
if Start is None:
# Before SEP 47: load, march and observe the backend directly, through the
# stepping seam every backend had then.
stepped = cast("HostStepping", engine)
stepped = cast("Any", engine)
stepped.set_initial(problem.initial.field0, None, z=problem.initial.z)
if until > problem.initial.z:
stepped.propagate_to(until)
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ $f_{\max} = 1.1$, and a lag of one step by default.
{py:func}`solprop.stepper.controller.limit_step`;
{py:func}`solprop.stepper.schedule.landing` with
{py:class}`solprop.stepper.schedule.StepTargets`. The loop is the reference's
`backends/host/driver.py`; the native session's compiled march performs the same steps.
`backends/host/runge_kutta.py`; the native session's compiled march performs the same steps.

**Why a global magnitude.** Per-element scaling is catastrophic here: the in-band dynamic
range of a hollow-fibre spectrum reaches $10^{17}$ and about a third of in-band bins carry
Expand Down
12 changes: 7 additions & 5 deletions docs/dev/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,10 @@ class Backend(Protocol):
def memory_ledger(self) -> dict[str, int]: ...
def close(self) -> None: ...

# The reference's host stepping seam (set_initial, propagate_to, observe, stats, the
# monitor and the march's snapshot) is a protocol of its own, HostStepping, which
# its session drives (backends.md section 1).
# Nothing else: a run is its session's on both backends (SEP 52). Behind the
# protocol each backend has a lowering, a workspace, engines, marches and a
# session; the reference's session (HostSession) is the Python counterpart of
# native's session.cpp (backends.md section 1).
```

- `numpy_ref`: the readable oracle. Plain NumPy + `scipy.fft`, no fusion, no in-place
Expand Down Expand Up @@ -736,7 +737,7 @@ otherwise, with a warning, `numpy_ref` (ADR-029, ADR-064); the installed native
[SEP 22](seps/archive/sep-0022-memory-lean-spatial-execution.md)): a plane without its field is not copied, converted or
stored, the stores allocate field storage for the kept planes only, and the admission
charges those alone (its `output` group). The backend is asked for the field only on
the kept planes: `HostDriver.observe(field=False)` transfers nothing from a device,
the kept planes: a field-free observation transfers nothing from a device,
scans nothing for finiteness, skips the collar diagnostic (counted in the execution
record) and forms no noise-phase volume, so a field-free plane costs its statistics
alone. Under the low-storage march a step abandoned in flight after such a plane leaves
Expand All @@ -745,7 +746,8 @@ otherwise, with a warning, `numpy_ref` (ADR-029, ADR-064); the installed native
frequency, at most a node chunk's worth of samples at a time, never the whole volume.
- A `SimulationRunner` keeps one backend's buffers and plans across many inputs, and is
admitted once; each session's load restores everything a march reads (the native
backend's `_load`, the reference's `HostDriver.set_initial`), so a reused backend
backend's `_load`; the reference's session builds its march afresh and loads its
workspace), so a reused backend
repeats a fresh one's run. An input array of more than 2²⁰ elements is
recorded by its SHA-256 digest, not inline, so the run record stays small; the runner
reads such an array in place and marches on a problem without it, so no input outlives
Expand Down
Loading
Loading