Skip to content

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

Description

@chengleizheng

Describe the bug

When KPAR > NPROC, ABACUS crashes with "Number of processes must be greater than the number of groups". A KPAR auto-adjustment exists in read_input_item_system.cpp but is guarded by para.input.device == "gpu", which is never true at the time the callback runs — because device's own reset_value callback (which resolves auto→gpu) executes after kpar's callback due to registration order.

Affected tests: 007, 026, 052, 063, 087, 088, 089, scf_out_chg_tau

026:

Error: Number of processes (1) must be greater than the number of groups (2).

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

 Number of processes must be greater than the number of groups.
 CHECK IN FILE : OUT.autotest/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!
 ---------------------------------------------------------

Expected behavior

ABACUS should auto-adjust KPAR <= NPROC, instead of crashing with "Number of processes must be greater than the number of groups".

To Reproduce

Case A: Clean rebuild from scratch

cmake -B build -DUSE_CUDA=1 -DCUDA_SEPARABLE_COMPILATION=OFF \
-DCMAKE_CUDA_FLAGS="--static-global-template-stub=false"
cd build && make -j`nproc`
cd tests/01_PW/026_PW_KPAR/ && /build/abacus_basic_gpu

Case B: Reuse precompiled binary (skip rebuild)

cd build && make -j$(nproc) abacus_basic_gpu
cd tests/01_PW/026_PW_KPAR/ && /build/abacus_basic_gpu

Environment

  • ABACUS v3.11.0-beta.6 (GPU build with -DUSE_CUDA=ON)
  • NVIDIA RTX 4060 Laptop GPU, CUDA 13.1
  • Intel(R) Core(TM) i9-14900HX

Additional Context

No response

Task list for Issue attackers (only for developers)

  • Verify the issue is not a duplicate.
  • Describe the bug.
  • Steps to reproduce.
  • Expected behavior.
  • Error message.
  • Environment details.
  • Additional context.
  • Assign a priority level (low, medium, high, urgent).
  • Assign the issue to a team member.
  • Label the issue with relevant tags.
  • Identify possible related issues.
  • Create a unit test or automated test to reproduce the bug (if applicable).
  • Fix the bug.
  • Test the fix.
  • Update documentation (if necessary).
  • Close the issue and inform the reporter (if applicable).

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugsBugs that only solvable with sufficient knowledge of DFTGPU & DCU & HPCGPU and DCU and HPC related any issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions