Repository navigation
feat(lcao): add optional LibRI GPU contractions through DDLA - #8169
Stardust0831 wants to merge 12 commits into
Conversation
|
the LibDDLA version which is compatible with LibRI GPU is https://github.com/userchba/LibDDLA/releases/tag/v0.0.4, current LibRI GPU can't correctly compute symmetry situation which LibRI CPU can compute correctly |
ABACUS-PR-BOT
left a comment
There was a problem hiding this comment.
Static review of f07d8d14f39d26782490cc4bc15d0a58c5700e62 with independent source review and adjudication. No build/runtime/MPI/GPU tests were run; CI diagnostics were unavailable.
| (default OFF), `USE_CUDA=ON`, and a CUDA build of DDLA. Like other dependent | ||
| options, GPU RI is disabled when its LibRI/CUDA prerequisites are disabled. | ||
| INPUT `exx_device` defaults to `cpu`, retaining CPU contractions even with | ||
| `device gpu`. To use GPU contractions, set both `device gpu` and `exx_device gpu`. |
There was a problem hiding this comment.
[P2] State the GPU visibility requirement for MPI runs
For two ranks on one node, exposing one different GPU per rank through CUDA_VISIBLE_DEVICES passes ABACUS device setup but makes the pinned LibRI validate_local_gpu_count() throw at the first GPU contraction (local_size=2 > device_count=1). This backend therefore requires each process to see at least as many GPUs as there are node-local ranks, a constraint missing here. Please document it with a compatible launch layout, or extend the compatibility patch to respect the existing per-rank binding.
| Exx_Info& exx_info) | ||
| { | ||
| #ifdef __EXX | ||
| const bool use_gpu = inp.exx_device == "gpu"; |
There was a problem hiding this comment.
Non-blocking: Please clarify the selector's scope for independent LR/RDMFT exchange engines. Standalone LR, fresh LR-kernel setup after KS, and RDMFT construct their own Exx_LRI objects, which retain CPU mode despite accepted exx_device=gpu; matching-kernel KS pointer reuse retains GPU mode. If those engines are in scope, pass the selection to them; otherwise document or reject the unsupported combinations. A follow-up after merge is fine for these additional workflows.
| { | ||
| return 1; | ||
| } | ||
| lri.cal_mode = RI::LRI_Cal_Mode::GPU; |
There was a problem hiding this comment.
Non-blocking: Consider an opt-in numerical regression for the patch's signed accumulation in a follow-up after merge. This consumer switches cal_mode but then executes only CPU nrm2, and the configure probe only compiles/links. Alongside the reported force/stress runs, a tiny real/complex CPU-versus-GPU case with nonempty output and repeated +1/-1 contractions would preserve the specific accumulation fix across dependency updates.
What's changed?
Add
ENABLE_LIBRI_GPU(default OFF) and INPUTexx_device(defaultcpu) for optional LCAO exact-exchange contractions through LibRI's DDLA CUDA backend. With GPU RI compiled in, setdevice gpuandexx_device gputo use it. Omittingexx_deviceor setting it tocpuretains CPU RI and GPU solvers in the same executable.LibRI::LibRIandDDLA::DDLAimported targets with transitive dependencies and compile/link checks for real and complex GPU contractions. Make the base MKL target importable by these checks.symmetry=1andexx_symmetry_realspace=true). Withsymmetry=1, use CPU RI or setexx_symmetry_realspace=0.exx_deviceand the shared GPU visibility required by the pinned LibRI backend. Independent LR/RDMFT exchange objects retain CPU mode; LR inherits the selected backend only when it reuses the Kohn-Sham object.docs/advanced/install.md.GPU mode requires LibRI
6ce3c84withtests/lcao_hse_gpu/libri-compat.patchand a CUDA build of DDLAv0.0.4(9c404ac), located throughDDLA_ROOTorCMAKE_PREFIX_PATH. The patch fixes API mismatches and output accumulation needed for correct forces and stress.Unit Tests and/or Case Tests for my changes
Validation used SAI V100 GPUs and
OMP_NUM_THREADS=1.63ca5ef0763ca5ef0763ca5ef0763ca5ef07--check-inputf07d8d14ff07d8d14ff07d8d14ff07d8d14f--version,-h exx_device, generated parameter metadata and--check-inputd8d32046fd8d32046fVerification commands
For the full GPU build and input-test builds (the incremental rebuild used
--parallel 8):From copies of
tests/08_RI, using the existing references:Variants cover
device cpu,device gpuwith the default EXX backend, and explicitexx_device cpu|gpu. Solver selections arescalapack_gvxandcusolver, respectively. Symmetry cases exercise CPU RI with real-space symmetry enabled and CPU/GPU RI with it disabled. Gamma and symmetry cases check energy, forces and stress; complex multi-k checks energy. The two-rank run uses the complex multi-k case.Standalone dependency checks use the following command. Add
-DENABLE_LIBRI_GPU_TESTS=ONto enable the numerical test, which requires one GPU and MPI. The default consumer test needs no GPU hardware.The numerical regression was run with
OMP_NUM_THREADS=1andctest --test-dir build-consumer -V -R '^libri_gpu_accumulation$'. Its CPU reference and GPU result are checked after each factor in-1, +1, +1, -1. The negative control keeps the API fixes but restores the 18 original download destinations; the same test must then fail with an accumulation mismatch.CPU variants disable GPU RI and DDLA discovery. MKL variants additionally set
MKL_ROOT,MKL_MPI=openmpi, andMKL_LINK=staticordynamic.The GPU regression build uses
ENABLE_NCCL_PARALLEL_DEVICE=OFF: the input-test target had unresolved NCCL symbols with it enabled. NCCL runtime behavior was not verified. GPU memory use increases, and prior single-node multi-GPU tests reduce per-GPU usage without establishing ideal memory scaling. Initialization remains largely on CPU. A Si32 comparison needed explicitscf_ene_thr=1e-8for consistent outer-loop stopping. Default-threshold convergence, full MKL application builds, multi-node execution, SOC and long MD runs need further validation; the backend remains experimental.Follow-up
Add DDLA installation to the existing
toolchain/scripts/workflow, including pinned versions, checksums, CUDA builds and support for existing installations.Linked Issue
No linked issue; this adds optional support for an existing LibRI backend.
Governance Notes
exx_device=cpu|gpu, defaultcpu, with help metadata, installation documentation and focused input tests. Generated parameter documentation is not committed.Contribution checklist
AGENTS.mdanddocs/developers_guide/agent_governance.md.source/changes.