-
Notifications
You must be signed in to change notification settings - Fork 467
IncFock Standardization Part 3: DFJCOSK #2816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
So the CI issue on this one seems... interesting, as well.
Seems to be an issue with loading and installing packages with apt-get? Maybe this is a one-time thing that can be fixed with a CI restart. |
a34da09
to
6d58793
Compare
psi4/src/psi4/libfock/jk.h
Outdated
|
||
// Is the JK currently on a guess iteration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be useful to expand on this definition. I had supposed it was simply not-the-SAD iteration, but can it be initial more than once in a jobs? if there's a guess from a smaller basis? if there's DF iterations before CONV direct iterations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dug into this a little bit. For DF_SCF_GUESS=True runs, it shows as true on the first CONV direct SCF iteration and false otherwise. For runs using a BASIS_GUESS, it shows up as true for the first iteration of each SCF cycle present (i.e., once for both the smaller and the larger basis set SCFs) and false otherwise. This is all from my testing.
Further looking into it, this is a feature of the old DirectJK/DFJLinK IncFock scheme that does two things. First, that disables incremental Fock construction on the first SCF iteration of a given cycle. Second, it is set to true when the size of the previous D matrix vector is not the same length as the current D matrix vector. The second component is described in a comment in the original IncFock scheme in DirectJK as being "used to handle stability analysis case". I couldn't tell you how or why that particular component works, but I carried it over to make sure nothing broke.
Regardless, you're right; the comment could use a better description. I'm thinking something like // Is the JK currently on the first SCF iteration of this SCF cycle?
tests/pytests/test_dfjcosk.py
Outdated
|
||
# how do SCF iteration counts compare? | ||
if hasattr(wfn_dfjcosk_noinc, "iteration_") and hasattr(wfn_dfjcosk_inc, "iteration_"): | ||
assert compare_values(wfn_dfjcosk_noinc.iteration_, wfn_dfjcosk_inc.iteration_, 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
niter_noinc = int(wfn_dfjcosk_noinc.variable("SCF ITERATIONS"))
can give you the count, too
I'm not sure what you're doing in the assert. why would the the niter be the same to 1.e-3? You could do assert compare(True, (niter_noinc - niter_inc) >= 3, "reduced by at least 3 iterations by incfock")
if that's what you had in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I was trying to do with the test was to make sure that the SCF iteration count for the IncFock run was not significantly higher than that of the non-IncFock run. IncFock won't generally reduce the number of SCF iterations significantly, but it CAN greatly increase them. This test is designed to ensure that the IncFock run doesn't require significantly more iterations (defined as more than 3 in this test); and this assert is the point at which the comparison is made.
Thank's for the clarification on the compare functions! With everything here, most likely what I would have in mind is assert compare(True, (niter_inc - niter_noinc) <= 3, "reduced by at least 3 iterations by incfock")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see now, thanks. do you want an abs(niter_noinc - niter_inc)
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're welcome! Abs could be something we do, because it would catch cases where IncFock gives significantly lower SCF iterations than no-IncFock. It may be worth catching this in case it indicates some other error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, I think this file has been largely refined based on the discussion here!
6d58793
to
041f11f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
build_K(D_eff, K_ao_); | ||
timer_off("COSK"); | ||
build_K(D_ref_, K_ao_); | ||
timer_off("COSK"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if your editor isn't counting spaces right or not converting tabs to 4 spaces. No harm or need to edit further, as we'll catch it in a clang-format someday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a possibility. I use vim, and I'm pretty sure one can adjust vimrc to automatically convert tabs to 4 spaces. It's possible I haven't set this up yet.
This reminds me, there is a technique to avoid recomputing every |
Thank you for telling me about this! This is an intriguing idea overall. Essentially, instead of hard-setting a number of iterations to fully recompute the Fock matrix, one does it dynamically based on how much the density matrix has changed over time. While I don't think this PR is the right place to implement such a scheme (with 1.7 is right around the corner; and since such a scheme would break standardization of IncFock between the different integral-direct JK builds Psi4 has currently, assuming we implement it only in DFJCOSK for this PR), it could be worth investigating in the future. The potential for removing a human-set parameter (INCFOCK_FULL_FOCK_EVERY in this case) is always appealing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nitpicky changes, but LGTM otherwise.
Three cheers for standardization!
|
||
// If there is no previous pseudo-density, this iteration is normal | ||
if(D_prev_.size() != njk) { | ||
D_eff = D_ao_; | ||
if(initial_iteration_ || D_prev_.size() != njk) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need a CF pass later.
Co-authored-by: Lori A. Burns <lori.burns@gmail.com>
Co-authored-by: Lori A. Burns <lori.burns@gmail.com>
Co-authored-by: Lori A. Burns <lori.burns@gmail.com>
Co-authored-by: Lori A. Burns <lori.burns@gmail.com>
Co-authored-by: Jonathon Misiewicz <jonathon.paul.misiewicz@emory.edu>
Co-authored-by: Jonathon Misiewicz <jonathon.paul.misiewicz@emory.edu>
Co-authored-by: Jonathon Misiewicz <jonathon.paul.misiewicz@emory.edu>
Co-authored-by: Jonathon Misiewicz <jonathon.paul.misiewicz@emory.edu>
6794e89
to
d6ed131
Compare
All right, I just did a final rebase. Given no issues with CI, and if others agree, this should be ready to merge! |
Description
... and another one!
This PR is a continuation of the IncFock standardization effort initially started in #2682, and continued in #2792 and #2808.
This PR continues to standardize the Incremental Fock process across the current integral-direct JK algorithms present in Psi4. However, this PR stands somewhat in contrast to #2682 and #2792. In those PRs, their IncFock schemes were adapted to use that of DFJCOSK, without removing the bells and whistles of their IncFock implementations (e.g., recomputing the full Fock matrix every so often, disabling IncFock after a given convergence threshold). In contrast, DFJCOSK is the template IncFock upon which the two previous PRs were based; however, DFJCOSK does not have the IncFock bells and whistles that DirectJK and DFJLinK had. Unmitigated, the incremental Fock procedure can actually significantly increase the number of SCF iterations needed to converged; and the IncFock bells and whistles in DirectJK and DFJLinK notably mitigate the effect of IncFock on SCF convergence counts. Without these bells and whistles, DFJCOSK runs the significant risk of excessive SCF iterations needed to converge when IncFock is enabled, an issue I have run into in my own calculations.
This PR seeks to rectify the aforementioned issue by implementing the IncFock bells and whistles of DirectJK and DFJLinK into DFJCOSK. With these extra features, DFJCOSK can now recompute the full Fock matrix every n iterations, or disable IncFock past a given convergence threshold, at the will of the end user. These features can notably reduce the amount of SCF iterations needed to converge.
This PR is also the continued effort to standardize IncFock among all integral-direct SCF algorithms in Psi4. With this PR, DirectJK, DFJLinK, and DFJCOSK will have effectively the exact same incremental Fock schemes, each featuring the lower memory usage of DFJCOSK's former IncFock scheme, and the bells and whistles of DirectJK and DFJLinK's former IncFock schemes. The final step to the IncFock standardization process, then, is the movement of the IncFock scheme of these algorithms into the base JK class itself - the final step of the PR scheme discussed in the comments in #2682.
It is worth noting for the reviewers that, since this PR more closely matches the IncFock of DFJCOSK to that of DFJLinK, it should be considered relevant to the CompositeJK PR chain as well, as it smooths the combination of DFJLinK and DFJCOSK into a single class as planned in the next CompositeJK step.
User API & Changelog headlines
Dev notes & details
Questions
N/A
Checklist
Status