Skip to content

feat(hsolver): add an optional LibDDLA eigensolver for LCAO - #8499

Draft
userchba wants to merge 2 commits into
deepmodeling:developfrom
userchba:feat/ddla-eigensolver-only
Draft

userchba wants to merge 2 commits into
deepmodeling:developfrom
userchba:feat/ddla-eigensolver-only

Conversation

@userchba

@userchba userchba commented Dec 3, 2026 •

Copy link
Copy Markdown

Reminder

  • I have read AGENTS.md and docs/developers_guide/agent_governance.md.
  • I have linked an issue or explained why this PR does not need one.
  • I have added adequate unit tests and/or case tests, or explained why not.
  • I have listed the verification commands and their results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained the core-module impact.
  • I have requested any needed governance exception below.

What's changed?

Add ks_solver ddla as an optional LCAO solver for real and complex generalized eigenproblems on CPU and CUDA. The existing HSolver dispatcher calls DiagoDdla, which owns the LibDDLA handles and buffers. It copies H and S into backend storage for each solve and returns the requested eigenvectors to the existing host workflow.

ENABLE_DDLA defaults to OFF. To enable it, configure with -DENABLE_DDLA=ON -DENABLE_MPI=ON -DENABLE_LCAO=ON and point CMake to LibDDLA 0.0.7 or later. Set ks_solver ddla and kpar 1 in INPUT. CUDA execution also requires a CUDA-enabled LibDDLA build and one MPI rank per active GPU.

Linked issue

This is the eigensolver contribution discussed in #8474.

Draft status and HIP benchmark

ABACUS needs to enable and validate ELPA's HIP backend for distributed LCAO diagonalization on AMD GPUs and Hygon DCUs. The integration is tracked in #8508.

Once ABACUS can run ELPA on the DCUs, I will benchmark LibDDLA and ELPA on the same Si1024 input using four Hygon DCUs and one MPI rank per device. The comparison will use the same ABACUS revision and SCF settings, verify that both solvers execute on the DCUs and agree numerically, and report eigensolver time, SCF wall time, and peak host and device memory. The prior HIP/DCU results below are from an earlier integration.

Unit tests and case tests

  • Built the Release CPU and CUDA applications with ENABLE_DDLA=ON and OFF using cmake --build <build-dir> --parallel 8 --target <targets>. Builds with DDLA disabled passed with CMAKE_DISABLE_FIND_PACKAGE_LibDDLA=TRUE.
  • Ran mpirun -np <1|4|6> --bind-to core ./MODULE_HSOLVER_diago_ddla for CPU numerical tests in the DDLA-enabled builds. Ran mpirun -np <1|4> --bind-to core ./MODULE_HSOLVER_LCAO_sk_cut in all four builds. All 14 MPI suite invocations passed.
  • Ran ctest --test-dir <build-dir> --output-on-failure -R '^(02_NAO_Gamma_ddla|03_NAO_multik_ddla)$'. Both CPU SCF cases passed. The native CPU Si and Fe runs used ScaLAPACK and ELPA, respectively.
  • On V100, ran ABACUS_TEST_DDLA_GPU=1 mpirun -np <1|2> --bind-to core ./MODULE_HSOLVER_diago_ddla --gtest_filter=DiagoDdla.GpuRealAndComplex and repeated both SCF comparisons against cuSOLVER using mpirun -np <1|2> --bind-to core ./abacus_basic_gpu.
  • Verified rejection of an unavailable DDLA build, kpar 2, and a GPU request with the CPU-only LibDDLA library.
SCF case Orbitals CPU total energy difference CUDA maximum total energy difference (1 or 2 GPUs)
Si₂, Γ only 26 2.84 × 10⁻¹⁴ eV 2.56 × 10⁻¹³ eV
Fe₂, spinor with multiple k points 108 9.09 × 10⁻¹³ eV 2.73 × 10⁻¹² eV

