Skip to content

feat(xc): offload Libxc grid potentials to CUDA - #8364

Open
Stardust0831 wants to merge 5 commits into
deepmodeling:developfrom
Stardust0831:feat/libxc-cuda-grid-7-1
Open

Stardust0831 wants to merge 5 commits into
deepmodeling:developfrom
Stardust0831:feat/libxc-cuda-grid-7-1

Conversation

@Stardust0831

Copy link
Copy Markdown
Collaborator

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.

Linked Issue

Related to deepmodeling/abacus-develop#3344: Support the GPU version of libxc.

Unit Tests and/or Case Tests for my changes

  • Commands run:
compute-sanitizer --tool memcheck --report-api-errors no --leak-check full --error-exitcode 99 \
  "$build/source/source_hamilt/module_xc/test/MODULE_HAMILT_XCTest_VXC" --gtest_filter='*LibxcCudaPotential*'
abacus_std_gpu -h device_xc
abacus_std_gpu --check-input
OMP_NUM_THREADS=4 mpirun -np 1 abacus_std_gpu
  • Result summary: All 24 LDA, GGA and HSE grid tests passed with Libxc 7.1.2. Memcheck reported zero device-memory errors or leaks. Help showed the CPU default, and all four Si32 input combinations passed --check-input.
  • Checks not run, with reason: The full integration suite was not run. Verification targeted the CUDA grid evaluator, INPUT handling and the HSE06 case below.

Si32 HSE06, official Libxc 7.1.2. Both Libxc modes used the same executable, one Tesla V100, one MPI rank and four physical CPU cores. cuSOLVER used the GPU and exact exchange used the CPU throughout. Times are medians of three runs per mode.

Calculation Libxc grid, CPU → GPU Total time, CPU → GPU
Single point 45.62 → 5.71 s (7.99x) 99.65 → 61.05 s (1.63x)
Forces and stress 46.12 → 6.41 s (7.20x) 141.78 → 102.26 s (1.39x)

Download the Si32 case · Per-run timings

What's changed?

ABACUS can evaluate Libxc LDA/GGA potentials on CUDA, including the semilocal part of HSE. It uses Libxc's public host/device API, available in official releases since 7.1.0. CPU evaluation is the default. With CUDA-enabled ABACUS and Libxc, enable GPU evaluation with these INPUT settings. Libxc 7.1.2

device     gpu
device_xc  gpu

Governance Notes

  • INPUT/docs changes: device_xc accepts cpu or gpu. Its registration provides CLI help and the generated parameter reference. The installation guide describes the CUDA build requirements.
  • Core module impact: The ElecState potential factory passes the device choice to the Hamiltonian XC evaluator, which batches each rank's grid. The existing global reads supply magnetism and RDMFT settings. The host initialization helper includes xc.h for the Libxc types and flags it uses.
  • Exceptions requested: None.

@Stardust0831
Stardust0831 marked this pull request as ready for review November 22, 2026 16:34
@Stardust0831
Stardust0831 force-pushed the feat/libxc-cuda-grid-7-1 branch from 23464e9 to 3332ebf Compare November 22, 2026 16:41
Comment thread source/CMakeLists.txt
Comment on lines +72 to +73
if(USE_CUDA AND ENABLE_LIBXC AND Libxc_ENABLE_CUDA AND
Libxc_VERSION VERSION_GREATER_EQUAL "7.1.0")

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.

Maybe, export an cmake dependent option ENABLE_LIBXC_CUDA, and then

if(ENABLE_LIBXC_CUDA AND Libxc_VERSION VERSION_LESS "7.1.0")
  message(
    FATAL_ERROR
    "Enabling LibXC with CUDA support requires LibXC >= 7.1.0; found version ${Libxc_VERSION}"
  )
endif()

Then the if condition here in source/CMakeLists.txt can be simply if(ENABLE_LIBXC_CUDA)

@Growl1234

Copy link
Copy Markdown
Collaborator

@susilehtola Sorry to bother you here, but would you like to have a look?

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

Static source review at 3332ebfd; no build or runtime tests were run.

}
for (int j = 0; j < nsigma; ++j)
{
sigma[i * nsigma + j] = density * density * (j == 1 ? 0.1 : 0.3);

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.

Non-blocking: the ordinary-density samples keep sigma/rho^2 fixed, while the tiny-gradient samples also fall below the density cutoff, so this grid misses the finite-density, small-gradient HSE case described in install.md. Add zero/tiny sigma at ordinary density and record a version-specific expectation for the known Libxc limitation.

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.

3 participants