Fix GPU spinor density accumulation without magnetization - #7902
Merged
mohanchen merged 1 commit intoSep 3, 2026
Merged
Conversation
Collaborator
|
We should have tests to protect these features. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reminder
AGENTS.mdanddocs/developers_guide/agent_governance.md.source/changes.Linked Issue
Fix #7549
Issue validation
The kernel-level problem is reproducible on the current
developcommitc2fa3ac19539bd10817d66e99ac5ff1cfd2156ddwith an NVIDIA A800 and CUDA 12.9.A direct call to the GPU spinor-density kernel with
DOMAG=falseandDOMAG_Z=falseproduced:For the same initial density and wavefunctions, the CPU implementation preserves and accumulates scalar charge, giving
rho[0] = {2.0, 8.5}. The regression test added by this PR failed before the production fix with those exact CPU/GPU differences and passes afterward.The standard INPUT initialization currently makes this boolean combination unreachable for
nspin=4:noncolin=trueselects(DOMAG, DOMAG_Z)=(true,false), whilenoncolin=falseselects(false,true). Therefore this PR fixes a verified backend contract inconsistency and protects future/internal callers; it does not claim that a normal current INPUT case already reaches the affected branch.Unit Tests and/or Case Tests for my changes
PATH=/usr/local/cuda-12.9/bin:$PATH cmake -S . -B build-cuda-issue7549 -G Ninja -DUSE_CUDA=ON -DBUILD_TESTING=ON -DENABLE_FLOAT_FFTW=ON -DCMAKE_CUDA_ARCHITECTURES=80 -DFETCHCONTENT_FULLY_DISCONNECTED=ONPATH=/usr/local/cuda-12.9/bin:$PATH cmake --build build-cuda-issue7549 --target MODULE_ESTATE_Elecstate_Op_UTs -j2OMP_NUM_THREADS=1 ctest --test-dir build-cuda-issue7549 -V -R '^MODULE_ESTATE_Elecstate_Op_UTs$'PATH=/usr/local/cuda-12.9/bin:$PATH cmake --build build-cuda-issue7549 --target abacus_basic_gpu -j4git diff --checkpython3 tools/03_code_analysis/agent_governance_check.py --stagedpython3 tools/03_code_analysis/code_quality_score.py --output /dev/stdout source/source_estate/kernels/test/elecstate_op_test.cpprho[0]was{0, 0}while CPUrho[0]was{2.0, 8.5}.MODULE_ESTATE_Elecstate_Op_UTspassed on an NVIDIA A800.abacus_basic_gpuexecutable built successfully.git diff --checkpassed.pre-commitwas not run because it is not installed in this environment.What's changed?
rho[0]in the CUDA and ROCm spinor-density kernels when magnetization output is disabled.rho[1..3], matching the CPU implementation.Governance Notes
source_estateCUDA/ROCm density-accumulation kernel and its focused unit-test target. No interface, global dependency, header dependency, or MPI behavior changes.