SLATE as a linear-algebra backend

Status: requirements for the swappable linear-algebra backend interface. SLATE is currently selected at compile time and runs inside the ScaLAPACK path. This page states what an interface has to carry for SLATE to become one of its backends, measured against develop e694a016b.

Where SLATE sits today

-Dlinalg_backend=slate defines both GPR_LINALG_SLATE and GPR_LINALG_SCALAPACK. SlateBackend.h only includes ScalapackBackend.h. There is no SLATE data path. SLATE shares everything the ScaLAPACK backend owns:

  • DistributedState: the BLACS grid, the block-cyclic descriptors, scatter and gather, the cached distributed factor and its inverse.

  • The collectives that keep ranks bitwise in step: ordered_sum_bcast, exact_sum_bcast and disjoint_sum_bcast.

  • About 25 distributed-only BackendContext methods that take descriptor buffers (cholesky_distributed, forward_solve_mat_bilinear_distributed, factor_inverse_lower, trace_lower_symmetric_local, the distributed SVD and eigensolvers, among others).

The GP core calls these directly. distributed() has 55 call sites in 13 files under gpr/ml, and GPR_LINALG_SCALAPACK guards about 200 preprocessor blocks (EnergyGradient.cpp 31, GaussianProcessRegression.inl 27, Decompose.cpp 15, CovarianceAssembly.cpp 15, Predict.cpp 13).

SLATE differs from ScaLAPACK in one place only: the kernel that runs on a block-cyclic buffer.

--linalg-mode

ScaLAPACK build

SLATE build

reproducible

canonical tile kernels (canonical::)

canonical tile kernels, unchanged

library

pdpotrf, pdtrsm, pdpotri, pdsyevd

slate::potrf, trsm, potri, heev

In reproducible mode a SLATE build does not call SLATE at all. In library mode it calls the six entry points in SlateKernels.h (potrf_lower, potri_lower, trsm_left_lower, heev_lower, rank_block_cholesky_append_lower, gram_lower) on views made from the ScaLAPACK descriptors.

What the interface has to carry

SLATE fits as a distributed kernel provider behind a shared layout. That is three layers, and the interface needs a seam between each pair.

  1. Local dense backend on EigenMatrix: Eigen/LAPACK (default), Kokkos (CUDA, HIP/ROCm), cuSOLVER, stdpar, CHOLMOD. These are the nine functions in Backend.h.

  2. Distributed layout and collectives: process group, grid, descriptors, scatter and gather, cached factor, ordered, exact and disjoint reductions. One implementation, DistributedState over MPI and BLACS. It owns the reproducibility contract: the same bits on every rank.

  3. Distributed kernel provider on the layout: ScaLAPACK, SLATE (host, or HIP and CUDA devices through Target::Devices), and the canonical reproducible kernels. Factor, append, triangular solve, inverse, symmetric eigensolver and Gram.

Requirements on the interface:

  • Runtime provider choice inside one distributed build. ScaLAPACK and SLATE use the same layout, so selecting between them, and the canonical kernels, should be a run-time choice. It is the same choice --linalg-mode already makes between canonical and library.

  • Distributed operations as first-class members, not ``#ifdef`` overloads. The descriptor-taking calls and the three reductions have to be reachable through the interface. Otherwise every caller in gpr/ml keeps its GPR_LINALG_SCALAPACK block. A local backend answers them trivially: one rank, no-op reductions, a 1 x 1 grid.

  • Collective ordering is part of the contract. Every rank must make the same sequence of provider calls. A provider may not take a local shortcut on one rank, for example a cache hit that skips a collective.

  • Declared arithmetic class. Each provider states whether its results are invariant under the grid shape, and whether they equal the serial Eigen bits. Today only the canonical kernels are grid-invariant, and no distributed provider equals Eigen. A gate that compares trajectories needs to know which comparison applies.

  • Thread budget per provider. SLATE’s OpenMP task budget (slate_kernels::task_thread_budget, configure_nested_blas_threading) and the team threads for local factors (--linalg-threads, TilePool) must not oversubscribe each other. The interface should hand each provider its budget.

  • Wall accounting. KernelWall scopes already cover the canonical, SLATE and ScaLAPACK factor and solve kernels. A provider behind the interface keeps them, so the GP kernel times line does not depend on the backend.

  • Shape from N and the rank count. The tile size and the grid come from the problem order and the process count, not from per-system constants. A near-square grid with p <= q and a 64-wide tile was optimal or within a few percent of it for N in {1000, 2000, 4000} and 1 to 8 ranks on an 8-core Emerald Rapids host. The reproducible kernels fix their tile order, so changing the tile with N would break grid invariance without a measured gain.

Device residency

The Kokkos backend factors on the device through cuSOLVER or rocSOLVER (KokkosFactor.h), but it still copies Eigen buffers to the device and back for every call. The distributed factor is cached in host buffers (DistributedState::cache_L holds a std::vector<double>), so a SLATE build with --gpu-backend hip or cuda would also stage through host memory between calls. A GPU-resident interface would let the layout layer own device tiles, so SLATE and Kokkos on ROCm could share residency rather than each staging through host memory.

Measured behaviour

  • With --linalg-threads 8 on the Eigen backend, 01_hcn, 16_oxirane and 11_grignard reproduce serial bit for bit (TeamKernelThreadsTest guards this).

  • SLATE in either mode does not reproduce the serial Eigen trajectory. Every cell still converges and certifies, but on 11_grignard the certified barrier is 1.741 eV in reproducible mode against 1.610 eV serial. That record is TheochemUI/gpridge#214, closed unmerged.

  • Reproducible mode is invariant from 1 to 8 ranks. Library mode is not.