Skip to content

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

Merged
mohanchen merged 3 commits into
deepmodeling:developfrom
Stardust0831:perf/ri-integral-reuse
Nov 2, 2026
Merged

mohanchen merged 3 commits into
deepmodeling:developfrom
Stardust0831:perf/ri-integral-reuse

Conversation

@Stardust0831

Copy link
Copy Markdown
Collaborator

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. Vector evaluation preserves each component's angular summation order; common-factor reuse can change FP64 rounding. Temporary arrays are local to evaluation. This changes CPU integral evaluation and introduces 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

LCAO HSE calculations on displaced Si32 and CsPbI3 (5 atoms), using one V100, one MPI rank, four physical CPU cores/OpenMP threads and serial BLAS on SAI. Both versions use cuSOLVER diagonalization and CPU LibRI contractions. The baseline is unmodified d20090cc137f.

Ranges cover two paired runs in separate allocations on shared nodes, with reversed execution order. Ratios are calculated within each pair; SCF iteration counts match. Complete time includes process startup. The RI stage is measured by Exx_LRI::cal_exx_ions, which includes geometry-dependent integrals and derivatives; EXX force contractions are unchanged.

Unit Tests and/or Case Tests for my changes

The full CUDA executable build and integral tests passed with one and four OpenMP threads. 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)$'

The benchmark cases, a CPU execution control, and complex-tensor Si32 on a regular 2x1x1 k mesh with two MPI ranks/GPUs all converged with matching iteration counts. Maximum differences were 1.4e-11 eV/atom, 2.0e-10 eV/Angstrom and 1.4e-9 kbar. These comparisons establish agreement with the baseline. The combined changes also passed a build and regression checks with CUDA disabled.

Inputs, timings, numerical comparisons and test logs. Benchmark executables enable identical existing timer JSON output; this instrumentation is excluded from the change.

Linked Issue

Supersedes the integral-evaluation part of #8193. This change is independent of the radial-table and Libxc optimizations and does not require #8169.

Governance Notes

No documentation update required: this changes internal LCAO integral evaluation without changing INPUT parameters, dependencies or numerical settings.

@AsTonyshment AsTonyshment left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No confirmed correctness regression found in the inspected paths. The inline comments suggest a matrix-level regression and one project-rule cleanup.

Static review of 06ab2be77 against d20090cc: whitespace and governance checks passed. The linked baseline comparisons were inspected as author-provided evidence; no build or runtime checks were performed.

Resolve the CMake formatting conflict while retaining the integral reuse
test target and its source list.
@mohanchen mohanchen added Refactor Refactor ABACUS codes Performance Issues related to fail running ABACUS labels Nov 2, 2026
@mohanchen
mohanchen merged commit c089aed into deepmodeling:develop Nov 2, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Performance Issues related to fail running ABACUS Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants