Repository navigation
perf(gasci): compact sparse alpha streams in RDM contractions - #246
Conversation
|
Thanks, Yi. The compact path looks correct to me, and the speedup reproduces (see below). Before merging I'd like the following:
A broader request for future perf PRs on GASCI: please start with an end-to-end profile of a GASSCF run (or at least the time split between sigma and RDM) to show which kernel matters. For the (34e,34o) 12/10/12 case below, one 1+2-RDM call costs about 2.3 sigma calls on master. So this PR is worthwhile, but its effect on a whole GASSCF run is much smaller than 2×. With that context, I'd rather review one PR with a stated end-to-end target than a series of individually tuned kernel paths. The AB RDM now has four code paths, and each one has to be covered and maintained. Checks run by Claude Code (not independently verified by me)
Max abs difference in This comment was drafted with the help of Claude Code. The checks above were run by Claude Code and have not been re-run by me. |
|
Hi Matt, updated in 50a89a1, a51cd58, and 247fddf:
Normal GASCI/GASSCF regressions, the additional RDM benchmark matrix, and targeted ASan/UBSan checks passed. Agreed on profiling a representative GASSCF run before choosing the next optimization. |
|
One additional
8000
check is still pending: a controlled comparison with AVX2 enabled. Since I normally enable AVX2 for production calculations, I’ll benchmark both master and this PR with and without |
|
The AVX2 comparison is now complete. Both versions benefit from AVX2, and the sparse AB speedup remains. Full 1+2-RDM timings on 32 bound physical AMD EPYC 7713 cores:
Baseline is d8cbdbd; PR is 247fddf. All builds used GCC 13.2.0 with Each value is the median of two independent process medians, with three repeat calls per process and balanced forward/reverse order. Timings include output allocation and spin summation, excluding plan construction. Inputs were identical across builds. All 128 calls passed numerical checks; the maximum cross-version absolute difference was 2.66e-15. Performance depends on the GAS partition and occupation constraints; these speedups apply to the tested configurations. |
Pack only contributing alpha rows in eligible AB RDM batches and reuse the existing dot kernels. Supports ordinary and transition RDMs and keeps the dense/direct fallbacks. The Python API is unchanged.
Behaviour changes
GAS_ERR_MEMORYnow propagate to the caller. Previously, any error fell back silently to the direct path.GAS_ERR_MEMORYstill falls back.fci_rdm_gas_plan_set_ab_compact_limits(plan, scratch_elems, min_lanes)overrides the compact-path scratch budget and minimum-work cutoff on one plan. It exists so that tests can force the beta-tiled and multi-consumer branches. Production defaults are unchanged.Benchmarks
Full 1+2-RDM timings with plan reuse, on 32 bound physical AMD EPYC 7713 cores. Baseline is d8cbdbd and PR is 247fddf. All builds used GCC 13.2.0 with
-O3 -msse3 -fopenmp. The AVX2 builds added only-mavx2, without-march=native,-mfma, or fast-math.Each value is the median of two independent process medians, with three repeat calls per process in balanced forward/reverse order. Timings include output allocation and spin summation and exclude plan construction. Inputs were identical across builds. All 128 calls passed numerical checks, and the maximum cross-version absolute difference was 2.66e-15.
An earlier SSE-only measurement on 32 physical AMD EPYC 9534 cores, taken before the AA contraction PR (#243) was integrated, gave 2.15× (ordinary) and 2.21× (transition) on the 12/10/12 case. Polyacetylene with two-orbital GAS subspaces showed no stable benefit. Performance depends on the GAS partition and occupation constraints, and these speedups apply to the tested configurations.
Testing
test_sparse_ab_rdmscovers ordinary and transition RDMs againstdirect_spin1. It uses the plan-local limits to force beta tiling, tail tiles, bra reuse, and repacking for multiple beta consumers. Independent full-FCI comparisons and GASCI/GASSCF regressions passed, including plan reuse, thread-count changes, RDM tests without OpenMP, and targeted ASan/UBSan checks.Description consolidated from the author's comments by MatthewRHermes with the help of Claude Code.