Skip to content

Fix(PW): avoid GPU crash in Wannier90 output - #7801

Closed
CleverPhysician wants to merge 1 commit into
deepmodeling:developfrom
CleverPhysician:fix/pw-gpu-wannier90-segfault
Closed

Fix(PW): avoid GPU crash in Wannier90 output#7801
CleverPhysician wants to merge 1 commit into
deepmodeling:developfrom
CleverPhysician:fix/pw-gpu-wannier90-segfault

Conversation

@CleverPhysician

Copy link
Copy Markdown

Summary

  • Fix the PW-GPU crash in the post-NSCF Wannier90 MMN calculation.
  • Keep the existing CPU behavior and Wannier90 formulas unchanged.
  • Enable 100_PW_W90 in the existing 01_PW GPU regression list.

Root cause

toWannier90_PW::unkdotkb() operated on valid host-side wave functions, but called the CPU-style PW_Basis_K::recip2real() interface. In a CUDA build, the basis owns an FFT_CUDA backend, which implements the device-aware 3D FFT interface but not the CPU auxiliary-buffer interface. The first CPU-style auxiliary-buffer dispatch therefore reached an unresolved weak virtual slot and jumped to address 0x0. This occurs only after the NSCF calculation has completed, when Wannier90 starts constructing the MMN matrix.

Changes

  • Pass the selected FFT backend into the PW Wannier90 object.
  • Add a small RAII staging helper for the MMN calculation:
    • CPU builds continue to call the existing CPU FFT functions directly.
    • GPU builds reuse two device buffers and ABACUS memory synchronization operators around the existing device-aware recip_to_real() and real_to_recip() interfaces.
  • Keep the LCAO-in-PW caller on its previous CPU FFT path.
  • Uncomment the existing 100_PW_W90 GPU case; no new input or reference data is added.

Verification

  • Baseline, Slurm job 213795 on RTX 4090:
    • CPU 100_PW_W90: passed all 5 checks.
    • GPU run 1: exit 139.
    • GPU run 2: exit 139.
    • GDB: null indirect call from PW_Basis_K::recip2real<double>(), called by toWannier90_PW::unkdotkb().
  • Final CPU/GPU integration run, Slurm job 213879, OMP_NUM_THREADS=1, one MPI rank:
    • CPU 100_PW_W90: passed all 5 existing checks.
    • CUDA 100_PW_W90: passed all 5 existing checks.
    • Existing AMN/MMN/EIG references and comparison settings were not changed.
    • GPU NSCF control with towannier90=0: exit 0.
  • CUDA Compute Sanitizer, Slurm job 213880:
    • exit 0;
    • ERROR SUMMARY: 0 errors.
  • LCAO-enabled io_advanced compile target, Slurm job 213874: passed.
  • git diff --check: passed.
  • ABACUS agent-governance check: passed with only the expected no-documentation warning.

Behavior change

PW-GPU Wannier90 MMN output now uses the FFT interface matching the CUDA backend instead of crashing. The synchronization and two temporary device buffers exist only during post-NSCF Wannier90 MMN output; the SCF/NSCF iteration path is unchanged.

INPUT/documentation impact

None. No INPUT keyword, meaning, default, reference result, or tolerance is changed.

Core-module impact

None. No wave-function, FFT, device-memory, solver, or physics implementation is modified; the fix is confined to the Wannier90 I/O boundary and its call site.

Fixes part of #7770

@mohanchen mohanchen added the GPU & DCU & HPC GPU and DCU and HPC related any issues label Aug 11, 2026
@mohanchen

Copy link
Copy Markdown
Collaborator

It seems to make things more complicated, we provide FFT interfaces for both CPU and GPU, you don't need to define new ones. Please submit new PRs if you have better solutions.

@mohanchen mohanchen closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GPU & DCU & HPC GPU and DCU and HPC related any issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants