Store the two-electron integrals packed (8- or 4-fold), not dense — 4-8x on the largest replicated array
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend, distributed-systems, performance
Research direction
Start with src/qops/bindings_qops.cpp, include/common/fcidump.hpp, and python/gpu_dmrg_scf.py to trace how packed PySCF integrals become the resident FCIDUMP array. Compare 4-fold or 8-fold storage and lookup costs, then benchmark µ-term assembly and complementary-operator forming. Done means lower resident memory with no measured forming or assembly regression and the CPU block-sparse path remains bit-identical to the dense 4^m oracle.
Written by the indexing model from the issue text.
Description
The two-electron integrals are stored fully dense — K⁴ doubles — on every rank, and are materialized densely twice on the way in. Real permutational symmetry is 8-fold for the restricted case, so the resident array is ~8× larger than it needs to be.
This is the largest single replicated array in a multi-rank run, and replicated memory is the per-rank floor that decides how large a system fits no matter how many GPUs are added. It is plausibly implicated in the n16 BD=6000 OOM recorded at grow_gpu.cpp:620-623 ("33 GB captive + 14 GB free < the ML=6000 forming ctx") — not as the sole cause, but as a term that is pure duplication.
Where it comes from — our side of the boundary, not PySCF's
// src/qops/bindings_qops.cpp:48-64
using Arr4 = nb::ndarray<const double, nb::ndim<4>, nb::c_contig>;
...
fd.h2e.assign(g2e.data(), g2e.data() + n2 * n2);
// include/common/fcidump.hpp:52-54
std::size_t index2(int p, int q, int r, int s) const {
return ((static_cast<std::size_t>(p) * norb + q) * norb + r) * norb + s;
}
The binding takes a dense rank-4 array and flat-assigns K⁴ doubles; FCIDUMP then indexes it as a fully dense ((p·K+q)·K+r)·K+s.
PySCF hands over a 4-fold-packed (npair, npair) ERI from get_h2eff() and is perfectly happy to. The ao2mo.restore(1, ...) call in _normalize_integrals (python/gpu_dmrg_scf.py) exists purely to satisfy that signature — it is not a PySCF requirement and not a physics requirement.
So per rank, at session construction, three copies coexist:
- PySCF's packed
(npair, npair)array —~K⁴/4 - the dense numpy expansion from
restore(1)—K⁴ - the C++
fd.h2ecopy —K⁴
At K = 100: ~800 MB apiece for (2) and (3), so ~1.6 GB per rank of duplication, on every rank, before a single renormalized block is allocated.
Proposed work, in ascending order
| change | payoff | risk | |
|---|---|---|---|
| a | Consume the numpy buffer without the extra fd.h2e copy, or free the numpy array once copied |
halves the transient peak | low — no algorithmic change |
| b | Store 4-fold packed (npair, npair), expand indices inside FCIDUMP::h2() |
4× on the resident array | medium |
| c | Store 8-fold packed (restricted case) | 8× | medium |
(a) is worth doing on its own and is close to free.
The catch, and why this is not a half-day job
FCIDUMP::h2() is on the hot path of µ-term assembly and complementary-operator forming. Replacing a flat multiply-add index with a packed lookup (ij = p >= q ? p*(p+1)/2 + q : q*(q+1)/2 + p) puts branches where there is currently arithmetic. This wants measuring, not assuming.
An honest version of (b)/(c) is therefore:
- the storage change, plus
- a forming/assembly benchmark showing no regression, plus
- possibly a one-off unpack into the dense form for the phases that genuinely stream it, keeping the packed array as the resident copy.
It is a dmrg_common change and touches both engines (dmrg_qops and dmrg_mpo), so the layered-oracle gates apply: the CPU block-sparse path must stay bit-identical, and the dense 4^m Fock-space oracle is the reference.
Secondary benefit
The MPI integral broadcast added in feat/pyscf_interface (_bcast_integrals) shrinks by the same factor. That is the smaller prize — the broadcast is O(K⁴) once per solver call against a solve that is O(K³M²) per sweep — while this memory is resident for the whole run. It already broadcasts the packed form rather than the expansion, so the wire cost is 4× lower today; only the resident cost remains.
Notes
- Recorded as B1 in
multigpu.md. - Flagged there as the one Part II item that does not need the profiling work done first: the win is a memory ratio computable from
Kbefore writing a line, so it can proceed in parallel. - The UHF path stores three dense
K⁴blocks (h2e,h2ab,h2bb) and has its own packing structure —aa/bbare 8-fold symmetric,abonly 4-fold. Worth scoping separately.
Effort: ~1-2 days including the benchmark. Payoff: 4-8× on the single largest replicated array.
- Dominant language
- C++
- Stars
- 3
- Forks
- 0
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 31
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Algorithmiq/exa-dmrg
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Algorithmiq/exa-dmrg#153 ·
Maintainers usually reply within 2 days
-
Add CITATION.cff once the paper is outPossibly taken @FabioTarocco claimed this 1 day ago. Opendocumentation request
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Algorithmiq/exa-dmrg#106 · 2 assignees ·
Maintainers usually reply within 2 days
-
bug
Difficulty 5/5 Over a week Newbie friendliness 35/100
Algorithmiq/exa-dmrg#161 ·
Maintainers usually reply within 2 days
-
bug cpp
Difficulty 5/5 Over a week Newbie friendliness 35/100
Algorithmiq/exa-dmrg#157 ·
Maintainers usually reply within 2 days
-
Shorten the tests of the wheels in cibuildwheelPossibly taken @robertodr claimed this 1 day ago. Openci request
Algorithmiq/exa-dmrg#155 · 1 comment · 1 assignee ·
Maintainers usually reply within 2 days
All issues in Algorithmiq/exa-dmrg
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
simnJS/AnyPS5#735 · 1 comment ·
Maintainers usually reply within 1 day
-
area:tests kind:test
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
? - Needs Triage bot_watch bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/cudf-spark-jni#5594 ·
Maintainers usually reply within 1 day
-
Branch-master
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
TrinityCore/TrinityCore#32177 ·
Maintainers usually reply within 10 days