Skip to content

Fix accumulator aliasing and Hartree atom-list indexing - #15

Merged
PeizeLin merged 6 commits into
abacusmodeling:masterfrom
Stardust0831:fix/gpu-scaled-accumulation
Oct 24, 2026
Merged

PeizeLin merged 6 commits into
abacusmodeling:masterfrom
Stardust0831:fix/gpu-scaled-accumulation

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Initializing an accumulator from a const tensor with coefficient 1 currently shares its storage. Later in-place accumulation can then modify the input and another result. Copy the input in that case; the existing Hartree reference test and a focused input-immutability regression verify the correction.

Two indexed Hartree loops also use the wrong atom list:

  • Bound the density-contraction u loop by list_J.size(), matching list_J[u_index].
  • Select mu from list_I in the CVC contraction, matching the original loop domain.

Distinct and unequal atom-list tests reproduce the out-of-range/missing-contribution failures and check the corrected results against independent scalar references. Accumulation tests cover all 18 contractions individually and together, seeded/empty outputs, and signed, zero, fractional and complex coefficients.

This builds on PeizeLin's implementation now in master at 6534722. The PR adds three one-line production corrections and regression tests; the original author metadata is preserved.

Validation on NVIDIA V100 GPUs with GCC 13.3/OpenMP and DDLA v0.0.4/CUDA:

  • 16/16 CPU-only and GPU-enabled runs pass across float/double, real/complex and 1/4 OpenMP threads, covering both CPU modes and GPU execution.
  • Existing Hartree, atom-list and exchange/force/stress tests pass; all three defects reproduce against the original implementation.
  • Complete ABACUS GPU build, including BSE, and 8/8 HSE calculations pass unchanged repository checks.
  • The existing LR reference assertion fails before and after these changes because its rounded values exceed the original tolerance. Full-precision outputs are identical in both versions at 1 and 4 threads; reference files and tolerances are unchanged.

Complete original build and test logs. The merge with current master preserves the tested file tree exactly; merge verification and joint #16 validation.

Related: #16 and deepmodeling/abacus-develop#8169.

Apply fac_add_Ds while merging downloaded GPU contributions through the
existing tensor accumulation helper. Remove the unused GPU result map
and locks; the result merge runs outside the OpenMP packing regions.

Add regression coverage for signed, zero and fractional coefficients,
seeded outputs, repeated calls and combined contraction labels.
PeizeLin and others added 4 commits October 24, 2026 14:21
(cherry picked from commit 6534722)
Use the right atom list to bound the density loop and the left atom list to select mu in the CVC loop. Add scalar-reference regressions for distinct and unequal atom partitions.
Copy the input when initializing an empty result with unit coefficient. Tensor assignment shares storage, so subsequent in-place additions otherwise change the input and other accumulators. Cover independent outputs and complex accumulation coefficients.
@Stardust0831 Stardust0831 changed the title Fix scaled accumulation in GPU contractions Fix GPU accumulation and support complex coefficients Oct 24, 2026
Upstream now contains the original PeizeLin commits already imported here. Keep the independent const-input accumulator and corrected Hartree atom-list indexing. The merged tree is identical to the previously validated PR head.
@Stardust0831 Stardust0831 changed the title Fix GPU accumulation and support complex coefficients Fix accumulator aliasing and Hartree atom-list indexing Oct 24, 2026
@PeizeLin
PeizeLin merged commit 7025df6 into abacusmodeling:master Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants