evaleev / libint

Libint: high-performance library for computing Gaussian integrals in quantum mechanics
Other
225 stars 95 forks source link

default MAX_AM influences task MAX_AM #191

Closed loriab closed 3 years ago

loriab commented 3 years ago

When one specifies explicit AM for tasks, but does not reset the general with-max-am, as in the setup below, the library builds just fine and tests just fine. When interfaced with Psi4, conventional Hartree--Fock energies run just fine up to the point where lmax_exceeded throws. DF Hartree--Fock energies run just fine up to cc-pVQZ but segfault at cc-pV5Z in xs_xx

    -DENABLE_ERI=1 \
    -DENABLE_ERI3=1 \
    -DENABLE_ERI2=1 \
    -DWITH_ERI_MAX_AM="6;5" \
    -DWITH_ERI3_MAX_AM="6;5" \
    -DWITH_ERI2_MAX_AM="6;5" \
    -DWITH_MAX_AM=4

If I bump up the general with-max-am to 6 to match the ERI, then define LIBINT2_CENTER_DEPENDENT_MAX_AM_3eri<deriv> 1 disappears from libint2_params.h, far more library source files are generated (59k instead of 39k; ONEBODY AM 4->6 also happening), and the 5Z DF HF in Psi4 succeeds.

You added the CENTER_DEPENDENT twist to the code, so to some extent this behavior must be expected, whereas I had supposed with-max-am to have a purely fallback role (catching ONEBODY and the like). Simplest thing to do is add some text to configure/CMakeLists.txt warning to bump the general with-max-am along with specifying the explicit lists. I'm creating this issue to confirm with you that we've analyzed the situation correctly since CENTER_DEPENDENT is a little mysterious.

By the way, libint tests fail with segfaults when I bump up with-max-am to 6 to suppress CENTER_DEPENDENT. @andysim pointed out that libint is generating zeros in the tests, so maybe just what-to-test logic involved there. I also checked with the libtool buildsystem (below) to the point of building the export tarball, and that, too, includes CENTER_DEPENDENT, so I'd expect it to have the same segfault problem in psi4 for DF.

../configure --enable-shared --disable-static \
    --enable-eri=1 --enable-eri3=1 --enable-eri2=1 \
    --with-eri-max-am=6,5 --with-eri-opt-am=3 \
    --with-eri3-max-am=6 --with-eri2-max-am=6
loriab commented 3 years ago

By mirroring the --with-eri3-max-am setting in --with-max-am, I'm able to get energies and gradients behaving. If my current Hessian build shows the expected characteristics in psi, I'll close this issue. I've added some guidance to CMakeLists.txt and configure.ac to warn others.

loriab commented 3 years ago

This is now understood and manageable. The Libint2 quirk is to mirror --with-max-am to --with-eri3-max-am (or maybe --with-max-am = max(--with-eri-max-am, --with-eri3-max-am) -- I haven't explored and eri3 >= eri in practice). The downstream quirk is to be sure to initialize libint2::Engines with no greater-centered braket than needed, otherwise the AM check in l2 will throw on perfectly accessible integrals.