GP execution and component ownership

Status: partially implemented. The MPI ownership types (MpiCommunicator, BackendContext, DistributedState), the covariance ownership states and the bounded derivative storage are implemented and have regression tests, described in the Integration evidence section. The device execution contract is design intent. The cuSOLVER and CUTLASS paths still use a static solver handle, a fixed device index 0 (gpr/linalg/CusolverEigh.cpp) and device-wide synchronization. Native integration of the search controllers and potential entry points is not complete.

This page lists the contracts that connect molecular GP composition, numerical resources, optimizers and measured potentials.

Component boundaries

The GP model composes a covariance, a mean prior, observations, and a likelihood. Conditioning produces a posterior that owns its numerical factor and coefficients. Fit trials belong to the fitting operation; publication of a usable posterior follows successful conditioning.

Component

Owns

Borrows or shares

Kernel expression

Kernel parameters and component expression

Geometry and requested derivative channels

Mean prior

Prior parameters

Geometry and species

Observation store

Measured energies, forces, and identities

readcon/readcon-db interfaces

Conditioned posterior

Factor, coefficients, and model support

Immutable kernel/prior definition and execution resources

Fitting operation

Trial parameters and failure state

Training observations and rgmin solver

Search controller

Band/dimer state and acceptance policy

GP posterior, rgsaddle, and measured potential

Measured potential

Provider instance and physical-call accounting

rgpot/eOn and its execution resources

Execution resources

Communicator and device resource lifetimes

Caller-selected process group and device policy

Numerical factors belong to individual posteriors. Sharing execution resources does not give one posterior access to another posterior’s factor. Kernel, prior, and solver selection do not determine the process group or silently replace the selected device.

MPI lifetime and collective participation

MpiCommunicator duplicates an active intracommunicator and owns the duplicate. Construction is collective. Components share its lifetime through shared_ptr<const MpiCommunicator>; MpiContext supplies a borrowed rank, size, and native communicator view. Owners must be destroyed before MPI_Finalize. The resource neither initializes nor finalizes MPI. Native entry points use MpiLifetime for runtime ownership.

The required thread level depends on the compiled backend. ScaLAPACK uses MPI_THREAD_FUNNELED; SLATE uses MPI_THREAD_MULTIPLE because its OpenMP tasks may communicate concurrently. Both MpiLifetime and the library-owned DistributedState runtime request that level. A caller that initializes MPI must provide at least the same level. The library rejects an insufficient borrowed runtime without finalizing it. The SLATE matrix example requests the same thread level.

The test_mpi_thread_support executable exercises each initializer in a separate process, including an insufficient borrowed runtime. Its Meson cases run on one and four ranks and check that rejected borrowed runtimes remain owned by their caller.

SLATE kernels establish a single OpenBLAS thread at each entry because BLAS thread settings are mutable process state. The thread increase used for ScaLAPACK solves does not surround SLATE task kernels. This keeps a sequence of dense operations from multiplying SLATE’s task workers by an independent BLAS worker team. The backend regression changes the BLAS thread count between factorization, forward solve, and backward solve, then checks the restored thread budget and the linear-system residual.

DistributedState accepts shared communication and owns its BLACS grids. Each grid instance has a private BLACS system communicator so releasing an interned system handle cannot release a sibling’s handle. All three BLACS layouts are released on reconfiguration and destruction.

ScalapackPDPotrfInverse owns its factor and retains its process grid. A grid generation identifies the layout on which the factor was built; solves reject a factor whose grid has been replaced. SLATE factorization and solve adapters accept that same explicit state. ProbeExecutor uses the supplied communicator and distinguishes rank-local work from operations that require collective participation.

Collectives on a shared communicator require the same ordering on every participating rank. An optimizer objective may invoke collective GP conditioning; every participant must enter the same trial. An oracle that internally uses collective MPI cannot be invoked by one selected image owner without a separate, correctly sized process group. Potential adapters therefore need an explicit participation contract, as numerical inverse operators already expose through KernelInverse::Kind.

Covariance assembly returns an explicit Complete or Disjoint ownership state. A complete dense result is replicated and requires no sum across ranks. Disjoint contributions require exactly one reduction before adding the diagonal observation noise. Summing complete replicas multiplies the kernel by the communicator size and changes the statistical model. Distributed factorization assigns geometry tiles before invoking the joint operator; the operator completes the requested tile without changing its process ownership.

Device execution contract

A device resource identifies a device and an execution stream and owns or explicitly borrows the associated handles. Buffers retain their device and allocator ownership. An asynchronous operation retains its inputs, outputs, and resource until completion. A synchronous adapter waits on its own operation before returning host-visible results. Process-wide device switches and synchronization do not satisfy this contract when GP kernels and potential providers share a process.

The existing cuSOLVER and CUTLASS interfaces require integration with this contract. Static solver handles, pooled scratch storage, forced device zero, and device-wide synchronization are present in those paths. The MPI ownership implementation does not establish GPU resource isolation or overlap of communication and device work.

Kernel composition contract

The joint observation layout is [E; G_col0; ...; G_colD-1]. Scalar kernel composition determines the energy covariance; differentiating that composition determines all energy-gradient and gradient-gradient blocks. Multiplying complete joint covariance matrices entrywise does not implement the derivative blocks of a scalar kernel product.

Heat compositions assemble full energy-gradient records through the same joint operator for training and cross covariance. The observation adapter restores channel-major or geometry-major row order after assembly. Heat features and Jacobians are evaluated together for each geometry set rather than separately for every Cartesian channel pair. Partial uncharted records use the scalar block interface with the same component parameters.

The runtime operator interface contains Sum, Pullback, Project, Kronecker, and molecular primitives. Arbitrary kernel division is not a positive-semidefiniteness-preserving operation. A quotient requires an explicit admissible construction and domain contract. New algebraic operators require symbolic derivative checks and numerical joint-kernel tests before use in fitting or molecular searches.

Integration evidence

The optimizer component contract is documented in GP optimizer boundary contracts. MPI regressions use split process groups with different data and work counts, free the caller’s original communicator, interleave factors on different layouts, and invalidate one grid while continuing to solve with the other. Numerical solves, matrix solves, log determinants, and trace actions are compared with dense references.

BackendContext owns each GP numerical workspace. Main conditioning, Cholesky updates, posterior predictions, RFF, stable bases, Laplace and SVGD propagate its process group through their numerical operations. The default constructor retains compatibility with a caller that starts MPI on the world group; an explicit shared MpiCommunicator selects an independent group. The distributed objective adapter uses the model’s borrowed communicator view without owning or configuring a process grid.

Search controllers and potential entry points require propagation of the caller’s selected resources. CUDA factor storage also requires ownership by the posterior. Component regressions compare complete GP posteriors on split groups with independent serial references; native integration validation remains in progress. These tests do not establish molecular convergence, device execution, or strong scaling.

Design basis

Reddy, API Design for C++, second edition (2024), pp. 60-68, 83-92, and 173-177, supplies the ownership, dependency, private implementation, and exception-contract principles. Lakos, Large-Scale C++: Process and Architecture (2020), sections 1.6 and 2.6, supplies the physical component and interface rules.

MPI ownership follows MPI_Comm_dup and MPI_Comm_free. The BLACS conversion types and system-handle lifetime follow Csys2blacs_handle, Cblacs2sys_handle, and Cfree_blacs_system_handle.

Dense covariance and bounded derivative storage

For A anchor geometries, Q query geometries, and d Cartesian coordinates, write the joint covariance in anchor/query order as

K = [ Kaa  Kaq ],  H = Kaa + anchor_noise,  W = H^(-1) Kaq,
    [ Kqa  Kqq ]
S = Kqq - Kqa W,   B = [ -W ; I ].

If Z is the symmetric likelihood weight on S, then dS = B^T dK B and the Frobenius adjoint is B Z B^T. A row selector R satisfies R (B Z B^T) = (R B) Z B^T. The fit evaluates this product for 16 geometry rows at a time, retaining every energy and Cartesian-gradient channel in a batch. Kernel entries are contracted directly with these rows; no full covariance derivative or full joint adjoint is needed. The factor and the borrowed fixed covariance retain their existing ownership. Prepared contractions evaluate the chart coordinates and Jacobians once, then borrow the requested geometry rows for every parameter and batch.

The joint order is (A + Q) (d + 1). A dense joint matrix needs eight bytes times the square of that order in double precision; the batched adjoint needs at most 16 (d + 1) rows of that matrix. The implementation also retains the anchor/query solve weights and the query likelihood weight. These are storage bounds, not measurements of total resident memory.

Metatensor uses labeled sparse blocks with dense arrays inside each block. Its gradient representation can omit structurally zero sample/atom derivatives. Those missing entries differ from the generally nonzero correlations between observations of a Gaussian-process energy surface. The exact fit keeps these correlations and partitions their computation. It does not impose a distance cutoff, discard small covariance entries, or change the observation noise.

The SOAP decoder uses metatensor’s labeled gradient samples to allocate only the movable Cartesian rows. Frozen atoms retain their descriptor values and their contribution to the energy kernel. For N environments, M movable atoms and F descriptor features, the decoded Jacobians occupy N (3M) F doubles instead of N (3N) F doubles plus a selected-row copy. This does not change the dense block storage within featomic or the exact GP covariance.

Geometry pairs in each contraction are divided over the supplied MPI group; local workers own independent scalar sums. Failure status is shared before the scalar result is reduced. Conditioning continues to use the selected ScaLAPACK or SLATE factor and solve operations. Energy/force units and the physical force stopping criterion are independent of this storage layout.

scripts/derive_conditional_cholesky.py checks the Schur derivative and its row-partitioned contraction with SymPy. The adjoint_rows theorem in proofs/lean/GPRidge/ObservationEquilibration.lean proves the row selection identity for arbitrary finite matrix dimensions. Numerical regressions compare bounded blocks and contracted chart derivatives with dense channel formulas.