Skip to content

Fix kpar auto-adjustment for PW basis - #7723

Open
chengleizheng wants to merge 3 commits into
deepmodeling:developfrom
chengleizheng:fix/kpar-gpu
Open

Fix kpar auto-adjustment for PW basis#7723
chengleizheng wants to merge 3 commits into
deepmodeling:developfrom
chengleizheng:fix/kpar-gpu

Conversation

@chengleizheng

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

Fix #7722

Case Tests for my changes

Commands run:

  cd tests/01_PW/026_PW_KPAR
  echo "device    gpu" >> INPUT
  cd .. 
  bash ../integrate/Autotest.sh -n 1 -a /home/chenglei/abacus-develop/build/abacus_basic_gpu -f <(echo "026_PW_KPAR/")

Result summary:

Before fix:

-----AUTO TESTS OF ABACUS ------
ABACUS path: /home/chenglei/abacus-develop/build/abacus_basic_gpu
Number of processes: 1
Number of threads: 32
Test accuracy totenergy: 0.0000001 eV
Test accuracy force: 0.0001
Test accuracy stress: 0.001
Test accuracy descriptor mean: 0.00001
Check accuaracy: 8
Test cases file: /dev/fd/63
Test cases regex: ^[^#].*_.*$
Generate reference:
--------------------------------

[ RUN      ] 026_PW_KPAR/
--------------------------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[50287,1],0]
  Exit code:    1
--------------------------------------------------------------------------
[ERROR     ] 026_PW_KPAR/ failed.

                     ▄████▄ █████▄ ▄████▄ ▄█████ ██  ██ ▄█████
                     ██▄▄██ ██▄▄██ ██▄▄██ ██     ██  ██ ▀▀▀▄▄▄
                     ██  ██ ██▄▄█▀ ██  ██ ▀█████ ▀████▀ █████▀


                                v3.11.0-beta7

               Atomic-orbital Based Ab-initio Computation at UStc

                     Website: http://abacus.ustc.edu.cn/
               Documentation: https://abacus.deepmodeling.com/
                  Repository: https://github.com/abacusmodeling/abacus-develop
                              https://github.com/deepmodeling/abacus-develop
                      Commit: 7ba39dd18 (Thu Jul 30 13:17:17 2026 +0800)

 Fri Jul 31 17:22:17 2026

 ---------------------------------------------------------
                         !NOTICE!
 ---------------------------------------------------------

 The parameter device has been read twice.
 CHECK IN FILE : warning.log

 For detailed manual of ABACUS, please see the website
 https://abacus.deepmodeling.com
 For any questions, propose issues on the website
 https://github.com/deepmodeling/abacus-develop/issues
 ---------------------------------------------------------
                         !NOTICE!
 ---------------------------------------------------------

 TIME STATISTICS
-----------------------------------------------------
 CLASS_NAME    NAME    TIME/s  CALLS   AVG/s  PER/%
-----------------------------------------------------
            total      0.00   1        0.00   100.00
-----------------------------------------------------

 See output information in :
[----------] Time elapsed: 3.033 seconds

[WARNING]    1 test cases out of 1 failed.
026_PW_KPAR/

After fix:

  -----AUTO TESTS OF ABACUS ------
  ABACUS path: /home/chenglei/abacus-develop/build/abacus_basic_gpu
  Number of processes: 1
  Number of threads: 32
  Test accuracy totenergy: 0.0000001 eV
  Test accuracy force: 0.0001
  Test accuracy stress: 0.001
  Test accuracy descriptor mean: 0.00001
  Check accuaracy: 8
  Test cases file: /dev/fd/63
  Test cases regex: ^[^#].*_.*$
  Generate reference:
  --------------------------------
  
[ RUN      ] 026_PW_KPAR/
  [----------] test parallel method kpar. Must be run by MPI with at least 2 cores, otherwise please ignore this test.
  [      OK  ]  etotref
  [      OK  ]  etotperatomref
  [      OK  ]  pointgroupref
  [      OK  ]  spacegroupref
  [      OK  ]  nksibzref
  [----------] Time elapsed: 3.715 seconds
  
[ PASSED   ]  5 test cases passed.

with warning, runs normally.

Additional context

Although I solve the kpar related problems, 007_PW_UPF201_USPP_Fe, 063_PW_CR and scf_out_chg_tau​ cases still have other issues.

What's changed?

Fixed KPAR auto-adjustment that was broken due to reset_value callback ordering. Previously the check para.input.device == "gpu" in kpar's callback always evaluated to false because device's own callback (which resolves auto→gpu) runs later in the registration order. Removed the #if defined(__CUDA) guard and device == "gpu" check — the auto-adjust is now unconditional for PW basis.

Governance Notes

  • INPUT/docs changes: None. KPAR behavior unchanged when NPROC matches; only affects the error case where KPAR > NPROC.
  • Core module impact: read_input_item_system.cpp — input parameter post-processing only.
  • Exceptions requested: None.

@chengleizheng chengleizheng added Bugs Bugs that only solvable with sufficient knowledge of DFT GPU & DCU & HPC GPU and DCU and HPC related any issues labels Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT GPU & DCU & HPC GPU and DCU and HPC related any issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KPAR auto-adjustment fails when device parameter is not explicitly set in INPUT

1 participant