Force and stress aggregates matched at printed precision. HPC3 jobs 4218694, 4218752, and 4218814 passed. The validated source tree matches functional commit cf32719ff. The follow-up 5154d73b7 restored upstream CMake formatting. The legacy Make build and HIP build/runtime remain untested.

Governance notes

The build flag and INPUT option are documented in the installation guide. HSolver owns the DDLA dispatch and state. The other runtime changes register the solver's matrix layout and SCF display label. The existing density and response paths continue to consume the same host outputs. No governance exceptions requested.

Prior GPU benchmark

The earlier branch from #8474 (bae4e7473) was timed on one HPC3 node with four V100s allocated and four MPI ranks. For these single-k-point inputs, cuSOLVER used one active GPU and LibDDLA used four. Each measurement ran three LCAO SCF iterations, with three separate process launches per solver and size. The figure reports whole-run wall time.

Silicon atoms cuSOLVER median (s) LibDDLA median (s)
128 9.13 10.28
256 23.45 24.01
512 59.22 51.10

For Si512, the cuSOLVER-to-LibDDLA median time ratio was 1.16× in this allocation. cuSOLVER had the lower median for Si128 and Si256. These measurements are from the earlier branch (HPC3 job 4215721). Performance of the eigensolver-only branch at these sizes has yet to be measured.

silicon-v100-timing

LCAO solver time on CPU and CUDA

The same Si128/256/512 inputs were also timed on one HPC3 CPU node with 48 physical cores (4 MPI ranks × 12 threads). The CUDA run used 4 MPI ranks × 3 host threads, with the active GPU counts shown below. These are medians of rank-0 HSolverLCAO::solve elapsed time, summed across three SCF iterations per launch, with three launches per solver and size. This timer covers the ABACUS solver step, including work outside the eigensolve kernel.

System CPU ScaLAPACK (s) CPU ELPA (s) CPU LibDDLA (s) CUDA cuSOLVER, 1 V100 (s) CUDA LibDDLA, 4 V100s (s)
Si128 14.29 8.42 8.77 2.60 3.65
Si256 47.64 26.66 45.44 7.47 8.04
Si512 211.84 124.04 263.74 27.45 19.32

ELPA had the lowest CPU median at all three sizes. On CUDA, Si512 took 19.32 s with LibDDLA versus 27.45 s with cuSOLVER in this allocation, a 1.42× solver-time ratio. The CUDA Si256 sample ranges overlap. Both HPC3 jobs (4215720 and 4215721) used the earlier #8474 branch. GPU ELPA and cuSOLVERMp were outside this test matrix.

silicon-hsolver-timing

Prior HIP/DCU results

An earlier ABACUS 3.11.0-beta12 integration with LibDDLA 0.0.6 was tested on gfx906 DCUs (job 23298926). Each cell is one whole-process measurement at one-second resolution. The CPU used one thread per rank, and HIP used one DCU per rank.

SCF case ScaLAPACK, 1 CPU rank LibDDLA, 1 DCU ScaLAPACK, 2 CPU ranks LibDDLA, 2 DCUs
Si₂, 26 orbitals 7 s 11 s 4 s 10 s
Fe₂, 108 orbitals 8 s 12 s 5 s 12 s

The Si and Fe runs agreed with the matched CPU runs within 6.37 × 10⁻¹² eV in total energy. The DCU wall times were higher for both small cases. Matched larger HIP timings and GPU ELPA comparisons on the eigensolver-only branch remain open.

Standalone LibDDLA benchmark at fixed CPU core count

The figure compares standard dense eigensolves outside ABACUS on HPC3. Each layout uses 40 physical CPU cores and changes the number of MPI ranks and cores per rank (1×40, 4×10, 20×2, or 40×1). The test requests all eigenvectors of a synthetic 10,000×10,000 real or complex double-precision matrix, with block size 64. Points are medians of three maximum-rank wall times after one warm-up. Whiskers span the observed range.

In this LibDDLA development snapshot (based on 50b5314), the two-stage solver took 19.80 s real and 53.22 s complex at 1×40, and 10.19 s real and 29.48 s complex at 40×1. The ELPA 4×10 spike is specific to the tested 2025.01.001 build and layout. This figure characterizes the standard eigensolver's sensitivity to process layout. The ABACUS SCF benchmarks above use generalized eigensolves.

libddla-fixed-40-core

Runtime selection of the LibDDLA eigenmethod

ABACUS calls LibDDLA's phegvd. After reducing the generalized problem to standard form, LibDDLA selects the eigensolver method at runtime. In the default DDLA_EIGEN_METHOD=auto mode, its dispatch rules use the matrix size, number of requested eigenvectors, backend, MPI process grid, and thread settings. They select among the eligible methods without timing both on each solve. In the tested LibDDLA snapshot, distributed partial-spectrum requests default to two-stage. For controlled comparisons, LibDDLA accepts DDLA_EIGEN_METHOD=one_stage or two_stage.

For example, a separate LibDDLA development snapshot was benchmarked on four gfx906 DCUs with a 2×2 process grid and block size 64. The standalone pheevd test requested all eigenvectors and passed its numerical checks. The times below are medians of four warmed solves per method from two launches in alternating order.

Synthetic matrix One-stage Two-stage
Order 2,048, real double 0.755 s 0.597 s
Order 5,000, complex double 3.056 s 4.598 s

Standalone generalized eigensolver on CPU, CUDA, and DCU

This benchmark exercises the dense generalized problem $AX=BX\Lambda$ outside ABACUS. Each platform solves the same order-5,000 matrix pair for each precision and returns all eigenvectors. All runs use four MPI ranks on a 2×2 grid with block size 128. CPU runs use 24 threads per rank. Accelerator runs use one rank and one host thread per device. The table reports median maximum-rank wall time over three solves after one warmup. Accelerator timings include host–device transfers.

Platform Solver Real FP64 (s) Complex FP64 (s)
96 CPU cores LibDDLA 7.51 19.60
96 CPU cores ScaLAPACK (divide and conquer) 6.15 7.94
4 V100 GPUs LibDDLA 1.55 2.82
4 V100 GPUs ELPA 2025.01.001 3.30 7.62
4 V100 GPUs cuSOLVERMp 0.5.1 5.98 6.15
4 gfx906 DCUs LibDDLA 2.61 4.80
4 gfx906 DCUs ELPA 2026.02.001 5.03 15.56

On the CPU node, ScaLAPACK had the lowest median for both precisions. On four V100s, LibDDLA was 2.13× faster than ELPA in real FP64 and 2.70× in complex FP64. On four DCUs, the corresponding ratios were 1.93× and 3.24×. Whiskers in the figure show the minimum and maximum measured times.

The archived HPC3 CPU and CUDA measurements use LibDDLA 1ff05d9 (jobs 4025795 and 4026599). The CPU job also included separate one-rank cases that exceeded the OpenBLAS thread limit. The four-rank cases shown here passed validation. The new df_dcu comparison uses LibDDLA bf2ecfc and DTK 25.04.3 (job 23511048). The maximum DCU eigenvalue difference against the CPU and CUDA archives was 2.78 × 10⁻¹⁵. These standalone results compare libraries within each platform.

libddla-generalized-cpu-cuda-dcu

Standalone CPU eigensolver benchmark on df_dcu

Each run used one Hygon C86 7185 node with 30 physical CPU cores, HPC-X Open MPI and block size 64. All seven configurations solved the same 10,000 × 10,000 standard eigenproblem and returned all eigenvectors. Points show the median maximum-rank wall time across three independent MPI launches and whiskers show the observed range. All 252 timed solves passed numerical checks. LibDDLA was built from 4f93216. The references were ScaLAPACK 2.2.2, ELPA 2026.02.001 (AVX2/OpenMP), and oneMKL 2024.2.2 and 2026.2.2.

