Skip to content

experiment(lcao): retain cuSOLVER eigenvectors for Gamma FP64 density matrices - #8392

Draft
Stardust0831 wants to merge 5 commits into
deepmodeling:developfrom
Stardust0831:experiment/dm-direct-98700b9
Draft

Stardust0831 wants to merge 5 commits into
deepmodeling:developfrom
Stardust0831:experiment/dm-direct-98700b9

Conversation

@Stardust0831

Copy link
Copy Markdown
Collaborator

What's changed?

Gamma-only LCAO currently returns cuSOLVER eigenvectors to the host for CPU density-matrix construction. This pilot retains them on the GPU through the actual occupation calculation, builds D = C diag(f) C^T with FP64 cuBLAS, and redistributes D for the existing CPU DMR consumer.

The default-off CMake option ABACUS_DM_DIRECT_PILOT enables environment modes cpu, direct and verify. Scope: real Gamma, nspin=1, one k point, kpar=1, one node/GPU, multiple MPI ranks and charge updates; other configurations retain the existing path.

Unit Tests and/or Case Tests for my changes

Matched Si/PBE/DZP SCFs used the same binary and full FP64 cusolverDnDsygvd, four MPI ranks, a 2×2 grid, one OpenMP/BLAS thread, and three alternating pairs after warmup.

Case / GPU Basis / bands CPU-DM SCF median Direct-DM SCF median Time reduction
Si216 / V100 16GB 2808 / 520 33.86 s 33.00 s 2.54%
Si1080 / V100 32GB 14040 / 2602 410.27 s 321.61 s 21.61%

Both paths converged in 12 iterations. Large-case process wall time fell from 473.27 s to 384.17 s (18.83%), including startup, transfers and synchronization. Hardware differs between sizes; each A/B comparison uses the same machine.

  • Correctness: maximum distributed DM error 8.44e-15 (tolerance 1e-10), Tr(DS) error 1.82e-8 electrons (1e-7), and paired final-energy difference 1.02e-10 eV (1e-6). Fractional occupations were exercised.
  • Tests: both targeted CTest suites passed, covering seven tests; 23 final/review SCFs passed, including single-rank fallback. The retained-DM test covers zero/fractional/signed weights and overwrites host Psi before device DM construction.
  • Not covered: the full GPU regression suite, complex/spin/multi-GPU variants, and injected allocation/CUDA failures remain outside this pilot's validation.
Verification commands and source identity
cmake --build build --target abacus_basic_gpu \
  MODULE_HSOLVER_direct_dm MODULE_HSOLVER_LCAO_cusolver --parallel 8
ctest --test-dir build -V \
  -R '^MODULE_HSOLVER_(direct_dm|LCAO_cusolver)$'
git diff 98700b9 HEAD --check
python3 tools/03_code_analysis/agent_governance_check.py \
  --base 98700b9 --head HEAD --format text

Build/tests and whitespace checks passed; governance reported no blockers. Build: Release/sm70, GCC 13.3, CUDA 12.9.1, OpenMPI 5.0.10, OpenBLAS 0.3.32. SAI jobs 2821707, 2821899, 2822271 and 2822576 completed with exit 0:0.

Baseline: 98700b960746a4acecb86ee57f131804a1e5d9a6. Timings: 520dada; final source: 880b0aa, which only names intermediate expressions/test results and was separately rebuilt and checked with both unit suites and a Si8 CPU/verify pair. Raw cases, logs, binaries and hashes remain in the experiment evidence bundle.

Linked Issue

No linked issue; this is a standalone experimental evaluation.

Governance Notes

  • INPUT/docs: no documentation update required: this private, default-off trial adds no supported INPUT and changes no default behavior.
  • Core impact: HSolver retains solver ownership through occupations and preserves the existing DM descriptors/DMR consumer. New header includes supply directly used types. New code uses explicit types, with no auto, decltype, direct MPI calls or global-control references.
  • Limits: host Psi and full N² device eigenvector storage remain. B's total D2H increases by 292,256,640 bytes per large call because it also returns D. The gain includes smaller host-Psi buffers and is not established for RTX4090 or a subset eigensolver baseline.
  • Exceptions requested: none.
Template checklist

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 exact verification commands run and their results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained core-module impact for ESolver, HSolver, ElecState, Hamilt, Operator, Psi, or other source/ changes.
  • I have requested any needed governance exception below.

@mohanchen mohanchen added GPU & DCU & HPC GPU and DCU and HPC related any issues Performance Issues related to fail running ABACUS Refactor Refactor ABACUS codes labels Nov 25, 2026

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

GPU & DCU & HPC GPU and DCU and HPC related any issues Performance Issues related to fail running ABACUS Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants