Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0d0f29b
experiment(lcao): connect device selection to LibRI DDLA GPU contract…
Stardust0831 Oct 15, 2026
b408a31
refactor(lcao): select RI backend once before runner initialization
Stardust0831 Oct 16, 2026
d20dde7
test(lcao): record HSE GPU backend parity performance and memory
Stardust0831 Oct 16, 2026
784610d
docs(lcao): record successful multi-GPU RI memory scaling
Stardust0831 Oct 17, 2026
fa9c853
docs(lcao): verify size-dependent GPU RI memory and strong scaling
Stardust0831 Oct 17, 2026
33d400f
build(lcao): encapsulate LibRI GPU dependencies in CMake targets
Stardust0831 Oct 17, 2026
8dd6925
build: make MKL adapters usable in dependency probes
Stardust0831 Oct 17, 2026
9d40406
test(lcao): record CMake dependency and HSE regressions
Stardust0831 Oct 17, 2026
d8d3204
build(libri): minimize GPU integration and follow CMake conventions
Stardust0831 Oct 17, 2026
2ca0421
style(libri): align GPU dependency adapter formatting
Stardust0831 Oct 18, 2026
f07d8d1
feat(lcao): select LibRI contractions with exx_device
Stardust0831 Oct 18, 2026
63ca5ef
test(libri): cover GPU accumulation and clarify runtime limits
Stardust0831 Oct 18, 2026
1b27028
Merge upstream/develop into experiment/lcao-hse-gpu
Stardust0831 Oct 20, 2026
3fa1f97
refactor(input): rename exx_device to device_exx
Stardust0831 Oct 20, 2026
d098ea5
Merge branch 'develop' into experiment/lcao-hse-gpu
mohanchen Oct 21, 2026
484bf4c
build(libri): remove superseded GPU compatibility patch
Stardust0831 Oct 23, 2026
b30b66a
Merge develop into experiment/lcao-hse-gpu
Stardust0831 Oct 23, 2026
1bd79c4
feat(lcao): prepare GPU EXX symmetry for the LibRI release
Stardust0831 Oct 24, 2026
b6e8883
build(libri): use DDLA 0.0.6 CMake package
Stardust0831 Nov 1, 2026
892dbd6
Merge develop into LCAO GPU RI integration
Stardust0831 Nov 10, 2026
4f5fc68
docs(libri): update merged DDLA dependency status
Stardust0831 Nov 10, 2026
c1d3b81
build(libri): require released GPU API and migrate device input test
Stardust0831 Nov 21, 2026
64b7ef6
fix(lcao): guard GPU EXX against LibRI symmetry regression
Stardust0831 Nov 21, 2026
f2667c6
fix(lcao): reject symmetry with GPU EXX until upstream fix
Stardust0831 Nov 21, 2026
853b164
docs(lcao): clarify GPU EXX symmetry check after input resets
Stardust0831 Nov 21, 2026
af5c02d
build(libri): keep integration checks focused and link RI workspace t…
Stardust0831 Nov 21, 2026
5c4a7dd
test(io): cover effective symmetry in GPU EXX input reading
Stardust0831 Nov 21, 2026
b36ba5d
docs(lcao): clarify CPU exchange scope for LR geometry reuse
Stardust0831 Nov 21, 2026
6dd58cf
test(io): migrate serial reader coverage into unittests
Stardust0831 Nov 21, 2026
e56d5c3
Merge develop into experiment/lcao-hse-gpu
Stardust0831 Nov 23, 2026
fa1c75d
fix(lcao): enable GPU EXX symmetry with released LibRI
Stardust0831 Nov 23, 2026
e47e269
build: use DDLA 0.0.7 with C++14 GPU RI consumers
Stardust0831 Nov 23, 2026
5425be4
docs: remove obsolete DDLA override note
Stardust0831 Nov 23, 2026
cd093c6
Merge branch 'develop' into experiment/lcao-hse-gpu
mohanchen Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ cmake_dependent_option(ENABLE_ELPA "Enable ELPA eigensolver" ON "ENABLE_MPI"
OFF)
cmake_dependent_option(ENABLE_LIBRI "Enable LibRI for hybrid functional" OFF
"ENABLE_LCAO;ENABLE_MPI" OFF)
cmake_dependent_option(
ENABLE_LIBRI_GPU "Enable experimental LibRI CUDA contractions through DDLA"
OFF "ENABLE_LIBRI;USE_CUDA" OFF)
cmake_dependent_option(ENABLE_PEXSI "Enable PEXSI for LCAO" OFF
"ENABLE_LCAO;ENABLE_MPI" OFF)
cmake_dependent_option(ENABLE_MLALGO "Enable the machine learning algorithms"
Expand Down Expand Up @@ -580,8 +583,6 @@ endfunction()
if(ENABLE_LIBRI)
set_if_higher(CMAKE_CXX_STANDARD 14)
find_package(LibRI REQUIRED)
find_package(LibComm REQUIRED)
find_package(cereal REQUIRED CONFIG)
endif()

if(ENABLE_LIBXC)
Expand Down
2 changes: 2 additions & 0 deletions cmake/CollectBuildInfoVars.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ list(APPEND CMAKE_OPTIONS_LIST " USE_ROCM=${USE_ROCM}")
list(APPEND CMAKE_OPTIONS_LIST " ENABLE_LCAO=${ENABLE_LCAO}")
list(APPEND CMAKE_OPTIONS_LIST " ENABLE_ELPA=${ENABLE_ELPA}")
list(APPEND CMAKE_OPTIONS_LIST " ENABLE_LIBXC=${ENABLE_LIBXC}")
list(APPEND CMAKE_OPTIONS_LIST " ENABLE_LIBRI_GPU=${ENABLE_LIBRI_GPU}")
list(APPEND CMAKE_OPTIONS_LIST " ENABLE_MLALGO=${ENABLE_MLALGO}")
list(APPEND CMAKE_OPTIONS_LIST " ENABLE_ASAN=${ENABLE_ASAN}")
list(APPEND CMAKE_OPTIONS_LIST " BUILD_TESTING=${BUILD_TESTING}")
Expand Down Expand Up @@ -477,6 +478,7 @@ message(" DeePMD = ${ABACUS_DEEPMD_VERSION}")
message(" NEP = ${ABACUS_NEP_VERSION}")
message(" Features : Libxc = ${ABACUS_LIBXC_VERSION}")
message(" LibRI = ${ABACUS_LIBRI_VERSION}")
message(" LibRI GPU = ${ENABLE_LIBRI_GPU}")
message(" DFT-D4 = ${ABACUS_DFTD4_VERSION}")
message(" JSON = ${ABACUS_JSON_VERSION}")
message(" PEXSI = ${ABACUS_PEXSI_VERSION}")
Expand Down
77 changes: 76 additions & 1 deletion cmake/modules/FindLibRI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# LIBRI_FOUND - True if LibRI is found.
# LIBRI_DIR - Where to find LibRI files.
# LibRI::LibRI - Header-only target, including optional DDLA requirements.

find_path(
LIBRI_DIR include/RI/version.h
Expand All @@ -12,6 +13,12 @@ find_path(
HINTS ${libri_DIR})

if(NOT LIBRI_DIR)
if(ENABLE_LIBRI_GPU)
message(
FATAL_ERROR
"ENABLE_LIBRI_GPU requires an explicitly supplied, compatible LIBRI_DIR; "
"see docs/advanced/install.md")
endif()
include(FetchContent)
FetchContent_Declare(
LibRI URL https://codeload.github.com/abacusmodeling/LibRI/tar.gz/b0eff7a)
Expand All @@ -23,5 +30,73 @@ endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibRI DEFAULT_MSG LIBRI_DIR)

# Copy the results to the output variables and target.
if(LibRI_FOUND AND NOT TARGET LibRI::LibRI)
find_package(LibComm REQUIRED)
find_package(cereal REQUIRED CONFIG)

add_library(LibRI::LibRI INTERFACE IMPORTED)
set_target_properties(
LibRI::LibRI
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${LIBRI_DIR}/include;${LIBCOMM_DIR}/include"
INTERFACE_COMPILE_FEATURES cxx_std_14
INTERFACE_LINK_LIBRARIES "MPI::MPI_CXX;cereal::cereal")
if(ENABLE_OPENMP)
target_link_libraries(LibRI::LibRI INTERFACE OpenMP::OpenMP_CXX)
endif()
# Reuse ABACUS's selected math backend. Special platforms without these
# targets retain their existing numerical libraries in the final link.
foreach(_libri_math_target IN ITEMS LAPACK::LAPACK BLAS::BLAS)
if(TARGET ${_libri_math_target})
target_link_libraries(LibRI::LibRI INTERFACE ${_libri_math_target})
endif()
endforeach()

if(ENABLE_LIBRI_GPU)
find_package(LibDDLA 0.0.7 CONFIG REQUIRED HINTS "${DDLA_ROOT}")
target_compile_definitions(LibRI::LibRI INTERFACE __GPU_RI __DDLA_RI)
target_link_libraries(LibRI::LibRI INTERFACE ddla::ddla)

include(CMakePushCheckState)
include(CheckCXXSourceCompiles)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_LIBRARIES LibRI::LibRI)
# Recheck when users update dependency sources or installation paths.
unset(LIBRI_GPU_API_WORKS CACHE)
check_cxx_source_compiles(
[=[
#include <complex>
#include <RI/version.h>
#if __LIBRI_VERSION < 30000
#error "LibRI GPU requires LibRI v0.3.0.0 or newer"
#endif
#include <RI/ri/LRI.h>
#if !DDLA_HAS_GPU
#error "LibRI GPU requires DDLA's public GPU API"
#endif
template <typename T> void check_gpu()
{
RI::LRI<int, int, 3, T> lri;
lri.cal_mode = RI::LRI_Cal_Mode::GPU;
std::map<int, std::map<std::pair<int, std::array<int, 3>>, RI::Tensor<T>>> result;
lri.cal_loop3({}, result, 1.0);
}
int main()
{
check_gpu<double>();
check_gpu<std::complex<double>>();
}
]=]
LIBRI_GPU_API_WORKS)
cmake_pop_check_state()
if(NOT LIBRI_GPU_API_WORKS)
message(
FATAL_ERROR
"LibRI/DDLA GPU compile/link check failed. Supply compatible "
"LibRI v0.3.0.0 or newer and CUDA DDLA v0.0.7 or newer; see docs/advanced/install.md "
"and the CMake configure log.")
endif()
endif()
endif()

mark_as_advanced(LIBRI_DIR)
10 changes: 5 additions & 5 deletions cmake/modules/FindMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ if(MKL_FOUND)
set(_mkl_base_archives ${MKL_INTERFACE_LIB} ${MKL_THREAD} ${MKL_CORE})
_mkl_link_group(_mkl_base ${_mkl_base_archives})

add_library(abacus_mkl INTERFACE)
add_library(abacus::mkl ALIAS abacus_mkl)
target_include_directories(abacus_mkl INTERFACE "${MKL_INCLUDE}"
"${MKL_FFTW_INCLUDE}")
target_link_libraries(abacus_mkl INTERFACE ${_mkl_base} ${_mkl_runtime})
# Imported interfaces also propagate into dependency compile/link probes.
add_library(abacus::mkl INTERFACE IMPORTED GLOBAL)
target_include_directories(abacus::mkl INTERFACE "${MKL_INCLUDE}"
"${MKL_FFTW_INCLUDE}")
target_link_libraries(abacus::mkl INTERFACE ${_mkl_base} ${_mkl_runtime})

if(ENABLE_MPI)
add_library(abacus_mkl_scalapack INTERFACE)
Expand Down
54 changes: 54 additions & 0 deletions docs/advanced/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,60 @@ The new EXX implementation directly depends on [LibRI](https://github.com/abacus
`ENABLE_LIBCOMM` is deprecated because LibComm is not a standalone ABACUS feature. CMake locates it automatically as a dependency of LibRI. If you prefer using manually downloaded libraries, enable LibRI and provide their locations via `-DLIBRI_DIR=/path/to/LibRI` and `-DLIBCOMM_DIR=/path/to/LibComm`.
```

Experimental LCAO GPU contractions additionally require `ENABLE_LIBRI_GPU=ON`
(default OFF), `USE_CUDA=ON`, LibRI v0.3.0.0 or newer, and a CUDA
build of DDLA v0.0.7 or newer. Like other dependent
options, GPU RI is disabled when its LibRI/CUDA prerequisites are disabled.
INPUT `device_exx` defaults to `cpu`, retaining CPU contractions even with
`device gpu`. To use GPU contractions, set both `device gpu` and `device_exx gpu`.
The latter requires GPU RI to be compiled in. GPU contractions support
`symmetry 1`, including real-space EXX reduction with
`exx_symmetry_realspace 1`.

The selector applies to the LCAO Kohn-Sham exchange engine. LR and RDMFT exchange
engines retain CPU contractions, including when LR reuses Kohn-Sham exchange
geometry.

All MPI ranks on a node must see the same allocated
GPU list, with at least as many visible GPUs as local ranks. Giving each rank its
own single-GPU `CUDA_VISIBLE_DEVICES` list fails LibRI's GPU-count check when
multiple ranks share a node. For example, on one node allocated GPUs 0 and 1:

```bash
CUDA_VISIBLE_DEVICES=0,1 mpirun -np 2 abacus
```

[LibRI v0.3.0.0](https://github.com/abacusmodeling/LibRI/releases/tag/v0.3.0.0)
is the minimum GPU release. Use the release tagged at
`589f6f8c6df3916575a1ba41e840de919d40d345` or a newer compatible release;
it includes the GPU symmetry, accumulation, OpenMP, atom-list and DDLA adapter
fixes. Earlier LibRI versions remain usable for CPU RI.

Use [DDLA v0.0.7](https://github.com/userchba/LibDDLA/releases/tag/v0.0.7)
or a newer compatible release, built with CUDA support. ABACUS consumes its
installed `LibDDLAConfig.cmake` package, `ddla::ddla` target and public
`DDLA_HAS_GPU` capability. Building DDLA itself requires C++17; ABACUS with
either CPU or GPU RI requires C++14.
GPU mode requires an explicitly supplied, compatible LibRI installation;
the default CPU dependency download is unchanged.

```bash
cmake -B build -DENABLE_LIBRI=ON -DUSE_CUDA=ON -DENABLE_LIBRI_GPU=ON \
-DLIBRI_DIR=/path/to/LibRI -DDDLA_ROOT=/path/to/DDLA
```

`CMAKE_PREFIX_PATH` can also name the DDLA installation prefix, or `LibDDLA_DIR`
can point to the directory containing `LibDDLAConfig.cmake`. The package supplies
DDLA's include paths, backend definitions and link dependencies.
A configure-time compile/link check
rejects incompatible GPU APIs, but does not validate numerical correctness.
The standalone consumer in `tests/lcao_hse_gpu/cmake` checks that `LibRI::LibRI`
provides its compile and link dependencies with `ENABLE_LIBRI_GPU=OFF` or `ON`.
Numerical contraction regressions belong to LibRI's upstream tests; ABACUS HSE
comparisons validate application-level results.
This experimental backend has additional GPU memory requirements; its temporary
buffer limit is not a bound on total GPU memory.

## Build with DFT-D4 support

ABACUS can use the external [DFT-D4](https://github.com/dftd4/dftd4) library for Grimme's DFT-D4 dispersion correction. DFT-D4 support is optional and disabled by default.
Expand Down
9 changes: 3 additions & 6 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ set(_abacus_feature_libs
$<$<BOOL:${ENABLE_PEXSI}>:PEXSI::PEXSI>
$<$<BOOL:${ENABLE_CNPY}>:cnpy>
$<$<BOOL:${ENABLE_CNPY}>:ZLIB::ZLIB>
$<$<BOOL:${ENABLE_LIBRI}>:cereal::cereal>
$<$<BOOL:${ENABLE_LIBRI}>:LibRI::LibRI>
$<$<BOOL:${ENABLE_LIBXC}>:Libxc::xc>
$<$<BOOL:${ENABLE_PLUMED}>:PLUMED::plumed>
$<$<BOOL:${ENABLE_NEP}>:nep::nep_cpu>)
Expand Down Expand Up @@ -326,11 +326,6 @@ if(ENABLE_CNPY)
endif()
endif()

if(ENABLE_LIBRI)
list(APPEND _abacus_feature_include_dirs ${LIBRI_DIR}/include
${LIBCOMM_DIR}/include)
endif()

if(DEFINED DeePMD_DIR)
if(DeePMDC_FOUND)
list(APPEND _abacus_feature_libs DeePMD::deepmd_c)
Expand Down Expand Up @@ -413,6 +408,8 @@ target_compile_options(abacus_compile_requirements
foreach(
_abacus_feature_target IN
ITEMS nlohmann_json::nlohmann_json
LibRI::LibRI
Comment thread
Stardust0831 marked this conversation as resolved.
Resolved
ddla::ddla
cereal::cereal
ELPA::ELPA
Libxc::xc
Expand Down
1 change: 1 addition & 0 deletions source/source_io/module_parameter/input_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ struct Input_para
///< the evaluation of Fock exchange
double exx_mixing_beta = 1.0; ///< mixing_beta for outer-loop when exx_separate_loop=1
std::string exx_real_number = "default"; ///< exx calculated in real or complex
std::string device_exx = "cpu"; ///< computing device for LCAO EXX tensor contractions
double exx_pca_threshold = 0.0001; ///< threshold to screen on-site ABFs in exx
double exx_c_threshold = 0.0001; ///< threshold to screen C matrix in exx
double exx_v_threshold = 0.1; ///< threshold to screen C matrix in exx
Expand Down
37 changes: 36 additions & 1 deletion source/source_io/module_parameter/read_inp_exx_dftu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,40 @@ void ReadInput::item_exx()
sync_stringvec(input.exx_fock_lambda, para.input.exx_fock_lambda.size(), "");
this->add_item(item);
}
{
Input_Item item("device_exx");
item.annotation = "computing device for LCAO EXX tensor contractions";
item.category = "Exact Exchange (LCAO)";
item.type = "String";
item.description = R"(Selects the LibRI tensor-contraction device for LCAO Kohn-Sham exact exchange.
* cpu: retain CPU contractions, including when device=gpu.
* gpu: use the experimental GPU backend; requires ENABLE_LIBRI_GPU=ON and device=gpu.
LR and RDMFT exchange engines retain CPU contractions, including when LR reuses
Kohn-Sham exchange geometry.
For GPU contractions, all MPI ranks on a node must see the same allocated GPU
list, with at least as many visible GPUs as local ranks; per-rank single-GPU
masking is unsupported.)";
item.default_value = "cpu";
item.set_availability("basis_type==lcao");
read_sync_string(input.device_exx);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.device_exx != "cpu" && para.input.device_exx != "gpu")
{
ModuleBase::WARNING_QUIT("ReadInput", "device_exx must be cpu or gpu");
}
if (para.input.device_exx == "gpu")
{
if (para.input.basis_type != "lcao" || para.input.device != "gpu")
{
ModuleBase::WARNING_QUIT("ReadInput", "device_exx=gpu requires basis_type=lcao and device=gpu");
}
#ifndef __GPU_RI
ModuleBase::WARNING_QUIT("ReadInput", "device_exx=gpu requires a build with ENABLE_LIBRI_GPU=ON");
#endif
}
};
this->add_item(item);
}
{
Input_Item item("exx_pca_threshold");
item.annotation = "threshold to screen on-site ABFs in exx";
Expand Down Expand Up @@ -611,7 +645,8 @@ Use the same scheme for consistent SCF and NSCF bands. A source configuration mi
item.annotation = "whether to reduce real-space sector in Hexx calculation";
item.category = "Exact Exchange (LCAO)";
item.type = "Boolean";
item.description = R"(* False: only rotate k-space density matrix D(k) from irreducible k-points to accelerate diagonalization
item.description =
R"(* False: only rotate k-space density matrix D(k) from irreducible k-points to accelerate diagonalization
* True: rotate both D(k) and Hexx(R) to accelerate both diagonalization and EXX calculation
For multi-k calculations, D(k) is averaged over the unitary little group of each irreducible k point before star expansion, for either setting.)";
item.default_value = "True";
Expand Down
2 changes: 1 addition & 1 deletion source/source_io/test_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abacus_copy_test_files(support)
addtest(
TARGET MODULE_IO_read_input_serial
LIBS parameter io_input_serial
SOURCES read_input_test.cpp ../../source_base/test/tool_quit_no_exit.cpp
SOURCES ../../source_base/test/tool_quit_no_exit.cpp
../../source_base/module_device/device.cpp
../../source_base/module_device/output_device.cpp)

Expand Down
24 changes: 20 additions & 4 deletions source/source_io/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ abacus_disable_feature_definitions(__CUDA)
abacus_disable_feature_definitions(__ROCM)
abacus_disable_feature_definitions(__EXX)

# Keep the existing serial INPUT target and its compile definitions.
target_sources(MODULE_IO_read_input_serial PRIVATE test_read_input_serial.cpp)
target_sources(MODULE_IO_read_item_serial PRIVATE test_read_inp_exx_dftu.cpp)

if(ENABLE_LIBRI_GPU)
# Exercise the real device probe while keeping DeviceContext free of MPI.
set_property(
SOURCE ${PROJECT_SOURCE_DIR}/source/source_base/module_device/device.cpp
TARGET_DIRECTORY MODULE_IO_read_input_serial
APPEND
PROPERTY COMPILE_DEFINITIONS __CUDA)
target_link_libraries(MODULE_IO_read_input_serial PRIVATE CUDA::cudart)
endif()

addtest(
TARGET MODULE_IO_write_bands
LIBS parameter base device symmetry
Expand Down Expand Up @@ -34,7 +48,8 @@ if(NOT ENABLE_MPI)
endif()

add_executable(
MODULE_IO_input_error_mpi test_read_input.cpp
MODULE_IO_input_error_mpi
test_read_input.cpp
# io_input references stru_frame_io::extract_last_frame without linking cell.
../../source_cell/stru_frame_io.cpp)
target_link_libraries(
Expand Down Expand Up @@ -84,9 +99,10 @@ abacus_copy_test_files(support INPUTs)
addtest(
TARGET MODULE_IO_input_test_para
LIBS parameter base device io_input
SOURCES test_read_input_parallel.cpp
# io_input references stru_frame_io::extract_last_frame without linking cell.
../../source_cell/stru_frame_io.cpp)
SOURCES
test_read_input_parallel.cpp
# io_input references stru_frame_io::extract_last_frame without linking cell.
../../source_cell/stru_frame_io.cpp)

add_test(
NAME MODULE_IO_input_test_para_4
Expand Down
Loading
Loading