For complex double, oneMKL 2026 took 718.7 s at 5×6 and 173.2 s at 30×1. LibDDLA two-stage ranged from 137.6 to 152.2 s across the six layouts. The fastest results in the sweep were ELPA two-stage at 37.1 s for real double (30×1) and ELPA one-stage at 99.6 s for complex double (15×2). The benchmark is standalone. ABACUS LCAO solves the generalized H/S eigenproblem.

df-dcu-cpu-eigensolvers-onemkl

@userchba
userchba marked this pull request as ready for review December 3, 2026 09:56
Restore the upstream formatting of the ENABLE_CNPY block so the ENABLE_DDLA diff stays focused.
@userchba
userchba force-pushed the feat/ddla-eigensolver-only branch from 5154d73 to 4dec9ac Compare December 3, 2026 10:10
@userchba

userchba commented Dec 3, 2026

Copy link
Copy Markdown
Author

Hi @AsTonyshment, could you review this eigensolver-only follow-up to #8474? It adds ks_solver ddla and keeps the LibDDLA calls and buffer ownership inside HSolver/Diago. I’d appreciate your feedback on that boundary and the optional build wiring. Thanks!

@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.

Ah, this implementation looks significantly cleaner than the previous one.

However, it is not up to me to decide whether to introduce new dependencies or not. This may need further discussions with @mohanchen and other relevant developers :)

@userchba

userchba commented Dec 3, 2026

Copy link
Copy Markdown
Author

Thanks for reviewing the narrower implementation. Upstream ABACUS already uses LibDDLA 0.0.7 or newer for the optional LibRI GPU/DCU contractions introduced in #8169. This PR uses the same CMake package and ddla::ddla target for LCAO generalized diagonalization in HSolver.

The new ENABLE_DDLA option defaults to OFF. It lets users opt into the eigensolver independently of LibRI. With both ENABLE_DDLA and ENABLE_LIBRI_GPU disabled, ABACUS builds without LibDDLA.

The decision here is whether to extend the use of the existing optional dependency to HSolver. I’d welcome feedback from @mohanchen and the other maintainers on that scope.

@mohanchen mohanchen added GPU & DCU & HPC GPU and DCU and HPC related any issues Feature Discussed The features will be discussed first but will not be implemented soon Interfaces Interfaces with other packages labels Dec 4, 2026
@mohanchen

Copy link
Copy Markdown
Collaborator

Before proposing any code to be merged, please open an issue first to explain why this change is needed, what limitations the existing approach has, and how the codebase will be improved after adding it.

The goal of developing ABACUS is to solve problems, not to keep adding code that does not solve any. Based on the current PR description, I do not see what challenging problem this PR solves. We will not merge code just for the sake of merging code. Please state in the issue what problem you want to solve and how you plan to solve it.

In this PR, you need to highlight what problem the newly added method solves. From your comparison between 4 GPUs and 1 GPU using cuSOLVER, I do not see any advantage. Compared with ScaLAPACK, it even looks slower—so I am very confused about what problem this PR is trying to solve.

@userchba

userchba commented Dec 4, 2026

Copy link
Copy Markdown
Author

Thanks for the feedback. I’m sorry I didn’t clearly explain what problem I was trying to solve in the original PR description.

I opened #8508 to discuss the missing path for distributing a single LCAO eigensolve across HIP/DCU devices. The current patch still needs HIP validation.

On CPUs, the use case is memory-limited hybrid DFT with LibRI. More MPI ranks can increase peak node memory, so we use fewer ranks and more OpenMP threads per rank. I’m testing whether LibDDLA keeps diagonalization efficient in that layout. I’ll compare it with CPU ELPA and ScaLAPACK at a fixed core count and report eigensolver time, total SCF wall time, and peak node memory.

@userchba
userchba marked this pull request as draft December 4, 2026 12:15

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

Feature Discussed The features will be discussed first but will not be implemented soon GPU & DCU & HPC GPU and DCU and HPC related any issues Interfaces Interfaces with other packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants