Skip to content

perf(lcao): batch RI radial table construction on CUDA - #37

Draft
Stardust0831 wants to merge 8 commits into
review/ri-performance-base-20261101from
perf/ri-radial-gpu
Draft

Stardust0831 wants to merge 8 commits into
review/ri-performance-base-20261101from
perf/ri-radial-gpu

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

What's changed?

LCAO EXX initialization builds radial tables with many small quadrature operations and repeated product-orbital transforms. For CUDA calculations, batch the existing Simpson quadrature into FP64 GEMM using ABACUS's tensor/BLAS interfaces. Preserve the derivative recurrence and analytic origin values.

The existing resolved device selection is passed explicitly through initialization and Coulomb refresh. CPU full-table construction retains individual quadrature. Product orbitals are shared during batched and selective construction, and their unused origin derivative is omitted. Call-site updates preserve CPU behavior for the other RI consumers.

This uses the unmodified default LibRI revision b0eff7a; DDLA and LibRI GPU contractions are not required. There is no new build or INPUT option.

Performance

System Stage Baseline (s) This PR (s) Paired speedup
Si32 RI initialization 6.52–7.15 1.34–1.41 4.86–5.09x
Si32 Complete SCF + forces + stress 182.22–203.71 181.38–187.34 1.00–1.09x
CsPbI3 RI initialization 343.48–344.15 14.73–15.38 22.33–23.37x
CsPbI3 Complete SCF + forces + stress 424.48–426.14 95.52–96.23 4.43–4.44x

Ranges cover two paired runs in separate allocations; speedups are computed within each pair.

HSE SCF, forces and stress on Si32 and CsPbI3 (5 atoms), using one V100, one MPI rank, four physical CPU cores/OpenMP threads and serial BLAS on SAI. cuSOLVER diagonalization and CPU LibRI contractions in both versions. Each candidate is compared with unmodified d20090cc137f; two repetitions reverse the execution order. Reported performance pairs have identical SCF iteration counts.

Exx_LRI::init includes radial-table preparation before SCF. Its speedup includes GPU batching and product preparation reuse; it is not an isolated GPU-kernel comparison.

Explicit device workspace is bounded at 160 MiB per MPI rank, with at most 160 MiB of corresponding host staging. These buffers are released before SCF. The bounds exclude CUDA context/library allocations and the existing host tables. Sampled total process GPU peaks (baseline / candidate): Si32: 442–450 / 460–462 MiB; CsPbI3: 438 / 530 MiB. Sampling interval: 0.5 s.

Unit Tests and/or Case Tests for my changes

Maximum differences across the 29 completed calculations are 2.2e-11 eV/atom, 2.3e-09 eV/Angstrom and 9.6e-09 kbar. These checks establish agreement with the baseline, not absolute force accuracy. All matched SCF iteration counts agree. Validation includes one-thread controls, CPU execution, a build with CUDA disabled, and complex tensors on a 2x1x1 k mesh with two MPI ranks/GPUs.

The standalone CUDA executable and CPU/CUDA radial-table tests pass. Tests cover individual versus batched tables, product sharing, high angular momenta, origin/cutoff behavior, radial tiling and gradients.

cmake --build build --target abacus_std_gpu MODULE_LCAO_radial_tables MODULE_LCAO_radial_tables_gpu --parallel 24
OMP_NUM_THREADS=1 ctest --test-dir build -V -R '^(MODULE_LCAO_radial_tables|MODULE_LCAO_radial_tables_gpu)$'
OMP_NUM_THREADS=4 ctest --test-dir build -V -R '^(MODULE_LCAO_radial_tables|MODULE_LCAO_radial_tables_gpu)$'

Inputs, individual timings, numerical comparisons and test logs. All benchmark executables enable the same existing full-precision timer JSON output; that instrumentation is absent from these PRs.

Linked Issue

Related performance study: #30. Independently reviewable part of #32.

Governance Notes

Companion changes: Libxc scheduling and integral evaluation. All three branches start at the same frozen develop commit, have no prerequisite PR, and merge in all six orders without conflicts or differences in the resulting tree. Shared files with the integral-evaluation PR have separate change regions.

Core impact is limited to RI table construction and explicit device propagation. No documentation update required: the existing device option and its metadata are unchanged. <memory> is required by the owning shared_ptr<const ProductOrbitals> member. No governance exception is requested.

Stardust0831 and others added 7 commits November 2, 2026 12:55
* Make self-defined testing helper happy

* Format CMake files

* Adjust comment
* Precommit: Prettify toolchain scripts

* Toolchain: CMake arguments in Linux build scripts

shfmt breaks the bash logic when combined with `\` and comments

* Use quote vars

* Apply case indent
Keep existing product orbitals and radial entries when selective
initialization is called again with additional radii. Prepare only new
objects in selective batches so existing Orb11 references remain valid.

Add a regression for individual and mixed-batch initialization, checking
overlaps and gradients against complete tables.
Retain the CPU and CUDA radial-table tests with the upstream CMake format.

Validation: clean CUDA build and both radial-table test targets on SAI,
with OMP_NUM_THREADS=1 and 4 (14 test executions passed, no skips).
Exercise destruction and full reinitialization of the first Orb21 in a
shared batch. Check the remaining object after a selective update against
independent full tables, including retained and new overlaps and gradients.

Validation: CPU/CUDA radial-table tests with one and four OpenMP threads
(18 test executions passed), plus the ownership regression under
AddressSanitizer with CUDA disabled.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants