Skip to content

Complete early symmetry screening for staged GPU callbacks - #1

Merged
PeizeLin merged 1 commit into
PeizeLin:symmetry_GPU_2from
maki49:pr24-gpu-output-filter
Nov 23, 2026
Merged

PeizeLin merged 1 commit into
PeizeLin:symmetry_GPU_2from
maki49:pr24-gpu-output-filter

Conversation

@maki49

@maki49 maki49 commented Nov 21, 2026 •

Copy link
Copy Markdown

PR abacusmodeling#24's latest commit (39c953b) already restores correct final-output screening: the split callback names stop the old intermediate Aa2 pair check from being dispatched, while for32 still screens the actual output pair. The independent 31,104-combination final-output mask check passes for that version.

This follow-up completes earlier screening, rather than fixing another numerical error. The old two-argument rule is still under for21(TA,TAC), but the matching label family calls for21(TAC,TAC) in stage 1; stage-2/stage-3 callbacks otherwise inherit no-op behavior. Route useful checks to their actual positions:

  • for12: check left-output atom membership when Aa01 is an output, and defer when it is intermediate.
  • for13: check left-output atom membership in the third stage of a01b2_a2b01.
  • for22: check (Aa01,Ab01) only for a01b01_a2b2; leave (Aa01,Aa2) unrestricted in a01b2_a2b01.
  • for23: check the final (Aa01,Ab01) pair in a01b2_a2b01.
  • Remove the ineffective for21 override; for21 and for31 retain base no-op behavior. Keep for32 as the complete output-pair check.

The contraction loops, callback argument order, generator and CPU symmetry implementation are unchanged.

Validation and performance status:

Check Status
CPU build and existing tensor numerical regression (18 labels plus sum, real/complex, both CPU modes) Pass
New CPU-host GPU callback regression: all eight positions, 31,104 label/sector/atom/cell combinations Pass
Per-position expectations on unmodified 39c953b Detects missing earlier screening (a1b1_a2b2, callback 12); final-output mask still passes
GPU contraction regression, 1/4 threads, LibDDLA 0.0.6/CUDA Pass: Slurm 4097957, COMPLETED/0:0; V100 32GB; each thread count: 38 label/scalar groups, 456 scenario checks including 152 GPU checks
Performance change Completed with a common DDLA launch fix: Si64 wall median 385.18 → 345.79 s; combined EXX timer median 164.12 → 162.55 s. The wall-time difference is not an isolated/established screening speedup; see raw results and limitations below.

The submitted GPU regression also runs the new callback test. Its source, script and completed logs are in df1:~/work/lr-grad/pr24-output-filter-20261121/. The completed Si64 material/performance comparison is documented below.

The per-callback test derives final output indices from each label's uncontracted a/b indices and independently masks atom pairs and centered relative cells. It tests unrestricted, off-diagonal/restricted and empty-output sectors, including intermediate cells outside the sector when the final pair is accepted. It calls each callback separately through Filter_Atom, so a late for32 rejection cannot hide a missing early-stage check.

GPU staged callback behavior

The first digit in filter_GPU_forXY is the loop depth, the second is the
occurrence/stage. The loop call sites and their argument order are unchanged.

  • F: return false (do not screen at this position).
  • L: reject atoms absent from the sector's left/output atom identities (Aa01).
  • R: reject atoms absent from the sector's right/output atom identities (Ab01).
  • P: reject only if the final output pair/cell is outside the sector.
  • —: no such call for this label. Bold entries gain screening in this change.
Label 11 12 13 21 22 23 31 32 Final output pair
a0b0_a1b1 F F — F F — F P (Aa2, Ab2)
a0b1_a1b0 F F — F F — F P (Aa2, Ab2)
a0b0_a1b2 R F — F F — F P (Aa2, Ab01)
a0b1_a1b2 R F — F F — F P (Aa2, Ab01)
a0b2_a1b0 R F — F F — F P (Aa2, Ab01)
a0b2_a1b1 R F — F F — F P (Aa2, Ab01)
a0b0_a2b1 L L — F F — F P (Aa01, Ab2)
a0b1_a2b0 L L — F F — F P (Aa01, Ab2)
a1b0_a2b1 L L — F F — F P (Aa01, Ab2)
a1b1_a2b0 L L — F F — F P (Aa01, Ab2)
a0b0_a2b2 L L — F P — F P (Aa01, Ab01)
a0b1_a2b2 L L — F P — F P (Aa01, Ab01)
a1b0_a2b2 L L — F P — F P (Aa01, Ab01)
a1b1_a2b2 L L — F P — F P (Aa01, Ab01)
a1b2_a2b1 R L L F F P F P (Aa01, Ab01)
a0b2_a2b0 R L L F F P F P (Aa01, Ab01)
a0b2_a2b1 R L L F F P F P (Aa01, Ab01)
a1b2_a2b0 R L L F F P F P (Aa01, Ab01)

for21 and for31 remain no-ops. In particular, for22(Aa01,Aa2) in
a01b2_a2b01 must not screen its intermediate Aa2; its final pair is checked
by for32(Aa01,Aa2,Ab01) and for23(Aa01,Ab01). By contrast,
for22(Aa01,Ab01) in a01b01_a2b2 already has both output atoms and can screen.

The for32 arguments and selected pair are:

Family Arguments Pair screened
a01b01_a01b01 Aa01, Aa2, Ab2 Aa2, Ab2
a01b01_a01b2 Aa01, Ab01, Aa2 Aa2, Ab01
a01b01_a2b01 Aa01, Ab01, Ab2 Aa01, Ab2
a01b01_a2b2 Aa01, Ab01, Ab2 Aa01, Ab01
a01b2_a2b01 Aa01, Aa2, Ab01 Aa01, Ab01

For cell-bearing left outputs, use the relative translation (Rb-Ra) % period;
for origin-based Aa01, use Rb % period. Empty sector means unrestricted
output, matching the existing API.

The CPU-host gpu_symmetry_filters test invokes all GPU callback positions
through Filter_Atom, checking 31,104 label/sector/atom/cell combinations against
independent output-index and sector membership expectations. It needs no DDLA or
GPU. It checks intermediate cells that are outside the sector while the final
output is inside, off-diagonal pairs, periodic translations and empty output.

Completed DDLA diagnosis and Si64 performance results

Job Outcome
4098234: original baseline/optimized ABACUS builds COMPLETED, exit 0:0
4103163: independent patched DDLA build and test tools COMPLETED, exit 0:0, 5m36s
4103164: original-failure diagnosis, batch-boundary tests and GPU numerical regression COMPLETED, exit 0:0, 2m23s
4103165: six Si64 runs with the common fixed backend COMPLETED, exit 0:0, 38m04s

Confirmed cause of the original failure

The initial performance attempt (4098235) failed in baseline 39c953b at the first EXX update. The diagnostic rerun captured CUDA status 9 with:

grid=(2,6,66182) block=(16,16,1) shared_bytes=10624

The third grid dimension exceeds the 65,535 launch limit. Ordinary DDLA variable-batched GEMM already sub-batches at that limit, while gemm_template_vbatched_2s previously used an entire memory segment as grid.z. Memory capacity and kernel-launch capacity are separate constraints. A direct boundary test confirmed the old backend succeeds at 65,535 but fails at 65,536 with grid=(1,1,65536).

The independent DDLA 0.0.6 patch sub-batches within each original memory segment, completing stage 0 and dependent stage 1 for a sub-batch before advancing. Thus 66,182 entries become 65,535 + 647 without losing entries or breaking temporary-storage reuse. This confirms a DDLA launch-size defect, not an ABACUS calculation or ABI/version mismatch.

The public API and the original baseline/optimized ABACUS binaries are unchanged. Both variants load the same private patched DDLA, verified by ldd and hashes; the original shared DDLA installation is untouched. The backend patch is a common test prerequisite and is not part of this LibRI PR.

