Repository navigation
Description
What happens
Group construction is not transactional with respect to the caller's entrance states and backend owners:
- The reference/transitional
DriverGroupSessioncallsStart.take_field()beforeselect_batchchecks schedule, tableau and other compatibility. A group refused for differing schedules has already consumed every entrance field. NativeGroupSessionconstructs owning child sessions in order. If a later child cannot start, cleanup closes earlier backend owners and leaves their original entrances consumed, although no group was returned.- Duplicate
Startor backend-owner objects are not refused structurally before loading (read, not independently propagated).
This predates SEP 48's generic execution-owner dispatch. The new ownership interface makes the existing failure behavior explicit.
Why it matters
A caller cannot safely retry construction after correcting an incompatible member: earlier inputs or owners have been taken or closed. Reusing one mutable backend for multiple group members can also alias their numerical state. Admission should preserve caller-owned starts and owners until the complete group has been constructed.
Reproduction
Reproduced on 2026-11-10, macOS arm64, Python 3.14.5, NumPy reference and native CPU at one thread. Constructor and common-admission source checked at d1feaa15. The native extension is the CPU build from 83da0ad5; no native numerical kernel is changed by this reproduction.
From that checkout, with SOLPROP_THREADS=1 SOLPROP_CALIBRATION=off, run:
import sys
from contextlib import ExitStack
sys.path.insert(0, "tests")
from sessions.test_group import PLANES, STEP, constructed, member
from solprop.backends.driver_session import DriverGroupSession
from solprop.backends.session import Start
from solprop.stepper.schedule import FixedSchedule
from solprop_native.group import NativeGroupSession
for backend in ("numpy_ref", "native"):
options = {} if backend == "native" else {
"schedule": FixedSchedule.uniform(
0.0, PLANES[-1], STEP / 2, save_planes=PLANES
)
}
simulations = [member(0, backend), member(1, backend, **options)]
problems = [simulation.translate() for simulation in simulations]
requests = [simulation._run_request() for simulation in simulations]
starts = [Start.entrance(problem) for problem in problems]
if backend == "native":
starts[1].take_field()
with ExitStack() as cleanup:
owners = [constructed(simulation, cleanup) for simulation in simulations]
constructor = (
DriverGroupSession if backend == "numpy_ref" else NativeGroupSession
)
try:
constructor(owners, problems, requests, starts)
except Exception as error:
print(backend, type(error).__name__, str(error))
print("fields_preserved", [start.field is not None for start in starts])
print("owners_open", [not owner.closed for owner in owners])Observed:
numpy_ref BackendError lockstep members require the same schedule and save planes
fields_preserved [False, False]
owners_open [True, True]
native SessionError this start was already used: a start is handed to one session
fields_preserved [False, False]
owners_open [False, True]
For reference, both fields should remain available. For native, the first field should remain available, the deliberately used second field should remain absent, and both owners should remain open.
Context
- Reference/transitional construction.
- Native construction and partial-failure cleanup.
- SEP 47 ownership work: SEP 47: Backend-owned execution sessions #588 and SEP 47 milestone 2: the native execution session (phase 3) #607.
- SEP 48 generic execution-owner integration: SEP 48: A Julia backend #608 and WIP: SEP 48 — Julia execution backend #611. The focused correction will be included in WIP: SEP 48 — Julia execution backend #611; it changes construction/lifetime handling, not propagation arithmetic.
To do
- Refuse reused/duplicate Start objects and duplicate mutable backend owners before loading.
- Let transitional construction borrow the entrance arrays, consuming originals only after the runner and group are fully constructed.
- Construct native child sessions without prematurely adopting caller owners; preserve original starts on failure, release partially constructed children, and transfer ownership only after whole-group success.
- Ensure successful group close attempts cleanup of every child and owner, even if one cleanup raises.
- Add schedule-refusal, aliasing, second-child failure and successful close regressions for the common and direct factory paths.
Done when
The two reproduced refusals preserve the caller's remaining fields and all owners; injected later-construction failures do likewise; invalid aliases are refused before consumption; a successfully constructed group consumes each entrance once and closes each owned resource. Existing short group conformance tests continue to pass on NumPy and native CPU.
Activity
jtravs commentedon Nov 13, 2026
Picked up by the issue-fixing session (branch
fix/group-construction-623).Make group construction transactional for starts and backends