Repository navigation
Conversation
Stardust0831
left a comment
There was a problem hiding this comment.
These suggestions address two reproduced GPU regressions: accessing an input that the contraction does not need, and sharing cached tensor values between copied objects after their inputs diverge. The a0b0 lookup fix can be accepted independently; please add the four cache suggestions to one batch and commit them together.
Validated on NVIDIA V100 GPUs with GCC 13.3 and DDLA 0.0.4:
- Minimal-input contractions: the original head fails 14/18 with
unordered_map::at; the suggested code passes all 18, with residency disabled and enabled. - Copy construction, copy assignment, C/V replacement, freeing/reloading tensors, D updates, and subsequent updates to either object pass in real/complex arithmetic, with 1/2 MPI ranks and 1/4 OpenMP threads. A two-rank case where only rank 0 retains an extra copy also completes correctly.
- Symmetry and physics regression checks pass. ABACUS completes 20 HSE runs and all 16 energy/force/stress comparisons, including eight GPU EXX runs, real/complex tensors and symmetry on/off.
The ABACUS integration check uses commit 1bd79c473134b366fa45f422e0efd0c54491c43c and default residency. All 95 translation units depending on LibRI were rebuilt. Optional residency is covered by the direct API checks; performance was not remeasured.
|
Thanks for catching these issues! Applied the Validated on V100 GPUs (GCC 13.3, CUDA 12.6): all 9 CTest cases passed, with no skips. Coverage includes all 18 minimal-input contractions with residency on/off, copy construction/assignment, C/V replacement and free/reload, D updates, and rank-dependent cache ownership, in real/complex arithmetic with 1/2 MPI ranks and 1/4 OpenMP threads. The existing symmetry tests also pass. |
|
Thanks for addressing these issues and adding the regression coverage. I re-tested the latest head (a5760c7) on V100 GPUs: all 52 independent regression tests and all 9 tests in the updated suite passed, with no failures or skips. I also rebuilt ABACUS against the updated headers and verified four GPU HSE integration cases covering real/complex arithmetic and EXX symmetry on/off. Energies, forces, and stresses agree with the CPU and previously validated GPU references within the test tolerances. The issues I reported are resolved in my tests. I have no remaining blockers from my review and consider this PR ready to merge. |
ce4feb7 to
75cb5e0
Compare
Port the worker-private packing design from userchba/LibRI 365b29d. Retain per-owner input buffers, independent cached layouts, resident C/V bindings, and ordinary allocation.
Port the per-worker arena design from userchba/LibRI 365b29d with the default new/delete upstream. Keep host tensor buffers and batch storage unchanged.
Port temporary metadata compression and bounded segmentation from userchba/LibRI 365b29d. Preserve worker ordering and update layout cache capture/restore together.
Move immutable pair maps, Pack arrays and dimensions into the plan and borrow them during each contraction. Retain device dimension arrays with their allocating context across calls, and invalidate on communicator, layout or shape changes. Rebind numerical input tasks to current tensors and retain address-dependent pointer uploads. Cover aliasing, cross-queue dimension lifetime and cache invalidation in regression checks.
Resolve the GPU regression-directory move by keeping the packing, resident-cache and budget tests alongside the new callback tests. Retain the master DDLA public API adapter and GPU symmetry callbacks.
Repeated EXX GPU contractions spend substantial time preparing batches on the host and uploading unchanged tensors. This PR reduces that overhead for the four labels used by EXX and LR-TDDFT:
cal_Hsis called thousands of times.set_gpu_resident_data_names(), invalidated when tensors are replaced or freed, and falls back to ordinary uploads when the memory budget is exceeded.Benchmark: 63-atom NV⁻ in diamond, PBE0, one NVIDIA V100, six OpenMP threads. Values are median
cal_loop3_GPUwall times during early Davidson iterations.The first comparison uses 31 calls per run; the cached-layout result uses 33 cache hits. The residency comparison uses the same binary and 54 calls per run after excluding initial cache construction. Ground-state GPU contractions also improved from 4.3460 to 2.9063 s/call with residency enabled (1.50×).
GPU validation in ABACUS covered changing D values, changing D block keys, and replacing C/V tensors with the same shapes. The residency on/off runs produced identical ground-state energies at printed precision.
Follow-up: A800 performance and host-memory measurements
This follow-up includes all eight commits from
a3a8f88througha7589be, preserving their individual history and authors. The five most recent optimization commits are compared below, together with0e8afc3as the original baseline. The0e8afc3→1e37530comparison also includes the preceding worker-private maps, monotonic arenas and Tmp compaction commits; its entire benefit cannot be attributed to1e37530alone.System and environment
7f2675d, with an MPI name-lookup build fix), and LibXC 7.0.0 with third derivatives enabled.Measurement protocol
Each version/configuration runs in its own process. Measure five calls in forward version order and five in reverse order, discarding the first call of each process: eight retained samples per row, reported as mean ± sample standard deviation. Uninstrumented
cal_loop3wall time includes transpose, packing, uploads, contraction, output recovery and object destruction; input loading and correctness comparisons are outside the timed region. Peak process RSS includes warm-up; post-call RSS is the mean VmRSS after retained calls. Separate processes prevent one configuration’s high-water mark contaminating another. Minor page faults are measured during the contraction call.Every H block, shape and element is checked against an independent CPU reference; all 128 retained samples passed, with maximum scaled error 7.682e-16 (tolerance 1e-10). Separate diagnostic runs verify actual cache loads and resident hits and are excluded from these timing statistics.
The same original baseline is repeated as the first row of all three tables for reference. It has neither layout caching nor residency; the repeated rows are the same measurement, not three supported baseline configurations.
Layout cache disabled / no residency
0e8afc3(baseline: no layout cache or residency)1e37530(remove registration lock contention; cache layouts and residency; compact Tmp metadata)3a3009a(compact Mul and Output batches)0869200(compact Input batches)2cd488d(release host work earlier)a7589be(remove redundant initialization)Layout-cache hits / no residency
0e8afc3(baseline: no layout cache or residency)1e37530(remove registration lock contention; cache layouts and residency; compact Tmp metadata)3a3009a(compact Mul and Output batches)0869200(compact Input batches)2cd488d(release host work earlier)a7589be(remove redundant initialization)Layout-cache hits / partial C/V residency
0e8afc3(baseline: no layout cache or residency)1e37530(remove registration lock contention; cache layouts and residency; compact Tmp metadata)3a3009a(compact Mul and Output batches)0869200(compact Input batches)2cd488d(release host work earlier)a7589be(remove redundant initialization)Interpretation and residency limits
The latest commit reduces cache-disabled time from 107.998 to 42.896 s/call (60.3% less time, 2.52× throughput) and peak RSS from 17.613 to 11.681 GiB (33.7% lower).
3a3009aand0869200improve both time and memory;2cd488dprimarily reduces peak memory. The final initialization change does not show a timing benefit clearly exceeding the observed single-sample variability. These are fixed-input results and must not be interpreted as whole-application speedups.Residency uses the unchanged 4 GiB budget: original C and V occupy 3,972,574,248 bytes (~3.700 GiB) and are reused on device. Transposed C needs another 2,596,548,448 bytes and falls back to uploads. Thus the third table measures partial residency, not full residency of all C/V variants. All five candidates showed cache reuse and resident hits; cold runs showed no layout-cache loads.
An additional latest-commit-only ABACUS single-point LR calculation with default caching/residency and analytic forces completed with process exit code 0: LR Davidson converged 3/3 roots; both Z-vector solves reached true residual 5.63e-7. Internal total time was 28,412 s. Aggregated stages: ground-state runner 3407.02 s; LR including setup but excluding ground-state runner/force 6583.37 s; Z-vector 6615.61 s; LR force excluding Z-vector 11000.86 s. Ground-state forces add 745.64 s; other overhead is ~59.50 s. These stages are derived from nested existing timers, not additive kernel timings. Actual peak host RSS was 252.307 GiB; the 96 GiB submission request is not the measured peak. This single run is not an end-to-end cross-version speedup benchmark. The Slurm wrapper reported failure only because its trailing grep expected a closed-shell output string absent from this open-shell run; the calculation itself exited normally.