Backend and numerical validation

  • Fixed DDLA passes 12 boundary cases: batch counts 65,535 / 65,536 / 131,073 × double/complex × both C0_left values. The 131,073 case spans two memory segments (65,536 + 65,537) and reuses temporary storage across them.
  • With the patched backend, LibRI GPU numerical regression passes again at 1 and 4 threads. Each run completes 38 label/scalar groups, 456 scenario checks including 152 GPU checks, covering 18 labels plus their sum, real/complex tensors, restricted/unrestricted/empty-output sectors and signed/zero/fractional seeded accumulation.
  • The CPU-host per-position callback regression passed 31,104 combinations in the original validation job 4097957, whose original-backend GPU runs also passed at 1/4 threads.

Si64 comparison setup and numerical agreement

Baseline 39c953b versus 27daefe; the library snapshots differ only in Filter_Atom_Symmetry_GPU.h. Use the repository P102_si64_lcao 64-atom Si structure, HSE, LCAO DZP (Si_gga_8au_100Ry_2s2p1d), 1×1×1 Gamma mesh, real RI tensors, real-space EXX symmetry, SCF threshold 1e-7, and final force/stress evaluation.

All six calculations used the same V100-SXM2-32GB allocation, one MPI rank, six OpenMP threads, single-threaded MKL/OpenBLAS, identical input hashes and the same common patched DDLA. The frozen ABACUS source and test-only C/V-residency compatibility patch are common to both variants. Run order was baseline/optimized/optimized/baseline/baseline/optimized. All six runs converged, returned zero and logged GPU EXX execution.

Consistency check Maximum difference
Final energy, full range across all six runs 5.46e-12 eV
Force component, all baseline–optimized pairings 3.70e-9 eV/Å
Stress component, all baseline–optimized pairings 1.25e-8 kbar

Measured timings and limits of interpretation

Variant Three wall times, seconds (in variant run order) Median, seconds
Baseline 385.18, 397.92, 355.09 385.18
Earlier screening 350.07, 345.79, 322.81 345.79

The observed end-to-end wall median is 10.23% lower (1.114×) in this sample. It includes MPI/process startup, input reading, SCF, forces/stress and I/O; it is not an isolated timing of the GPU contractions.

Existing ABACUS timer Baseline median (s) Earlier-screening median (s)
Exx_LRI::cal_exx_elec, total of 3 calls 15.61 15.12
Exx_LRI::cal_exx_force 60.30 59.60
Exx_LRI::cal_exx_stress 87.87 88.36
Per-run sum of these three timers, then median 164.12 162.55

The combined EXX timer median is only 0.96% lower, with overlapping per-run ranges (baseline 163.01–165.06 s; earlier screening 161.63–163.60 s). Startup/input-reading times vary considerably as well. Therefore this experiment establishes numerical agreement and successful large-batch execution, but does not establish a stable 10% screening/kernel speedup. The three-repetition result suggests, at most, a small EXX timing benefit requiring more controlled profiling/repeats to distinguish from variability. The stress timer does not improve in the median.

Reproducibility records

  • df1:~/work/lr-grad/pr24-ddla-retry-20261121/completed-evidence.tar.gz: raw six-run logs, summary/records, hardware, binary/linkage records, original launch diagnostics, boundary and numerical test logs, patch, manifest and scripts.
  • df1:~/work/lr-grad/pr24-ddla-retry-20261121/ddla-chunk.patch: independent DDLA fix.
  • Original failure and original-backend numerical records remain in ~/work/lr-grad/pr24-si64-performance-20261121/result-evidence.tar.gz and ~/work/lr-grad/pr24-output-filter-20261121/result-evidence.tar.gz.

Relative to master a385ac9, the checks restored at for12/for13 and for23 existed under the shared legacy callback names; the a01b01_a2b2 output-pair check at for22 is additionally new. The benchmark baseline here is 39c953b, not master.

Copilot AI balanced review requested due to automatic review settings November 21, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@PeizeLin
PeizeLin merged commit a689c83 into PeizeLin:symmetry_GPU_2 Nov 23, 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.

3 participants