Skip to content

AO screening: sqrt((ii|kk)) never screens, the overlap test is not a bound #419

Closed

Description

@AbdAmmar

Severity. Low: no measurable effect on energies at the default threshold (1e-15). This is a correctness and
documentation point, with a modest speed gain.

Where. src/ao_two_e_ints/two_e_integrals.irp.f:
ao_two_e_integral_schwartz(i,k) = sqrt(ao_two_e_integral(i,i,k,k)), used in ao_two_e_integral_zero
(screening.irp.f) and in the direct Fock build. The _erf version uses the standard (ik|ik).

Why. Since (ik|ik) <= (ii|kk), the test is valid, but (ii|kk) is a Coulomb integral (~1/R_ik for distant AOs):
it never screens anything in the tests below. All the screening comes from the overlap test
ao_overlap_abs(i,k) ao_overlap_abs(j,l) < thr, which is not a bound on (ik|jl): roughly
(ik|jl) ~ S_ik S_jl <1/r12>, and <1/r12> can exceed 1. The standard Cauchy-Schwarz factor sqrt((ik|ik)) is a
rigorous bound and decays like the overlap.

Measurement 1: Kr2, 4.0 Å. Temporary test program: for every unique quartet it evaluates the three tests; for
every quartet dropped by the overlap test but kept by the rigorous bound it computes the exact integral (all
primitive quartets).

cc-pVTZ (98 AOs, 11 768 526 unique quartets):

thr dropped: overlap sqrt((ii|kk)) sqrt((ik|ik)) overlap-dropped with abs(v) >= thr largest dropped largest/thr
1e-15 585 190 0 714 847 (+22 %) 12 6.6e-15 6.6
1e-12 1 492 042 0 1 781 172 (+19 %) 52 4.7e-12 4.7
1e-10 2 648 588 0 3 124 231 (+18 %) 86 5.9e-10 5.9
1e-8 4 298 131 0 4 846 958 (+13 %) 146 1.0e-7 10.1
1e-6 6 012 100 0 6 588 217 (+10 %) 104 7.6e-6 7.6

cc-pVDZ (58 AOs, 1 464 616 quartets): same picture, smaller: sqrt((ii|kk)) drops 0, sqrt((ik|ik)) drops
14–17 % more than the overlap test, and the overlap test drops at most 18 integrals above thr, the largest
2.5 x thr. Over all quartets tested, abs(v)/(S_ik S_jl) reaches 5.8 (DZ) and 13 (TZ).

Measurement 2: (H2O)4 chain, cc-pVDZ, thr 1e-15 (map path, screening switched by a temporary patch):

test quartets skipped skipped with abs(v) >= 1e-15 largest skipped integrals kept CPU energy
overlap + sqrt((ii|kk)) (now) 70.2 % 0 5.9e-16 2 831 197 35.6 s reference
sqrt((ik|ik)) only 71.0 % 0 1.0e-15 2 831 197 34.0 s identical

Here both tests keep exactly the same integrals (every integral >= thr is computed with either test), so the energy
is identical; only the number of sub-threshold quartets skipped differs.

Remarks.

  • The diagonal integrals (ik|ik) must be computed without the primitive Schwarz acceleration (do_schwartz_accel),
    whose absolute threshold sets small diagonals to exactly 0. The Cholesky path already does this
    (do_schwartz_accel is false when do_ao_cholesky).
  • That primitive acceleration is a larger error source than the screening: on the Kr2 quartets above, the values of
    the default path differ from the full primitive sums by up to 3.9e-14 (DZ) and 6.9e-14 (TZ), i.e. up to ~70 x
    the default threshold.

Proposal. Replace both the overlap test and sqrt((ii|kk)) by sqrt((ik|ik)) (diagonals without the primitive
acceleration) for real GTOs: rigorous, and 10–22 % more quartets skipped in the tests above. At minimum, the doc of
ao_two_e_integral_schwartz and ao_two_e_integral_zero should not call sqrt((ii|kk)) a Schwarz bound.

Activity

  1. scemama commented on Nov 18, 2026

    @scemama
    Member

    Verified, and fixed in #422 (one line). Summary of the check:

    The bound as written is not a proven bound on the screened integral.
    ao_two_e_integral_zero(i,j,k,l) screens the integral whose electron pairs are
    (i,k) and (j,l), i.e. (ik|jl) — every call site (Fock loops, Cholesky
    on-the-fly, map lookups) interleaves the pairs that way. The issue's proposed
    inequality (ik|ik) ≤ (ii|kk) (repeated k, Cauchy–Schwarz between the AOs
    and the product AO ik) does hold, but the factor used in the code is the
    cross-pairing sqrt((ii|kk))·sqrt((jj|ll)), which is not a bound on (ik|jl).
    The direct Cauchy–Schwarz bound is

    |(ik|jl)| ≤ sqrt( (ik|ik) · (jl|jl) ),
    

    i.e. the self-energy of each product AO. That is the one-line fix:
    sqrt(ao_two_e_integral(i,k,i,k)) — the same factor the erf matrix already
    uses (providers_ao_erf.irp.f), so the two providers now agree.

    What this buys, measured on B2 @ 3.0 Å (6-31G, 18 AO):

    • the old cross-pairing decays only as 1/R in stretched two-center
      geometries, so at the default threshold 1e-15 it effectively never
      triggers there — that is why the impact is low, consistent with the
      "severity: low" label;
    • the new factor is a rigorous bound on the integral at every call site:
      verified numerically (3-D Gauss–Legendre) on a 4-distinct-primitive grid,
      tight within ~1.1×; the old factor is a looser bound in that geometry
      (up to ~4000× looser where it does fire);
    • the Fock-loop twin is fixed by the same line:
      local_threshold = schwartz(k,l)*schwartz(i,j) is now exactly the CS
      bound of the quartet's base integral (kl|ij);
    • A/B at threshold_ao = 1e-4 (same build, only the provider line flipped):
      identical SCF energy to all digits (-49.0123445289287) — no observable
      change on this system, so the risk of the change is minimal;
    • new regression test B-B_screening in src/hartree_fock/10.hf.bats: SCF
      at threshold_ao = 1e-8 converges to -48.9950589230371, within 3.8e-7 a.u.
      of the unscreened reference -48.9950585434279; passes with the default
      configuration (Cholesky on).

    Two follow-ups noted in #422's description:

    1. the ao_two_e_integral_zero docstring documents (ij|kl); the actual
      convention is (ik|jl). Fixed in ao_two_e_ints: same-side Schwartz bound sqrt((ik|ik)) (fix #419) #422.
    2. the overlap test ao_overlap_abs(i,k)*ao_overlap_abs(j,l) < threshold in
      the same function is also not a bound (e.g. two 1s on atoms 5–8 bohr
      apart: S² ≈ 1e-15 while the integral is 1.1e-15, at the threshold).
      It is a pre-existing heuristic, left untouched in ao_two_e_ints: same-side Schwartz bound sqrt((ik|ik)) (fix #419) #422 to keep that PR
      one-line; happy to discuss a principled replacement (or its removal,
      since the CS bound covers it) in a separate issue.
  2. added 2 commits that reference this issue on Nov 18, 2026
    66de718
    41b119c
  3. AbdAmmar commented on Nov 18, 2026

    @AbdAmmar
    CollaboratorAuthor

    Thanks for the quick fix. One problem remains with #422 on the map path (do_ao_cholesky = F), the point of the
    first remark in the issue: ao_two_e_integral(i,k,i,k) goes through ao_two_e_integral_schwartz_accel when the
    product of the primitive numbers exceeds 1024. That shortcut skips primitive quartets with an absolute threshold
    (ao_integrals_threshold**2), so small diagonals (ik|ik) come out as exactly 0 (or too small), and the Schwartz test
    then drops integrals far above the threshold. With the old factor sqrt((ii|kk)) this could not happen, since (ii|kk)
    is never small.

    Measured on current dev-stable (66de718), threshold 1e-15, do_ao_cholesky = F; temporary test program comparing
    the provider with the exact sqrt((ik|ik)) (all primitive quartets), and, for every quartet that passes the overlap
    test but is dropped by the Schwartz test while its exact bound is >= thr, the exact integral:

    system Schwartz factors = 0 (exact > 0) integrals >= 1e-15 dropped largest dropped
    (H2O)4 chain, cc-pVDZ 43 of 5050 34 482 3.9e-9
    Kr2 (4 Å), cc-pVDZ 141 of 1711 47 948 9.4e-8

    (H2O)4, one SCF iteration from the same MOs: 2 796 731 integrals stored with #422 vs 2 831 197 with the previous
    line, energy -303.9355174989487 vs -303.9355174993626 (4.1e-10 Ha). Before #422 the stored integrals were exactly
    those of the unscreened calculation.

    The Cholesky path is not affected (do_schwartz_accel is false when do_ao_cholesky), which is why the new
    B-B_screening test (default configuration, Cholesky on, 6-31G) passes.

    Possible fix: compute the diagonals without the primitive shortcut, e.g. by moving the full primitive sum of
    ao_two_e_integral into its own function and calling it in the provider. This is what the Cholesky diagonal already
    does for real GTOs and what #421 does for cGTOs (ao_two_e_integral_cgtos_prim). A map-path test
    (do_ao_cholesky = F) with a basis having more than 1024 primitive quartets, e.g. cc-pVDZ water, would catch it.

    Minor: sqrt((ii|kk)(jj|ll)) is a valid bound on (ik|jl) (since (ik|ik) <= (ii|kk), exchange <= Coulomb for the
    positive-definite 1/r12); it is only useless, as it decays like 1/R.

    On the overlap test: the Kr2 numbers in the issue show it drops integrals up to ~10 x thr, and the rigorous test
    skips 10–22 % more quartets, so removing it (once the diagonals are exact) seems the cleanest choice.

  4. added a commit that references this issue on Nov 18, 2026
    fd7faae
  5. AbdAmmar commented on Nov 19, 2026

    @AbdAmmar
    CollaboratorAuthor

    Sorry, I closed this by mistake. Reopening: the map-path problem in my previous comment (exact diagonals needed when do_ao_cholesky = F) is still present in dev-stable after #422.

  6. scemama commented on Nov 19, 2026

    @scemama
    Member

    Done!

  7. scemama commented on Nov 19, 2026

    @scemama
    Member

    Fixed in #423 (merged into dev-stable, 264d3e7). The two remaining points:

    Map path (do_ao_cholesky = F). The (ik|ik) diagonals of the Schwartz factors are now summed over all primitive quartets: a new ao_two_e_integral_full (the full-primitive branch of the ao_two_e_integral dispatcher, moved verbatim) is used by the ao_two_e_integral_schwartz provider, so the primitive accelerator's absolute threshold (ao_integrals_threshold**2) can no longer zero the small diagonals. The same fix is applied to the long-range (erf) path, which had the identical defect (ao_two_e_integral_erf_full + the ao_two_e_integral_erf_schwartz provider). The Cholesky path is untouched and bit-identical (do_schwartz_accel is already off there); cGTO was already correct via #421.

    Overlap test. Removed from ao_two_e_integral_zero per the issue's proposal: the rigorous CS bound subsumes it at zero cost (the factors are already provided). The (ik|jl) convention and the rigorous CS bound are now documented in ao_two_e_integral_zero (the doc fix that the merge of #422 dropped is restored).

    Measured on a new (H2O)4 chain fixture (cc-pVDZ, 100 AOs, threshold 1e-15, map path), same setup as the measurements above:

    • zeroed (ik|ik) factors: 881/5050 -> 0
    • integrals >= 1e-15 dropped by the old factor: 49 582 -> 0 (map count 3 866 749 -> 3 916 331)
    • map-path SCF energy: -304.1242786330997 -> -304.12427863337 (delta 2.7e-10 Ha); map vs Cholesky agreement 1.4e-11
    • new regression test B-B_screening_map (10.hf.bats) gates the deterministic map count and the energy at 1e-8; the other 33 hf tests are unchanged, all Cholesky-path reference energies bit-identical. CI green (ubuntu bats + macOS build).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions