Skip to content

Fix: add EXX erfc parameter handling for pw basis type#7166

Merged
mohanchen merged 7 commits intodeepmodeling:developfrom
Flying-dragon-boxing:260328-exx-hse-default
Apr 5, 2026
Merged

Fix: add EXX erfc parameter handling for pw basis type#7166
mohanchen merged 7 commits intodeepmodeling:developfrom
Flying-dragon-boxing:260328-exx-hse-default

Conversation

@Flying-dragon-boxing
Copy link
Copy Markdown
Collaborator

@Flying-dragon-boxing Flying-dragon-boxing commented Mar 28, 2026

Summary
Fix the issue where HSE EXX calculation is broken by #7019 with "trtri: failed to invert matrix" error when using basis_type = pw.
Problem
When using HSE functional with basis_type = pw, the exx_erfc_alpha parameter is not being properly set in coulomb_param, causing:

  • pot (exchange potential) to be all zeros
  • L_ace matrix to be all zeros
  • trtri lapack call to fail when trying to invert

Root Cause
In input_conv.cpp, the handling for exx_erfc_alpha was only implemented for basis_type == "lcao", missing the pw and lcao_in_pw cases.

HSE CI/CD is also required.

Flying-dragon-boxing and others added 6 commits March 28, 2026 10:56
Add runtime check (PARAM.inp.device == "gpu") before calling
cudaHostRegister and cudaHostUnregister to avoid failures when
CUDA is enabled but running on CPU device (e.g., on clusters with
both CPU and GPU nodes but only compiling once).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes HSE exact-exchange (EXX) failures when running with basis_type=pw by ensuring ERFC (screened exchange) parameters are propagated into GlobalC::exx_info.info_global.coulomb_param, and includes a small PW EXX potential buffer handling correction.

Changes:

  • Add ERFC (exx_erfc_alpha / exx_erfc_omega) coulomb_param initialization for basis_type=pw and basis_type=lcao_in_pw.
  • In PW EXX potential routines, only pin host memory when device=gpu and fix array deallocation (delete[]).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
source/source_pw/module_pwdft/op_pw_exx_pot.cpp Guards CUDA host-memory pinning by device=gpu and corrects deallocation for pot_cpu.
source/source_io/module_parameter/input_conv.cpp Extends ERFC Coulomb parameter conversion to PW / LCAO-in-PW basis types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@mohanchen mohanchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mohanchen mohanchen added EXX and lr-TDDFT Related to EXX or lr-TDDFT Refactor Refactor ABACUS codes labels Mar 28, 2026
@Flying-dragon-boxing Flying-dragon-boxing marked this pull request as ready for review April 3, 2026 06:18
@mohanchen mohanchen merged commit b9cfd1e into deepmodeling:develop Apr 5, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

EXX and lr-TDDFT Related to EXX or lr-TDDFT Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants