Skip to content

Conversation

@davpoolechem
Copy link
Contributor

Description

This PR is a rather important update to the DFJLinK JK subclass, counting both as the continuation of the CompositeJK development started in #2762 and the first PR in the new incremental Fock build standardization seen in #2682.

To describe the problem, as of now, different integral-direct JK algorithms use different implementations of the incremental Fock build formalism. DirectJK and DFJLinK use the same incremental Fock build formalism, while DFJCOSK uses its own methodology. This introduces two problems:

  1. The next step of CompositeJK development is to combine DFJLinK and DFJCOSK into the pilot CompositeJK subclass. To ease this process, DFJLinK and DFJCOSK need to use the same incremental Fock process.
  2. The incremental Fock formalism currently used by DirectJK and DFJLinK has a couple of extra bells and whistles that DFJCOSK does not have - mainly, the ability to recompute the full Fock matrix every couple of iterations and the ability to disable incremental Fock construction entirely past a specific convergence threshold. These bells and whistles can greatly improve the convergence capabilities of the calculation, while "normal" IncFock implementations without these bells and whistles run the risk of greatly increasing the number of SCF iterations needed to converge. This issue is meant to be addressed with Refactor Incremental Fock Builds in Chain-of-Spheres Exchange #2682; however, the introduction of DFJLinK to the JK hierarchy has potentially changed how that PR should be handled.

This PR addresses both of the above issues by changing DFJLinK to use the same incremental Fock formalism as DFJCOSK. Using the DFJCOSK incremental Fock formalism is preferred because DFJCOSK stores fewer matrices in the DFJCOSK class for incremental Fock usage, reducing memory requirements from a practical perspective, and lowering the amount of state contained in DFJLinK from a code design perspective. In standardizing the DFJLinK and DFJCOSK incremental Fock processes, the next CompositeJK PR will be smoother, and CompositeJK development can continue parallel to the developments discussed in #2682. Additionally, this PR serves as a first step the to decomposition of #2682 as discussed in that PR's comments, allowing for the full standardization of IncFock among integral-direct JK subclasses.

For reviewers, since this PR is the bottleneck for two different routes of JK development (CompositeJK and IncFock standardization), it should be considered the highest-priority JK development PR to merge into Psi4 at the moment.

User API & Changelog headlines

N/A

Dev notes & details

  • Switches DFJLinK to using the incremental Fock build implementation used in DFJCOSK. This change standardizes the incremental Fock implementation between DFJLinK and DFJCOSK and improves the memory usage of DFJLinK in the process.
  • Changes LinK machinery to support new incremental Fock formalism.

Questions

  • Since this PR specifically focuses on changes to DFJLinK, there are still a couple of small differences in IncFock between DFJLinK and DFJCOSK, mainly, refactorings and the aforementioned bells and whistles that DFJLinK has that DFJCOSK doesn't. Would it be better to make adjustments to DFJCOSK in this PR as well, to further standardize the two; or is it preferrable to punt that down to the next CompositeJK PR, when DFJLinK and DFJCOSK are combined into the pilot CompositeJK implementation? If we decide to make the changes to DFJCOSK this PR, it would essentially consist of refactoring the DFJCOSK IncFock to match that of DFJLinK, and adding the bells and whistles that DFJLinK currently has.
  • Should the relevant test outputs be updated?

Checklist

Status

  • Ready for review
  • Ready for merge

@davpoolechem
Copy link
Contributor Author

Something that has been brought to my attention that I should clarify and haven't - the bells and whistles that DFJLinK used to have with its IncFock formalism are still there; this PR does not remove those. Rather, this PR updates DFJLinK's IncFock to be as close to DFJCOSK's IncFock as possible while keeping the bells and whistles.

This is also where my first question comes from - would it be good to fully standardize the two by changing DFJCOSK's IncFock in this PR, as well?

@loriab loriab added the scf Involves general SCF: convergence algorithms, RHF/UHF/ROHF/CUHF... label Nov 23, 2022
@loriab loriab added this to the Psi4 1.7 milestone Nov 23, 2022
@davpoolechem davpoolechem force-pushed the dpoole34/dfjlink-incfock branch from eefaa36 to a004ba6 Compare November 28, 2022 14:32
Copy link
Member

@loriab loriab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lgtm after some whitespace tidying for clarity. Would it be useful to add a check to existing tests of each of the JK classes that can use incfock along the lines of compare(1, variable("SCF ITERATIONS") < 15.0, "incfock efficient")?

@davpoolechem
Copy link
Contributor Author

This lgtm after some whitespace tidying for clarity. Would it be useful to add a check to existing tests of each of the JK classes that can use incfock along the lines of compare(1, variable("SCF ITERATIONS") < 15.0, "incfock efficient")?

Thanks; whitespace issues cleaned up!

Regarding the test you suggest, I do think that is a good idea. In principle, if we wanted to measure IncFock efficiency in a test, it might be better measured using a difference in SCF iteration counts between IncFock and corresponding non-IncFock runs, rather than using a raw SCF iteration count for the IncFock run. But none of the tests, as far as I am aware, have both IncFock and non-IncFock runs for the same SCF method executed simultaneously. Your suggested method works with the current tests, and it should still work quite well for testing IncFock efficiency since it will catch any cases where IncFock causes serious convergence issues. I will implement it!

@davpoolechem
Copy link
Contributor Author

Also, based on your comment, I just took a look at the SCF iteration counts for linK-1, and it seems IncFock now leads to a higher SCF iteration count then it should. I didn't think I touched the DFJLinK bells and whistles, but maybe I accidentally did somewhere along the way. Let me resolve this before merging in this PR.

@davpoolechem
Copy link
Contributor Author

davpoolechem commented Nov 28, 2022

All right, bug fixed, and IncFock tests added! The new IncFock efficiency tests compare against an SCF ITERATIONS value of x+3, where x is the number of SCF iterations observed in the corresponding non-IncFock run (which also matches the iteration count seen in each output.ref file). I can reduce the 3 component down to something else if desired.


void DFJLinK::incfock_setup() {

// The prev_D_ao_ condition is used to handle stability analysis case
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the stability analysis case get checked? I don't know right off if it was attached to any tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just finished checking this, using the linK-1 test as my test case. Using STABILITY_ANALYSIS=CHECK with RHF and ROHF references, the stability analysis runs to completion. However, for STABILITY_ANALYSIS=CHECK with a UHF reference, the calculation segfaults after the SCF iterations converge. As it were, this issue seems to exist with DFJLinK in the base version of Psi4 at the moment, as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking. I think UHF is what @JonathonMisiewicz has moved py-side recently. We can trap the combination if there's not a clean fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is that some save_jk flags are needed by the Py-side Davidson tech, and that wasn't properly documented. Based on what David says, that seems unrelated to this PR.

Copy link
Contributor

@JonathonMisiewicz JonathonMisiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving merge rights to @loriab.

@loriab loriab merged commit 2278417 into psi4:master Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scf Involves general SCF: convergence algorithms, RHF/UHF/ROHF/CUHF...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants