Run a search across MPI ranks

A gprn or gprd search spends its time in the oracle calls and in the dense linear algebra of the Gaussian process (GP), and which one dominates depends on the oracle. Under an MPI launcher the ranks share both. This page builds a distributed gprn, launches a band search on several ranks, and sets the flags that choose the factorization and the thread layout. It assumes the commands of the pentamer tutorial. For a job on a cluster allocation, continue with Run on an HPC cluster.

What the ranks share

  • Oracle points. The band images, stencil displacements and probes that one step needs form a batch. Each point belongs to one rank, chosen from the point index and the rank count alone, and that rank evaluates it. Afterwards every rank holds the owner’s values bit for bit (gpr/potentials/OracleBatch.h). The call counters are summed over the ranks (reduceOracleProviderCalls in gpr/neb/OCINEBController.cpp), so the Oracle calls: line counts each evaluation once.

  • Dense GP linear algebra. The distributed backend factors the training matrix and solves with it across the ranks.

  • Everything else. Every rank runs the same driver on the same inputs. Rank 0 prints the log and writes the --output file, the --write-con band and the observation archive; the other ranks write none of them.

A step with fewer points than ranks leaves some ranks without oracle work. In the pentamer tutorial run, ten outer iterations used 15 oracle calls, so most GP-accelerated steps carry one or two points and extra ranks do not shorten them. Wide batches come from the validation stencil (--oracle-stencil) and from --nebmode standard, which evaluates every movable image of the band as one batch at each step.

The recorded strong-scaling measurement of a complete GP fit (paper/jcim/records/fit-scaling/strong.csv, cell 11_grignard, 48 observations, 5376 matrix rows, 47 objective evaluations, --linalg-mode reproducible) shows the trend: the median time falls from 197.1 s on 1 core to 18.8 s on 48 cores of one node and 12.9 s on 96 cores of two nodes, while the parallel efficiency falls to 0.22 and 0.16. Each layout has 3 repetitions, which the manuscript says supports no timing claim, so read the numbers as a trend and measure your own system. A small system with a cheap oracle, such as the pentamer, gains little from ranks. The performance guide discusses where the time goes, and Find where a search spends its time shows how to measure it on your own run.

Build an MPI-enabled binary

The default Eigen backend has no MPI. -Dlinalg_backend=scalapack or -Dlinalg_backend=slate links MPI and the distributed code, and -Duse_mpi=true with any other backend stops Meson with an error. The scalapack pixi environment (Linux) provides the MPI library and ScaLAPACK:

pixi run -e scalapack smoke-gprn-lj

The task builds gprn with the ScaLAPACK backend and without the optional external oracles into bld-gprn/ (set GPR_GPRN_BUILD_DIR to change the directory), then runs a one-iteration Lennard-Jones check on a hydrogen molecule on a single rank (scripts/setup_gprn_external.sh). Use it first. The other routes build more:

  • pixi run -e scalapack build-scalapack-real builds gprd and gprn into build-scalapack-real/ against conda ScaLAPACK. It also builds the metatomic oracle, so the environment must supply libtorch.

  • pixi run -e scalapack build-slate builds gprd and gprn against SLATE into build-slate-real/. The task first builds a tagged SLATE release into ~/.cache/gpridge/slate/prefix-<tag> (task build-slate-prefix).

  • Spack with the mpi variant (Installation) and the EasyBuild recipes with --backend scalapack (EasyBuild guide) build the same backends outside pixi.

Check that a binary links MPI before launching it:

ldd bld-gprn/gprn | grep -i libmpi

No line means a non-MPI build. Such a binary ignores the launcher: mpirun -np 4 gprn starts four independent copies, and each one prints the log and writes the output files.

The MPI tests of the repository are the Meson tests whose names end in _np<N> (_np4 runs mpiexec -np 4 --oversubscribe). List and run a few after configuring with -Dwith_tests=true (the smoke task sets it):

meson test -C bld-gprn --list | grep _np
meson test -C bld-gprn test_gprn_shutdown_np4 test_oracle_batch_np4 \
    test_mpi_thread_support_native_np4

test_gprn_shutdown_np4 starts a four-rank gprn band search and checks that the exit handlers run on every rank (tests/gpr/native_shutdown.py). test_oracle_batch_np4 tests the sharing of oracle points. test_mpi_thread_support_native_np4 checks the thread level that the MPI library provides. meson test rebuilds every target first, which takes longer than the smoke task.

Copy the inputs

Use the supplied endpoints from the pentamer tutorial.

examples="$GPRIDGE_ROOT/examples/lj-pentamer"
cp "$examples/reactant.con" "$examples/product.con" .
test -s reactant.con -a -s product.con

Choose the factorization, threads and batching

Flag

Default

Effect

--linalg-mode MODE

reproducible

reproducible factors, solves and inverts with the tile-ordered kernels of this repository, designed to give the same bits at every rank and thread count. Each rank then computes the HS-SVD kernel eigensolve and its basis product whole, with Eigen’s self-adjoint solver. library calls the ScaLAPACK or SLATE routines. The host eigensolve stays on that same solver. Across ranks, ScaLAPACK pdsyev runs from order 1 when unconstrained reductions are enabled, and the basis product is distributed from order 512. Library rounding follows the process grid and the BLAS.

--linalg-threads N

1

Threads per rank. Eigen and BLAS products stay on one thread in both modes. The count sets the thread team of the kernel and Hessian assembly in a build with parallel STL, and under reproducible it also runs independent tiles of the factorization and the solves in parallel.

--kernel-threads N

1

Independent kernel-block threads per rank. Needs a build with parallel STL (TBB, the use_stdpar option) and --linalg-threads 1.

--oracle-batch-chunk K

0

With 0, each rank evaluates all the points it owns in one call. With K, a step is cut into contiguous chunks of K points, and a chunk is the unit of ownership and of the batch call. Set K to the batch size that an engine was traced at when its batched forward depends on the batch composition.

--scalapack-block-size N

0

ScaLAPACK block size. 0 uses the backend default.

--scalapack-nprow N

0

Rows of the ScaLAPACK process grid. 0 uses the backend default.

The TOML equivalents are [linalg] mode and threads, and [gp] scalapack_block_size and scalapack_nprow (--config needs a build with -Duse_capnp=true). --kernel-threads and --oracle-batch-chunk have no TOML key. The gprn flag reference and the configuration keys list the rest.

The OpenMP build option does not combine with the distributed backends: Meson stops on -Duse_openmp=true with scalapack or slate, because threads on top of ranks oversubscribe the host. Threads inside a rank come from the two flags above. gprn and gprd set OPENBLAS_NUM_THREADS, MKL_NUM_THREADS, OMP_NUM_THREADS and RAYON_NUM_THREADS to 1 when they are unset, and keep the values that you export. Keep ranks times threads within the cores of the allocation.

Two checks of these options run without MPI. --dump-cli-args prints the parsed options and the startup lines, then exits with status 0. The line [startup] linalg reports the factorization and the thread count:

gprn --reactant reactant.con --product product.con --potential lj \
     --linalg-mode library --linalg-threads 2 --dump-cli-args \
     | grep '^\[startup\] linalg'

--kernel-threads above 1 together with --linalg-threads above 1 is an error, and the exit status is 1:

status=0
gprn --reactant reactant.con --product product.con --potential lj \
     --linalg-threads 2 --kernel-threads 2 --dump-cli-args > threads.log 2>&1 || status=$?
test "$status" -eq 1
cat threads.log

gprd prints the same [startup] linalg line in a normal run, from rank 0.

If a run fails

Message or symptom

Cause and action

distributed execution requires MPI_THREAD_FUNNELED thread support or SLATE requires MPI_THREAD_MULTIPLE thread support

The MPI library started the process with a lower thread level (gpr/linalg/MpiThreading.h). Use an MPI library built with thread support, and run test_mpi_thread_support_native_np4.

parallel kernel blocks require --linalg-threads 1

Both thread flags are above 1. Set one of them to 1.

kernel threads require a positive count and parallel STL support

--kernel-threads is above 1 on a build without TBB. Leave it at 1, or rebuild with TBB (-Duse_stdpar=enabled).

gprn: error: ... on one rank, then the whole job ends

An exception on any rank ends the job through MPI_Abort, with status 1 (reportFatal in managers/MpiLifetime.h). Read the first error: line in the output of every rank.

Four copies of every log line, or the output files overwritten

The binary has no MPI. Check it with ldd.

The launcher reports too few slots under Slurm

The step’s task count is lower than -np. See Run on an HPC cluster .

See also