Scheme II training products¶
gprn and gprd accept --training-product-library PATH to select a GPU
matrix-product library, or --training-product-library scheme2:ENGINE to select
an in-process CPU engine, during covariance and HS-SVD training. The GPU library
implements Ozaki Scheme II through
GEMMul8.
The same option selects the CPU engines described under
CPU engines with scheme2:fp64 or scheme2:int8.
For Cholesky factors of order 512 or greater, the selected path uses panels of 256 columns. Native arithmetic factors each diagonal panel and solves its border; Scheme II updates the trailing matrix. Distributed factors retain their ScaLAPACK layout and replicate one column panel. Their solves use the selected backend, including ScaLAPACK or Software for Linear Algebra Targeting Exascale (SLATE). Incremental factor appends retain the backend’s arithmetic.
HS-SVD uses the selected products for the projection of appended columns and the rotation of the retained basis. Distributed basis rotation assigns output columns to ranks and gathers their results.
Inputs and outputs use binary64 storage. GEMMul8 uses INT8 matrix products, 20 coprime moduli, and its accurate scaling mode. Modular workspace is limited to 256 MiB; input, output, and transfer buffers require separate storage. Buffers persist across calls. Inputs and results cross between host and device on each call.
Small products use native arithmetic when any global dimension is below 128. Distributed products retain the selected arithmetic on smaller local blocks. The accurate INT8 implementation supports inner dimensions up to 131072. A requested library that cannot load or execute raises an error.
Build and select¶
The standalone build in gpr/linalg/gemmul8 links the GEMMul8 static library.
Its default revision is ce63fe92c2de14b89b364f805cd27911fcf0d668.
CUDA builds require toolkit 12.9 or newer. The build also provides a HIP
configuration for the Heterogeneous-compute Interface for Portability (HIP)
through GPR_GPU_BACKEND=HIP.
The public reproduction archive provides
a Slurm build script for the training product (scripts/build_training_product_*.sbatch). It verifies the dependency
archive, builds the library, and records its checksums. Set GPR_REPRO_ROOT,
GPR_SOURCE_ROOT, and GPR_GPU_PREFIX to the reproducer, GP source, and CUDA
toolkit directories before submitting that script.
For a native search, add the library to the usual input arguments:
gprn --reactant reactant.con --product product.con \
--training-product-library build-training-product/libgpr_training_product.so
The initialization log identifies the selected arithmetic:
[training-product] GEMMul8 revision=ce63fe92c2de14b89b364f805cd27911fcf0d668 INT8 moduli=20 fastmode=false device=0
The exit log records the number of device products and their total wall time. A zero count means every product used the native path.
For reproducible searches, the reproducer’s scripts/package_native_runtime.py
packages the library when given --training-product-library PATH, and its
scripts/launch_native_campaign.py selects it with --training-product-gpu.
These two scripts are not part of this repository. The campaign verifies the
packaged library, allocates a GPU, and records its hash with the device details.
The reproducer’s --dimer-training-product-gpu option compares dimer arithmetic
from identical saved band seeds. The saved band retains its own settings and
provenance.
Numerical and performance checks¶
The tests/test_training_product executable checks products against binary128
references. Its cases cover rectangular transposes and padded matrix views.
It also checks Cholesky factor and solve residuals. The distributed checks use
one and four ranks with different block sizes, including a last panel shorter
than 256 columns.
Setting GPR_TRAINING_PRODUCT_LIB requires those tests to execute the device
products. Missing libraries and device errors fail the run.
benchmarks/bench_training_product compares host, binary64 GPU, and Scheme II
products on shared inputs. Its CSV records each repetition and reference error.
The reproducer’s training-product test job (scripts/test_training_product_*.sbatch) runs both programs
on an allocated GPU and keeps their source, library, and device records.
The GPU timings measure each matrix contraction. Search comparisons also require wall time, oracle calls, and the independent saddle validator on the pinned publication panels.
Compare fits on retained observations¶
The reproducer’s fit replay job (scripts/replay_native_fit_*.sbatch) compares two fits on
copies of the same readcon-db observations. Set GPR_TRAINING_PRODUCT_LIB to
the product library to select Scheme II for the candidate fit. The control
retains the recorded arithmetic. Each fit records its command and library hash.
The replay requires zero oracle calls. It also checks that the source archives
remain unchanged.
Use --case for a completed campaign cell, --build for the candidate runtime,
and --baseline-runtime for the control runtime. --data relocates the
benchmark’s environment types when the cell comes from another machine.
--band-only --warm-start compares fits from the saved band and its kernel.
Submit the replay with a GPU allocation when selecting the product library.
The replay uses the campaign’s GPU environment and records the device and CUDA
library hashes. GPR_NATIVE_PROFILE=nsys adds an Nsight trace to each Message
Passing Interface (MPI) rank.
The reports distinguish copies, device products, CPU work, and communication.
Device transfers¶
GDRCopy maps device memory for CPU access. It targets small transfers to the GPU; reads from the GPU use the slower CPU mapping. Its hardware and driver requirements must be checked on the allocated device.
NVIDIA Inference Xfer Library (NIXL) provides asynchronous transfers between registered buffers. Using it for distributed training requires device buffers that remain valid across panel updates, explicit transfer completion, and ordering with matrix kernels.
The training product API accepts host matrices and returns each result to the host. Its transfer boundary must change to keep a factor on the GPU throughout training. Compare transports over the factorization and solve together. Keep the matrix, rank placement, and residual checks fixed, and record peak memory.
CPU engines¶
--training-product-library scheme2:fp64 and scheme2:int8 select an
in-process implementation of Ozaki Scheme II
(Ozaki, Uchino and Imamura, arXiv:2504.08009).
A product C = alpha op(A) op(B) + beta C proceeds in four steps:
Row i of op(A) and column j of op(B) are scaled by powers of two and rounded to integers of at most
bitsbits (default 56). The exponent of a row depends on that row’s largest magnitude only.The integer operands are reduced modulo N pairwise coprime moduli and each residue product runs as an ordinary matrix product that is exact: FP64 GEMM with primes p satisfying k ((p - 1) / 2)^2 <= 2^53 (Section 3.2 of the paper), or INT8 GEMM with INT32 accumulation and the largest pairwise coprime moduli up to 256 (Section 3.1).
The Chinese Remainder Theorem recovers the integer product exactly; the moduli satisfy 2 k 2^(2 bits - 2) (1 + 2^-16) < M for their product M.
The integer is rounded to binary64 and unscaled; alpha and beta apply entry by entry.
An entry of the result is a function of one row of op(A), one column of
op(B) and bits. It does not depend on the BLAS thread count, the blocking
of the residue products, the split of rows or columns across calls or ranks,
or the engine: FP64 and INT8 return identical bits for the same bits.
With a_i the largest magnitude in row i of op(A) and b_j in column j of
op(B), the rounding to integers bounds the error before the final rounding
by k a_i b_j (2^(2 - bits) + 2^(2 - 2 bits)). For bits 56 this is half of
the worst case k u a_i b_j of an FP64 GEMM (u = 2^-53). The bound is
normwise per row and column: entries much smaller than their row maximum
carry the error of the row maximum, as for every Ozaki scheme.
Options follow the engine name, separated by colons:
Option |
Meaning |
|---|---|
|
integer width of the scaled operands, 2 to 62 |
|
number of moduli; the widest supported |
|
INT8 GEMM: |
|
shared library of the INT8 provider |
|
worker threads; the default follows |
|
INT8 tensor cores through |
|
CUDA device of |
|
|
|
output block of one work item; defaults 512 and 256; the residue workspace per thread is (N + 2) R C 8 bytes |
oneDNN loads at run time and need not be present at build time. MKL is
reached through libgpr_scheme2_mkl.so, built when -Dmkl_libdir=DIR names
the directory of the MKL shared libraries. The shim keeps MKL’s symbols in
its own scope: libmkl_rt places MKL’s BLAS and LAPACK in the global symbol
scope, where they would replace the routines ScaLAPACK and LAPACKE call, and
the engine refuses it. The default INT8 provider tries the MKL shim, then
oneDNN, then the portable kernel, and the startup log names the one in use:
[training-product] scheme2 int8 provider=mkl libgpr_scheme2_mkl.so bits=56 moduli=16 chunk=256 log2M=125.375636
With --linalg-mode reproducible (the default) a CPU engine also carries
the products of the distributed tile kernels: the Cholesky factor, its
incremental extension, the triangular solves with at least 32 right-hand
sides, the inverse and the Gram products. Diagonal tiles, panel solves and
the updates inside an outer block of 512 rows use fixed-order scalar
kernels; each outer block applies one exact product to the rest of the
trailing matrix. Narrow solves use the fixed-order kernel for their
updates. The factor and solves give the same bits at every rank count,
process grid and thread count that share the block size. Without an engine
the tile kernels keep their aligned-copy dense products. With
--linalg-mode library the ScaLAPACK routines run unchanged.
Workspace per rank for one outer block of width W with R local rows and C
local columns below it is W (R + C) (8 + N s) bytes for the panel copies and
residues (s = 8 for FP64, 1 for INT8) plus T (N + 2) 512 x 256 x 8 bytes of
block residues for T threads. A standalone product (Context::gemm) keeps its
prepared residues under 2 GiB by working through row and column panels.
The v1 C ABI over the same engines is libgpr_scheme2_product.so, for
programs that load a product library by path; GPR_SCHEME2 gives the
engine specification and GPR_SCHEME2_THREADS its threads.
CUDA provider¶
scheme2:int8:provider=cuda[:library=PATH] runs the INT8 engine on an
NVIDIA GPU. Build libgpr_scheme2_cuda.so with -Dscheme2_cuda=true and
name the target architectures with -Dscheme2_cuda_arch (default
80,90,120); nvcc and cuBLAS come from the gpu-cuda pixi feature.
The host computes the scale exponents from the row and column maxima as
the CPU engines do. The device receives the operand values, scales them and
forms their residues with the operations of the host residue pass, multiplies
the residues of all sixteen moduli in one strided batched INT8 GEMM with
INT32 accumulation per output tile, reduces the products modulo each p and
reconstructs the integer with the limb arithmetic of the CPU reconstruction.
The reconstruction rounds with explicit round-to-nearest operations and the
library is compiled with -fmad=false, the device counterpart of
-ffp-contract=off. Every partial sum of an INT32 product is an integer of
magnitude at most 65536 x 128 x 128 = 2^30, so the product is exact for any
kernel, split-K or summation order cuBLAS chooses. The result therefore has
the bits of the CPU engines, on every GPU and at every rank and device
count; the engine tests, the exact tile kernels and the training-product
suite run the provider next to the CPU engines when it is built.
Each rank uses one device, by default its node-local rank modulo the visible
devices; ranks may share a device. A run whose products total fewer than
device_min multiply-adds stays on the host in an FP64 engine with the same
bits, which returns the same entries; launches, transfers and the
time-slicing of a device shared by several ranks would cost more than such a
product. One call moves the operand values (8
bytes per entry) and the products (8 bytes per entry) across the bus.
GEMMul8 itself is not used for this engine. Its shift for a row is derived
from the number of moduli and, in its accurate mode, from a preliminary
low-precision product of both operands, so an entry depends on the other
operand and on k, and its results differ from the CPU engines in the last
bits. The GEMMul8 library under gpr/linalg/gemmul8 remains available
through the v1 ABI by path.