Skip to content

Hotfix (CUDA CI failures): Make plane-wave wavefunction checks phase invariant and align complex cuBLAS scalars - #8372

Merged
mohanchen merged 2 commits into
deepmodeling:developfrom
AsTonyshment:fix/scf_out_wf
Nov 24, 2026
Merged

mohanchen merged 2 commits into
deepmodeling:developfrom
AsTonyshment:fix/scf_out_wf

Conversation

@AsTonyshment

@AsTonyshment AsTonyshment commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Linked Issue

Fixes #8153.

What's Changed?

1. scf_out_wf failure

After #8357 switched the CI Docker image to Ubuntu 24.04, scf_out_wf started failing on GPU. The test compared the largest absolute value among the real and imaginary components of each band's wavefunction. A change in the band's overall phase can change that value even for the same physical state.

We now sort the plane-wave coefficients by G vector, check each band's norm, and use the same fingerprint as the cube tests, where the phase cancels in products of projections. We also shift one Si atom slightly so the six bands at Gamma are distinct and can be compared individually.

2. scf_deltaspin2 failure

With the newer cuBLAS in the same image, scf_deltaspin2 crashed in cublasZgemm during the on-site projection. The GEMM wrapper treated a host std::complex<double> as a cuDoubleComplex, whose 16-byte alignment requirement exceeds the 8-byte alignment of the C++ scalar on x86-64.

The cuBLAS (and cuBLASMp) wrappers now construct native CUDA scalars, and complex dot products use an aligned temporary when the device output address needs one. We also fix the single-precision complex matrix transpose, correct transpose and triangle flags in the CUDA wrappers, and preserve 64-bit strides in batched GEMV. Scalar einsum contractions now honor conjugation and apply both alpha and beta when updating an existing result.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The phase-invariant construction and paired G/coefficient sorting are consistent with the intended check. Focused collector regressions and reference-generation evidence would strengthen the validation.

Static source review at bc707a5; no build, collector test or CPU/GPU calculation was run, and the regenerated references and GPU band separation were not independently verified.

Comment thread tests/11_PW_GPU/scf_out_wf/result.ref Resolved
@AsTonyshment

Copy link
Copy Markdown
Collaborator Author

scf_deltaspin2 fails, this is weird.

@AsTonyshment

AsTonyshment commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

scf_deltaspin2 fails, this is weird.

The cuBLAS upgrade in the new Docker image exposed a bug in how ABACUS passes complex scalars to cublasZgemm without guaranteeing 16-byte alignment. I'm working on a fix.

I found that previously we ran into the same issue with cublasZgemv in #5497. PR #5763 fixed the GEMV calls, but GEMM and several other cuBLAS calls still use the same pointer cast.

@AsTonyshment AsTonyshment changed the title Test: Make plane-wave wavefunction checks phase invariant Hotfix (CUDA CI failures): Make plane-wave wavefunction checks phase invariant and align complex cuBLAS scalars Nov 24, 2026
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT GPU & DCU & HPC GPU and DCU and HPC related any issues Refactor Refactor ABACUS codes labels Nov 24, 2026
@mohanchen
mohanchen merged commit 456e608 into deepmodeling:develop Nov 24, 2026
24 checks passed
@AsTonyshment
AsTonyshment deleted the fix/scf_out_wf branch November 24, 2026 09:18
Shane-Sayoko added a commit to Shane-Sayoko/abacus-develop that referenced this pull request Nov 24, 2026
Include the upstream phase-invariant PW wavefunction regression from deepmodeling#8372.
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 Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests: scf_out_wf fails on GPU with phase-sensitive per-band coefficient references

3 participants