solprop.backends.mlx_gpu.adams#

The exponential Adams history on the Metal device, for the mlx backend.

MlxAdams is an AdamsEngine: the march (AdamsMarch) keeps the controller – the orders, the slots, rejection, restarts – and this engine keeps the history’s untransported source rows on the device and forms each trial there, as HostHistory forms it on the host. The step’s flow exp(x) and its moments k! phi_{k+1}(x) are evaluated on the host in binary64 and rounded once to binary32, as the single-precision oracle rounds them; the predictor, the corrector and the defects are compiled device passes over the rows, with their Lagrange coefficients as inputs; and a trial reads its norms, the anchor’s magnitude, the trial state’s finiteness and the envelope plasma’s failures in one synchronisation. One source evaluation per trial.

It takes the exponential formulation, with or without a carrier frame. A varying operator (a gradient, a taper) adds the transported compensation of SEP 16 section 4.2: each history sample keeps its state on the device and its rate D(z_j) on the host, the state-independent factor exp((1 - theta_j) x) (D(z_j) - x / h) is formed in binary64 and rounded once, and the products with the states and the integrated Adams weights are device passes. The backend refuses the untransported witness by name.

Classes

MlxAdams(backend, method)

The exponential Adams history and its arithmetic, on the Metal device.

class solprop.backends.mlx_gpu.adams.MlxAdams(backend, method)[source]#

Bases: object

The exponential Adams history and its arithmetic, on the Metal device.

Parameters:
backendsolprop.backends.mlx_gpu.backend.MlxBackend

The backend whose state, sources, controller and synchronisation are used.

methodsolprop.stepper.multistep.Multistep

The method, in the exponential formulation.

Attributes:
denseNone

No dense observation: interpolate_planes is refused on mlx.

compensatedbool

Whether a varying operator’s samples carry the transported compensation.

carriersolprop.backends.exponential.CarrierReference or None

The carrier frame the trials remove (SEP 35), as the host engine’s.

dense: Any = None#
exponential_accept(keep, free, *, interpolate)[source]#

Adopt the held trial; its source takes row free.

Parameters:
keepnumpy.ndarray

The rows kept; nothing moves in this formulation.

freeint

The row the new sample takes.

interpolatebool

Must be false: dense observation is refused on mlx.

exponential_trial(z, dz, nodes, slots, order, orders)[source]#

Form one exponential trial on the device and return its defects’ norms.

HostHistory.exponential_trial’s arithmetic over device rows, read in one synchronisation.

Parameters:
z, dzfloat

The anchor and the step, m.

nodeslist of float

The history’s normalised positions, newest first.

slotsnumpy.ndarray

Their rows, int64.

orderint

The step’s order.

orderslist of int

The orders scored, the step’s own first.

Returns:
numpy.ndarray

One scaled norm per scored order; infinite when the trial is not finite.

fused_accept(keep, free, *, interpolate)[source]#

Refuse the interaction formulation, which this engine does not run.

Parameters:
keepnumpy.ndarray

The rows kept.

freeint

The free row.

interpolatebool

Whether the interpolant is kept.

Raises:
BackendError

Always.

fused_trial(*args, **kwargs)[source]#

Refuse the interaction formulation, which this engine does not run.

Parameters:
*args, **kwargsobject

The march’s trial arguments.

Raises:
BackendError

Always.

hold()[source]#

Return the accepted state, the device array itself.

Returns:
object

The state.

load_rows(rows, shape)[source]#

Install rows a snapshot holds, narrowed to complex64 on the device.

Parameters:
rowscollections.abc.Mapping

The rows, by name.

shapetuple of int

The state’s shape.

Raises:
BackendError

If the rows are not a store of this history’s shape, or hold any other name (a compensated or coupled history’s).

property n_slots: int[source]#

The history’s rows: the method’s order and two more.

Returns:
int

order + 2.

observe(position)[source]#

Refuse dense observation, which mlx does not run.

Parameters:
positionfloat

The plane, m.

Raises:
BackendError

Always.

reset()[source]#

Forget any trial in flight.

restore(z, held)[source]#

Make a held state current again at z.

Parameters:
zfloat

Its position, m.

heldobject

What hold() returned.

snapshot_nbytes()[source]#

Return the bytes snapshot_rows() would copy.

Returns:
int

The rows’ size, complex64.

snapshot_rows()[source]#

Return host copies of the history’s rows, in complex64.

Returns:
dict

"store": one row per slot, zero where the history has none yet.

start(z, *, stored)[source]#

Evaluate the source at the accepted state into row zero.

Parameters:
zfloat

The accepted position, m.

storedbool

Must be true: the general path runs on the host and is refused.

Raises:
BackendError

For an unstored sample, which only the general path asks for.

value(slot)[source]#

Return nothing: the history’s rows stay on the device.

Parameters:
slotint

The row.