Skip to content

perf(lcao): reuse common terms across magnetic components - #36

Draft
Stardust0831 wants to merge 1 commit into
review/ri-performance-base-20261101from
perf/ri-integral-reuse
Draft

Stardust0831 wants to merge 1 commit into
review/ri-performance-base-20261101from
perf/ri-integral-reuse

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

What's changed?

RI integral assembly repeatedly evaluates the same radial interpolation and solid harmonics for different magnetic components. Compute these common terms once per orbital pair and reuse the two-center results during three-center assembly.

The scalar interfaces remain available. The new vector evaluation preserves each component's angular summation order; common-factor reuse can change FP64 rounding. Temporary arrays are local to evaluation, with no persistent geometry cache or device allocation.

Performance

System Stage Baseline (s) This PR (s) Paired speedup
Si32 RI integrals and derivatives 6.64–7.59 1.97–2.19 3.36–3.47x
Si32 Complete SCF + forces + stress 182.22–203.71 174.42–186.09 1.04–1.09x
CsPbI3 RI integrals and derivatives 16.21–16.28 2.48–2.54 6.38–6.57x
CsPbI3 Complete SCF + forces + stress 424.48–426.14 407.10–414.09 1.03–1.04x

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::cal_exx_ions includes geometry-dependent integrals and their derivatives. This PR does not change the EXX force contraction.

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 integral tests pass. The tests compare all magnetic components against scalar evaluation, cover origin/near-origin/cutoff behavior, and check gradients by finite differences in all three directions.

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

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 radial tables. 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 radial-table PR have separate change regions.

No documentation update required: this changes internal LCAO integral evaluation without changing INPUT metadata, dependencies or numerical settings. No governance exception is requested.

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.

1 participant