Fix: Correct PW KPAR/BNDPAR occupations and distributed output - #7845
Open
AsTonyshment wants to merge 2 commits into
Open
Fix: Correct PW KPAR/BNDPAR occupations and distributed output#7845AsTonyshment wants to merge 2 commits into
AsTonyshment wants to merge 2 commits into
Conversation
AsTonyshment
requested review from
mohanchen
and
a lite review from Copilot
and removed request for
Copilot
August 21, 2026 10:06
AsTonyshment
requested
a lite review from Copilot
and removed request for
Copilot
August 21, 2026 11:58
Collaborator
|
Could you add some unit tests or integrate tests? |
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.
Summary
This PR fixes several PW KPAR/BNDPAR correctness issues. The changes correct fixed and explicitly supplied occupations under distributed k-point and band layouts, reconstruct complete band data before shared-file output, and fix the real-space grid collection used by charge-density
.cubeoutput.The
kpar,bndpar, andocp_setparameter descriptions are also updated to match the current implementation.Problems addressed
smearing_method=fixedandbndpar>1, every band group treated its local band zero as global band zero. Multiple groups therefore occupied their first local bands repeatedly, producing incorrect electron counts, charge densities, band energies, and SCF results.ocp_setvalidated its input length using the pool-local number of k-points and indexed the input with a local-band stride. KPAR could reject a correctly sized input, while BNDPAR could silently assign occupations to the wrong bands.out_chgused source ranks derived from a larger process layout as ranks inPOOL_WORLD. Under BPCG this could pass an invalid communicator rank toMPI_Recvafter the SCF calculation had completed.out_bandand eigenvalue/occupation output treated band-local matrices as if they contained all global bands. This could cause out-of-bounds access, omit bands owned by other band groups, duplicate k-point contributions, or allow multiple groups to write the same shared file.Validation
A standalone edge-case test was carried out with 21 calculations: 17 CPU cases and 4 GPU cases. PW CPU cases used 6 MPI ranks, 8 k-points, 7 bands, and BPCG. The following layouts were compared:
kpar=1,bndpar=1kpar=2,bndpar=1kpar=1,bndpar=33+2+2kpar=2,bndpar=3kpar=3,bndpar=23+3+2, and uneven band ownership,4+3The edge-case test covered
nspin=1andnspin=2, fixed occupations, k-point-dependentocp_setvalues, PW CPU/GPU execution, and LCAO temporarykpar=1/2/3diagonalization. Every PW case checked the complete occupation table, total energy, band table, charge-density.cubevalues, and.cubeintegral.All 21 cases completed successfully and reported no failures.
7.190692e-121.534826e-102.299966e-131.199041e-148.526513e-141.163514e-131.000589e-142.042810e-140.000000e+003.730349e-141.000589e-145.329071e-15